X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fsystems%2Fclass_servService.inc;h=850a9551550e61b9f2ae218bd37b010e3bdb3c7f;hb=f46b5bdda0a7bb0773e5fc982c0c5098a77b10c8;hp=444df8cf0ae3410562407ef4ab59a24a81847c20;hpb=3c1bce87328c1c6cfa54a096cf44697fb98994de;p=gosa.git diff --git a/plugins/admin/systems/class_servService.inc b/plugins/admin/systems/class_servService.inc index 444df8cf0..850a95515 100644 --- a/plugins/admin/systems/class_servService.inc +++ b/plugins/admin/systems/class_servService.inc @@ -7,22 +7,26 @@ 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 $goXdmcpIsEnabled =""; - var $goFontPath= ""; - var $goNTPServer=""; - var $goLdapServer=""; - var $goTerminalServer=""; - var $goSyslogServer=""; - var $goCupsServer=""; + var $goExportEntry = array(); + var $goTimeSource = array(); + var $goLdapBase = ""; + var $goXdmcpIsEnabled = ""; + var $goFontPath = ""; + var $goNTPServer = ""; + var $goShareServer = ""; + var $goLdapServer = ""; + var $goTerminalServer = ""; + var $goSyslogServer = ""; + var $goCupsServer = ""; + var $o_subWindow = NULL; /* attribute list for save action */ var $ignore_account= TRUE; var $attributes = array("goLdapBase","goXdmcpIsEnabled","goFontPath"); - var $objectclasses = array("top","goServer"); - var $additionaloc = array( "goNfsServer" => array("goExportEntry"), + var $possible_objectclasses= array( "goShareServer", "goNtpServer", "goServer", "goLdapServer", + "goTerminalServer", "goSyslogServer", "goCupsServer"); + var $objectclasses = array( "top","goServer"); + var $additionaloc = array( "goShareServer" => array("goExportEntry"), "goNtpServer" => array("goTimeSource"), "goLdapServer" => array("goLdapBase"), "goTerminalServer"=> array("goXdmcpIsEnabled", "goFontPath"), @@ -41,7 +45,7 @@ class servservice extends plugin } /* Load arrays */ - foreach (array("goTimeSource", "goExportEntry") as $name){ + foreach (array("goTimeSource") as $name){ $tmp= array(); if (isset($this->attrs[$name])){ for ($i= 0; $i<$this->attrs[$name]['count']; $i++){ @@ -51,10 +55,30 @@ class servservice extends plugin $this->$name= $tmp; } + $tmp =array(); + $tmp2=array(); + unset($this->attrs['goExportEntry']['count']); + if((isset($this->attrs['goExportEntry']))&&(isset($this->attrs['goExportEntry']))){ + foreach($this->attrs['goExportEntry'] as $entry){ + $tmp2= split("\|",$entry); + $tmp[$tmp2[0]]= $entry; + } + } + $this->goExportEntry = $tmp; + /* Always is account... */ $this->is_account= TRUE; } + function addToList($entry){ + $key = key($entry); + $this->goExportEntry[$key]=$entry[$key]; + } + + function deleteFromList($id){ + unset($this->goExportEntry[$id]); + } + function execute() { @@ -63,20 +87,50 @@ class servservice extends plugin $smarty->assign("staticAddress", ""); - /* Here we add a new entry */ - if(isset($_POST['NewNfsAdd']) && $_POST['NewNfsExport'] != "") { - $this->goExportEntry[$_POST['NewNfsExport']]= $_POST['NewNfsExport']; - asort($this->goExportEntry); + if((isset($_POST['DelNfsEnt']))&&(isset($_POST['goExportEntry']))){ + $this->deleteFromList($_POST['goExportEntry']); } - /* Deleting an Entry, is a bit more complicated than adding one*/ - if(isset($_POST['DelNfsEnt']) && isset($_POST['goExportEntry'])) { - foreach ($_POST['goExportEntry'] as $entry){ - if (isset($this->goExportEntry[$entry])){ - unset($this->goExportEntry[$entry]); + if(isset($_POST['NewNfsAdd'])){ + $this->o_subWindow = new servnfs($this->config, $this->dn); + $this->dialog = true; + } + + if((isset($_POST['NewNfsEdit']))&&(isset($_POST['goExportEntry']))){ + $entry = $this->goExportEntry[$_POST['goExportEntry']]; + $this->o_subWindow = new servnfs($this->config, $this->dn,$entry); + $this->dialog = true; + } + + if(isset($this->o_subWindow)){ + $this->o_subWindow->save_object(TRUE); + } + + /* Save NFS setup */ + if(isset($_POST['NFSsave'])){ + if(count($this->o_subWindow->check())>0){ + foreach($this->o_subWindow->check() as $msg) { + print_red($msg); } + }else{ + $this->o_subWindow->save_object(); + $newone = $this->o_subWindow->save(); + $this->addToList($newone) ; + unset($this->o_subWindow); + $this->dialog = false; } } + + /* Cancel NFS setup */ + if(isset($_POST['NFScancel'])){ + unset($this->o_subWindow); + $this->dialog = false; + } + + /* Execute NFS setup dialog*/ + if(isset($this->o_subWindow)){ + return $this->o_subWindow->execute(); + } /* Here we add a new entry */ if(isset($_POST['NewNTPAdd']) && $_POST['NewNTPExport'] != "") { @@ -99,13 +153,20 @@ class servservice extends plugin $smarty->assign("$attr"."ACL", chkacl($this->acl, $attr)); $smarty->assign($attr."State",""); } - - /* Arrays */ - foreach (array("goTimeSource", "goExportEntry") as $name){ - $smarty->assign("$name", $this->$name); - $smarty->assign("$name"."ACL", chkacl($this->acl, $name)); - $smarty->assign($name."State",""); + + $tellSmarty=array(); + foreach($this->goExportEntry as $name=>$values){ + $tmp = split("\|",$values); + $tellSmarty[$name] = $tmp[0]." ".$tmp[4]; } + $smarty->assign("goExportEntry",array_keys($tellSmarty)); + $smarty->assign("goExportEntryKeys",($tellSmarty)); + $smarty->assign("goExportEntryACL", chkacl($this->acl, "goExportEntry")); + + $smarty->assign("goTimeSource", $this->goTimeSource); + $smarty->assign("goTimeSourceACL", chkacl($this->acl, "goTimeSource")); + $smarty->assign("goTimeSourceState",""); + /* Classes... */ foreach ($this->additionaloc as $oc => $dummy){ @@ -121,6 +182,10 @@ class servservice extends plugin } } + if(!count($this->goExportEntry)){ + $smarty->assign("goShareServerState", " disabled "); + } + /* Different handling for checkbox */ if($this->goXdmcpIsEnabled == "true"){ $smarty->assign("goXdmcpIsEnabled","checked"); @@ -170,6 +235,10 @@ class servservice extends plugin function check() { $message= array(); + + if((isset($_POST['goTerminalServer']))&&(empty($this->goFontPath))){ + $message[]=_("Terminal server, must have fontpath specified."); + } return ($message); } @@ -178,27 +247,27 @@ 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(); - /* Normalize objectclasses */ - $this->attrs['objectClass']= $this->objectclasses; + $tmp= array(); - /* Remove illegal attributes */ - foreach ($this->additionaloc as $oc => $attrs){ - if (!in_array($oc, $this->objectclasses)){ - foreach ($attrs as $attr){ - $this->attrs[$attr]= array(); - } + /* Remove all from this plugin */ + foreach($this->attrs['objectClass'] as $oc){ + if (!in_array_ics($oc, $this->possible_objectclasses)){ + $tmp[]= $oc; + } + } + + /* Merge our current objectclasses */ + foreach($this->objectclasses as $oc){ + if (!in_array_ics($oc, $tmp)){ + $tmp[]= $oc; } } + /* Reassign cleaned value */ + $this->attrs['objectClass']= $tmp; + /* Arrays */ foreach (array("goTimeSource", "goExportEntry") as $name){ $this->attrs[$name]= array(); @@ -206,6 +275,15 @@ class servservice extends plugin $this->attrs[$name][]= $element; } } + + /* Remove illegal 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();