Code

Udpated get_printer_list to use those printers that are defined in ldap
[gosa.git] / include / class_acl.inc
index 522f10e3247a703a52c3b3bccd3aaf820afd149f..dec421bec554a299818248ac8a34567b071c4ee5 100644 (file)
@@ -215,7 +215,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 +245,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 +263,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 && is_array($this->ocMapping[$this->aclObject])){
+
       foreach ($this->ocMapping[$this->aclObject] as $oc){
         unset($this->aclContents[$oc]);
         unset($this->aclContents[$this->aclObject.'/'.$oc]);
@@ -467,16 +473,39 @@ 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);
+
+    foreach($list as $name => $translation){
+      $na  =  preg_replace("/^.*\//","",$name);
+      $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);
 
     /* Build general objects */
+
+    $list =$this->sort_by_priority($list);
     foreach ($list as $key => $name){
 
       /* Create sub acl if it does not exist */
@@ -500,7 +529,7 @@ class acl extends plugin
                      "\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>".