Page 1 of 1

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

Posted: Sun 11. Jul 2004, 17:58
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ß !!!

Super!

Posted: Mon 12. Jul 2004, 10:16
by Keules
Danke, für den Hack, werde Ihn nachher gleich mal testen, endlich wurden meine gebete erhört :)

THX a lot!

Ciao
Keules

Posted: Mon 12. Jul 2004, 10:32
by pSouper
if anyone knows German & English better than (google) would you mind translating this for 'little old me' :0)

Posted: Mon 12. Jul 2004, 10:37
by duergner
This mod lets you assign an article a 'public' owner. That means everyone in the backend can edit this article. In short.

Posted: Mon 12. Jul 2004, 11:11
by pSouper
:D i like your translation already :D

Posted: Mon 19. Jul 2004, 23:27
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

Posted: Tue 20. Jul 2004, 23:25
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

Posted: Wed 10. Aug 2005, 14:28
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?

Posted: Wed 10. Aug 2005, 14:57
by frold
hmm looks cool this mod :D I have to test it ;D

news?

Posted: Tue 10. Jan 2006, 11:02
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.