Code

Added some logging
[gosa.git] / plugins / admin / departments / class_divListDepartment.inc
index a5a0762bf469b585d87f938e6d4978b1b2db839e..c3a59151906c925885b8f3cc8d0416205c2cd143 100755 (executable)
@@ -69,20 +69,26 @@ class divListDepartment extends MultiSelectWindow
     $first = "";
     $found = FALSE;
     $base = $this->config->current['BASE'];
-    $deps= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
-                    array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH);
 
     /* Add base */
-    $deps[] = array("dn"=>$this->config->current['BASE']);
+    $tmp = array();
+    $tmp[] = array("dn"=>$this->config->current['BASE']);
+    $tmp=  array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
+                    array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH));
+
+    $deps = array();
+    foreach($tmp as $tm){
+      $deps[$tm['dn']] = $tm['dn'];
+    }
 
     /* Load possible departments */
     $ui= get_userinfo();
     $tdeps= $ui->get_module_departments("department");
-
     $ids = $this->config->idepartments;
-
-    foreach($deps as $dep){
-      if(isset($ids[$dep['dn']]) && in_array_ics($dep['dn'], $tdeps)){
+    $first = "";
+    $found = FALSE;
+    foreach($ids as $dep => $name){
+      if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){
 
         /* Keep first base dn in mind, we could need this
          *  info if no valid base was found
@@ -91,11 +97,12 @@ class divListDepartment extends MultiSelectWindow
           $first = $dep['dn'];
         }
 
-        $value = $ids[$dep['dn']];
-        if ($this->selectedBase == $dep['dn']){
-          $options.= "<option selected='selected' value='".$dep['dn']."'>$value</option>";
+        $value = $ids[$dep];
+        if ($this->selectedBase == $dep){
+          $found = TRUE;
+          $options.= "<option selected='selected' value='".$dep."'>$value</option>";
         } else {
-          $options.= "<option value='".$dep['dn']."'>$value</option>";
+          $options.= "<option value='".$dep."'>$value</option>";
         }
       }
     }