From 954d85102ed73971fb026c26f1167161303d48e9 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 23 Aug 2005 09:47:33 +0000 Subject: [PATCH] goShareServer Added git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1206 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/systems/class_servNfs.inc | 153 ++++++++++++++++++++ plugins/admin/systems/class_servService.inc | 107 +++++++++++--- plugins/admin/systems/servnfs.tpl | 86 +++++++++++ plugins/admin/systems/servservice.tpl | 14 +- 4 files changed, 335 insertions(+), 25 deletions(-) create mode 100644 plugins/admin/systems/class_servNfs.inc create mode 100644 plugins/admin/systems/servnfs.tpl diff --git a/plugins/admin/systems/class_servNfs.inc b/plugins/admin/systems/class_servNfs.inc new file mode 100644 index 000000000..bb85475f5 --- /dev/null +++ b/plugins/admin/systems/class_servNfs.inc @@ -0,0 +1,153 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + var $attributes = array("NFSdescription","NFStype","NFScharset","NFSpath","NFSoption"); + var $objectclasses = array("whatever"); + var $is_account = true; + + var $NFSname =""; // Name of NFS + var $NFSdescription =""; // description + var $NFStype =""; // Type NFS/Samba/NCP + var $NFScharset =""; // charset + var $NFStypes =array(); // Array Types NFS/Samba/NCP + var $NFScharsets =array(); // Array with charsets + var $NFSpath =""; // Path + var $NFSoption =""; // Options + var $is_edit =false; + + + function servnfs ($config, $dn= NULL,$entry = false) + { + plugin::plugin ($config, $dn); + $this->NFStypes = array("NFS"=>"NFS","samba"=>"samba","NCP"=>"NCP"); + $this->NFScharsets = array("UTF-8" => "UTF-8", + "ISO8859-1"=>"ISO8859-1 (Latin 1)", + "ISO8859-2"=>"ISO8859-2 (Latin 2)", + "ISO8859-3"=>"ISO8859-3 (Latin 3)", + "ISO8859-4"=>"ISO8859-4 (Latin 4)", + "ISO8859-5"=>"ISO8859-5 (Latin 5)"); + + if($entry){ + $tmp = split("\|",$entry); + $this->NFSname = $tmp[0]; // Name of NFS + $this->NFSdescription = $tmp[1]; // description + $this->NFStype = $tmp[2]; // Type NFS/Samba/NCP + $this->NFScharset = $tmp[3]; // charset + $this->NFSpath = $tmp[4]; // Path + $this->NFSoption = $tmp[5]; // Options + $this->is_edit = true; + }else{ + $this->attributes[] = "NFSname"; + } + } + + function execute() + { + /* Fill templating stuff */ + $smarty= get_smarty(); + + $smarty->assign("NFScharsets" ,$this->NFScharsets); + $smarty->assign("NFStypes" ,$this->NFStypes); + + /* attrs to smarty*/ + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + + $smarty->assign("NFSnameACL",""); + + if($this->is_edit){ + $smarty->assign("NFSnameACL"," disabled "); + $smarty->assign("NFSname",""); + } + + $display= $smarty->fetch(get_template_path('servnfs.tpl', TRUE)); + return($display); + } + + function remove_from_parent() + { + /* This cannot be removed... */ + } + + + /* Save data to object */ + function save_object() + { + plugin::save_object(TRUE); + if(isset($_POST['NFSpath'])){ + foreach($this->attributes as $attr){ + $this->$attr = $_POST[$attr]; + } + } + } + + + /* Check supplied data */ + function check() + { + $message= array(); + + // fixme : a check for the path ? ? + if(empty($this->NFSpath)){ + $message[]=_("Please specify a valid path for your setup."); + } + + // only 0-9a-z + if(!$this->is_edit){ + if(preg_match("/[^a-z0-9]/i",$this->NFSname)){ + $message[]=_("Please specify a valid name for your setup."); + } + if(empty($this->NFSname)){ + $message[]=_("Please specify a name for your setup."); + } + } + + $ldap= $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(objectClass=goShareServer)", array("goExportEntry")); + while($test = $ldap->fetch()){ + if($test['dn']==$this->dn) + continue; + foreach($test['goExportEntry'] as $entry){ + $tmp = split("\|",$entry); + if($tmp[0] == $this->NFSname){ + $message[]="Name already in use"; + } + } + } + return ($message); + } + + + /* Save to LDAP */ + function save() + { + /* Everything seems perfect, lets + generate an new export Entry + */ + + $s_return = ""; + + $s_return.= $this->NFSname."|"; + $s_return.= $this->NFSdescription."|"; + $s_return.= $this->NFStype."|"; + $s_return.= $this->NFScharset."|"; + $s_return.= $this->NFSpath."|"; + $s_return.= $this->NFSoption; + + return(array($this->NFSname=>$s_return)); + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/plugins/admin/systems/class_servService.inc b/plugins/admin/systems/class_servService.inc index 176316384..020f6d58d 100644 --- a/plugins/admin/systems/class_servService.inc +++ b/plugins/admin/systems/class_servService.inc @@ -17,14 +17,15 @@ class servservice extends plugin 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 $possible_objectclasses= array( "goNfsServer", "goNtpServer", "goServer", "goLdapServer", + var $possible_objectclasses= array( "goShareServer", "goNtpServer", "goServer", "goLdapServer", "goTerminalServer", "goSyslogServer", "goCupsServer"); var $objectclasses = array("top","goServer"); - var $additionaloc = array( "goNfsServer" => array("goExportEntry"), + var $additionaloc = array( "goShareServer" => array("goExportEntry"), "goNtpServer" => array("goTimeSource"), "goLdapServer" => array("goLdapBase"), "goTerminalServer"=> array("goXdmcpIsEnabled", "goFontPath"), @@ -43,7 +44,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++){ @@ -53,10 +54,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() { @@ -65,20 +86,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'] != "") { @@ -101,13 +152,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){ @@ -123,6 +181,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"); @@ -184,6 +246,7 @@ class servservice extends plugin /* Save to LDAP */ function save() { + plugin::save(); $tmp= array(); @@ -221,6 +284,14 @@ class servservice extends plugin $this->attrs[$name][]= $element; } } + + $oc = array(); + foreach($this->attrs['objectClass'] as $name){ + if($name!="goNfsServer"){ + $oc[]=$name; + } + } + $this->attrs['objectClass']=$oc; /* Write to LDAP */ $ldap= $this->config->get_ldap_link(); diff --git a/plugins/admin/systems/servnfs.tpl b/plugins/admin/systems/servnfs.tpl new file mode 100644 index 000000000..687bfb48d --- /dev/null +++ b/plugins/admin/systems/servnfs.tpl @@ -0,0 +1,86 @@ +

 Freigabe bearbeiten

+ + + + + + + + + + + + +
+ + + + + + + + + + +
+ {t}Name{/t} {$must} + + +
+ {t}Description{/t} + + +
+
+ + + + + + + + + + + +
+ {t}Type{/t} + + +
+ {t}Charset{/t} + + +
+
+

 

+
+ + + + + + +
+ {t}Path{/t} + + +
+
+ + + + + +
+ {t}Option{/t} + + +
+
+ + diff --git a/plugins/admin/systems/servservice.tpl b/plugins/admin/systems/servservice.tpl index bb2cbf8dc..8cac0f487 100644 --- a/plugins/admin/systems/servservice.tpl +++ b/plugins/admin/systems/servservice.tpl @@ -2,9 +2,9 @@ - @@ -12,14 +12,14 @@
- + {html_options values=$goExportEntry output=$goExportEntryKeys}
- - - + + +
-- 2.30.2