Code

Updated strings
[gosa.git] / gosa-core / include / class_acl.inc
index 34a9fc3445613bf7eadc9fcac8a23290046ee3d7..853893edcd486e35178ebc96cee973e92e7d3f23 100644 (file)
@@ -54,7 +54,10 @@ class acl extends plugin
   var $myAclObjects = array();
   var $acl_category = "acl/";
 
-   var $list =NULL;
+  var $list =NULL;
+
+  var $sectionList = NULL;
+  var $roleList = NULL;
 
   function acl (&$config, $parent, $dn= NULL)
   {
@@ -239,6 +242,27 @@ class acl extends plugin
     $this->is_account= TRUE;
 
     $this->updateList();
+
+    // Prepare lists 
+    $this->sectionList = new sortableListing();
+    $this->sectionList->setDeleteable(false);
+    $this->sectionList->setEditable(false);
+    $this->sectionList->setWidth("100%");
+    $this->sectionList->setHeight("120px");
+    $this->sectionList->setColspecs(array('200px','*'));
+    $this->sectionList->setHeader(array(_("Section"),_("Description")));
+    $this->sectionList->setDefaultSortColumn(1);
+    $this->sectionList->setAcl('rwcdm'); // All ACLs, we filter on our own here.
+
+    $this->roleList = new sortableListing();
+    $this->roleList->setDeleteable(false);
+    $this->roleList->setEditable(false);
+    $this->roleList->setWidth("100%");
+    $this->roleList->setHeight("120px");
+    $this->roleList->setColspecs(array('20px','*','*'));
+    $this->roleList->setHeader(array(_("Used"),_("Name"),_("Description")));
+    $this->roleList->setDefaultSortColumn(1);
+    $this->roleList->setAcl('rwcdm'); // All ACLs, we filter on our own here.
   }
 
     
@@ -268,8 +292,11 @@ class acl extends plugin
   function convertForListing($entry)
   {
     $member = implode($entry['members'],", ");
-    $acl = implode(array_keys($entry['acl']),", ");
-    $type = implode(array_keys($entry['acl']),", ");
+    if(isset($entry['acl']) && is_array($entry['acl'])){
+        $acl = implode(array_keys($entry['acl']),", ");
+    }else{
+        $acl="";
+    }
     return(array('data' => array($member, $acl, $this->aclTypes[$entry['type']])));
   }
 
@@ -298,7 +325,7 @@ class acl extends plugin
     // Get listing actions. Delete or Edit.
     $this->list->save_object();
     $lAction = $this->list->getAction();
-    $this->gosaAclEntry = $this->list->getMaintainedData();
+    $this->gosaAclEntry = array_values($this->list->getMaintainedData());
 
     /* Act on HTML post and gets here.
      */
@@ -378,6 +405,9 @@ class acl extends plugin
       if(isset($_POST['selected_role']) && $_POST['aclType'] == 'role'){
         $this->aclContents = "";
         $this->aclContents = base64_decode($_POST['selected_role']);
+      }else{
+          if(is_string($this->aclContents))
+              $this->aclContents = array();
       }
     }
 
@@ -503,55 +533,63 @@ class acl extends plugin
 
     if ($this->dialogState == 'create'){
 
-      $aclList= new divSelectBox("aclList");
-      $aclList->SetHeight(150);
-
-      // Create a map of all used sections, this allows us to simply hide the remove button 
-      //  if no acl is configured for the given section 
-      // e.g. ';all;department/country;users/user;
-      $usedList = ";".implode(array_keys($this->aclContents),';').";";
-
-      /* Add settings for all categories to the (permanent) list */
-      foreach ($this->aclObjects as $section => $dsc){
-        $summary= "";
-        foreach($this->ocMapping[$section] as $oc){
-          if (isset($this->aclContents[$oc]) && count($this->aclContents[$oc]) && isset($this->aclContents[$oc][0]) &&
-              $this->aclContents[$oc][0] != ""){
 
-            $summary.= "$oc, ";
-            continue;
-          }
-          if (isset($this->aclContents["$section/$oc"]) && count($this->aclContents["$section/$oc"])){
-            $summary.= "$oc, ";
-            continue;
-          }
-          if (isset($this->aclContents[$oc]) && !isset($this->aclContents[$oc][0]) && count($this->aclContents[$oc])){
-            $summary.= "$oc, ";
-          }
-        }
+        if($this->aclType != 'role'){
+
+            // Create a map of all used sections, this allows us to simply hide the remove button 
+            //  if no acl is configured for the given section 
+            // e.g. ';all;department/country;users/user;
+            $usedList = ";".implode(array_keys($this->aclContents),';').";";
+
+            /* Add settings for all categories to the (permanent) list */
+            $data = $lData = array();
+            foreach ($this->aclObjects as $section => $dsc){
+                $summary= "";
+                foreach($this->ocMapping[$section] as $oc){
+                    if (isset($this->aclContents[$oc]) && 
+                            count($this->aclContents[$oc]) && 
+                            isset($this->aclContents[$oc][0]) &&
+                            $this->aclContents[$oc][0] != ""){
+
+                        $summary.= "$oc, ";
+                        continue;
+                    }
+                    if (isset($this->aclContents["$section/$oc"]) && 
+                            count($this->aclContents["$section/$oc"])){
+                        $summary.= "$oc, ";
+                        continue;
+                    }
+                    if (isset($this->aclContents[$oc]) && 
+                            !isset($this->aclContents[$oc][0]) && 
+                            count($this->aclContents[$oc])){
+                        $summary.= "$oc, ";
+                    }
+                }
 
-        /* Set summary... */
-        if ($summary == ""){
-          $summary= '<i>'._("No ACL settings for this category!").'</i>';
-        } else {
-          $summary= sprintf(_("Contains ACLs for these objects: %s"), preg_replace('/, $/', '', $summary));
-        }
+                /* Set summary... */
+                if ($summary == ""){
+                    $summary= '<i>'._("No ACL settings for this category!").'</i>';
+                } else {
+                    $summary= trim($summary,", ");
+                    $summary= " ".sprintf(_("ACLs for: %s"), $summary);
+                }
 
-        $actions ="";
-        if($this->acl_is_readable("")){
-          $actions.= image('images/lists/edit.png','cat_edit_'.$section, msgPool::editButton(_("category ACL")));
+                $actions ="";
+                if($this->acl_is_readable("")){
+                    $actions.= image('images/lists/edit.png','cat_edit_'.$section, 
+                            msgPool::editButton(_("category ACL")));
+                }
+                if($this->acl_is_removeable() && preg_match("/;".$section."(;|\/)/", $usedList)){
+                    $actions.= image('images/lists/trash.png','cat_del_'.$section, 
+                            msgPool::delButton(_("category ACL")));
+                }   
+                $data[] = $section;
+                $lData[] = array('data'=>array($dsc, $summary, $actions));
+            }
+            $this->sectionList->setListData($data,$lData);
+            $this->sectionList->update();
+            $smarty->assign("aclList", $this->sectionList->render());
         }
-        if($this->acl_is_removeable() && preg_match("/;".$section."(;|\/)/", $usedList)){
-          $actions.= image('images/lists/trash.png','cat_del_'.$section, msgPool::delButton(_("category ACL")));
-        }   
-
-        $field1= array("string" => $dsc, "attach" => "style='width:100px'");
-        $field2= array("string" => $summary);
-        $field3= array("string" => $actions, "attach" => "style='border-right:0px;width:50px'");
-        $aclList->AddEntry(array($field1, $field2, $field3));
-      }
-
-      $smarty->assign("aclList", $aclList->DrawList());
     
       $smarty->assign("aclType", $this->aclType);
       $smarty->assign("aclFilter", $this->aclFilter);
@@ -590,13 +628,12 @@ class acl extends plugin
 
       /* Role selector if scope is base */
       if ($this->aclType == 'role'){
-        $smarty->assign('roleSelector', "Role selector");#, $this->buildRoleSelector($this->myAclObjects));
         $smarty->assign('roleSelector', $this->buildRoleSelector($this->roles));
       }
     }
 
     if ($this->dialogState == 'edit'){
-      $smarty->assign('headline', sprintf(_("Edit ACL for '%s' - scope is '%s'"), $this->aclObjects[$this->aclObject], $this->aclTypes[$this->aclType]));
+      $smarty->assign('headline', sprintf(_("Edit ACL for '%s' with scope '%s'"), $this->aclObjects[$this->aclObject], $this->aclTypes[$this->aclType]));
 
       /* Collect objects for selected category */
       foreach ($this->ocMapping[$this->aclObject] as $idx => $class){
@@ -659,29 +696,24 @@ class acl extends plugin
 
   function buildRoleSelector($list)
   {
-    $D_List =new divSelectBox("Acl_Roles");
     $selected = $this->aclContents;
     if(!is_string($this->aclContents) || !isset($list[$this->aclContents])){
       $selected = key($list);
     }
 
-    $str ="";
+    $data = $lData = array();
     foreach($list as $dn => $values){
-
       if($dn == $selected){    
         $option = "<input type='radio' name='selected_role' value='".base64_encode($dn)."' checked>";
       }else{
         $option = "<input type='radio' name='selected_role' value='".base64_encode($dn)."'>";
       }
-      $field1 = array("string" => $option) ;
-      $field2 = array("string" => $values['cn'], "attach" => "style='width:200px;'") ;
-      $field3 = array("string" => $values['description'],"attach" => "style='border-right:0px;'") ;
-
-      $D_List->AddEntry(array($field1,$field2,$field3));
+      $data[] = postEncode($dn);
+      $lData[] = array('data'=>array($option, $values['cn'], $values['description']));
     }
-    return($D_List->DrawList());
+    $this->roleList->setListData($data,$lData);
+    $this->roleList->update();
+    return($this->roleList->render());
   } 
 
 
@@ -914,9 +946,13 @@ class acl extends plugin
     if(count($list) == 5){
       list($index, $type,$member,$permission,$filter)= $list;
       $filter = base64_decode($filter);
-    }else{
+    }elseif(count($list) == 4){
       $filter = "";
       list($index, $type,$member,$permission)= $list;
+    }else{
+      $permission = "";
+      $filter = "";
+      list($index, $type,$member)= $list;
     }
 
     $a= array( $index => array("type" => $type,
@@ -1050,9 +1086,9 @@ class acl extends plugin
       if($entry['type'] == "role"){
 
         if(isset($this->roles[$entry['acl']])){  
-          $summary.= sprintf(_("Role: %s"), $this->roles[$entry['acl']]['cn']);
+          $summary.= sprintf(_("ACL role: %s"), $this->roles[$entry['acl']]['cn']);
         }else{
-          $summary.= sprintf(_("Role: %s"), "<i>"._("unknown role")."</i>");
+          $summary.= sprintf(_("ACL role: %s"), "<i>"._("unknown ACL role")."</i>");
         }
       }else{
         foreach ($entry['acl'] as $name => $object){
@@ -1096,7 +1132,7 @@ class acl extends plugin
       $acl= $this->gosaAclEntry[$this->currentIndex];
       $this->aclType= $acl['type'];
       $this->recipients= $acl['members'];
-      $this->aclContents= $acl['acl'];
+      $this->aclContents= (isset($acl['acl'])) ? $acl['acl'] :"";
       $this->aclFilter= $acl['filter'];
     }
 
@@ -1146,8 +1182,9 @@ class acl extends plugin
       }
 
       /* ACL's if needed */
+      $final.= ":";
       if ($entry['type'] != "reset" && $entry['type'] != "role"){
-        $acl= ":";
+        $acl = "";
         if (isset($entry['acl'])){
           foreach ($entry['acl'] as $object => $contents){
 
@@ -1180,7 +1217,7 @@ class acl extends plugin
       }
 
       $tmp_acl[]= $final;
-    } 
+    }
 
     /* Call main method */
     plugin::save();
@@ -1255,8 +1292,7 @@ class acl extends plugin
           "plCategory"    => array("acl" => array("description"  => _("ACL")."&nbsp;&amp;&nbsp;"._("ACL roles"),
                                                           "objectClass"  => array("gosaAcl","gosaRole"))),
           "plProvidedAcls"=> array(
-            "gosaAclEntry"          => _("Acl entries")
-//            "description" => _("Role description")
+           "gosaAclEntry"          => _("ACL Entries")
             )
 
           ));