From: hickert Date: Wed, 20 Sep 2006 05:13:02 +0000 (+0000) Subject: Updated serverService : Set acl base/category for services X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a83032a4d10878c03c61e43882baa01a2211b22d;p=gosa.git Updated serverService : Set acl base/category for services Added acls for repository service git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4735 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/systems/class_servRepository.inc b/plugins/admin/systems/class_servRepository.inc index b49778d17..e3dc800cd 100644 --- a/plugins/admin/systems/class_servRepository.inc +++ b/plugins/admin/systems/class_servRepository.inc @@ -1,6 +1,8 @@ assign("is_createable",$this->acl_is_createable()); $display= ""; /* Smarty vars*/ @@ -103,13 +104,13 @@ class servrepository extends plugin if(isset($_POST['servRepository'])){ foreach($_POST as $name => $value){ - if(preg_match("/AddRepository/",$name)){ + if(preg_match("/AddRepository/",$name) && $this->acl_is_createable()){ $once = true; $this->dialog = new servRepositorySetup($this->config,$this->dn); - $this->dialog->acl = $this->acl; + $this->dialog->parent = $this; } - if((preg_match("/^delete_/",$name))&&(!$once)){ + if((preg_match("/^delete_/",$name)) && (!$once) && $this->acl_is_removeable()){ $once = true; $value = preg_replace("/delete_/","",$name); $value = base64_decode(preg_replace("/_.*$/","",$value)); @@ -178,7 +179,7 @@ class servrepository extends plugin /* to be able to detect if this was renamed */ $obj['initialy_was'] = $obj['Release']; $this->dialog = new servRepositorySetup($this->config,$this->dn,$obj); - $this->dialog->acl = $this->acl; + $this->dialog->parent = $this; } } } @@ -188,16 +189,9 @@ class servrepository extends plugin $obj = $this->repositories[base64_decode($_GET['id'])]; $obj['initialy_was'] = $obj['Release']; $this->dialog = new servRepositorySetup($this->config,$this->dn,$obj); - $this->dialog->acl = $this->acl; + $this->dialog->parent = $this; } - /* - if(isset($_POST['AddRepository'])){ - $this->dialog = new servRepositorySetup($this->config,$this->dn); - $this->dialog->acl = $this->acl; - } - */ - if(isset($_POST['repository_setup_save'])){ $this->dialog->save_object(); if(($this->dialog->is_new_name())&&(isset($this->repositories[$this->dialog->GetName()]))){ @@ -248,23 +242,25 @@ class servrepository extends plugin $link = "%s"; $edit = " "; - $delete = ""; + + /* Hide delete icon, if delete is not allowed */ + if($this->acl_is_removeable()){ + $delete = ""; + }else{ + $delete = " "; + } foreach($this->repositories as $name => $reps){ $str = " "; - if(preg_match("/".str_replace("*",".*",$this->regex)."/",$reps['Release'])){ - - foreach($reps['Sections'] as $sec){ $str.=$sec." "; } - $divlist->AddEntry(array( - array("string"=>sprintf($link,base64_encode($name),$name),"attach"=>"style='width:80px;'"), - array("string"=>sprintf($link,base64_encode($name),_("Sections")." :".$str)), - array("string"=>preg_replace("/%s/",base64_encode($name),$edit.$delete),"attach"=>"style='border-right:0px;width:55px;text-align:right;'") + array("string"=>sprintf($link,base64_encode($name),$name),"attach"=>"style='width:80px;'"), + array("string"=>sprintf($link,base64_encode($name),_("Sections")." :".$str)), + array("string"=>preg_replace("/%s/",base64_encode($name),$edit.$delete),"attach"=>"style='border-right:0px;width:55px;text-align:right;'") )); } } @@ -275,30 +271,6 @@ class servrepository extends plugin return($display); } - 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(); - } - - $ldap= $this->config->get_ldap_link(); - $ldap->cd ($this->config->current['BASE']); - - $ldap->cat($this->dn, array('dn')); - - if($ldap->count()){ - $ldap->cd($this->dn); - $this->cleanup(); - $ldap->modify ($this->attrs); - - $this->handle_post_events("modify"); - } - } - /* Save data to object */ function save_object() @@ -315,7 +287,6 @@ class servrepository extends plugin { /* Call common method to give check the hook */ $message= plugin::check(); - return ($message); } @@ -361,69 +332,15 @@ class servrepository extends plugin } } - /* 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 getListEntry() { - $this->updateStatusState(); - $flag = $this->StatusFlag; - if(empty($flag)){ - $fields['Status'] = ""; - }else{ - $fields['Status'] = $this->$flag; - } + $fields = goService::getListEntry(); $fields['Message'] = _("Repository service"); - $fields['AllowStart'] = true; - $fields['AllowStop'] = true; - $fields['AllowRestart'] = true; - $fields['AllowRemove']= true; $fields['AllowEdit'] = true; return($fields); } - - /* Directly save new status flag */ - function setStatus($value) - { - if($value == "none") return; - if(!$this->initially_was_account) return; - if(empty($this->StatusFlag)) 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 server services/repository with dn '%s' failed."),$this->dn)); - $this->action_hook(); - } - } - - /* Return plugin informations for acl handling */ function plInfo() { @@ -439,6 +356,7 @@ class servrepository extends plugin "plProvidedAcls"=> array( "cn" => _("Name"), "Release" => _("Releases"), + "Section" => _("Sections"), "ParentServer" => _("Parent server"), "Url" => _("Url")) )); diff --git a/plugins/admin/systems/class_servRepositorySetup.inc b/plugins/admin/systems/class_servRepositorySetup.inc index a1c62e7ba..3ed15dfab 100644 --- a/plugins/admin/systems/class_servRepositorySetup.inc +++ b/plugins/admin/systems/class_servRepositorySetup.inc @@ -20,6 +20,7 @@ class servRepositorySetup extends plugin var $ParentServers = ""; var $initialy_was = false; var $cn = ""; + var $parent = ""; function servRepositorySetup ($config, $dn= NULL,$data = false) { @@ -107,9 +108,15 @@ class servRepositorySetup extends plugin $smarty->assign("Sections",$divlist->DrawList()); + /* Get && assign acls */ + $tmp = $this->parent->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translated){ + $smarty->assign($name."ACL",$this->parent->getacl($name)); + } + + /* Assign values */ foreach($this->attributes as $attr){ $smarty->assign($attr ,$this->$attr); - $smarty->assign($attr."ACL" ,chkacl($this->acl,$attr)); } $tmp = $this->getParentServers(); @@ -121,7 +128,7 @@ class servRepositorySetup extends plugin /* Save data to object */ function save_object() - { + { plugin::save_object(); } diff --git a/plugins/admin/systems/class_serverService.inc b/plugins/admin/systems/class_serverService.inc index 514563c8a..62a31f1e1 100644 --- a/plugins/admin/systems/class_serverService.inc +++ b/plugins/admin/systems/class_serverService.inc @@ -45,6 +45,21 @@ class ServerService extends plugin $this->divList = new divListSystemService($config,$this); } + function set_acl_base($base) + { + plugin::set_acl_base($base); + foreach($this->plugins as $name => $obj){ + $this->plugins[$name]->set_acl_base($base); + } + } + + function set_acl_category($category) + { + plugin::set_acl_category($category); + foreach($this->plugins as $name => $obj){ + $this->plugins[$name]->set_acl_category($category); + } + } function execute() { @@ -106,10 +121,12 @@ class ServerService extends plugin /* Create resetted obj */ $new_obj = new $s_entry($this->config,$this->dn); + $new_obj -> set_acl_base($this->acl_base); + $new_obj -> set_acl_category(preg_replace("/\/$/","",$this->acl_category)); $tmp = $new_obj->getListEntry(); if($tmp['AllowRemove']){ - $this->plugins[$s_entry] = new $s_entry($this->config,$this->dn); + $this->plugins[$s_entry] = $new_obj; $this->plugins[$s_entry]->is_account = false; } } @@ -137,6 +154,9 @@ class ServerService extends plugin if(isset($_POST['CancelService'])){ if($this->backup == NULL){ $this->plugins[$this->current] = new $this->current($this->config,$this->dn); + $this->plugins[$this->current]-> set_acl_base($this->acl_base); + $this->plugins[$this->current]-> set_acl_category(preg_replace("/\/$/","",$this->acl_category)); + }else{ foreach($this->backup as $name => $value){ $this->plugins[$this->current]->$name = $value; diff --git a/plugins/admin/systems/servRepository.tpl b/plugins/admin/systems/servRepository.tpl index 84a4bcdb9..7feaf1d3c 100644 --- a/plugins/admin/systems/servRepository.tpl +++ b/plugins/admin/systems/servRepository.tpl @@ -8,7 +8,9 @@
- +{if $is_createable} + +{/if}
diff --git a/plugins/admin/systems/servRepositorySetup.tpl b/plugins/admin/systems/servRepositorySetup.tpl index a87c7b151..210d853c1 100644 --- a/plugins/admin/systems/servRepositorySetup.tpl +++ b/plugins/admin/systems/servRepositorySetup.tpl @@ -8,32 +8,44 @@ {t}Parent server{/t} - {html_options options=$ParentServers values=$ParentServerKeys selected=$ParentServer} +{/render} {t}Release{/t} - +{render acl=$ReleaseACL} + +{/render} {t}URL{/t} - +{render acl=$UrlACL} + +{/render} {t}Sections{/t}
+{render acl=$SectionACL} {$Sections} +{/render} +{render acl=$SectionACL} +{/render} +{render acl=$SectionACL} +{/render}