Quick "Public Article" Mod --> jeder darf editi
-
- Posts: 45
- Joined: Fri 27. Feb 2004, 16:00
Quick "Public Article" Mod --> jeder darf editi
So, ich mal wieder (nach längerer Abwesenheit)
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
Viel Spaß !!!
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
Viel Spaß !!!
Last edited by pixelpeter on Mon 19. Jul 2004, 23:20, edited 1 time in total.
-
- Posts: 45
- Joined: Fri 27. Feb 2004, 16:00
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:
It's mainly an addition of the SQL-Statements to SELECT also our "virtual" and "public" user with the id "999".
ORIGINAL:
ADDED " OR 999"
As said before, everything you need to do is to paste the first code completely over the existing file
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();
?>
ORIGINAL:
Code: Select all
......
WHERE (acontent_uid=".$_SESSION["wcs_user_id"]." OR ".$_SESSION["wcs_user_admin"].")"
......
Code: Select all
......
WHERE (acontent_uid=".$_SESSION["wcs_user_id"]." OR ".$_SESSION["wcs_user_admin"]." OR 999)"
......
-
- Posts: 45
- Joined: Fri 27. Feb 2004, 16:00
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 !!!
won't work
this statement is only true for the combination of two values
To work with more than two values it has to be
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
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
...
this statement is only true for the combination of two values
Code: Select all
...
id = x or y
...
Code: Select all
...
id = x OR
id = y OR
id = z
...
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
hmm looks cool this mod I have to test it ;D
http://www.studmed.dk Portal for doctors and medical students in Denmark
news?
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.
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