Code

Fixed one department level up <- action in management lists.
[gosa.git] / gosa-core / include / class_MultiSelectWindow.inc
index c77f07b6497d1a9e1619e30b16b17430bd96ee3c..fa59990e053b1fef5d9f436e1efd54513afc60b3 100644 (file)
@@ -555,16 +555,8 @@ class MultiSelectWindow{
       $base_back= preg_replace("/^[^,]+,/", "", session::get('CurrentMainBase'));
       $dep_id = $this->ui->get_module_departments($this->module);
       if(in_array_ics($base_back,$dep_id)){
-
-        /* The department array keeps non DN entries as index. We need to convert
-           it before checking the existance. */
-        $base_back= trim(convert_department_dn($base_back));
-
-        /* Check if the department exists, otherwise revert to the configure base DN */
-        if(isset($this->config->departments[$base_back])){
-          $this->selectedBase= $this->config->departments[$base_back];
-        }else{
-          $this->selectedBase= $this->config->departments['/'];
+        if(in_array($base_back,$this->config->departments)){
+          $this->selectedBase = $base_back;
         }
       }
     }
@@ -663,25 +655,33 @@ class MultiSelectWindow{
 
                /* Get all departments within this subtree */
                $deps= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
-                    array("ou", "description"), GL_SIZELIMIT );
+                    array("ou", "description","objectClass"), GL_SIZELIMIT );
 
                /* Edit delete link for system types
                 */
                $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
 
                /* Create an array with all visible (in the list) departments */
+    $types = departmentManagement::get_support_departments();
+
                $departments = array();
                foreach($deps as $value){
       $name = $value['ou'][0]." -".$value['dn'];
-                 $this->departments[$name]= $value; 
+      foreach($types as $type){
+        if(in_array($type['OC'],$value['objectClass'])){
+          $value['type'] = $type;
+          break;
+        }
+      }       
+                 $this->departments[$name]= $value;
                }
     uksort($this->departments, 'strnatcasecmp');
-    $this->departments = array_values($this->departments);
 
     $ui = get_userinfo();
     $module_deps = $ui->get_module_departments($this->module);
   
                /* Add deps to this dialog object list */
+    $this->departments = array_values($this->departments);
                foreach($this->departments as $key=> $val){
 
       if(!in_array($val['dn'],$module_deps)) continue;
@@ -689,13 +689,15 @@ class MultiSelectWindow{
       /* Check if this department contains sub-departments
          Display different image in this case
        */
-      $non_empty="";
+      $img = $val['type']['IMG'];
       foreach($this->config->departments as $keyd){
         if(preg_match("/,".normalizePreg($val['dn'])."$/",$keyd)){
-          $non_empty="-full";
+          $img = $val['type']['IMG_FULL'];
         }
       }
 
+      $img = "<image src='".$img."' class='center'>";
+
                        /* Add spacer cols to divlist 
        */
                        $row = array();
@@ -714,7 +716,6 @@ class MultiSelectWindow{
 
       /* Add departments
        */
-      $img = "<img src='images/lists/folder".$non_empty.".png' alt='department'>";
                        $row[]=$field1=array("string"=> $img,"attach"=>"style='text-align:center;width:20px;'");
                        $row[]=$field2=array("string"=>sprintf($linkopen,$key,$name), "attach" => "style=''");