Code

Readded template functionality for workstations and terminals
[gosa.git] / plugins / admin / systems / class_divListSystem.inc
index fe125e2aa7090e760c6afafae5d23041836084b5..7544aceaef882cc5ee5d91f64f64a1b6890a8109 100644 (file)
@@ -28,7 +28,11 @@ class divListSystem extends MultiSelectWindow
 
   function divListSystem ($config,$parent)
   {
-    MultiSelectWindow::MultiSelectWindow($config,"System");
+    MultiSelectWindow::MultiSelectWindow($config, "System", array("server",
+                                                                  "workstation",
+                                                                  "terminal",
+                                                                  "phone",
+                                                                  "printer"));
 
     $this->parent       = $parent;
     $this->ui           = get_userinfo();
@@ -48,7 +52,7 @@ class divListSystem extends MultiSelectWindow
     $this->EnableSaveButton (false);
 
     /* Dynamic action col, depending on snapshot icons */
-    $action_col_size = 50;
+    $action_col_size = 70;
     if($this->parent->snapshotEnabled()){
       $action_col_size += 38;
     }
@@ -78,17 +82,47 @@ class divListSystem extends MultiSelectWindow
 
   function GenHeader()
   {
-    /* Prepare departments,
+   /* Prepare departments,
        which are shown in the listbox on top of the listbox
      */
     $options= "";
-    foreach ($this->config->idepartments as $key => $value){
-      if ($this->selectedBase == $key){
-        $options.= "<option selected='selected' value='$key'>$value</option>";
-      } else {
-        $options.= "<option value='$key'>$value</option>";
+
+    /* Get all departments within this subtree */
+    $base = $this->config->current['BASE'];
+    $deps= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
+                    array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH);
+
+    $tmp =array();
+    foreach($deps as $dep){
+      $tmp[$dep['dn']] = $dep;
+    }
+    $deps = $tmp;
+
+    /* Load possible departments */
+    $ui= get_userinfo();
+    $department = array();
+    foreach($this->module as $module){
+  
+      $d = $ui->get_module_departments($module);      
+      foreach($d as $department){
+        $departments[$department] = $department;
+      }
+    }
+
+    $ids = $this->config->idepartments;
+
+    foreach($deps as $dep){
+      if(isset($ids[$dep['dn']]) && in_array_ics($dep['dn'], $departments)){
+
+        $value = $ids[$dep['dn']];
+        if ($this->selectedBase == $dep['dn']){
+          $options.= "<option selected='selected' value='".$dep['dn']."'>$value</option>";
+        } else {
+          $options.= "<option value='".$dep['dn']."'>$value</option>";
+        }
       }
     }
+
     $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
       " <input class='center' type='image' src='images/list_root.png' align='middle'
       title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'>&nbsp;".
@@ -191,8 +225,13 @@ class divListSystem extends MultiSelectWindow
         $action2 = "";
       }
 
+      if(in_array("gotoWorkstation",$val['objectClass'])){
+        $action2= "<input class='center' type='image' src='images/cdrom.png' alt='"._("Create CD")."'   
+                      name='gen_cd_%KEY%' title='"._("Create FAI CD")."'>".$action2;
+      }
+
       if(isset($val['message'])){
-        $display.= "  (".$val['message']." '".$this->config->idepartments[$_SESSION['CurrentMainBase']]."'  )";
+        $display.= "  (".$val['message'].")";
       }
 
       $img    = $this->parent->convert_list($val);