Code

Fixed size test.
[gosa.git] / include / class_acl.inc
index a3a169a06e8685555823cbd6b80a26dd014c64c0..41082b3106b9f17b2e92c18561030ced671d004b 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)
   {
@@ -154,8 +154,8 @@ class acl extends plugin
                              "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"));
@@ -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;
     }
 
@@ -449,6 +451,11 @@ class acl extends plugin
       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'){
@@ -464,7 +471,13 @@ class acl extends plugin
       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 */
@@ -478,10 +491,14 @@ class acl extends plugin
     $tmp= get_global('plist');
     $plist= $tmp->info;
     asort($plist);
+    $newSort = array();
 
     foreach($list as $name => $translation){
       $na  =  preg_replace("/^.*\//","",$name);
-      $prio=  $plist[$na]['plPriority'] ;
+      $prio = 0;
+      if(isset($plist[$na]['plPriority'])){
+        $prio=  $plist[$na]['plPriority'] ;
+      }
 
       $newSort[$name] = $prio;
     }
@@ -533,8 +550,8 @@ class acl extends plugin
     $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 */
 
+    /* Build general objects */
     $list =$this->sort_by_priority($list);
     foreach ($list as $key => $name){
 
@@ -597,7 +614,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 */
@@ -706,7 +723,7 @@ class acl extends plugin
         break;
       
       case 'role':
-        echo "Role";
+        echo "Role: $acl";
         break;
 
       case 'reset':