Commit 0903937d authored by sylvieg's avatar sylvieg

[FIX]perms: integrate local/specific perms in get_perm_object

parent b7c4c3d7
<?php
// CVS: $Id: tikilib.php,v 1.795 2007-10-10 19:53:08 sylvieg Exp $
// CVS: $Id: tikilib.php,v 1.796 2007-10-10 20:27:00 sylvieg Exp $
//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) {
header("location: index.php");
......@@ -3758,7 +3758,7 @@ function add_pageview() {
return(TRUE);
}
/* get all the perm of an object either in a table or global and smarty set
/* get all the perm of an object either in a table or global+smarty set
* OPTIMISATION: better to test tiki_p_admin outside for global=false
* TODO: all the objectType
* global = true set the global perm and smarty var, otherwise return an array of perms
......@@ -3789,6 +3789,8 @@ function add_pageview() {
}
return $ret;
/* else : all the perms have already been set in tiki-setup_base */
} elseif ($perms = $this->get_local_perms($user, $objectId, $objectType, $info, $global)) {
return $ret;
} elseif ($userlib->object_has_one_permission($objectId, $objectType)) {
$perms = $userlib->get_permissions(0, -1, 'permName_desc', '', $this->get_permGroup_from_objectType($objectType));
$userPerms = $userlib->get_object_permissions_for_user($objectId, $objectType, $user);
......@@ -3804,7 +3806,6 @@ function add_pageview() {
$smarty->assign("$perm", 'y');
}
}
echo "FFFF";
return $ret;
}
foreach ($perms['data'] as $perm) { // foreach perm of the same group of perms
......@@ -4034,6 +4035,32 @@ function add_pageview() {
}
return $ret;
}
/* deal all the special perm */
function get_local_perms($user, $objectId, $objectType, $info, $global) {
global $userlib, $smarty;
$ret = array();
switch ($objectType) {
case 'wiki page': case 'wiki':
global $wiki_creator_admin;
if ($wiki_creator_admin == 'y' && $info['creator'] == $user) {
$perms = $userlib->get_permissions(0, -1, 'permName_desc', '', $this->get_permGroup_from_objectType($objectType));
foreach ($perms['data'] as $perm) {
$perm = $perm['permName'];
$ret[$perm] = 'y';
if ($global) {
global $$perm;
$$perm = 'y';
$smarty->assign("$perm", 'y');
}
}
return $ret;
}
break;
default:
break;
}
return false;
}
// This method overrides the prefs with those specified in database
// and should only be used when populating the prefs array in session vars (during tiki-setup.php process)
......
<?php
// $Header: /cvsroot/tikiwiki/tiki/tiki-index.php,v 1.194 2007-10-10 17:44:37 sylvieg Exp $
// $Header: /cvsroot/tikiwiki/tiki/tiki-index.php,v 1.195 2007-10-10 20:27:03 sylvieg Exp $
// Copyright (c) 2002-2007, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
......@@ -230,14 +230,6 @@ if (isset($wiki_authors_style) && $wiki_authors_style != 'classic') {
$creator = $wikilib->get_creator($page);
$smarty->assign('creator',$creator);
// Let creator set permissions
if($wiki_creator_admin == 'y') {
if ($creator && $user && ($creator==$user)) {
$tiki_p_admin_wiki = 'y';
$smarty->assign( 'tiki_p_admin_wiki', 'y' );
}
}
require_once('tiki-pagesetup.php');
$tikilib->get_perm_object($page, 'wiki page', $info, true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment