X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=include%2Fclass_acl.inc;h=2d9e72501b28b2e872d42c82deb8037d9d12a181;hb=f1714ac56cc41319519c97c1ab7749d4d8a637c3;hp=398ecd0e188bf661f8490732bd027a6b9f42a69f;hpb=f6cbbeb8a28187d769ccdf3e11b1073e6942e803;p=gosa.git diff --git a/include/class_acl.inc b/include/class_acl.inc index 398ecd0e1..2d9e72501 100644 --- a/include/class_acl.inc +++ b/include/class_acl.inc @@ -28,7 +28,7 @@ class acl extends plugin var $wasNewEntry= FALSE; var $ocMapping= array(); var $savedAclContents= array(); - + var $myAclObjects = array(); function acl ($config, $parent, $dn= NULL) { @@ -187,11 +187,13 @@ class acl extends plugin $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(); @@ -215,7 +217,7 @@ class acl extends plugin 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; } @@ -245,6 +247,11 @@ class acl extends plugin $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(); @@ -258,7 +265,8 @@ class acl extends plugin } /* 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]); @@ -272,7 +280,7 @@ class acl extends plugin } /* Save new acl in case of base edit mode */ - if ($this->aclType == 'base'){ + if ($this->aclType == 'base' && !$firstedit){ $this->aclContents= $new_acl; } @@ -364,7 +372,7 @@ class acl extends plugin $action.= ""; $action.= ""; - $field3= array("string" => $action, "attach" => "style='border-right:0px;width:50px';text-align:right"); + $field3= array("string" => $action, "attach" => "style='border-right:0px;width:50px;text-align:right;'"); $aclList->AddEntry(array($field1, $field2, $field3)); } @@ -467,16 +475,73 @@ class acl extends plugin 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= ""; $cols= 3; $tmp= get_global('plist'); $plist= $tmp->info; asort($plist); + /* Add select all/none buttons */ + $style = "style='width:100px;'"; + + $display .= ""; + $display .= ""; + $display .= " - "; + $display .= ""; + $display .= " - "; + + $display .= ""; + $display .= ""; + + $display .= "
"; + + $style = "style='width:50px;'"; + $display .= ""; + $display .= ""; + $display .= ""; + $display .= ""; + $display .= ""; + $display .= " - "; + $display .= ""; + $display .= ""; + $display .= ""; + $display .= " - "; + + $display .= ""; + $display .= ""; + $display .= ""; + $display .= ""; + /* Build general objects */ + $list =$this->sort_by_priority($list); foreach ($list as $key => $name){ /* Create sub acl if it does not exist */ @@ -487,7 +552,33 @@ class acl extends plugin $currentAcl= $this->aclContents[$key]; /* Object header */ - $display.= ""; + if($_SESSION['js']) { + if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) { + $display.= "\n
"._("Object").": $name
". + "\n ". + "\n ". + "\n ". + "\n "; + } else if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/ie/i",$_SERVER['HTTP_USER_AGENT'])) { + $display.= "\n
"._("Object").": $name". + "\n
". + "\n ". + "\n ". + "\n ". + "\n "; + } else { + $display.= "\n
"._("Object").": $name". + "\n
". + "\n ". + "\n ". + "\n "; + } + } else { + $display.= "\n
"._("Object").": $name
". + "\n ". + "\n ". + "\n "; + } /* Generate options */ $spc= "  "; @@ -510,12 +601,28 @@ class acl extends plugin $more_options= $this->mkchkbx($key."_0_r", _("read"), preg_match('/r/', $currentAcl[0])).$spc; $more_options.= $this->mkchkbx($key."_0_w", _("write"), preg_match('/w/', $currentAcl[0])); - $display.= ""; + $display.= "\n ". + "\n ". + "\n ". + "\n "; /* Walk through the list of attributes */ $cnt= 1; $splist= $plist[preg_replace('%^.*/%', '', $key)]['plProvidedAcls']; asort($splist); + if($_SESSION['js']) { + if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/gecko/i",$_SERVER['HTTP_USER_AGENT'])) { + $display.= "\n ". + "\n
"._("Object").": $name
$options ".("Complete object:")." $more_options
$options "._("Complete object").": $more_options
". + "\n

\n"; } return ($display); @@ -562,7 +679,8 @@ class acl extends plugin function mkchkbx($name, $text, $state= FALSE) { $state= $state?"checked":""; - return ""; + return "\n ". + "\n "; } @@ -570,8 +688,10 @@ class acl extends plugin { $rstate= preg_match('/r/', $state)?'checked':''; $wstate= preg_match('/w/', $state)?'checked':''; - return ("". - ""); + return ("\n ". + "\n ". + "\n ". + "\n "); }