From b86ce75b4d415c7cddbef2855a6e6730266522a0 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 28 Apr 2006 04:19:13 +0000 Subject: [PATCH] Added workstation ntp multiple selection git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3151 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../systems/class_workstationGeneric.inc | 76 +++++++++++++++++-- plugins/admin/systems/workstation.tpl | 70 +++++++++++------ 2 files changed, 115 insertions(+), 31 deletions(-) diff --git a/plugins/admin/systems/class_workstationGeneric.inc b/plugins/admin/systems/class_workstationGeneric.inc index 02374a3db..cd714dea2 100644 --- a/plugins/admin/systems/class_workstationGeneric.inc +++ b/plugins/admin/systems/class_workstationGeneric.inc @@ -10,7 +10,8 @@ class workgeneric extends plugin /* Generic terminal attributes */ var $gotoMode= "locked"; var $gotoSyslogServer= ""; - var $gotoNtpServer= ""; + var $gotoNtpServer= array(); + var $gotoNtpServers= array(); var $gotoSndModule= ""; var $gotoFloppyEnable= ""; var $gotoCdromEnable= ""; @@ -37,6 +38,8 @@ class workgeneric extends plugin var $netConfigDNS; + var $inheritTimeServer = true; + /* attribute list for save action */ var $ignore_account= TRUE; var $attributes= array("gotoMode", "gotoSyslogServer", "gotoNtpServer", @@ -60,6 +63,30 @@ class workgeneric extends plugin } } + /* Create used ntp server array */ + $this->gotoNtpServer= array(); + if(isset($this->attrs['gotoNtpServer'])){ + $this->inheritTimeServer = false; + unset($this->attrs['gotoNtpServer']['count']); + foreach($this->attrs['gotoNtpServer'] as $server){ + $this->gotoNtpServer[$server] = $server; + } + } + + /* Set inherit checkbox state */ + if(in_array("default",$this->gotoNtpServer)){ + $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]); + } + } + $this->modes["active"]= _("Activated"); $this->modes["locked"]= _("Locked"); $this->modes["memcheck"]= _("Memory test"); @@ -73,11 +100,6 @@ class workgeneric extends plugin $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn); } - /* Workaround for not single-value attribute gotoNtpServer */ - if (isset($this->attrs['gotoNtpServer'][0])){ - $this->gotoNtpServer= $this->attrs['gotoNtpServer'][0]; - } - /* Save 'dn' for later referal */ $this->orig_dn= $this->dn; } @@ -138,12 +160,25 @@ class workgeneric extends plugin } } + /* Add new ntp Server to our list */ + if((isset($_POST['addNtpServer'])) && (isset($_POST['gotoNtpServers']))){ + $this->gotoNtpServer[$_POST['gotoNtpServers']] = $_POST['gotoNtpServers']; + } + + /* Delete selected NtpServer for list of used servers */ + if((isset($_POST['delNtpServer'])) && (isset($_POST['gotoNtpServerSelected']))){ + foreach($_POST['gotoNtpServerSelected'] as $name){ + unset($this->gotoNtpServer[$name]); + } + } + /* Fill templating stuff */ $smarty= get_smarty(); $smarty->assign("cn", $this->cn); $smarty->assign("l", $this->l); $smarty->assign("bases", $this->config->idepartments); $smarty->assign("staticAddress", ""); + $smarty->assign("gotoNtpServers",$this->gotoNtpServers); /* Check if workstation is online */ $query= "fping -q -r 1 -t 500 ".$this->cn; @@ -174,6 +209,9 @@ class workgeneric extends plugin } $smarty->assign("actionACL", chkacl($this->acl, 'action')); + /* tell smarty the inherit checkbox state */ + $smarty->assign("inheritTimeServer",$this->inheritTimeServer); + /* Show main page */ $smarty->assign("netconfig", $this->netConfigDNS->execute()); return($smarty->fetch (get_template_path('workstation.tpl', TRUE))); @@ -210,6 +248,16 @@ class workgeneric extends plugin $this->base= $_POST['base']; } $this->netConfigDNS->save_object(); + + /* Set inherit mode */ + if(isset($_POST['workgeneric_posted'])){ + if(isset($_POST["inheritTimeServer"])){ + $this->inheritTimeServer = true; + }else{ + $this->inheritTimeServer = false; + } + } + } @@ -249,6 +297,11 @@ class workgeneric extends plugin } } } + + /* Check for valid ntpServer selection */ + if((!$this->inheritTimeServer) && (!count($this->gotoNtpServer))){ + $message[]= _("There must be at least one NTP server selected, or the inherit mode activated."); + } return ($message); } @@ -286,6 +339,17 @@ class workgeneric extends plugin $this->attrs= $attrs; } + /* Update ntp server settings */ + if($this->inheritTimeServer){ + $this->attrs['gotoNtpServer'] = "default"; + }else{ + /* Set ntpServers */ + $this->attrs['gotoNtpServer'] = array(); + foreach($this->gotoNtpServer as $server){ + $this->attrs['gotoNtpServer'][] = $server; + } + } + /* Write back to ldap */ $ldap= $this->config->get_ldap_link(); if ($this->orig_dn == 'new'){ diff --git a/plugins/admin/systems/workstation.tpl b/plugins/admin/systems/workstation.tpl index d6ea1c539..27f3c00b1 100644 --- a/plugins/admin/systems/workstation.tpl +++ b/plugins/admin/systems/workstation.tpl @@ -2,7 +2,6 @@ - - - - + +
- {if $cn eq 'wdefault'} @@ -20,27 +19,9 @@ - - - - - -
 
{$must} - - -
-
-   - - + @@ -50,7 +31,6 @@ - +
{t}Mode{/t}
@@ -59,12 +39,52 @@
+
+

 

+ + + +
+ - + +
{$must} - + {html_options options=$bases selected=$base_select} + + +
+
+ + + + + +
+ {t}Inherit time server attributes{/t} +

+ +
+ + +
@@ -90,7 +110,7 @@
- + {if $cn eq 'wdefault'}