Code

Updated workstation - Startup
[gosa.git] / plugins / admin / systems / class_glpiSelectUser.inc
index 053bc0d13e45552c91c2bb576fa40866bd58d902..7073b12a40564807837d986f706cd683fb9f518b 100644 (file)
@@ -19,7 +19,7 @@ class glpiSelectUser extends plugin
 
   var $PostVarName      = "";
 
-  function glpiSelectUser ($config, $dn= NULL,$postvar)
+  function glpiSelectUser (&$config, $dn= NULL,$postvar)
   {
     plugin::plugin ($config, $dn);
 
@@ -106,6 +106,7 @@ class glpiSelectUser extends plugin
     $display= "";
 
     $divlist = new divlist("glpi users");
+    $divlist->SetPluginMode();
     $divlist->SetEntriesPerPage(0);
     $divlist->SetHeader(array(
           array("string" => " ", "attach" => "style='text-align:center;width:20px;'"),
@@ -146,12 +147,27 @@ class glpiSelectUser extends plugin
      /* Prepare departments,
        which are shown in the listbox on top of the listbox
      */
-    $options= "";
-    foreach ($this->config->idepartments as $key => $value){
-      if ($_SESSION['glpi_user_filter']['base'] == $key){
-        $options.= "<option selected='selected' value='$key'>$value</option>";
-      } else {
-        $options.= "<option value='$key'>$value</option>";
+
+    
+    /* Get all departments within this subtree */
+    $this->base = $_SESSION['glpi_user_filter']['base'];
+    $options  ="";
+    $base = $this->config->current['BASE'];
+    $deps= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", "users", $base,
+                    array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH);
+
+    /* Load possible departments */
+    $ui= get_userinfo();
+    $tdeps= $ui->get_module_departments("users");
+    $ids = $this->config->idepartments;
+    foreach($deps as $dep){
+      if(isset($ids[$dep['dn']]) && in_array_ics($dep['dn'], $tdeps)){
+        $value = $ids[$dep['dn']];
+        if ($this->base == $dep['dn']){
+          $options.= "<option selected='selected' value='".$dep['dn']."'>$value</option>";
+        } else {
+          $options.= "<option value='".$dep['dn']."'>$value</option>";
+        }
       }
     }
 
@@ -208,8 +224,8 @@ class glpiSelectUser extends plugin
      * So we are able to navigate like in konquerer
      */
 
-    $res3 =  get_list2($this->ui->subtreeACL, "(&(|(ou=*)(description=*))(objectClass=gosaDepartment))",
-        TRUE, $base, array("ou", "description"), TRUE);
+    $res3= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))","users",
+       $base, array("ou", "description"), GL_SIZELIMIT | GL_CONVERT);
 
     $this->departments= array();
     $tmp = array();
@@ -219,17 +235,19 @@ class glpiSelectUser extends plugin
     ksort($tmp);
     foreach($tmp as $value){
       if(isset($value["description"][0])){
-        $this->departments[$value['dn']]= convert_department_dn2($value['dn'])." - [".$value["description"][0]."]";
+        $this->departments[$value['dn']]= get_sub_department($value['dn'])." - [".$value["description"][0]."]";
       }else{
-        $this->departments[$value['dn']]= convert_department_dn2($value['dn']);//$value["description"][0];
+        $this->departments[$value['dn']]= get_sub_department($value['dn']);//$value["description"][0];
       }
     }
 
     /* END NEW LIST MANAGMENT
      */
     $ou = get_people_ou();
-    $res2 = get_list($this->ui->subtreeACL, "(&(|(cn=$regex)(sn=$regex))(objectClass=person))",
-        TRUE,$ou.$base, array("cn","sn","uid","givenName", "description"), TRUE);
+
+    $res2= get_list("(&(|(cn=$regex)(sn=$regex))(objectClass=person))", "users",
+                    $ou.$base, array("cn", "sn", "uid", "givenName", "description"),
+                    GL_SUBSEARCH | GL_SIZELIMIT);
 
     $tmp = array();