From a450ec266939d90755de4d2475789a9b10060a7d Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 20 Oct 2008 09:14:38 +0000 Subject: [PATCH] Updated Sudo Roles -Added ACLs to option tab git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12738 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../sudo/admin/sudo/class_sudoOption.inc | 233 ++++++++++-------- gosa-plugins/sudo/admin/sudo/options.tpl | 12 +- 2 files changed, 138 insertions(+), 107 deletions(-) diff --git a/gosa-plugins/sudo/admin/sudo/class_sudoOption.inc b/gosa-plugins/sudo/admin/sudo/class_sudoOption.inc index bbac63d1b..009071720 100644 --- a/gosa-plugins/sudo/admin/sudo/class_sudoOption.inc +++ b/gosa-plugins/sudo/admin/sudo/class_sudoOption.inc @@ -206,75 +206,79 @@ class sudoOption extends plugin /***** Handle Posts *****/ - foreach($_POST as $name => $value){ - - if(preg_match("/^negOption_/",$name)){ - - $opt = preg_replace("/^negOption_/","",$name); - $opt = preg_replace("/_[^_]*$/","",$opt); - $id = preg_replace("/^.*_([0-9])*$/","\\1",$opt); - $opt = preg_replace("/_[0-9]*$/","",$opt); + if($this->acl_is_writeable("")){ + + foreach($_POST as $name => $value){ + + if(preg_match("/^negOption_/",$name)){ + + $opt = preg_replace("/^negOption_/","",$name); + $opt = preg_replace("/_[^_]*$/","",$opt); + $id = preg_replace("/^.*_([0-9])*$/","\\1",$opt); + $opt = preg_replace("/_[0-9]*$/","",$opt); + + if(isset($this->sudoOption[$opt][$id])){ + $val = $this->sudoOption[$opt][$id]["VALUE"]; + + /***** + Negate STRING_BOOL && BOOL_INTEGER + *****/ + if(in_array($this->options[$opt]['TYPE'],array('STRING_BOOL','BOOL_INTEGER'))){ + if(in_array($val, array("TRUE","FALSE"))){ + if($val == "TRUE"){ + $this->sudoOption[$opt][$id]["VALUE"] = "FALSE"; + }else{ + $this->sudoOption[$opt][$id]["VALUE"] = "TRUE"; + } + }else{ + $this->sudoOption[$opt][$id]['NEGATE'] = !$this->sudoOption[$opt][$id]['NEGATE']; + } + } - if(isset($this->sudoOption[$opt][$id])){ - $val = $this->sudoOption[$opt][$id]["VALUE"]; + /***** + Negate STRING / INTEGER + *****/ + if(in_array($this->options[$opt]['TYPE'],array('STRING','INTEGER','LISTS'))){ + $this->sudoOption[$opt][$id]['NEGATE'] = !$this->sudoOption[$opt][$id]['NEGATE']; + } - /***** - Negate STRING_BOOL && BOOL_INTEGER - *****/ - if(in_array($this->options[$opt]['TYPE'],array('STRING_BOOL','BOOL_INTEGER'))){ - if(in_array($val, array("TRUE","FALSE"))){ + /***** + Negate BOOLEAN + *****/ + if(in_array($this->options[$opt]['TYPE'],array('BOOLEAN'))){ if($val == "TRUE"){ $this->sudoOption[$opt][$id]["VALUE"] = "FALSE"; }else{ $this->sudoOption[$opt][$id]["VALUE"] = "TRUE"; } - }else{ - $this->sudoOption[$opt][$id]['NEGATE'] = !$this->sudoOption[$opt][$id]['NEGATE']; } } + break; + } - /***** - Negate STRING / INTEGER - *****/ - if(in_array($this->options[$opt]['TYPE'],array('STRING','INTEGER','LISTS'))){ - $this->sudoOption[$opt][$id]['NEGATE'] = !$this->sudoOption[$opt][$id]['NEGATE']; + /***** + Remove options + *****/ + if(preg_match("/^delOption/",$name)){ + $opt = preg_replace("/^delOption_/","",$name); + $opt = preg_replace("/_[^_]*$/","",$opt); + $id = preg_replace("/^.*_([0-9])*$/","\\1",$opt); + $opt = preg_replace("/_[0-9]*$/","",$opt); + + if(isset($this->sudoOption[$opt][$id])){ + unset($this->sudoOption[$opt][$id]); } - - /***** - Negate BOOLEAN - *****/ - if(in_array($this->options[$opt]['TYPE'],array('BOOLEAN'))){ - if($val == "TRUE"){ - $this->sudoOption[$opt][$id]["VALUE"] = "FALSE"; - }else{ - $this->sudoOption[$opt][$id]["VALUE"] = "TRUE"; - } + if(!count($this->sudoOption[$opt])){ + unset($this->sudoOption[$opt]); } + break; } - break; - } - - /***** - Remove options - *****/ - if(preg_match("/^delOption/",$name)){ - $opt = preg_replace("/^delOption_/","",$name); - $opt = preg_replace("/_[^_]*$/","",$opt); - $id = preg_replace("/^.*_([0-9])*$/","\\1",$opt); - $opt = preg_replace("/_[0-9]*$/","",$opt); - - if(isset($this->sudoOption[$opt][$id])){ - unset($this->sudoOption[$opt][$id]); - } - if(!count($this->sudoOption[$opt])){ - unset($this->sudoOption[$opt]); - } - break; } } $smarty = get_smarty(); + $smarty->assign("ACL",$this->getacl("")); $smarty->assign("map", array("STRING" => _("string"), "BOOLEAN" => _("bool"), "INTEGER" => _("integer") , "BOOL_INTEGER" => _("integer")."-"._("bool") , "STRING_BOOL" => _("string")."-"._("bool"),"LISTS" => _("list"))); @@ -310,71 +314,73 @@ class sudoOption extends plugin */ function save_object() { - plugin::save_object(); - - if(isset($_POST['add_option']) && isset($_POST['option'])){ - $opt = get_post("option"); - - /* Append attribute only once, lists are handled below */ - if(isset($this->options[$opt])){ - $type = $this->options[$opt]['TYPE']; - $val = $this->options[$opt]['DEFAULT']; - $option = array("NAME" => $opt, "VALUE" => $val , "NEGATE" => FALSE); - $this->sudoOption[$opt][] = $option; + if($this->acl_is_writeable("")){ + plugin::save_object(); + + if(isset($_POST['add_option']) && isset($_POST['option'])){ + $opt = get_post("option"); + + /* Append attribute only once, lists are handled below */ + if(isset($this->options[$opt])){ + $type = $this->options[$opt]['TYPE']; + $val = $this->options[$opt]['DEFAULT']; + $option = array("NAME" => $opt, "VALUE" => $val , "NEGATE" => FALSE); + $this->sudoOption[$opt][] = $option; + } } - } - - foreach($this->sudoOption as $name => $opts){ - foreach($opts as $id => $opt){ - /**** - Get posted value for BOOLEAN - ****/ - if(in_array($this->options[$name]['TYPE'],array("BOOLEAN"))){ - if(isset($_POST['option_value__'.$name.'_'.$id])){ - $this->sudoOption[$name][$id]["VALUE"] = get_post('option_value__'.$name.'_'.$id); - } - } + foreach($this->sudoOption as $name => $opts){ + foreach($opts as $id => $opt){ - /**** - Get posted value for STRING / INTEGER - ****/ - if(in_array($this->options[$name]['TYPE'],array("STRING","INTEGER"))){ - if(isset($_POST['option_value__'.$name.'_'.$id])){ - $this->sudoOption[$name][$id]["VALUE"] = get_post('option_value__'.$name.'_'.$id); + /**** + Get posted value for BOOLEAN + ****/ + if(in_array($this->options[$name]['TYPE'],array("BOOLEAN"))){ + if(isset($_POST['option_value__'.$name.'_'.$id])){ + $this->sudoOption[$name][$id]["VALUE"] = get_post('option_value__'.$name.'_'.$id); + } } - } - /**** - Get posted value for STRING_BOOL / BOOL_INTEGER - ****/ - if(in_array($this->options[$name]['TYPE'],array("BOOL_INTEGER","STRING_BOOL"))){ - if(isset($_POST['option_selection__'.$name.'_'.$id])){ - $sel = get_post('option_selection__'.$name.'_'.$id); - $val = ""; + /**** + Get posted value for STRING / INTEGER + ****/ + if(in_array($this->options[$name]['TYPE'],array("STRING","INTEGER"))){ if(isset($_POST['option_value__'.$name.'_'.$id])){ - $val = get_post('option_value__'.$name.'_'.$id); + $this->sudoOption[$name][$id]["VALUE"] = get_post('option_value__'.$name.'_'.$id); } + } - if($sel == "FALSE" || $sel == "TRUE"){ - $this->sudoOption[$name][$id]['VALUE'] = $sel; - $this->sudoOption[$name][$id]['NEGATE'] = FALSE; - }else{ - $this->sudoOption[$name][$id]['VALUE'] = $val; + /**** + Get posted value for STRING_BOOL / BOOL_INTEGER + ****/ + if(in_array($this->options[$name]['TYPE'],array("BOOL_INTEGER","STRING_BOOL"))){ + if(isset($_POST['option_selection__'.$name.'_'.$id])){ + $sel = get_post('option_selection__'.$name.'_'.$id); + $val = ""; + if(isset($_POST['option_value__'.$name.'_'.$id])){ + $val = get_post('option_value__'.$name.'_'.$id); + } + + if($sel == "FALSE" || $sel == "TRUE"){ + $this->sudoOption[$name][$id]['VALUE'] = $sel; + $this->sudoOption[$name][$id]['NEGATE'] = FALSE; + }else{ + $this->sudoOption[$name][$id]['VALUE'] = $val; + } } } - } - /**** - Get posted value for LISTS - ****/ - if(in_array($this->options[$name]['TYPE'],array("LISTS"))){ - foreach($this->sudoOption[$name] as $entry_key => $entry){ - if(isset($_POST['list_value__'.$name.'_'.$entry_key])){ - $val = get_post('list_value__'.$name.'_'.$entry_key); - $this->sudoOption[$name][$entry_key]["VALUE"] = $val; - } - } + /**** + Get posted value for LISTS + ****/ + if(in_array($this->options[$name]['TYPE'],array("LISTS"))){ + foreach($this->sudoOption[$name] as $entry_key => $entry){ + if(isset($_POST['list_value__'.$name.'_'.$entry_key])){ + $val = get_post('list_value__'.$name.'_'.$entry_key); + $this->sudoOption[$name][$entry_key]["VALUE"] = $val; + } + } + } } } } @@ -521,6 +527,23 @@ class sudoOption extends plugin } + /*! \brief Add ACL object + @return Returns the ACL object. + */ + static function plInfo() + { + return (array( + "plShortName" => _("Options"), + "plDescription" => _("Sudo options"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 2, + "plSection" => array("admin"), + "plCategory" => array("sudo"), + "plProvidedAcls" => array() + )); + } + /*! \brief Unescape special chars in function parameters. @param String the string to that must be unescaped. */ diff --git a/gosa-plugins/sudo/admin/sudo/options.tpl b/gosa-plugins/sudo/admin/sudo/options.tpl index 701c48343..6df2a0b36 100644 --- a/gosa-plugins/sudo/admin/sudo/options.tpl +++ b/gosa-plugins/sudo/admin/sudo/options.tpl @@ -17,7 +17,7 @@ {/if} - +{render acl=$ACL} {if $options[$entry.NAME].TYPE == "STRING"} @@ -66,10 +66,15 @@ id="option_value__{$key}_{$entry_key}" {if $entry.VALUE == "FALSE" || $entry.VALUE == "TRUE"} disabled {/if}> {/if} +{/render} +{render acl=$ACL} +{/render} +{render acl=$ACL} +{/render} {/foreach} @@ -79,6 +84,7 @@

 


{t}Available options{/t}:

+{render acl=$ACL} +{/render} +{render acl=$ACL} - +{/render}