From 65685fde9dc586e9ece16454498131963d000ef9 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 13 May 2005 11:10:13 +0000 Subject: [PATCH] Updated service tab git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@201 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/systems/class_servService.inc | 187 +++++++++++++++++++- plugins/admin/systems/servservice.tpl | 117 +++++++++++- 2 files changed, 298 insertions(+), 6 deletions(-) diff --git a/plugins/admin/systems/class_servService.inc b/plugins/admin/systems/class_servService.inc index 68fdd380b..cd8788a56 100644 --- a/plugins/admin/systems/class_servService.inc +++ b/plugins/admin/systems/class_servService.inc @@ -7,24 +7,149 @@ class servservice extends plugin var $cli_description= "Some longer text\nfor help"; var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + var $goExportEntry = array(); + var $goTimeSource = array(); + var $goLdapBase= ""; + var $goXdmcPlsEnabled= ""; + var $goFontPath= ""; + var $goNTPServer=""; + var $goLdapServer=""; + var $goTerminalServer=""; + var $goSyslogServer=""; + var $goCupsServer=""; + + /* attribute list for save action */ - var $attributes= array(); - var $objectclasses= array(); + var $attributes = array("goExportEntry","goTimeSource","goLdapBase","goXdmcpIsEnabled","goFontPath"); + var $objectclasses = array("top","goServer"); + var $additionaloc = array( + + "goNfsServer" => array("goExportEntry"), + "goNtpServer" => array("goTimeSource"), + "goLdapServer" => array("goLdapBase"), + "goTerminalServer"=> array("goXdmcpIsEnabled", "goFontPath") +// "goSyslogServer" => array(""), +// "goCupsServer" => array("") + ); + + + + + + + + function servservice ($config, $dn= NULL) { plugin::plugin ($config, $dn); + /* Always is account... */ + + foreach ($this->additionaloc as $oc => $dummy){ + if (isset($this->attrs['objectClass']) && in_array($oc, $this->attrs['objectClass'])){ + $this->objectclasses[$oc]= $oc; + } + } /* Always is account... */ $this->is_account= TRUE; } + + function execute() { /* Fill templating stuff */ $smarty= get_smarty(); - return($smarty->fetch (get_template_path('servservice.tpl', TRUE))); + /* + Handling for Nfs Export Entries + */ + + /* Here we add a new entry */ + if(isset($_POST['NewNfsAdd'])) + { + $this->attrs['goExportEntry'][]=$_POST['NewNfsExport']; + } + + + + /* Deleting an Entry, is a bit more complicated than adding one*/ + if(isset($_POST['DelNfsEnt'])) + { + /* Go through all entries an skip the selected (The one we want to delete)*/ + foreach($this->attrs['goExportEntry'] as $key => $val) + { + /* Add all entries in an new Array, because when deleting one entry, the could be broken*/ + if(($val != $_POST['goExportEntry'] )) + { + /* Skip the entry that we want to delete*/ + $new_arr[]=$val; + } + } + /* Deleting complete so add result to the attrs */ + $this->attrs['goExportEntry']=$new_arr; + } + + /* Set the entry which we want to show in the frontend */ + $this->goExportEntry = ($this->attrs['goExportEntry']); + unset($this->goExportEntry['count']); + + + + /* + Handling for NTP Export Entries + */ + + /* Here we add a new entry */ + if(isset($_POST['NewNTPAdd'])) + { + $this->attrs['goTimeSource'][]=$_POST['NewNTPExport']; + } + + /*Deleting an Entry, is a bit more complicated than adding one*/ + if(isset($_POST['DelNTPEnt'])) + { + /* Go through all entries an skip the selected (The one we want to delete)*/ + foreach($this->attrs['goTimeSource'] as $key => $val) + { + /* Add all entries in an new Array, because wehn deleting one entry, the could be broken*/ + if($val != $_POST['goTimeSource'] ) + { + /* Skip the entry that we want to delete*/ + $new_arr[]=$val; + } + } + /* Deleting complete so add result to the attrs */ + $this->attrs['goTimeSource']=$new_arr; + } + + /* Set the entry which we want to show in the frontend */ + $this->goTimeSource = ($this->attrs['goTimeSource']); + unset($this->goTimeSource['count']); + + + + + /* Attributes... */ + foreach ($this->attributes as $attr){ + $smarty->assign("$attr", $this->$attr); + $smarty->assign("$attr"."ACL", chkacl($this->acl, $attr)); + } + + + /* Classes... */ + foreach ($this->additionaloc as $oc => $dummy){ + if (isset($this->objectclasses[$oc])){ + $smarty->assign("$oc", "checked"); + $smarty->assign("$oc"."ACL", chkacl($this->acl, $oc)); + } else { + $smarty->assign("$oc"."State", "disabled"); + } + } + + return($smarty->fetch (get_template_path('servservice.tpl', TRUE))); } function remove_from_parent() @@ -36,7 +161,17 @@ class servservice extends plugin /* Save data to object */ function save_object() { - plugin::save_object(); + plugin::save_object(); + + /* Save checkbox state */ + foreach ($this->additionaloc as $oc => $dummy){ + if (isset($_POST[$oc]) && $_POST[$oc] == '1'){ + $this->objectclasses[$oc]= $oc; + } else { + unset($this->objectclasses[$oc]); + } + } + } @@ -52,10 +187,52 @@ class servservice extends plugin /* Save to LDAP */ function save() { + /* Normalize lazy objectclass arrays */ + $objectclasses= array(); + foreach($this->objectclasses as $oc){ + $objectclasses[]= $oc; + } + + $this->objectclasses= $objectclasses; plugin::save(); + /* Remove objectclasses */ + unset ($this->attrs['objectClass']); + foreach($this->objectclasses as $oc){ + $this->attrs['objectClass'][]= $oc; + } + + /* Adapt sieve server if needed */ + if (in_array('goImapServer', $this->objectclasses)){ + $this->attrs['goImapSieveServer']= preg_replace('/:.*$/', '', + preg_replace('/^{([^}]+)}$/', '\\1', + $this->attrs['goImapConnect'])); + } + + /* Remove unneeded attributes */ + foreach ($this->additionaloc as $oc => $attrs){ + if (!in_array($oc, $this->objectclasses)){ + foreach ($attrs as $attr){ + $this->attrs[$attr]= array(); + } + } + } + + /* Write to LDAP */ + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + show_ldap_error($ldap->get_error()); + /* Optionally execute a command after we're done */ - #$this->handle_post_events($mode); + if ($this->initially_was_account == $this->is_account){ + if ($this->is_modified){ + $this->handle_post_events("mofify"); + } + } else { + $this->handle_post_events("add"); + } + } } diff --git a/plugins/admin/systems/servservice.tpl b/plugins/admin/systems/servservice.tpl index 53a90bffa..61bf58be9 100644 --- a/plugins/admin/systems/servservice.tpl +++ b/plugins/admin/systems/servservice.tpl @@ -1 +1,116 @@ -Empty +{t}Useful lheadline here.{/t} +

+  +

+ + + + + +
+ + + + {t}Nfs Export{/t} + + + + + +
{t}NFS Exports{/t} + +
+ + + +
+ +

 

+ +
+ + + + {t}Time Service{/t} + + + + + +
{t}NFS Exports{/t} + +
+ + + +
+ + + +
+ + + + {t}LDAP Service{/t} + + + + + + + +
{t}Base{/t} +
+ + +

 

+
+ + + + {t}Terminal Service{/t} + + + + + + + + + + +
Font path
Temporary disable login
+ + + + +

 

+
+ + + + {t}Syslog Service{/t} + +

 

+
+ + + + + {t} Print Service{/t} +
-- 2.30.2