From: <jon...@us...> - 2009-08-18 13:56:55
|
Revision: 20951 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=20951&view=rev Author: jonnybradley Date: 2009-08-18 13:56:46 +0000 (Tue, 18 Aug 2009) Log Message: ----------- [MOD] Now object permissions page can admin "global" perms (formerly known as "group" perms - we now have new group perms such as tiki_p_group_add_member so we need to disambiguate, i think) Not yet connected to the groups admin page or anywhere else. Please test by going to: tiki-objectpermissions.php?objectType=global TODO next Show/hide group columns Modified Paths: -------------- trunk/tiki-objectpermissions.php Modified: trunk/tiki-objectpermissions.php =================================================================== --- trunk/tiki-objectpermissions.php 2009-08-18 13:22:37 UTC (rev 20950) +++ trunk/tiki-objectpermissions.php 2009-08-18 13:56:46 UTC (rev 20951) @@ -5,10 +5,12 @@ // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. // $Id: /cvsroot/tikiwiki/tiki/tiki-objectpermissions.php,v 1.25.2.2 2008-03-11 15:17:54 nyloth Exp $ include_once ("tiki-setup.php"); -if (!isset($_REQUEST['objectName']) || empty($_REQUEST['objectType']) || empty($_REQUEST['objectId']) || empty($_REQUEST['permType'])) { - $smarty->assign('msg', tra("Not enough information to display this page")); - $smarty->display("error.tpl"); - die; +if (empty($_REQUEST['objectType']) || $_REQUEST['objectType'] != 'global') { + if (!isset($_REQUEST['objectName']) || empty($_REQUEST['objectId'])) { + $smarty->assign('msg', tra("Not enough information to display this page")); + $smarty->display("error.tpl"); + die; + } } $auto_query_args = array( 'referer', @@ -54,7 +56,7 @@ } $_REQUEST["objectId"] = urldecode($_REQUEST["objectId"]); $_REQUEST["objectType"] = urldecode($_REQUEST["objectType"]); -$_REQUEST["permType"] = urldecode($_REQUEST["permType"]); +$_REQUEST["permType"] = !empty($_REQUEST['permType']) ? urldecode($_REQUEST["permType"]) : 'all'; $smarty->assign('objectName', $_REQUEST["objectName"]); $smarty->assign('objectId', $_REQUEST["objectId"]); $smarty->assign('objectType', $_REQUEST["objectType"]); @@ -153,12 +155,12 @@ //Remove all permissions of a group foreach($perms['admin']['data'] as $perm) { - $userlib->remove_object_permission($group, $_REQUEST["objectId"], $_REQUEST["objectType"], $perm); + remove_perm($group, $_REQUEST["objectId"], $_REQUEST["objectType"], $perm); } //Add chosen quickperm bundle to the objcet/group foreach($perms["$permission"]['data'] as $perm) { - $userlib->assign_object_permission($group, $_REQUEST["objectId"], $_REQUEST["objectType"], $perm); + assign_perm($group, $_REQUEST["objectId"], $_REQUEST["objectType"], $perm); } } } @@ -166,7 +168,8 @@ } //Quickperm END -// Process the form to assign a new permission to this page + +// Process the form to assign a new permission to this object elseif (isset($_REQUEST['assign'])) { check_ticket('object-perms'); foreach($_REQUEST['perm'] as $group => $perms) { @@ -183,7 +186,7 @@ foreach($pageInfoTree as $subPage) { foreach($_REQUEST['perm'] as $group => $perms) { foreach($perms as $perm) { - $userlib->assign_object_permission($group, $subPage["pageName"], 'wiki page', $perm); + assign_perm($group, $subPage["pageName"], 'wiki page', $perm); } } } @@ -191,7 +194,7 @@ // set new perms foreach($_REQUEST['perm'] as $group => $perms) { foreach($perms as $perm) { - $userlib->assign_object_permission($group, $_REQUEST["objectId"], $_REQUEST["objectType"], $perm); + assign_perm($group, $_REQUEST["objectId"], $_REQUEST["objectType"], $perm); } } // remove unchecked ones @@ -205,7 +208,7 @@ } } if (!$stillChecked) { - $userlib->remove_object_permission($group, $_REQUEST["objectId"], $_REQUEST["objectType"], $perm); + remove_perm($group, $_REQUEST["objectId"], $_REQUEST["objectType"], $perm); } } } @@ -216,7 +219,7 @@ if (isset($_REQUEST["action"])) { check_ticket('object-perms'); if ($_REQUEST["action"] == 'remove') { - $userlib->remove_object_permission($_REQUEST["group"], $_REQUEST["objectId"], $_REQUEST["objectType"], $_REQUEST["perm"]); + remove_perm($_REQUEST["group"], $_REQUEST["objectId"], $_REQUEST["objectType"], $_REQUEST["perm"]); } } if (isset($_REQUEST['delsel_x']) && isset($_REQUEST['checked'])) { @@ -225,16 +228,20 @@ if (preg_match('/([^ ]*) (.*)/', $perm, $matches)) { if (!empty($_REQUEST['removestructure']) && $_REQUEST['removestructure'] == 'on' && !empty($pageInfoTree)) { foreach($pageInfoTree as $subPage) { - $userlib->remove_object_permission($matches[2], $subPage['pageName'], $_REQUEST['objectType'], $matches[1]); + remove_perm($matches[2], $subPage['pageName'], $_REQUEST['objectType'], $matches[1]); } } else { - $userlib->remove_object_permission($matches[2], $_REQUEST['objectId'], $_REQUEST['objectType'], $matches[1]); + remove_perm($matches[2], $_REQUEST['objectId'], $_REQUEST['objectType'], $matches[1]); } } } } // Now we have to get the individual page permissions if any -$page_perms = $userlib->get_object_permissions($_REQUEST["objectId"], $_REQUEST["objectType"]); +if ($_REQUEST['objectType'] == 'global') { + $page_perms = array(); +} else { + $page_perms = $userlib->get_object_permissions($_REQUEST["objectId"], $_REQUEST["objectType"]); +} //Quickperm foreach($page_perms as $perm) { $current_permissions[$perm['groupName']][] = $perm['permName']; @@ -388,24 +395,24 @@ $groupName = $groupNames[$i]; $beneficiaries = ''; for( $j = 0; $j < count($groupInheritance); $j++) { - if (is_array($groupInheritance[$j]) && in_array($groupName, $groupInheritance[$j])) { + if (in_array($groupName, $groupInheritance[$j])) { $beneficiaries .= !empty($beneficiaries) ? ',' : ''; $beneficiaries .= 'input[name="perm['.$groupNames[$j].'][]"]'; } } -//\$jq('input[name="perm[$groupName][]"]:checked').each( function() { // checked one of this group -// \$jq('input[value="'+\$jq(this).val()+'"]'). // other checkbxes of same value (perm) -// filter('$beneficiaries'). -// attr('checked','checked').attr('disabled','disabled'); // check and disable -//}); $js .= <<< JS \$jq('input[name="perm[$groupName][]"]').each( function() { // each one of this group - \$jq('input[value="'+\$jq(this).val()+'"]'). // other checkboxes of same value (perm) - filter('$beneficiaries'). // which inherit from this - attr('checked',\$jq(this).attr('checked')). // check and disable - attr('disabled',\$jq(this).attr('checked') ? 'disabled' : ''); + + if (\$jq(this).attr('checked')) { + \$jq('input[value="'+\$jq(this).val()+'"]'). // other checkboxes of same value (perm) + filter('$beneficiaries'). // which inherit from this + attr('checked',\$jq(this).attr('checked')). // check and disable + attr('disabled',\$jq(this).attr('checked') ? 'disabled' : ''); + } + \$jq(this).click( function() { // bind click event + if (\$jq(this).attr('checked')) { \$jq('input[value="'+\$jq(this).val()+'"]'). // same... filter('$beneficiaries'). @@ -414,6 +421,7 @@ } else { \$jq('input[value="'+\$jq(this).val()+'"]'). // same... filter('$beneficiaries'). + attr('checked',''). // check? attr('disabled',''); // disable } }); @@ -434,3 +442,23 @@ } else { $smarty->display("tiki.tpl"); } + +function assign_perm($group, $objectId, $objectType, $perm) { + global $userlib; + if ($objectType == 'global') { + $userlib->assign_permission_to_group($perm, $group); + } else { + $userlib->assign_object_permission($group, $objectId, $objectType, $perm); + } +} + +function remove_perm($group, $objectId, $objectType, $perm) { + global $userlib; + if ($objectType == 'global') { + $userlib->remove_permission_from_group($perm, $group); + } else { + $userlib->remove_object_permission($group, $objectId, $objectType, $perm); + } +} + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |