Code

Added inherit fix.
[gosa.git] / plugins / admin / systems / class_workstationStartup.inc
index dc8aebdc3bcb533b342f1c0387041455c335ef12..0f7f3d37cde59dad074c0a1d37c5a322ea7cc0a0 100644 (file)
@@ -42,7 +42,7 @@ class workstartup extends plugin
   var $FAIdebianMirror    = "auto";
 
   var $unresolved_classes = array();
-
+  var $view_logged        = FALSE;
   
   /* FAI class selection */
   var $InheritedFAIclass           = array();
@@ -56,6 +56,8 @@ class workstartup extends plugin
 
   var $fai_activated = FALSE;
 
+  var $member_of_ogroup   = FALSE;
+
   function workstartup ($config, $dn= NULL, $parent= NULL)
   {
     /* Check if FAI is active */
@@ -69,6 +71,13 @@ class workstartup 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;
+    }
+
     /* Creating a list of valid Mirrors 
      * none will not be saved to ldap.
      */
@@ -290,10 +299,11 @@ class workstartup extends plugin
     $this->gotoBootKernels= array("default-inherited" => '['._("inherited").']');
 
     /* Load hardware list */
-    $ldap= $this->config->get_ldap_link();
-    $ldap->cd($this->config->current['BASE']);
-    $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".$this->dn."))");
-    if ($ldap->count() == 1){
+    if ($this->member_of_ogroup){
+
+      if(count($this->FAIclass)==0 && $this->FAIrelease == ""){
+        $this->FAIdebianMirror = "inherited";
+      }
 
       if($this->fai_activated){
         $map= array("gotoLdapServer","FAIclass","FAIdebianMirror");
@@ -359,16 +369,10 @@ class workstartup extends plugin
       }
     }
 
-    if(count($this->FAIclass)==0 && $this->FAIrelease == ""){
-      $this->FAIdebianMirror = "inherited";
-    }
-
     /* Turn to default, if we've nothing to inherit */
     if (!isset($this->gotoBootKernels['default-inherited']) && $this->gotoBootKernel == "default-inherited"){
       $this->gotoBootKernel= "default";
     }
-
-    @log::log("view","workstation/".get_class($this),$this->dn);
   }
 
   
@@ -490,6 +494,11 @@ class workstartup extends plugin
        /* Call parent execute */
        plugin::execute();
 
+    if($this->is_account && !$this->view_logged){
+      $this->view_logged = TRUE;
+      new log("view","workstation/".get_class($this),$this->dn);
+    }
+
     /* Do we need to flip is_account state? */
     if(isset($_POST['modify_state'])){
       if($this->is_account && $this->acl_is_removeable()){
@@ -807,7 +816,7 @@ class workstartup extends plugin
   function remove_from_parent()
   {
     $this->handle_post_events("remove");
-    @log::log("remove","workstation/".get_class($this),$this->dn);
+    new log("remove","workstation/".get_class($this),$this->dn);
   }
 
   function generateDNSyn($release)
@@ -829,7 +838,13 @@ class workstartup extends plugin
   function getFAIdebianMirrors()
   {
     $ret = array();
-    $ret['inherited']="["._("inherited")."]";
+
+    /* Only add inherit option, if we are part in an object group 
+     */
+    if($this->member_of_ogroup)    {
+      $ret['inherited']="["._("inherited")."]";
+    }
+
     $ret['auto']=_("automatic");
     $secs  = array();
 
@@ -1089,7 +1104,7 @@ class workstartup extends plugin
 
     $this->cleanup();
     $ldap->modify ($this->attrs); 
-    @log::log("modify","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    new log("modify","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
 
     show_ldap_error($ldap->get_error(), sprintf(_("Saving of system workstation/startup with dn '%s' failed."),$this->dn));
     $this->handle_post_events("modify");
@@ -1156,6 +1171,18 @@ class workstartup extends plugin
   }
 
 
+  function PrepareForCopyPaste($source)
+  {
+    plugin::PrepareForCopyPaste($source);    
+
+    $source_o = new workstartup ($this->config, $source['dn']);
+    
+    foreach(array("gotoModules", "gotoAutoFs", "gotoFilesystem","gotoKernelParameters","gotoShares","customParameters") as $attr){
+      $this->$attr = $source_o->$attr;
+    }
+  }
+
+
   /* Return plugin informations for acl handling */ 
   function plInfo()
   {