From 7f7195906026b53e8e9dcd1aacaedeefd2710ed4 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 21 Sep 2006 06:34:45 +0000 Subject: [PATCH] Added ability to select ogroup membership in terminal Generic git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4751 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/systems/class_goShareServer.inc | 162 ++++-------------- plugins/admin/systems/class_servNfs.inc | 67 +++----- plugins/admin/systems/goShareServer.tpl | 13 +- plugins/admin/systems/servnfs.tpl | 21 ++- 4 files changed, 84 insertions(+), 179 deletions(-) diff --git a/plugins/admin/systems/class_goShareServer.inc b/plugins/admin/systems/class_goShareServer.inc index 99c75c326..5bfe63424 100644 --- a/plugins/admin/systems/class_goShareServer.inc +++ b/plugins/admin/systems/class_goShareServer.inc @@ -1,6 +1,8 @@ oldone = NULL; - $this->o_subWindow = new servnfs($this->config,$this->acl, $this->allow_mounts, $this->dn); + $this->o_subWindow = new servnfs($this->config, $this); + $this->o_subWindow->set_acl_category("server"); + $this->o_subWindow->set_acl_base($this->dn); $this->dialog = true; } @@ -75,7 +78,9 @@ class goShareServer extends plugin{ $entry = $this->goExportEntryList[$_POST['goExportEntryList'][0]]; $add_mount=isset($this->mounts_to_add[$entry]); $this->oldone=$entry; - $this->o_subWindow = new servnfs($this->config,$this->acl,$this->allow_mounts,$this->dn,$entry,$add_mount); + $this->o_subWindow = new servnfs($this->config,$this,$entry,$add_mount); + $this->o_subWindow->set_acl_base($this->dn); + $this->o_subWindow->set_acl_category("server"); $this->dialog = true; } if(isset($this->o_subWindow)){ @@ -117,14 +122,20 @@ class goShareServer extends plugin{ return $this->o_subWindow->execute(); } - - - - foreach($this->attributes as $attr){ $smarty->assign($attr,$this->$attr); - $smarty->assign($attr."ACL",chkacl($this->acl,$attr)); } + + /* Set acls */ + $tmp = $this->plInfo(); + $acl = ""; + foreach($tmp['plProvidedAcls'] as $name => $translated){ + $acl .= $this->getacl($name); + } + $smarty->assign("goExportEntryACL",$acl); + $smarty->assign("createable",$this->acl_is_createable()); + $smarty->assign("removeable",$this->acl_is_removeable()); + $tellSmarty= array(); ksort($this->goExportEntryList); foreach($this->goExportEntryList as $name=>$values){ @@ -133,53 +144,19 @@ class goShareServer extends plugin{ } $smarty->assign("goExportEntry",array_keys($tellSmarty)); $smarty->assign("goExportEntryKeys",($tellSmarty)); - $smarty->assign("goExportEntryACL", chkacl($this->acl, "goExportEntry")); - - return($smarty->fetch(get_template_path("goShareServer.tpl",TRUE,dirname(__FILE__)))); } function getListEntry() { - $this->updateStatusState(); - $flag = $this->StatusFlag; - $fields['Status'] = $this->$flag; - $fields['Message'] = _("Shares"); - $fields['AllowStart'] = true; - $fields['AllowStop'] = true; - $fields['AllowRestart'] = true; - $fields['AllowRemove']= true; + $fields = goService::getListEntry(); + $fields['Message'] = _("File service (Shares)"); $fields['AllowEdit'] = true; return($fields); } - function remove_from_parent() - { - plugin::remove_from_parent(); - - /* Remove status flag, it is not a memeber of - this->attributes, so ensure that it is deleted too */ - if(!empty($this->StatusFlag)){ - $this->attrs[$this->StatusFlag] = array(); - } - - /* Check if this is a new entry ... add/modify */ - $ldap = $this->config->get_ldap_link(); - $ldap->cat($this->dn,array("objectClass")); - if($ldap->count()){ - $ldap->cd($this->dn); - $ldap->modify($this->attrs); - }else{ - $ldap->cd($this->dn); - $ldap->add($this->attrs); - } - show_ldap_error($ldap->get_error(), sprintf(_("Removing of system server/shares with dn '%s' failed."),$this->dn)); - $this->handle_post_events("remove"); - } - - function save() { plugin::save(); @@ -198,7 +175,6 @@ class goShareServer extends plugin{ $this->process_mounts(); } - /* Check if this is a new entry ... add/modify */ $ldap = $this->config->get_ldap_link(); $ldap->cat($this->dn,array("objectClass")); @@ -218,30 +194,6 @@ class goShareServer extends plugin{ } - /* Directly save new status flag */ - function setStatus($value) - { - if($value == "none") return; - if(!$this->initially_was_account) return; - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->dn); - $ldap->cat($this->dn,array("objectClass")); - if($ldap->count()){ - - $tmp = $ldap->fetch(); - for($i = 0; $i < $tmp['objectClass']['count']; $i ++){ - $attrs['objectClass'][] = $tmp['objectClass'][$i]; - } - $flag = $this->StatusFlag; - $attrs[$flag] = $value; - $this->$flag = $value; - $ldap->modify($attrs); - show_ldap_error($ldap->get_error(), sprintf(_("Set status flag for system server/shares with dn '%s' failed."),$this->dn)); - $this->action_hook(); - } - } - - function check() { $message = plugin::check(); @@ -314,66 +266,6 @@ class goShareServer extends plugin{ } } - function action_hook($add_attrs= array()) - { - /* Find postcreate entries for this class */ - $command= search_config($this->config->data['MENU'], get_class($this), "ACTION_HOOK"); - if ($command == "" && isset($this->config->data['TABS'])){ - $command= search_config($this->config->data['TABS'], get_class($this), "ACTION_HOOK"); - } - if ($command != ""){ - /* Walk through attribute list */ - foreach ($this->attributes as $attr){ - if (!is_array($this->$attr)){ - $command= preg_replace("/%$attr/", $this->$attr, $command); - } - } - $command= preg_replace("/%dn/", $this->dn, $command); - /* Additional attributes */ - foreach ($add_attrs as $name => $value){ - $command= preg_replace("/%$name/", $value, $command); - } - - /* If there are still some %.. in our command, try to fill these with some other class vars */ - if(preg_match("/%/",$command)){ - $attrs = get_object_vars($this); - foreach($attrs as $name => $value){ - if(!is_string($value)) continue; - $command= preg_replace("/%$name/", $value, $command); - } - } - - if (check_command($command)){ - @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, - $command, "Execute"); - - exec($command); - } else { - $message= sprintf(_("Command '%s', specified as ACTION_HOOK for plugin '%s' doesn't seem to exist."), $command, get_class($this)); - print_red ($message); - } - } - } - - /* Get updates for status flag */ - function updateStatusState() - { - if(empty($this->StatusFlag)) return; - - $attrs = array(); - $flag = $this->StatusFlag; - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->cn); - $ldap->cat($this->dn,array($flag)); - if($ldap->count()){ - $attrs = $ldap->fetch(); - } - if(isset($attrs[$flag][0])){ - $this->$flag = $attrs[$flag][0]; - } - } - - function addToMountList($entry) { $key = key($entry); @@ -454,7 +346,15 @@ class goShareServer extends plugin{ "plCategory" => array("server"), "plProvidedAcls"=> array( - "goExportEntry" =>_("Share entry")) + "name" => _("Name"), + "netatalkmount" => _("Apple mounts"), + "description" => _("Description"), + "type" => _("Type"), + "charset" => _("Charset"), + "path" => _("Path"), + "option" => _("Option"), + "volume" => _("Volume")) + )); } diff --git a/plugins/admin/systems/class_servNfs.inc b/plugins/admin/systems/class_servNfs.inc index fbda97324..928f0052f 100644 --- a/plugins/admin/systems/class_servNfs.inc +++ b/plugins/admin/systems/class_servNfs.inc @@ -24,22 +24,22 @@ class servnfs extends plugin var $volume =""; // Volume var $option =""; // Options var $is_edit =false; - var $allow_mounts = false; //do we allow mount entries? var $create_mount_init = false; //mount entry set for this entry (while editing)? var $create_mount = false; //save mount entry - function servnfs ($config, $acl, $allow_mounts, $dn= NULL,$entry = false,$mount = false) + var $parent = NULL; + + function servnfs ($config, $parent,$entry= false,$mount =false) { + $this->parent = $parent; + $dn = $parent->dn; plugin::plugin ($config, $dn); - + $this->types = array("CIFS" => "CIFS", "NFS"=>"NFS","samba"=>"samba","netatalk"=>"netatalk","NCP"=>"NCP"); if($dn){ $this->host = substr($dn, 3, strpos($dn, ',')-3); } - $this->acl = $acl; - $this->allow_mounts=$allow_mounts; - $this->charsets = array(); if(!file_exists("/etc/gosa/encodings")){ @@ -96,21 +96,20 @@ class servnfs extends plugin $smarty->assign($attr,$this->$attr); } - $smarty->assign("nameACL",""); - $smarty->assign("name",$this->name); + $tmp = $this->parent->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->parent->getacl($name)); + } + $smarty->assign("name",$this->name); if($this->is_edit){ - $smarty->assign("nameACL"," disabled "); + $smarty->assign("nameACL", preg_replace("/w/",$this->getacl("name"))); } - $smarty->assign("allow_mounts", $this->allow_mounts); + $smarty->assign("allow_mounts", $this->parent->allow_mounts); $smarty->assign("mount_checked", ""); - - $appleMountsACL=chkacl($this->acl,"gotoShareAppleMounts"); - $appleMountsACLset=strpos($appleMountsACL, "disabled"); - $smarty->assign("appleMountsACL", $appleMountsACL); - $smarty->assign("appleMountsACLset", $appleMountsACLset); + $smarty->assign("appleMountsACL", $this->getacl("appleMounts")); if (($this->type == "netatalk") || ($this->type == "NFS")) { if ($this->create_mount_init) { @@ -154,17 +153,19 @@ class servnfs extends plugin /* Save data to object */ function save_object() { - plugin::save_object(TRUE); if(isset($_POST['path'])){ - foreach($this->attributes as $attr){ - $this->$attr = $_POST[$attr]; + + foreach($this->attributes as $name){ + if($this->parent->acl_is_writeable($name) && isset($_POST[$name])){ + $this->$name = $_POST[$name]; + } } - } - - if ((isset($_POST['netatalk_mount'])) && (($this->type == "netatalk") || ($this->type == "NFS"))) { + + if ((isset($_POST['netatalk_mount'])) && (($this->type == "netatalk") || ($this->type == "NFS"))) { $this->create_mount = true; - } else { + } else { $this->create_mount = false; + } } } @@ -256,27 +257,7 @@ class servnfs extends plugin return $this->create_mount; } - /* Return plugin informations for acl handling */ - function plInfo() - { - return (array( - "plShortName" => _("NFS"), - "plDescription" => _("NFS service"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 0, - "plSection" => array("administration"), - "plCategory" => array("server"), - - "plProvidedAcls"=> array( - "description" => _("Description"), - "type" => _("Type"), - "charset" => _("Charset"), - "path" => _("Path"), - "option" => _("Option"), - "volume" => _("Volume")) - )); - } + } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: diff --git a/plugins/admin/systems/goShareServer.tpl b/plugins/admin/systems/goShareServer.tpl index 1699407db..6cb4c45a6 100644 --- a/plugins/admin/systems/goShareServer.tpl +++ b/plugins/admin/systems/goShareServer.tpl @@ -2,14 +2,19 @@
- {html_options values=$goExportEntry output=$goExportEntryKeys} +{/render}
- - - + + +{render acl=$goExportEntryACL} + +{/render} +
diff --git a/plugins/admin/systems/servnfs.tpl b/plugins/admin/systems/servnfs.tpl index 4a7fb40ce..006f5d9c4 100644 --- a/plugins/admin/systems/servnfs.tpl +++ b/plugins/admin/systems/servnfs.tpl @@ -9,7 +9,9 @@ {t}Name{/t} {$must} +{render acl=$nameACL} +{/render} @@ -17,7 +19,9 @@ {t}Description{/t} +{render acl=$descriptionACL} +{/render} @@ -25,7 +29,9 @@ {t}Path{/t} / {t}Volume{/t} +{render acl=$pathACL} +{/render} @@ -33,7 +39,9 @@
{t}Server{/t}
+{render acl=$volumeACL} +{/render} @@ -44,14 +52,21 @@ @@ -104,7 +121,9 @@ {t}Option{/t}
+ {t}Type{/t} +{render acl=$typeACL} +{/render} {if $allow_mounts == TRUE} -

+

+{render acl=$netatalkmountACL} + +{/render} +

{/if} @@ -94,9 +109,11 @@ {t}Codepage{/t}
+{render acl=$charsetACL} +{/render}
+{render acl=$optionACL} +{/render}
-- 2.30.2