Quick "Public Article" Mod --> jeder darf editi

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
Post Reply
pixelpeter
Posts: 45
Joined: Fri 27. Feb 2004, 16:00

Quick "Public Article" Mod --> jeder darf editi

Post by pixelpeter »

So, ich mal wieder (nach längerer Abwesenheit) :wink:

Auch ich habe das Problem, das ein Artikel von unterschiedlichen (Backend-) Usern bearbeitet werden soll, ich diesen aber trotzdem keine Admin-Rechte geben moechte.

Daher hier ein kleiner, schneller Hack (Install < 1 Min).

Danach kann bei den Artikeleigenschaften der Artikelbesitzer public ausgewählt werden (vom Admin).

Getestet mit: phpwcms_1.1-RC4_2004-06-08
===============================================
[FILE]
include/inc_tmpl/article.editsummary.tmpl.php

[FIND][268]
<select name="article_uid" id="article_uid" style="width: 300px" class="f11b">

[ADD]
<!-- BoF: public article mod by pixelpeter -->
<option value="9999">public</option>
<!-- EoF: public article mod by pixelpeter -->


[FILE]
include/inc_lib/admin.functions.inc.php

[FIND][90]
if($article[$akey]["article_uid"] == $_SESSION["wcs_user_id"] || $_SESSION["wcs_user_admin"]) {

[REPLACE WITH]
// BoF: public article mod by pixelpeter
// org: if($article[$akey]["article_uid"] == $_SESSION["wcs_user_id"] || $_SESSION["wcs_user_admin"]) {
if($article[$akey]["article_uid"] == $_SESSION["wcs_user_id"] || $_SESSION["wcs_user_admin"] || $article[$akey]["article_uid"] == 9999) {
// EoF: public article mod by pixelpeter
===============================================

Das wars schon. Sollte funktionieren, solange Ihr nicht mehr als 9999 Benutzer im Backend habt :lol: :o :x :shock: :wink:

Viel Spaß !!!
Last edited by pixelpeter on Mon 19. Jul 2004, 23:20, edited 1 time in total.
Keules
Posts: 80
Joined: Tue 2. Mar 2004, 17:06
Location: Hamburg

Super!

Post by Keules »

Danke, für den Hack, werde Ihn nachher gleich mal testen, endlich wurden meine gebete erhört :)

THX a lot!

Ciao
Keules
User avatar
pSouper
Posts: 1552
Joined: Tue 11. Nov 2003, 15:45
Location: London
Contact:

Post by pSouper »

if anyone knows German & English better than (google) would you mind translating this for 'little old me' :0)
duergner
Posts: 139
Joined: Fri 14. May 2004, 12:10

Post by duergner »

This mod lets you assign an article a 'public' owner. That means everyone in the backend can edit this article. In short.
User avatar
pSouper
Posts: 1552
Joined: Tue 11. Nov 2003, 15:45
Location: London
Contact:

Post by pSouper »

:D i like your translation already :D
pixelpeter
Posts: 45
Joined: Fri 27. Feb 2004, 16:00

Post by pixelpeter »

This mod needs an addition, because the contentpart-functions like sorting, visibily and deletion won't work until you incorporate this code.

Just overwrite the complete code of include/inc_act/act_articlecontent.php with this:

Code: Select all

<?php
/*************************************************************************************
   Copyright notice
   
   (c) 2002-2004 Oliver Georgi (oliver@phpwcms.de) // All rights reserved.
 
   This script is part of PHPWCMS. The PHPWCMS web content management system is
   free software; you can redistribute it and/or modify it under the terms of
   the GNU General Public License as published by the Free Software Foundation;
   either version 2 of the License, or (at your option) any later version.
  
   The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
   A copy is found in the textfile GPL.txt and important notices to the license 
   from the author is found in LICENSE.txt distributed with these scripts.
  
   This script is distributed in the hope that it will be useful, but WITHOUT ANY 
   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
   PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 
   This copyright notice MUST APPEAR in all copies of the script!
*************************************************************************************/

session_start();

$ref = $_SERVER['HTTP_REFERER'];

require_once ("../inc_conf/conf.inc.php");
require_once ("../inc_lib/default.inc.php");
require_once ("../inc_lib/general.inc.php");
require_once ("../inc_lib/checklogin.inc.php");

if(isset($_GET["do"])) {
	$values = explode(",", $_GET["do"]);
	if(count($values)) {
		switch(intval($values[0])) {
			case 9: //delete article content part
					$sql = "UPDATE ".DB_PREPEND."phpwcms_articlecontent SET acontent_trash=9".
						   " WHERE (acontent_uid=".$_SESSION["wcs_user_id"]." OR ".$_SESSION["wcs_user_admin"]." OR 999)".
						   " AND acontent_aid=".intval($values[1]).
						   " AND acontent_id=".intval($values[2]).";";
					mysql_query($sql, $db) or die("error while deleting content part");
					break;
			case 1: //delete article
					$sql = "UPDATE ".DB_PREPEND."phpwcms_article SET article_deleted=9".
						   " WHERE (article_uid=".$_SESSION["wcs_user_id"]." OR ".$_SESSION["wcs_user_admin"]." OR 999)".
						   " AND article_id=".intval($values[1]).";";
					mysql_query($sql, $db) or die("error while deleting article");
					//$ref = $phpwcms["site"]."phpwcms.php?do=articles"; //&p=2
					break;
			case 2: //make content visible/invisible
					$sql = "UPDATE ".DB_PREPEND."phpwcms_articlecontent SET acontent_visible=".intval($values[3]).
						   " WHERE (acontent_uid=".$_SESSION["wcs_user_id"]." OR ".$_SESSION["wcs_user_admin"]." OR 999)".
						   " AND acontent_aid=".intval($values[1]).
						   " AND acontent_id=".intval($values[2]).";";
					mysql_query($sql, $db) or die("error while changing content visible/invisible");
					break;
			case 3: //make article visible/invisible
					$sql = "UPDATE ".DB_PREPEND."phpwcms_article SET article_aktiv=".intval($values[3]).
						   " WHERE article_id=".intval($values[1]).";";
					mysql_query($sql, $db) or die("error while changing article visible/invisible");
					break;
			case 4: //make article public/nonpublic
					$sql = "UPDATE ".DB_PREPEND."phpwcms_article SET article_public=".intval($values[3]).
						   " WHERE article_id=".intval($values[1]).";";
					mysql_query($sql, $db) or die("error while changing article visible/invisible");
					break;
		}
	}
}

if(isset($_GET["sort"])) {
	list($value1, $value2)	= explode("|", $_GET["sort"]);
	list($id1, $sort1) = explode(":", $value1); list($id2, $sort2) = explode(":", $value2);
	$id1 = intval($id1); $id2 = intval($id2); $sort1 = intval($sort1); $sort2	= intval($sort2);
	
	$sql1 = "UPDATE ".DB_PREPEND."phpwcms_articlecontent SET acontent_sorting=".$sort1.
		    " WHERE (acontent_uid=".$_SESSION["wcs_user_id"]." OR ".$_SESSION["wcs_user_admin"]." OR 999)".
		    " AND acontent_id=".$id1.";";
	$sql2 = "UPDATE ".DB_PREPEND."phpwcms_articlecontent SET acontent_sorting=".$sort2.
		    " WHERE (acontent_uid=".$_SESSION["wcs_user_id"]." OR ".$_SESSION["wcs_user_admin"]." OR 999)".
		    " AND acontent_id=".$id2.";";

	mysql_query($sql1, $db) or die("error while changing content part's sorting");
	mysql_query($sql2, $db) or die("error while changing content part's sorting");
}

header("Location: ".$ref);
exit();

?>
It's mainly an addition of the SQL-Statements to SELECT also our "virtual" and "public" user with the id "999".

ORIGINAL:

Code: Select all

......
WHERE (acontent_uid=".$_SESSION["wcs_user_id"]." OR ".$_SESSION["wcs_user_admin"].")"
......
ADDED " OR 999"

Code: Select all

......
WHERE (acontent_uid=".$_SESSION["wcs_user_id"]." OR ".$_SESSION["wcs_user_admin"]." OR 999)"
......
As said before, everything you need to do is to paste the first code completely over the existing file
pixelpeter
Posts: 45
Joined: Fri 27. Feb 2004, 16:00

Post by pixelpeter »

Well, I#m sad butI have to inform you the addition posted before is wrong in two ways ;-(
1: I used the "9999" for our virtual user not "999"
2: The posted SQL-Statements are wrong !!!

Code: Select all

...
id = x or y or z
...
won't work
this statement is only true for the combination of two values

Code: Select all

...
id = x or y
...
To work with more than two values it has to be

Code: Select all

...
id = x OR
id = y OR
id = z
...
The code was broken in such a cool way ;-) that's the functionality we want to have was actually/accidentially given !!!

But finally: ITS WRONG !!

A quick correction is not just done in 2 minutes because the articelcontents have their own user_id (with this hack we just changed the user_id of the articel itself) and this ist set during inserts, so there's a lot of changes and testing to be done.

I will inform you when any further step were taken.

Sorry
Strega
Posts: 24
Joined: Thu 12. May 2005, 14:14
Location: Germany

Post by Strega »

Hallo,
bin ja jetzt erst relativ spät auf diesen Beitrag gekommen. Läuft er auch noch unter der neuen 1.2.5DEV?
Grüße
S*T*R*E*G*A
frold
Posts: 2151
Joined: Tue 25. Nov 2003, 22:42

Post by frold »

hmm looks cool this mod :D I have to test it ;D
http://www.studmed.dk Portal for doctors and medical students in Denmark
phalancs
Posts: 793
Joined: Thu 19. Feb 2004, 05:09
Location: Germany

news?

Post by phalancs »

any news on this one?

i dont want to replace a whole file with that code as i am sing dev 1.2.6 and i presume that that file is not the same anymore...


what are the changes? Does it work?

Public user is a great idea.
2008
Post Reply