diff --git a/include/class_acl.inc b/include/class_acl.inc
index 522f10e3247a703a52c3b3bccd3aaf820afd149f..41082b3106b9f17b2e92c18561030ced671d004b 100644 (file)
--- a/include/class_acl.inc
+++ b/include/class_acl.inc
var $wasNewEntry= FALSE;
var $ocMapping= array();
var $savedAclContents= array();
-
+ var $myAclObjects = array();
function acl ($config, $parent, $dn= NULL)
{
"one" => _("One level"),
"base" => _("Current object"),
"sub" => _("Complete subtree"),
- "psub" => _("Complete subtree (permanent)"));
- //"role" => _("Use ACL defined in role"));
+ "psub" => _("Complete subtree (permanent)"),
+ "role" => _("Use ACL defined in role"));
} else {
$this->aclTypes= array("base" => _("Current object"),
"role" => _("Use ACL defined in role"));
$new_acl= array();
$aclDialog= FALSE;
+ $firstedit= FALSE;
foreach($_POST as $name => $post){
/* Actions... */
if (preg_match('/^acl_edit_.*_x/', $name)){
$this->dialogState= 'create';
+ $firstedit= TRUE;
$this->dialog= TRUE;
$this->currentIndex= preg_replace('/^acl_edit_([0-9]+).*$/', '\1', $name);
$this->loadAclEntry();
if (preg_match('/^cat_del_.*_x/', $name)){
$idx= preg_replace('/^cat_del_([^_]+)_.*$/', '\1', $name);
foreach ($this->ocMapping[$idx] as $key){
- unset($this->aclContents[$key]);
+ unset($this->aclContents["$idx/$key"]);
}
continue;
}
$aclDialog= TRUE;
list($dummy, $object, $attribute, $value)= split('_', $name);
+ /* Skip for detection entry */
+ if ($object == 'dummy') {
+ continue;
+ }
+
/* Ordinary ACLs */
if (!isset($new_acl[$object])){
$new_acl[$object]= array();
}
/* Only be interested in new acl's, if we're in the right _POST place */
- if ($aclDialog && isset($this->ocMapping[$this->aclObject])){
+ if ($aclDialog && $this->aclObject != "" && is_array($this->ocMapping[$this->aclObject])){
+
foreach ($this->ocMapping[$this->aclObject] as $oc){
unset($this->aclContents[$oc]);
unset($this->aclContents[$this->aclObject.'/'.$oc]);
}
/* Save new acl in case of base edit mode */
- if ($this->aclType == 'base'){
+ if ($this->aclType == 'base' && !$firstedit){
$this->aclContents= $new_acl;
}
if ($this->aclType == 'base'){
$smarty->assign('aclSelector', $this->buildAclSelector($this->myAclObjects));
}
+
+ /* Role selector if scope is base */
+ if ($this->aclType == 'role'){
+ $smarty->assign('roleSelector', "Role selector");#, $this->buildRoleSelector($this->myAclObjects));
+ }
}
if ($this->dialogState == 'edit'){
if ($this->aclObject == 'all'){
$aclObjects['all']= _("All objects in current subtree");
}
- $smarty->assign('aclSelector', $this->buildAclSelector($aclObjects));
+
+ /* Role selector if scope is base */
+ if ($this->aclType == 'role'){
+ $smarty->assign('roleSelector', "Role selector");#, $this->buildRoleSelector($this->myAclObjects));
+ } else {
+ $smarty->assign('aclSelector', $this->buildAclSelector($aclObjects));
+ }
}
/* Show main page */
return ($smarty->fetch (get_template_path('acl.tpl')));
}
-
+ function sort_by_priority($list)
+ {
+ $tmp= get_global('plist');
+ $plist= $tmp->info;
+ asort($plist);
+ $newSort = array();
+
+ foreach($list as $name => $translation){
+ $na = preg_replace("/^.*\//","",$name);
+ $prio = 0;
+ if(isset($plist[$na]['plPriority'])){
+ $prio= $plist[$na]['plPriority'] ;
+ }
+
+ $newSort[$name] = $prio;
+ }
+
+ asort($newSort);
+
+ $ret = array();
+ foreach($newSort as $name => $prio){
+ $ret[$name] = $list[$name];
+ }
+ return($ret);
+ }
+
function buildAclSelector($list)
{
- $display= "";
+ $display= "<input type='hidden' name='acl_dummy_0_0_0' value='1'>";
$cols= 3;
$tmp= get_global('plist');
$plist= $tmp->info;
asort($plist);
+ /* Add select all/none buttons */
+ $style = "style='width:100px;'";
+
+ $display .= "<input ".$style." type='button' name='toggle_all_create' onClick=\"acl_toggle_all('_0_c$');\" value='Toggle C'>";
+ $display .= "<input ".$style." type='button' name='toggle_all_move' onClick=\"acl_toggle_all('_0_m$');\" value='Toggle M'>";
+ $display .= "<input ".$style." type='button' name='toggle_all_remove' onClick=\"acl_toggle_all('_0_d$');\" value='Toggle D'> - ";
+ $display .= "<input ".$style." type='button' name='toggle_all_read' onClick=\"acl_toggle_all('_0_r$');\" value='Toggle R'>";
+ $display .= "<input ".$style." type='button' name='toggle_all_write' onClick=\"acl_toggle_all('_0_w$');\" value='Toggle W'> - ";
+
+ $display .= "<input ".$style." type='button' name='toggle_all_sub_read' onClick=\"acl_toggle_all('[^0]_r$');\" value='R+'>";
+ $display .= "<input ".$style." type='button' name='toggle_all_sub_write' onClick=\"acl_toggle_all('[^0]_w$');\" value='W+'>";
+
+ $display .= "<br>";
+
+ $style = "style='width:50px;'";
+ $display .= "<input ".$style." type='button' name='set_true_all_create' onClick=\"acl_set_all('_0_c$',true);\" value='C+'>";
+ $display .= "<input ".$style." type='button' name='set_false_all_create' onClick=\"acl_set_all('_0_c$',false);\" value='C-'>";
+ $display .= "<input ".$style." type='button' name='set_true_all_move' onClick=\"acl_set_all('_0_m$',true);\" value='M+'>";
+ $display .= "<input ".$style." type='button' name='set_false_all_move' onClick=\"acl_set_all('_0_m$',false);\" value='M-'>";
+ $display .= "<input ".$style." type='button' name='set_true_all_remove' onClick=\"acl_set_all('_0_d$',true);\" value='D+'>";
+ $display .= "<input ".$style." type='button' name='set_false_all_remove' onClick=\"acl_set_all('_0_d$',false);\" value='D-'> - ";
+ $display .= "<input ".$style." type='button' name='set_true_all_read' onClick=\"acl_set_all('_0_r$',true);\" value='R+'>";
+ $display .= "<input ".$style." type='button' name='set_false_all_read' onClick=\"acl_set_all('_0_r$',false);\" value='R-'>";
+ $display .= "<input ".$style." type='button' name='set_true_all_write' onClick=\"acl_set_all('_0_w$',true);\" value='W+'>";
+ $display .= "<input ".$style." type='button' name='set_false_all_write' onClick=\"acl_set_all('_0_w$',false);\" value='W-'> - ";
+
+ $display .= "<input ".$style." type='button' name='set_true_all_read' onClick=\"acl_set_all('[^0]_r$',true);\" value='R+'>";
+ $display .= "<input ".$style." type='button' name='set_false_all_read' onClick=\"acl_set_all('[^0]_r$',false);\" value='R-'>";
+ $display .= "<input ".$style." type='button' name='set_true_all_write' onClick=\"acl_set_all('[^0]_w$',true);\" value='W+'>";
+ $display .= "<input ".$style." type='button' name='set_false_all_write' onClick=\"acl_set_all('[^0]_w$',false);\" value='W-'>";
+
/* Build general objects */
+ $list =$this->sort_by_priority($list);
foreach ($list as $key => $name){
/* Create sub acl if it does not exist */
"\n <tr>".
"\n <td style='background-color:#C8C8C8;height:1.8em;' colspan=".($cols-1)."><b>"._("Object").": $name</b></td>".
"\n <td align='right' style='background-color:#C8C8C8;height:1.8em;'>".
- "\n <input type='button' onclick='divtoggle(\"$name\");' value='"._("Show/Hide Advanced Settings")."' /></td>".
+ "\n <input type='button' onclick='divtoggle(\"".preg_replace("/[^a-z0-9]/i","_",$name)."\");' value='"._("Show/Hide Advanced Settings")."' /></td>".
"\n </tr>";
} else {
$display.= "\n<table style='width:100%;border:1px solid #A0A0A0' cellspacing=0 cellpadding=2>".
$display.= "\n <tr>".
"\n <td style='background-color:#E0E0E0' colspan=".($cols-1).">$options</td>".
- "\n <td style='background-color:#D4D4D4'> ".("Complete object:")." $more_options</td>".
+ "\n <td style='background-color:#D4D4D4'> "._("Complete object").": $more_options</td>".
"\n </tr>";
/* Walk through the list of attributes */
break;
case 'role':
- echo "Role";
+ echo "Role: $acl";
break;
case 'reset':