Code

Added current-user-dn-update-function.
[gosa.git] / include / class_acl.inc
index 7bd9ba33f1c03eaa62b01d4b580be28d836e9bb2..2d9e72501b28b2e872d42c82deb8037d9d12a181 100644 (file)
@@ -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();
@@ -263,7 +265,7 @@ class acl extends plugin
     }
     
     /* Only be interested in new acl's, if we're in the right _POST place */
-    if ($aclDialog && is_array($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]);
@@ -278,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;
     }
 
@@ -473,7 +475,32 @@ 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= "<input type='hidden' name='acl_dummy_0_0_0' value='1'>";
@@ -482,7 +509,39 @@ class acl extends plugin
     $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 */
@@ -544,7 +603,7 @@ class acl extends plugin
 
       $display.= "\n  <tr>".
                  "\n    <td style='background-color:#E0E0E0' colspan=".($cols-1).">$options</td>".
-                 "\n    <td style='background-color:#D4D4D4'>&nbsp;".("Complete object:")." $more_options</td>".
+                 "\n    <td style='background-color:#D4D4D4'>&nbsp;"._("Complete object").": $more_options</td>".
                  "\n  </tr>";
 
       /* Walk through the list of attributes */