Code

Added . to list of available departments. To be able to set obtions for the current...
[gosa.git] / plugins / admin / departments / class_departmentManagement.inc
index 5f9ed0d06288d3f4aa463072ead95e5e1ed6ae6e..815f40da2b874a87de132c048275da4bac52637c 100644 (file)
@@ -55,10 +55,11 @@ class departmentManagement extends plugin
 
   function execute()
   {
+    global $config;
+  
     /* Call parent execute */
     plugin::execute();
 
-
     /***************
       Var init 
      ***************/
@@ -66,13 +67,8 @@ class departmentManagement extends plugin
     $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^dep_edit_.*/","/^dep_del_.*/");
 
     /* Reload departments */
-    $this->config->get_departments();
-    $this->config->make_idepartments();
-    $_SESSION['config']= $this->config;
-
     $smarty                                            = get_smarty();
     $display                                   = "";
-    $depfilter                                 = get_global("depfilter");
     $s_action                                  = "";  // Will contain an action, like del or edit
     $s_entry                                   = "";  // The entry name for edit delete -...
 
@@ -159,7 +155,7 @@ class departmentManagement extends plugin
         return(gen_locked_message($user, $this->dn));
       } else {
         add_lock ($this->dn, $this->ui->dn);
-        $smarty->assign("info", sprintf(_("You're about to delete the whole LDAP subtree placed under '%s'."), LDAP::fix($this->dn)));
+        $smarty->assign("info", sprintf(_("You're about to delete the whole LDAP subtree placed under '%s'."), @LDAP::fix($this->dn)));
         $display.= $smarty->fetch (get_template_path('remove.tpl', TRUE));
         return ($display);
       }
@@ -307,6 +303,7 @@ class departmentManagement extends plugin
       return ($display);
     }else{
       /* Display dialog with group list */
+      $this->DivListDepartment->parent = $this;
       $this->DivListDepartment->execute();
       $this->reload();
       $this->DivListDepartment->DepartmentsAdded = true;
@@ -340,18 +337,33 @@ class departmentManagement extends plugin
 
     if($this->DivListDepartment->SubSearch){
       $res= get_list("(&(|(ou=$Regex)(description=$Regex))(objectClass=gosaDepartment))",
-          $this->ui->subtreeACL, $base, array("ou", "description"), GL_SIZELIMIT | GL_CONVERT | GL_SUBSEARCH);
+          $this->ui->subtreeACL, $base, array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH);
     }else{
       $res= get_list("(&(|(ou=$Regex)(description=$Regex))(objectClass=gosaDepartment))",
-          $this->ui->subtreeACL, $base, array("ou", "description"), GL_SIZELIMIT | GL_CONVERT);
+          $this->ui->subtreeACL, $base, array("ou", "description"), GL_SIZELIMIT );
     }
 
     $this->departments= array();
-    foreach ($res as $value){
+
+    /* Add current base to the list of available departments, but only if its naming attribute is 'ou' */
+    if(preg_match("/^ou=/",$base)){
+      $this->departments [ convert_department_dn($base) ] = ".";
+    }
+
+    foreach ($res as $key => $value){
+
+      /* Don't display base as entry on subsearch */
+      if(($value['dn'] == $base) && ($this->DivListDepartment->SubSearch)){
+        continue;
+      }
+
+      $cdn= convert_department_dn($value['dn']);
+
+      /* Append to dep list */
       if(isset($value["description"][0])){
-        $this->departments[$value['dn']]= get_sub_department($value['dn'])." - [".$value["description"][0]."]";
+        $this->departments[$cdn]= get_sub_department($cdn)." - [".$value["description"][0]."]";
       }else{
-        $this->departments[$value['dn']]= get_sub_department($value['dn']);//$value["description"][0];
+        $this->departments[$cdn]= get_sub_department($cdn);//$value["description"][0];
       }
     }
     natcasesort ($this->departments);
@@ -387,8 +399,26 @@ class departmentManagement extends plugin
 
   function save_object()
   {
+    /* reload department */
+    $this->config->get_departments();
+    $config = $this->config;
+
+    $this->config->make_idepartments();
     $this->DivListDepartment->save_object();
   }
+
+  function plInfo()
+  {
+    return (array("plDescription" => _("Departments"),
+                  "plSelfModify" => FALSE,
+                  "plDepends" => array("objectClass" => "gosaDepartment", "description" => _("Departments")),
+                  "description" => _("Description"),
+                  "c" => _("Country"),
+                  "l" => _("Location"),
+                  "telephoneNumber" => _("Telephone"),
+                  "ou" => _("Department name") ));
+  }
+
   
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: