From df26d7c244d358324b57e57a575cf0835c9ad989 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 25 Oct 2006 07:23:27 +0000 Subject: [PATCH] Added acls to gofonMacro, macro parameter is still missing git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4936 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/gofon/macro/class_gofonMacro.inc | 88 +++++++++++-------- .../macro/class_gofonMacroManagement.inc | 17 ++-- .../macro/class_gofonMacroParameters.inc | 13 +-- plugins/gofon/macro/generic.tpl | 43 ++++++--- plugins/gofon/macro/tabs_macros.inc | 4 +- 5 files changed, 89 insertions(+), 76 deletions(-) diff --git a/plugins/gofon/macro/class_gofonMacro.inc b/plugins/gofon/macro/class_gofonMacro.inc index 60d0f5284..cbed42605 100755 --- a/plugins/gofon/macro/class_gofonMacro.inc +++ b/plugins/gofon/macro/class_gofonMacro.inc @@ -48,6 +48,8 @@ class macro extends plugin /*! Objectclasses that this calls handles */ var $objectclasses = array("top", "goFonMacro"); + var $ui ; + //! The Konstructor /*! Konstructor, load class with attributes of the given dn*/ function macro ($config, $dn= NULL, $parent= NULL) @@ -55,13 +57,11 @@ class macro extends plugin plugin::plugin ($config, $dn, $parent); $ldap= $config->get_ldap_link(); - $this->dn = $dn; /* This is always an account */ $this->is_account= TRUE; - /* Edit or new one ?*/ if ($this->dn == "new"){ if(isset($_SESSION['CurrentMainBase'])){ @@ -77,16 +77,14 @@ class macro extends plugin $this->orig_cn=$this->cn; $this->base= preg_replace("/ou=macros,ou=asterisk,ou=configs,ou=systems,/","",dn2base($this->dn)); } - $ui= get_userinfo(); - $acl= get_permissions ($ui->dn, $ui->subtreeACL); - $this->acl= get_module_permission($acl, "goFonMacro", $ui->dn); + $this->ui = get_userinfo(); } /*! Execute this plugin */ function execute() { - /* Call parent execute */ - plugin::execute(); + /* Call parent execute */ + plugin::execute(); /* Variables */ $vars = ""; @@ -129,16 +127,31 @@ class macro extends plugin } } - - /* Fill templating stuff */ $smarty= get_smarty(); - $smarty->assign("bases", $this->config->idepartments); + $smarty->assign("bases", $this->get_allowed_bases()); + + /* Assign base ACL */ + $baseACL = $this->getacl("base"); + if(!$this->acl_is_moveable()) { + $baseACL = preg_replace("/w/","",$baseACL); + } + $smarty->assign("baseACL", $baseACL); + + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + if($this->acl_is_writeable("base")){ + $smarty->assign("baseSelect",true); + }else{ + $smarty->assign("baseSelect",false); + } /* Assign all vars to Smarty */ foreach($this->attributes as $ar){ $smarty->assign($ar, $this->$ar); - $smarty->assign($ar."ACL", chkacl($this->acl,$ar)); } /* Checkboxes */ $smarty->assign("base_select", $this->base); @@ -150,23 +163,8 @@ class macro extends plugin $smarty->assign("goFonMacroVisibleChecked",""); } - if(isset($_POST['goFonMacroVisible'])) { - $this->goFonMacroVisible= 1 ; - $smarty->assign("goFonMacroVisibleChecked"," checked "); - }else { - if(isset($_POST['displayName'])){ - $this->goFonMacroVisible= 0 ; - $smarty->assign("goFonMacroVisibleChecked",""); - } - } - - if(!$this->is_new){ - $smarty->assign("disable_cn"," disabled "); - $smarty->assign("cn",$this->orig_cn); - }else{ - $smarty->assign("disable_cn"," "); - $smarty->assign("cn",$this->cn); - } + $smarty->assign("cnACL",$this->getacl("cn",!$this->is_new)); + $smarty->assign("cn",$this->cn); $this->generate_mysql_entension_entries(); /* Show main page */ return($smarty->fetch (get_template_path('generic.tpl', TRUE))); @@ -360,11 +358,29 @@ class macro extends plugin function save_object() { if (isset($_POST['displayName'])){ + $old_cn= $this->cn; + $old_visible = $this->goFonMacroVisible; + plugin::save_object(); - } - foreach($this->attributes as $attr){ - if(isset($_POST[$attr])){ - $this->$attr= $_POST [$attr]; + + /* Restore old cn if we have insuficient acls to change cn ... */ + if(!$this->acl_is_writeable("cn",!$this->is_new)){ + $this->cn = $old_cn; + } + + /* check if we are allowed to toggle visibility */ + if($this->acl_is_writeable("goFonMacroVisible")) { + + /* Checkbox selected ? */ + if(isset($_POST['goFonMacroVisible'])) { + $this->goFonMacroVisible= 1 ; + }else { + if(isset($_POST['displayName'])){ + $this->goFonMacroVisible= 0 ; + } + } + }else{ + $this->goFonMacroVisible = $old_visible; } } } @@ -398,13 +414,6 @@ class macro extends plugin $message[]=_("The given cn is too long, to create a Makro entry, maximum 20 chars."); } - foreach($this->attributes as $attr){ - if(chkacl($this->acl,"edit")){ - $str = sprintf( _("Insufficient permissions, can't change attribute '%s' in goFonMacro"),$attr) ; - return(array($str)); - } - } - if(count(split("\n",$this->goFonMacroContent))>100){ $message[] = _("Makro length must be lower than 100 lines"); } @@ -471,6 +480,7 @@ class macro extends plugin "plCategory" => array("gofon"), "plProvidedAcls" => array( + "cn" => _("Macro name"), "base" => _("Base"), "description" => _("Description"), "displayName" => _("Display name"), diff --git a/plugins/gofon/macro/class_gofonMacroManagement.inc b/plugins/gofon/macro/class_gofonMacroManagement.inc index 847d404ca..5fea98f34 100755 --- a/plugins/gofon/macro/class_gofonMacroManagement.inc +++ b/plugins/gofon/macro/class_gofonMacroManagement.inc @@ -96,7 +96,7 @@ class gofonMacro extends plugin $this->dn= "new"; /* Create new usertab object */ - $this->macrotabs= new macrotabs($this->config,$this->config->data['TABS']['MACROTABS'], $this->dn); + $this->macrotabs= new macrotabs($this->config,$this->config->data['TABS']['MACROTABS'], $this->dn,"gofon"); } @@ -161,8 +161,7 @@ class gofonMacro extends plugin if (($s_action=="edit") && (!isset($this->macrotabs->config))){ $dn = $this->macros[$s_entry]['dn']; - $acl = $this->ui->get_permissions($dn,"gofon/marco"); - + $acl = $this->ui->get_permissions($dn,"gofon/macro"); if(preg_match("/r/",$acl)){ $this->dn = $dn; @@ -177,13 +176,13 @@ class gofonMacro extends plugin add_lock ($this->dn, $this->ui->dn); /* Register macrotabs to trigger edit dialog */ $this->macrotabs= new macrotabs($this->config, - $this->config->data['TABS']['MACROTABS'], $this->dn); + $this->config->data['TABS']['MACROTABS'], $this->dn,"gofon"); $_SESSION['objectinfo']= $this->dn; } } /***************** - Remove marco + Remove macro *****************/ /* Remove user was requested */ @@ -191,7 +190,7 @@ class gofonMacro extends plugin /* Get 'dn' from posted 'uid' */ $dn = $this->macros[$s_entry]['dn']; - $acl = $this->ui->get_permissions($dn,"gofon/marco"); + $acl = $this->ui->get_permissions($dn,"gofon/macro"); if(preg_match("/d/",$acl)){ @@ -224,14 +223,12 @@ class gofonMacro extends plugin /* Confirmation for deletion has been passed. Macro should be deleted. */ if (isset($_POST['delete_macro_confirm'])){ - $acl = $this->ui->get_permissions($this->dn,"gofon/marco"); + $acl = $this->ui->get_permissions($this->dn,"gofon/macro"); if(preg_match("/r/",$acl)){ /* Delete request is permitted, perform LDAP action */ - $this->macrotabs= new macrotabs($this->config,$this->config->data['TABS']['MACROTABS'], $this->dn); - $this->macrotabs->set_acl(array($this->acl)); - + $this->macrotabs= new macrotabs($this->config,$this->config->data['TABS']['MACROTABS'], $this->dn,"gofon"); $this->macrotabs->delete (); gosa_log ("macro object'".$this->dn."' has been removed"); unset ($this->macrotabs); diff --git a/plugins/gofon/macro/class_gofonMacroParameters.inc b/plugins/gofon/macro/class_gofonMacroParameters.inc index cafc1da01..4815c6e22 100755 --- a/plugins/gofon/macro/class_gofonMacroParameters.inc +++ b/plugins/gofon/macro/class_gofonMacroParameters.inc @@ -35,6 +35,7 @@ class macroParameter extends plugin /*! Objectclasses needed by the class*/ var $objectclasses= array("top", "goFonMacro"); + var $ui; //! The konstructor of macroParameter /*! The konstructor of macroParameter... @@ -102,9 +103,7 @@ class macroParameter extends plugin $this->para_count = count ($tmp2); - $ui= get_userinfo(); - $acl= get_permissions ($ui->dn, $ui->subtreeACL); - $this->acl= get_module_permission($acl, "goFonMacro", $ui->dn); + $this->ui= get_userinfo(); } //! Perform Parameter check @@ -323,14 +322,6 @@ class macroParameter extends plugin /* Call common method to give check the hook */ $message= plugin::check(); - foreach($this->attributes as $attr){ - if(chkacl($this->acl,"edit")){ - $str = sprintf( _("Insufficient permissions, can't change attribute '%s' in goFonMacro."),$attr) ; - return(array($str)); - } - } - - foreach($this->goFonMacroParameter as $key=>$val){ if((strstr($val['default'],"!"))||(strstr($val['default'],"#"))) { $message[] = sprintf(_("The parameter %s contains invalid char. '!,#' is used as delimiter"),$val['name']); diff --git a/plugins/gofon/macro/generic.tpl b/plugins/gofon/macro/generic.tpl index 07ab79fe0..9c5d37c30 100755 --- a/plugins/gofon/macro/generic.tpl +++ b/plugins/gofon/macro/generic.tpl @@ -4,12 +4,19 @@ - + @@ -19,15 +26,16 @@
{$must} +{render acl=$cnACL} + +{/render} +
{$must} - +{render acl=$displayNameACL} + +{/render}
{$must} - - {if $baseACL == ""} - - {else} - - {/if} + {render acl=$baseACL} + + {/render} + + {render acl=$baseACL disable_picture='images/folder_gray.png'} + + {/render} +
@@ -40,12 +48,17 @@ - +{render acl=$descriptionACL} + +{/render} - {t}Visible for user{/t} +{render acl=$goFonMacroVisibleACL} + {t}Visible for user{/t} +{/render} @@ -56,7 +69,9 @@
{t}Macro text{/t}
- +{render acl=$goFonMacroContentACL} + +{/render}