Code

Apply fix for #4368
[gosa.git] / trunk / gosa-plugins / goto / admin / systems / goto / class_workstationGeneric.inc
index 7246e559782671d88870fd27aa25bafab71a8fb7..a9c0d62d8a4644083f60e952df26e573ca487701 100644 (file)
@@ -33,6 +33,7 @@ class workgeneric extends plugin
   var $orig_dn= "";
   var $orig_cn= "";
   var $orig_base= "";
+  var $ogroup=FALSE;
 
   /* Plugin side filled */
   var $modes= array();
@@ -182,6 +183,12 @@ class workgeneric extends plugin
     /* Call parent execute */
     plugin::execute();
 
+    if ($this->ogroup) {
+      $this->member_of_ogroup = TRUE;
+      $this->parent->by_object['workservice']->ogroup = $this->ogroup;
+      $this->set_everything_to_inherited();
+    }
+
     if($this->is_account && !$this->view_logged){
       $this->view_logged = TRUE;
       new log("view","workstation/".get_class($this),$this->dn);
@@ -636,6 +643,13 @@ class workgeneric extends plugin
         }
       }
     }
+
+    /* If $this->ogroup is set add the new system to the requested ogroup */
+    if ($this->ogroup) {
+      $og = new ogroup($this->config, $this->ogroup);
+      $og->AddDelMembership($this->dn);
+      $og->save();
+    }
   }
 
 
@@ -719,16 +733,44 @@ class workgeneric extends plugin
 
   function set_everything_to_inherited()
   {
+    /* Find out what is set in the object group as XDriver */
+    $inherit_xdriver = 0;
+    if ($this->dn != 'new' || $this->ogroup) {
+        $ldap = $this->config->get_ldap_link();
+        $entry = NULL;
+        /* If initialized with an object group we need to use this instead of
+         * an object group we'll become a member in */
+        if ($this->ogroup) {
+            $entry = $ldap->cat($this->ogroup, array("gotoXDriver"));
+        }else {
+          $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".LDAP::prepare4filter($this->dn)."))", array("gotoXDriver"));
+          if ($ldap->count() == 1) {
+            $entry = $ldap->fetch();
+          }
+        }
+        if ($entry) {
+            /* Get list of valid XDrivers */
+            $xdrivers = $this->parent->by_object['workservice']->getListOfXDrivers();
+            /* Only inherit if driver in object group is set to something in the list of
+             * valid XDrivers */
+            if (in_array($entry['gotoXDriver'][0], $xdrivers)) {
+              $inherit_xdriver = 1;
+            }
+        }
+    }
+
     $this->gotoSyslogServer  = "default";
     $this->inheritTimeServer = TRUE;
 
     /* Set workstation service attributes to inherited */
     if($this->member_of_ogroup && isset($this->parent->by_object['workservice'])){
-      foreach(array("gotoXKbLayout","gotoXKbModel","gotoXKbVariant",
-            "gotoXResolution","gotoXColordepth","gotoXMouseType","gotoXMouseport") as $name){
-        if($this->parent->by_object['workservice']->acl_is_writeable($name)){
-          $this->parent->by_object['workservice']->$name = "default"; 
-        }
+      foreach(array("gotoXKbLayout","gotoXKbModel","gotoXKbVariant", "gotoXDriver",
+        "gotoXResolution","gotoXColordepth","gotoXMouseType","gotoXMouseport") as $name){
+          if(!(($name == 'gotoXDriver') && ($inherit_xdriver == 0))) {
+              if($this->parent->by_object['workservice']->acl_is_writeable($name)){
+                $this->parent->by_object['workservice']->$name = "default"; 
+              }
+          }
       }
     }