From dfdd5986b6fcbb5da5b4b09478f68c0b1a89da31 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 18 Jul 2007 07:18:59 +0000 Subject: [PATCH] Updated Post check for faiManagement, create branch. git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@6902 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/fai/class_divListFai.inc | 7 +- plugins/admin/fai/class_faiManagement.inc | 79 ++++++++++++----------- 2 files changed, 48 insertions(+), 38 deletions(-) diff --git a/plugins/admin/fai/class_divListFai.inc b/plugins/admin/fai/class_divListFai.inc index 79b98c166..c474b15e0 100644 --- a/plugins/admin/fai/class_divListFai.inc +++ b/plugins/admin/fai/class_divListFai.inc @@ -80,8 +80,11 @@ class divListFai extends MultiSelectWindow $str = ""; if($position == 2){ - $r = "" != search_config($this->config->data,"faiManagement","POSTREMOVE"); - $c = "" != search_config($this->config->data,"faiManagement","POSTCREATE"); + /* Check if there are post commands available for fai management. + * If not, grey out freeze/branch and release remove buttons. + */ + $r = ("" != search_config($this->config->data,"faiManagement","POSTREMOVE")); + $c = ("" != search_config($this->config->data,"faiManagement","POSTCREATE")); $smarty = get_smarty(); $smarty->assign("allow_create", $c); diff --git a/plugins/admin/fai/class_faiManagement.inc b/plugins/admin/fai/class_faiManagement.inc index dbb18dc45..805927609 100644 --- a/plugins/admin/fai/class_faiManagement.inc +++ b/plugins/admin/fai/class_faiManagement.inc @@ -269,16 +269,18 @@ class faiManagement extends plugin */ if($s_action == "remove_branch"){ - $r = "" != search_config($this->config->data,"faiManagement","POSTREMOVE"); - if($r){ + /* Check if we have a post remove method configured + * else skip this operation. (Skip:Button in the ui should be disabled in this case) + */ + if("" != search_config($this->config->data,"faiManagement","POSTREMOVE")){ - $base= $this->DivListFai->selectedBranch; + $base= $this->DivListFai->selectedBranch; - /* Load permissions for selected 'dn' and check if - we're allowed to remove this 'dn' */ - $acl= get_permissions ($this->DivListFai->selectedBase, $this->ui->subtreeACL); - $this->acl= get_module_permission($acl, "FAIclass", $base); - if (chkacl($this->acl, "delete") == ""){ + /* Load permissions for selected 'dn' and check if + we're allowed to remove this 'dn' */ + $acl= get_permissions ($this->DivListFai->selectedBase, $this->ui->subtreeACL); + $this->acl= get_module_permission($acl, "FAIclass", $base); + if (chkacl($this->acl, "delete") == ""){ $smarty->assign("info", sprintf(_("You're about to delete a fai branch / freeze '%s'."), $this->DivListFai->selectedBranch)); return($smarty->fetch(get_template_path('remove_branch.tpl',TRUE))); } else { @@ -294,31 +296,34 @@ class faiManagement extends plugin if(isset($_POST['delete_branch_confirm'])){ - $r = "" != search_config($this->config->data,"faiManagement","POSTREMOVE"); - - $bb = $this->DivListFai->selectedBranch; - if(!isset($ldap)){ - $ldap = $this->config->get_ldap_link(); - } - - $br = $this->DivListFai->AvailableBranches; + /* Check if we have a post remove method configured + * else skip this operation. (Skip:Button in the ui should be disabled in this case) + */ + if("" != search_config($this->config->data,"faiManagement","POSTREMOVE")){ - if(isset($br[$bb])){ - $name = $br[$bb]; - $ldap->cd($bb); - $ldap->recursive_remove(); - $ldap->cd(preg_replace('/,ou=fai,ou=configs,ou=systems,/', ',ou=apps,', $bb)); - $ldap->recursive_remove(); - $this->DivListFai->selectedBranch = "main"; - $this->DivListFai->AvailableBranches = $this->getBranches(); + $bb = $this->DivListFai->selectedBranch; + if(!isset($ldap)){ + $ldap = $this->config->get_ldap_link(); + } - /* Post remove */ - $this->lock_name = $name; - $this->lock_dn = $bb; - $this->postremove(); + $br = $this->DivListFai->AvailableBranches; + + if(isset($br[$bb])){ + $name = $br[$bb]; + $ldap->cd($bb); + $ldap->recursive_remove(); + $ldap->cd(preg_replace('/,ou=fai,ou=configs,ou=systems,/', ',ou=apps,', $bb)); + $ldap->recursive_remove(); + $this->DivListFai->selectedBranch = "main"; + $this->DivListFai->AvailableBranches = $this->getBranches(); + + /* Post remove */ + $this->lock_name = $name; + $this->lock_dn = $bb; + $this->postremove(); + } } } - /**************** @@ -458,10 +463,11 @@ class faiManagement extends plugin /**************** Display dialog to enter new Branch name ****************/ - - $c = "" != search_config($this->config->data,"faiManagement","POSTMODIFY"); - - if($c){ + + /* Check if we have a post create method configured + * else skip this operation. (Skip:Button in the ui should be disabled in this case) + */ + if("" != search_config($this->config->data,"faiManagement","POSTCREATE")){ $acl= get_permissions ($this->DivListFai->selectedBase, $this->ui->subtreeACL); $this->acl= get_module_permission($acl, "FAIclass", $this->DivListFai->selectedBase); if((($s_action == "branch_branch")||($this->dispNewBranch)) && chkacl($this->acl,"FAIclass") == ""){ @@ -476,9 +482,10 @@ class faiManagement extends plugin Display dialog to enter new Freeze name ****************/ - $c = "" != search_config($this->config->data,"faiManagement","POSTMODIFY"); - - if($c){ + /* Check if we have a post create method configured + * else skip this operation. (Skip:Button in the ui should be disabled in this case) + */ + if("" != search_config($this->config->data,"faiManagement","POSTCREATE")){ $acl= get_permissions ($this->DivListFai->selectedBase, $this->ui->subtreeACL); $this->acl= get_module_permission($acl, "FAIclass", $this->DivListFai->selectedBase); if((($s_action == "freeze_branch")||($this->dispNewFreeze)) && chkacl($this->acl,"FAIclass") == ""){ -- 2.30.2