Code

Added inherit fix.
[gosa.git] / plugins / admin / systems / class_workstationGeneric.inc
index 344c3b93096461aed5149452ad42a73f21f52a20..e3900e931c2e1b098d02dd8be6be11886fd7e4c1 100644 (file)
@@ -64,6 +64,8 @@ class workgeneric extends plugin
   
   var $fai_activated = FALSE;
 
+  var $member_of_ogroup = FALSE;
+
   function workgeneric ($config, $dn= NULL, $parent= NULL)
   {
     $tmp = search_config($config->data,"faiManagement","CLASS");
@@ -72,6 +74,14 @@ class workgeneric extends plugin
     }
 
     plugin::plugin ($config, $dn, $parent);
+
+    if(!isset($this->parent->by_object['ogroup'])){
+      $ldap = $this->config->get_ldap_link();
+      $ldap->cd ($this->config->current['BASE']);
+      $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".$this->dn."))",array("cn"));
+      $this->member_of_ogroup = $ldap->count() >= 1;
+    }
+
     $this->netConfigDNS = new termDNS($this->config,$this->dn,$this->objectclasses);
 
     /* Read arrays */
@@ -100,6 +110,11 @@ class workgeneric extends plugin
       $this->gotoNtpServer=array();
     }
 
+    /* You can't inherit the NTP service, if we are not member in an object group */
+    if(!$this->member_of_ogroup){
+      $this->inheritTimeServer = FALSE;
+    }
+
     /* Create available ntp options */
     $tmp = $this->config->data['SERVERS']['NTP'];
     $this->gotoNtpServers = array();
@@ -123,7 +138,7 @@ class workgeneric extends plugin
     $tmp = $this->config->data['SERVERS']['SYSLOG'];
     foreach($tmp as $server){
       $visible = $server;
-      if($server == "default") {
+      if($server == "default" && $this->member_of_ogroup) {
         $visible = "["._("inherited")."]";
       }
       $this->gotoSyslogServers[$server] = $visible;
@@ -326,6 +341,7 @@ class workgeneric extends plugin
 
     /* tell smarty the inherit checkbox state */
     $smarty->assign("inheritTimeServer",$this->inheritTimeServer);
+    $smarty->assign("member_of_ogroup",$this->member_of_ogroup);
 
     /* Show main page */
     $smarty->assign("netconfig", $this->netConfigDNS->execute());
@@ -343,7 +359,7 @@ class workgeneric extends plugin
       show_ldap_error($ldap->get_error(), sprintf(_("Removing of system workstation/generic with dn '%s' failed."),$this->dn));
 
       /* Optionally execute a command after we're done */
-      $this->handle_post_events("remove", array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS-ipHostNumber));
+      $this->handle_post_events("remove", array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
 
       /* Delete references to object groups */
       $ldap->cd ($this->config->current['BASE']);
@@ -354,6 +370,10 @@ class workgeneric extends plugin
         $og->save ();
       }
     }
+
+    if(isset($_POST["inheritAll"])){
+      $this->set_everything_to_inherited();
+    }
   }
 
 
@@ -380,13 +400,16 @@ class workgeneric extends plugin
 
     /* Set inherit mode */
     if((isset($_POST['workgeneric_posted'])) && ($this->acl_is_writeable("gotoNtpServer"))){
-      if(isset($_POST["inheritTimeServer"])){
+      if(isset($_POST["inheritTimeServer"]) && $this->member_of_ogroup){
         $this->inheritTimeServer = true;
       }else{
         $this->inheritTimeServer = false;
       }
     }
-
+    
+    if(isset($_POST["inheritAll"])){
+      $this->set_everything_to_inherited();
+    }
   }
 
 
@@ -605,7 +628,26 @@ class workgeneric extends plugin
           ));
   }
 
-}
+  function set_everything_to_inherited()
+  {
+    $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){
+        $this->parent->by_object['workservice']->$name = "default"; 
+      }
+    }
 
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+    /* Set workstation startup attributes to inherited */
+    if($this->member_of_ogroup && isset($this->parent->by_object['workstartup'])){
+      $this->parent->by_object['workstartup']->gotoBootKernel = "default-inherited";
+      $this->parent->by_object['workstartup']->gotoLdapServer = "default-inherited";
+      $this->parent->by_object['workstartup']->FAIdebianMirror= "inherited";
+    }
+  }
+}
+  // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>