Code

Imroved speed of department listings,
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 30 Oct 2008 08:26:21 +0000 (08:26 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 30 Oct 2008 08:26:21 +0000 (08:26 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12819 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_MultiSelectWindow.inc

index 54df235d08f97e2d96f8af94fb707c1af8d8a796..0e40eab1e5547b792fd3837dc82859d95d8cceb1 100644 (file)
@@ -659,7 +659,7 @@ class MultiSelectWindow{
     $types = departmentManagement::get_support_departments();
     $ui = get_userinfo();
     $module_deps = $ui->get_module_departments($this->module);
-
+    $found_deps = array();
 
                /* check for a valid base */
                if(!$base){
@@ -693,29 +693,17 @@ class MultiSelectWindow{
         }
       }
     }
-    uksort($departments, 'strnatcasecmp');
 
     /* Detect allowed departments 
      */
     $deps = array_intersect($found_deps,$module_deps);
+    uksort($deps, 'strnatcasecmp');
     $key = 0;
     foreach($deps as $name => $dn){
       $key ++;
       $val = $departments[$name];
       $this->departments[$key] = $val;
-    
-      /* Check if this department contains sub-departments
-         Display different image in this case
-       */
-      $img = $val['TYPE']['IMG'];
-#      foreach($this->config->departments as $keyd){
-#        if(preg_match("/,".normalizePreg($val['dn'])."$/",$keyd)){
-#          $img = $val['TYPE']['IMG_FULL'];
-#        }
-#     }
-
-  
-      $img = "<image src='".$img."' class='center'>";
+      $img = "<image src='".$val['TYPE']['IMG']."' class='center'>";
 
                        /* Add spacer cols to divlist 
        */
@@ -757,45 +745,34 @@ class MultiSelectWindow{
 
   function create_department_list($modules)
   { 
-     /* Load possible departments */
+    $departments = array();
     $ui= get_userinfo();
     $first = "";
     $found = FALSE;
+    $options ="";
 
-    if(!is_array($modules)){
-      $modules = array($modules);
-    }
-
-    $department = $departments = array();
     $ids = $this->config->idepartments;
-    foreach($modules as $module){
-      $d = $ui->get_module_departments($module);
-
-      foreach($ids as $department => $desc){
-        if(in_array($department,$d)){
-          $departments[$department] = $department;
-        }
-      }
+    $d   = $ui->get_module_departments($modules);
+    $k_ids = array_keys($ids);
+    $deps = array_intersect($d,$k_ids);
+    foreach($k_ids as $department){
+      $departments[$department] = $ids[$department];
     }
 
-    $first = "";
-    $found = FALSE;
-    $options ="";
-    foreach($departments as $dep => $name){
+    foreach($departments as $value => $name){
 
       /* Keep first base dn in mind, we could need this
        *  info if no valid base was found
        */
       if(empty($first)) {
-        $first = $dep['dn'];
+        $first = $value;
       }
 
-      $value = $ids[$dep];
-      if ($this->selectedBase == $dep){
+      if ($this->selectedBase == $value){
         $found = TRUE;
-        $options.= "<option selected='selected' value='".$dep."'>$value</option>";
+        $options.= "<option selected='selected' value='".$value."'>$name</option>";
       } else {
-        $options.= "<option value='".$dep."'>$value</option>";
+        $options.= "<option value='".$value."'>$name</option>";
       }
     }