Code

Fixed acls
[gosa.git] / plugins / admin / departments / class_divListDepartment.inc
index e2b1509e63cc78e0eef04032205a99f3d2e7062b..5bb5c9d6e3f0c3ecfd1207f65d9220dc7324e6c0 100755 (executable)
@@ -18,7 +18,7 @@ class divListDepartment extends MultiSelectWindow
 
   function divListDepartment ($config,$parent)
   {
-    MultiSelectWindow::MultiSelectWindow($config,"Department");
+    MultiSelectWindow::MultiSelectWindow($config, "Department", "department");
     
     $this->parent       = $parent;
     $this->ui           = get_userinfo();
@@ -30,28 +30,23 @@ class divListDepartment extends MultiSelectWindow
 
     /* Result page will look like a headpage */
     $this->SetHeadpageMode();
-    $this->SetInformation(_("This menu allows you to create, delete and edit selected departments. Having a large size of departments, you might prefer the range selectors on   top of the department list."));
+    $this->SetInformation(_("This menu allows you to create, delete and edit selected departments. Having a large number of departments, you might prefer the range selectors on top of the department list."));
   
     /* Disable buttonsm */
     $this->EnableCloseButton(false);
     $this->EnableSaveButton (false);
 
-    /* Dynamic action col, depending on snapshot icons */
-    $action_col_size = 50;
-    if($this->parent->snapshotEnabled()){
-      $action_col_size += 20;
-    }
-
     /* set Page header */
     $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'"));
     $this->AddHeader(array("string"=>_("Department name"), "attach" => "style=''"));
-    $this->AddHeader(array("string" =>_("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"));
+    $this->AddHeader(array("string" =>_("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'"));
+
 
     /* Add SubSearch checkbox */    
     $this->AddCheckBox("SubSearch",  _("Select to search within subtrees"), _("Ignore subtrees"), false);
 
     /*                  Name                 ,Text                              ,Default  , Connect with alphabet  */
-    $this->AddRegex   ("Regex",     _("Regular expression for matching group names"), "*" , true);
+    $this->AddRegex   ("Regex",     _("Regular expression for matching department names"), "*" , true);
   }
 
 
@@ -70,29 +65,31 @@ class divListDepartment extends MultiSelectWindow
     }
 
     /* Generate list head */
+    $ui = get_userinfo();
+    $acl = $ui->get_permissions("ou=dummy,",$this->selectedBase  ,"department/department");
+
     $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
-      " <input type='image' class='center' src='images/list_root.png' align='middle' 
-        title='"._("Go to root department")."' name='dep_root' alt='".       _("Root")."'>&nbsp;".
-      " <input type='image' class='center' src='images/list_up.png' align='middle' 
-        title='"._("Go up one department")."' name='dep_back' alt='"._("Up").  "'>&nbsp;".
-      " <input type='image' class='center' src='images/list_home.png' align='middle' 
-        title='"._("Go to users home department")."' name='dep_home' alt='". _("Home")."'>&nbsp;".
-      " <input class='center' type='image' src='images/list_reload.png' align='middle' 
-        title='"._("Reload list")."' name='submit_department' alt='".      _("Submit")."'>&nbsp;".
-      " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;";
-
-    if($this->parent->snapshotEnabled()){
-      $listhead .= "  <input class='center' type='image' align='middle' src='images/restore.png'        
-        title='"._("Restore snapshopts of already deleted objects")."' alt='"._("Restore")."' name='RestoreDeletedSnapShot'>".
-        " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;";
+      " <input type='image' class='center' src='images/list_root.png' align='middle' ".
+      "   title='"._("Go to root department")."' name='dep_root' alt='".       _("Root")."'>&nbsp;".
+      " <input type='image' class='center' src='images/list_up.png' align='middle' ".
+      "   title='"._("Go up one department")."' name='dep_back' alt='"._("Up").  "'>&nbsp;".
+      " <input type='image' class='center' src='images/list_home.png' align='middle' ".
+      "   title='"._("Go to users home department")."' name='dep_home' alt='". _("Home")."'>&nbsp;".
+      " <input class='center' type='image' src='images/list_reload.png' align='middle' ".
+      "   title='"._("Reload list")."' name='submit_department' alt='".      _("Submit")."'>&nbsp;";
+      
+    if(preg_match("/c/",$acl)){
+      $listhead .=  " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
+        " <input class='center' type='image' src='images/list_new_department.png' ".
+        "   align='middle' alt='"._("Create new department")."' name='dep_new'>&nbsp; ";
     }
+  
 
-    $listhead .=  " <input class='center' type='image' src='images/list_new_department.png' 
-        align='middle' alt='"._("Create new department")."' name='dep_new'>&nbsp; ".
-      " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
-      _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
-      " <input class='center' type='image' src='images/list_submit.png' align='middle' 
-        title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
+    $listhead .= " <img class='center' src='images/list_seperator.png' align='middle' ".
+      " alt='' height='16' width='1'>&nbsp;".
+      " "._("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
+      " <input class='center' type='image' src='images/list_submit.png' align='middle' ".
+      "   title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
       "</div>";
 
     $this->SetListHeader($listhead);
@@ -106,29 +103,23 @@ class divListDepartment extends MultiSelectWindow
 
   function setEntries($list)
   {
-
     $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
 
-    /* Dynamic action col, depending on snapshot icons */
-    $action_col_size = 50;
-    if($this->parent->snapshotEnabled()){
-      $action_col_size += 20;
-    }
-
+    $ui = get_userinfo();
     foreach($list as $key => $val) {
-  
-      $cdn= convert_department_dn($val['dn']);  
-      if(isset($val["description"][0])) {
-        $disp = get_sub_department($cdn)." - [".$val["description"][0]."]";
-      }else{
-        $disp = get_sub_department($cdn);
+
+      $actions= "";      
+
+      $acl = $ui->get_permissions($this->config->departments[$key] ,"department/department");
+      if(preg_match("/r/",$acl)){
+        $actions.= "<input class='center' type='image' src='images/edit.png'
+          alt='"._("edit")."'   name='dep_edit_%KEY%' title='"._("Edit this entry")."'>";
+      }
+
+      if(preg_match("/c/",$acl)){
+        $actions.= "<input class='center' type='image' src='images/edittrash.png'
+          alt='"._("delete")."'   name='dep_del_%KEY%' title='"._("Delete this entry")."'>";
       }
-  
-      $actions= "<input class='center' type='image' src='images/edit.png'
-        alt='"._("edit")."'   name='dep_edit_%KEY%' title='"._("Edit this entry")."'>";
-      $actions.= $this->GetSnapShotActions($val['dn']);
-      $actions.= "<input class='center' type='image' src='images/edittrash.png'
-        alt='"._("delete")."'   name='dep_del_%KEY%' title='"._("Delete this entry")."'>";
 
       if(!isset($this->config->departments[trim($key)])){
         $this->config->departments[trim($key)]="";
@@ -144,8 +135,8 @@ class divListDepartment extends MultiSelectWindow
 
       $title = preg_replace('/ /', '&nbsp;', @LDAP::fix($this->config->departments[$key]));
       $field0 = array("string" => "<img src='images/".$non_empty."folder.png' title='"._("department")."' alt='department'>", "attach" => "style='text-align:center;width:20px;'");
-      $field1 = array("string" => sprintf($linkopen,base64_encode($cdn),$disp), "attach" => "style='' title='".$title."'");
-      $field2 = array("string" => preg_replace("/%KEY%/", base64_encode($key), $actions), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:
+      $field1 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style='' title='".$title."'");
+      $field2 = array("string" => preg_replace("/%KEY%/", base64_encode($key), $actions), "attach" => "style='width:60px;border-right:0px;text-align:
           right;'");
 
       $this->AddElement( array($field0,$field1,$field2));