Code

Fixed Terminal NTPserver .... syslogserver default to inherited
[gosa.git] / plugins / admin / systems / class_workstationGeneric.inc
index 9de46c9825fdba00b848790f41322c613ef94a6f..37fdfc923bd08d1fe1b30a84dc60ef8a37f73a46 100644 (file)
@@ -10,6 +10,7 @@ class workgeneric extends plugin
   /* Generic terminal attributes */
   var $gotoMode= "locked";
   var $gotoSyslogServer= "";
+  var $gotoSyslogServers= array();
   var $gotoNtpServer= array();
   var $gotoNtpServers= array();
   var $gotoSndModule= "";
@@ -24,8 +25,9 @@ class workgeneric extends plugin
   var $ghGfxAdapter= "-";
   var $ghSoundAdapter= "-";
   var $gotoLastUser= "-";
-  var $FAIscript="";
+  var $FAIscript= "";
   var $didAction= FALSE;
+  var $FAIstate= "";
 
   /* Needed values and lists */
   var $base= "";
@@ -74,17 +76,17 @@ class workgeneric extends plugin
     }
 
     /* Set inherit checkbox state */
-    if(in_array("default",$this->gotoNtpServer)){
+    if((in_array("default",$this->gotoNtpServer)) || (count($this->gotoNtpServer) == 0)){
       $this->inheritTimeServer = true;
       $this->gotoNtpServer=array();
     }
 
     /* Create available ntp options */
-    $this->gotoNtpServers = $this->config->data['SERVERS']['NTP'];
-    foreach($this->gotoNtpServers as $key => $server){
-      if($server == "default"){
-        unset($this->gotoNtpServers[$key]);
-      }
+    $tmp = $this->config->data['SERVERS']['NTP'];
+    $this->gotoNtpServers = array();
+    foreach($tmp as $key => $server){
+      if($server == "default") continue;
+      $this->gotoNtpServers[$server] = $server;
     }
 
     $this->modes["active"]= _("Activated");
@@ -100,6 +102,16 @@ class workgeneric extends plugin
       $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn);
     }
 
+    /* Create an array of all Syslog servers */
+    $tmp = $this->config->data['SERVERS']['SYSLOG'];
+    foreach($tmp as $server){
+      $visible = $server;
+      if($server == "default") {
+        $visible = "["._("inherited")."]";
+      }
+      $this->gotoSyslogServers[$server] = $visible;
+    }
+
     /* Save 'dn' for later referal */
     $this->orig_dn= $this->dn;
   }
@@ -199,7 +211,7 @@ class workgeneric extends plugin
     /* Arrays */
     $smarty->assign("modes", $this->modes);
     $smarty->assign("nfsservers", $this->config->data['SERVERS']['NFS']);
-    $smarty->assign("syslogservers", $this->config->data['SERVERS']['SYSLOG']);
+    $smarty->assign("syslogservers", $this->gotoSyslogServers);
     $smarty->assign("ntpservers", $this->config->data['SERVERS']['NTP']);
 
     /* Variables */
@@ -222,7 +234,7 @@ class workgeneric extends plugin
     $this->netConfigDNS->remove_from_parent();
     $ldap= $this->config->get_ldap_link();
     $ldap->rmdir($this->dn);
-    show_ldap_error($ldap->get_error());
+    show_ldap_error($ldap->get_error(), _("Removing workstation failed"));
 
     /* Optionally execute a command after we're done */
     $this->handle_post_events("remove", array("macAddress" => $this->netConfigDNS->macAddress));
@@ -341,7 +353,7 @@ class workgeneric extends plugin
 
     /* Update ntp server settings */
     if($this->inheritTimeServer){
-      $this->attrs['gotoNtpServer'] = "default";
+      $this->attrs['gotoNtpServer'] = array();
     }else{
       /* Set ntpServers */
       $this->attrs['gotoNtpServer'] = array();
@@ -366,7 +378,7 @@ class workgeneric extends plugin
       }
       $ldap->cd($this->dn);
       $this->cleanup();
-$ldap->modify ($this->attrs); 
+      $ldap->modify ($this->attrs); 
 
       if(!$this->didAction){
         $this->handle_post_events("modify");
@@ -374,7 +386,7 @@ $ldap->modify ($this->attrs);
     }
     $this->netConfigDNS->cn = $this->cn;
     $this->netConfigDNS->save($this->dn);
-    show_ldap_error($ldap->get_error());
+    show_ldap_error($ldap->get_error(), _("Saving workstation failed"));
   }
 
 }