Code

Apply fix for #4368
[gosa.git] / trunk / gosa-plugins / goto / admin / systems / goto / class_workstationService.inc
index fde0993dee56fd7ce4e142a2a532266bcc7344bd..47a3da9d939fda67aac55933038af92f214ce26e 100644 (file)
@@ -33,7 +33,7 @@ class workservice extends plugin
   var $MousePorts= array();
   var $hardware_list= array();
   var $used_hardware= array();
-
+  var $ogroup = FALSE;
 
   /* attribute list for save action */
   var $attributes= array("gotoXMonitor", "gotoXDriver", "gotoXResolution", "gotoXColordepth",
@@ -185,54 +185,6 @@ class workservice extends plugin
       $this->gotoXVsync = preg_replace("/\+/","-",$this->gotoXVsync);
     }
 
-    /* Load hardware list */
-    $ldap= $this->config->get_ldap_link();
-    $ldap->cd($this->config->current['BASE']);
-    $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".LDAP::prepare4filter($this->dn)."))");
-    if ($ldap->count() == 1){
-      $map= array("gotoXResolution", "gotoXColordepth", "gotoXKbModel", "gotoXKbLayout",
-                  "gotoXKbVariant", "gotoXMouseType", "gotoXMouseport", "gotoXDriver");
-      $attrs= $ldap->fetch();
-
-      foreach ($map as $name){
-        if (!isset($attrs[$name][0])){
-          continue;
-        }
-        
-        switch ($name){
-          case 'gotoXDriver':
-            $ogroup_driver = $attrs['gotoXDriver'][0];
-            if (in_array($ogroup_driver, $this->XDrivers) && (empty($this->attrs['gotoXDriver']))) {
-                $this->XDrivers = array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XDrivers;
-            }
-            break;
-          case 'gotoXResolution':
-            $this->XResolutions= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XResolutions;
-            break;
-          case 'gotoXColordepth':
-            $this->XColordepths= array('default' => _("inherited").' ['.$attrs[$name][0].' '._('Bit').']') + $this->XColordepths;
-            break;
-          case 'gotoXKbModel':
-            $this->XKbModels= array('default' => _("inherited").' ['.$attrs[$name][0].']') + $this->XKbModels;
-            break;
-          case 'gotoXKbLayout':
-            $this->XKbLayouts= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XKbLayouts;
-            break;
-          case 'gotoXKbVariant':
-            $this->XKbVariants= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XKbVariants;
-            break;
-          case 'gotoXMouseType':
-            $this->MouseTypes= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->MouseTypes;
-            break;
-          case 'gotoXMouseport':
-            $this->MousePorts= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->MousePorts;
-            break;
-        }
-
-      }
-
-    }
-
     /* Workaround to fill in inherited values if we've specified an objectclass */
     $SelectedSystemType = session::get("SelectedSystemType");
     if (isset($SelectedSystemType['ogroup']) && $SelectedSystemType['ogroup'] != 'none'){
@@ -252,6 +204,9 @@ class workservice extends plugin
     /* Call parent execute */
     plugin::execute();
 
+    /* Load hardware list */  
+    $this->loadHardwareList();
+
     if($this->is_account && !$this->view_logged){
       $this->view_logged = TRUE;
       new log("view","workstation/".get_class($this),$this->dn);
@@ -486,6 +441,61 @@ class workservice extends plugin
 
   }
 
+  function loadHardwareList()
+  {
+    $ldap= $this->config->get_ldap_link();
+
+    if ($this->ogroup) {
+      $ldap->cat($this->ogroup);
+    } else {
+      $ldap->cd($this->config->current['BASE']);
+      $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".LDAP::prepare4filter($this->dn)."))");
+    }
+      if ($ldap->count() == 1){
+        $attrs= $ldap->fetch();
+        $map= array("gotoXResolution", "gotoXColordepth", "gotoXKbModel", "gotoXKbLayout",
+                    "gotoXKbVariant", "gotoXMouseType", "gotoXMouseport", "gotoXDriver");
+        foreach ($map as $name){
+        if (!isset($attrs[$name][0])){
+          continue;
+        }
+        
+        switch ($name){
+          case 'gotoXDriver':
+            $ogroup_driver = $attrs['gotoXDriver'][0];
+            if (in_array($ogroup_driver, $this->XDrivers) && (empty($this->attrs['gotoXDriver']))) {
+                $this->XDrivers = array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XDrivers;
+            }
+            break;
+          case 'gotoXResolution':
+            $this->XResolutions= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XResolutions;
+            break;
+          case 'gotoXColordepth':
+            $this->XColordepths= array('default' => _("inherited").' ['.$attrs[$name][0].' '._('Bit').']') + $this->XColordepths;
+            break;
+          case 'gotoXKbModel':
+            $this->XKbModels= array('default' => _("inherited").' ['.$attrs[$name][0].']') + $this->XKbModels;
+            break;
+          case 'gotoXKbLayout':
+            $this->XKbLayouts= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XKbLayouts;
+            break;
+          case 'gotoXKbVariant':
+            $this->XKbVariants= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->XKbVariants;
+            break;
+          case 'gotoXMouseType':
+            $this->MouseTypes= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->MouseTypes;
+            break;
+          case 'gotoXMouseport':
+            $this->MousePorts= array('default' => _("inherited").' ['.$attrs[$name][0].']' ) + $this->MousePorts;
+            break;
+        }
+
+      }
+
+    }
+
+
+  }
 
   function getListOfXDrivers()
   {