Code

Updated workstation copy & paste
[gosa.git] / plugins / admin / systems / class_workstationGeneric.inc
index 36c9d3eb3a25cb641cab64df0a6d075df128df85..344c3b93096461aed5149452ad42a73f21f52a20 100644 (file)
@@ -28,6 +28,7 @@ class workgeneric extends plugin
   var $FAIscript= "";
   var $didAction= FALSE;
   var $FAIstate= "";
+  var $view_logged = FALSE;
 
   /* Needed values and lists */
   var $base= "";
@@ -50,9 +51,11 @@ class workgeneric extends plugin
       "ghGfxAdapter", "ghSoundAdapter", "gotoLastUser", "l","FAIscript");
   var $objectclasses= array("top", "gotoWorkstation", "GOhard");
 
-  var $mapActions   = array("reboot"          => "localboot",
+  var $mapActions   = array("reboot"          => "",
+                            "localboot"       => "localboot",
+                            "halt"            => "",
                             "instant_update"  => "softupdate",
-                            "update"          => "sceduledupdate",
+                            "update"          => "scheduledupdate",
                             "reinstall"       => "install",
                             "rescan"          => "",
                             "memcheck"        => "memcheck",
@@ -148,6 +151,11 @@ class workgeneric 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()){
@@ -175,8 +183,8 @@ class workgeneric extends plugin
             $res = $ldap->fetch();
 
             $attrs = array();
-            $attrs['FAIstate'] = "";
-            if(isset($this->mapActions[$_POST['saction']])){
+            $attrs['FAIstate'] = $this->FAIstate;
+            if(isset($this->mapActions[$_POST['saction']]) && $this->mapActions[$_POST['saction']] != ""){
               $attrs['FAIstate'] = $this->mapActions[$_POST ['saction']];
             }
 
@@ -287,12 +295,14 @@ class workgeneric extends plugin
                                        "reinstall" => _("Reinstall"),
                                        "rescan" => _("Rescan hardware"),
                                        "memcheck" => _("Memory test"),
+                                       "localboot" => _("Force localboot"),
                                        "sysinfo"  => _("System analysis")));
     } else {
       $smarty->assign("actions", array("wake" => _("Wake up"),
                                        "reinstall" => _("Reinstall"),
                                        "update" => _("Scheduled update"),
                                        "memcheck" => _("Memory test"),
+                                       "localboot" => _("Force localboot"),
                                        "sysinfo"  => _("System analysis")));
     }
     /* Arrays */
@@ -329,10 +339,11 @@ class workgeneric extends plugin
       $this->netConfigDNS->remove_from_parent();
       $ldap= $this->config->get_ldap_link();
       $ldap->rmdir($this->dn);
+      new log("remove","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
       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));
+      $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']);
@@ -488,9 +499,10 @@ class workgeneric extends plugin
       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
       $ldap->cd($this->dn);
       $ldap->add($this->attrs);
+      new log("create","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
       show_ldap_error($ldap->get_error(), sprintf(_("Saving of system workstation/generic with dn '%s' failed."),$this->dn));
       if(!$this->didAction){
-        $this->handle_post_events("add");
+        $this->handle_post_events("add",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
       }
     } else {
       if ($this->orig_dn != $this->dn){
@@ -499,9 +511,10 @@ class workgeneric extends plugin
       $ldap->cd($this->dn);
       $this->cleanup();
       $ldap->modify ($this->attrs); 
+      new log("modify","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
 
       if(!$this->didAction){
-        $this->handle_post_events("modify");
+        $this->handle_post_events("modify",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
       }
     }
 
@@ -516,6 +529,57 @@ class workgeneric extends plugin
   }
 
 
+  /* Display generic part for server copy & paste */
+  function getCopyDialog()
+  {
+    $vars = array("cn");
+    $smarty = get_smarty();
+    $smarty->assign("cn" ,$this->cn);
+    $smarty->assign("object","workstation");
+    $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE));
+    $ret = array();
+    $ret['string'] = $str;
+    $ret['status'] = "";
+    return($ret);
+  }
+
+
+  function saveCopyDialog()
+  {
+    if(isset($_POST['cn'])){
+      $this->cn = $_POST['cn'];
+    }
+  }
+
+
+  function PrepareForCopyPaste($source)
+  {
+    plugin::PrepareForCopyPaste($source);
+    if(isset($source['macAddress'][0])){
+      $this->netConfigDNS->macAddress = $source['macAddress'][0];
+    }
+    if(isset($source['ipHostNumber'][0])){
+      $this->netConfigDNS->ipHostNumber = $source['ipHostNumber'][0];
+    }
+
+    /* Create used ntp server array */
+    $this->gotoNtpServer= array();
+    if(isset($source['gotoNtpServer'])){
+      $this->inheritTimeServer = false;
+      unset($source['gotoNtpServer']['count']);
+      foreach($source['gotoNtpServer'] as $server){
+        $this->gotoNtpServer[$server] = $server;
+      }
+    }
+
+    /* Set inherit checkbox state */
+    if((in_array("default",$this->gotoNtpServer)) || (count($this->gotoNtpServer)==0)){
+      $this->inheritTimeServer = true;
+      $this->gotoNtpServer=array();
+    }
+  }
+
+
   /* Return plugin informations for acl handling 
       #FIXME FAIscript seams to ununsed within this class... */ 
   function plInfo()