From: hickert Date: Thu, 3 Apr 2008 10:32:10 +0000 (+0000) Subject: Updated sudo stuff X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=392ca1940f83a6db269a218445b4cbaf8556e6e9;p=gosa.git Updated sudo stuff git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10134 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/plugins/admin/sudo/class_sudoOptions.inc b/gosa-core/plugins/admin/sudo/class_sudoOptions.inc index 2bf27f823..838dc138d 100644 --- a/gosa-core/plugins/admin/sudo/class_sudoOptions.inc +++ b/gosa-core/plugins/admin/sudo/class_sudoOptions.inc @@ -156,6 +156,10 @@ class sudo_options extends plugin } } + if($this->options[$opt]['TYPE'] == "LISTS"){ + $this->sudoOption[$opt][] = $option; + } + /* Special handling for BOOLEAN values */ if(in_array($this->options[$opt]['TYPE'],array("BOOLEAN"))){ $option['NEGATE'] = FALSE; @@ -169,8 +173,6 @@ class sudo_options extends plugin /* Append values */ if(!isset($this->sudoOption[$opt])){ $this->sudoOption[$opt] = $option; - }else{ - $this->sudoOption[$opt]['VALUE'][] = $value; } } } @@ -185,6 +187,19 @@ class sudo_options extends plugin Handle Posts *****/ foreach($_POST as $name => $value){ + + if(preg_match("/^negListOption_/",$name)){ + $opt = preg_replace("/^negListOption_/","",$name); + $opt = preg_replace("/_[^_]*$/","",$opt); + $id = preg_replace("/^.*_([0-9])*$/","\\1",$opt); + $opt = preg_replace("/_[0-9]*$/","",$opt); + + if(isset($this->sudoOption[$opt][$id])){ + $this->sudoOption[$opt][$id]['NEGATE'] = !$this->sudoOption[$opt][$id]['NEGATE']; + } + break; + } + if(preg_match("/^negOption_/",$name)){ $opt = preg_replace("/^negOption_/","",$name); $opt = preg_replace("/_[^_]*$/","",$opt); @@ -227,11 +242,10 @@ class sudo_options extends plugin break; } + /***** + Remove options + *****/ if(preg_match("/^delOption_/",$name)){ - - /***** - Remove options - *****/ $opt = preg_replace("/^delOption_/","",$name); $opt = preg_replace("/_[^_]*$/","",$opt); if(isset($this->sudoOption[$opt])){ @@ -239,6 +253,24 @@ class sudo_options extends plugin } break; } + + /***** + Remove LISTS options + *****/ + if(preg_match("/^delListOption/",$name)){ + $opt = preg_replace("/^delListOption_/","",$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; + } } @@ -262,11 +294,25 @@ class sudo_options extends plugin 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]) && !isset($this->sudoOption[$opt])){ $type = $this->options[$opt]['TYPE']; $val = array($this->options[$opt]['DEFAULT']); $option = array("NAME" => $opt, "VALUE" => $val , "NEGATE" => FALSE); - $this->sudoOption[$opt] = $option; + + if($type == "LISTS"){ + $this->sudoOption[$opt][] = $option; + }else{ + $this->sudoOption[$opt] = $option; + } + } + + if(isset($this->options[$opt]) && isset($this->sudoOption[$opt]) && $this->options[$opt]['TYPE'] == "LISTS"){ + $type = $this->options[$opt]['TYPE']; + $val = array($this->options[$opt]['DEFAULT']); + $option = array("NAME" => $opt, "VALUE" => $val , "NEGATE" => FALSE); + $this->sudoOption[$opt][] = $option; } } @@ -309,6 +355,18 @@ class sudo_options extends plugin } } } + + /**** + 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'][0] = $val; + } + } + } } } @@ -321,6 +379,23 @@ class sudo_options extends plugin foreach($this->sudoOption as $name => $opt){ $type = $this->options[$name]['TYPE']; + + if($type=="LISTS"){ + foreach($this->sudoOption[$name] as $entry_key => $entry){ + $val = $entry['VALUE'][0]; + if(empty($val)){ + $option = $name; + }else{ + $option = $name."=".$val; + } + if($entry['NEGATE']){ + $option = "!".$option; + } + $this->attrs['sudoOption'][] = $option; + } + continue; + } + $neg = $opt['NEGATE']; $value = $opt['VALUE'][0]; $option = ""; diff --git a/gosa-core/plugins/admin/sudo/options.tpl b/gosa-core/plugins/admin/sudo/options.tpl index c1dbe46da..832e8b692 100644 --- a/gosa-core/plugins/admin/sudo/options.tpl +++ b/gosa-core/plugins/admin/sudo/options.tpl @@ -1,7 +1,7 @@ + + + + + + {/foreach} + {else} + + {$key} @@ -60,8 +83,6 @@ id="option_value__{$key}" {if $item.VALUE.0 == "FALSE" || $item.VALUE.0 == "TRUE"} disabled {/if}> - {else} - {$options[$item.NAME].TYPE} {/if} @@ -69,6 +90,7 @@ + {/if} {/foreach}