summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 69d3b9b)
raw | patch | inline | side by side (parent: 69d3b9b)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 3 Apr 2008 10:32:10 +0000 (10:32 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 3 Apr 2008 10:32:10 +0000 (10:32 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10134 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/plugins/admin/sudo/class_sudoOptions.inc | patch | blob | history | |
gosa-core/plugins/admin/sudo/options.tpl | patch | blob | history |
diff --git a/gosa-core/plugins/admin/sudo/class_sudoOptions.inc b/gosa-core/plugins/admin/sudo/class_sudoOptions.inc
index 2bf27f8234157e9387d1e5b1439f13ea023e2d91..838dc138d2c58ecc28be678eb1cdba03ef95b0a0 100644 (file)
}
}
+ 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;
/* Append values */
if(!isset($this->sudoOption[$opt])){
$this->sudoOption[$opt] = $option;
- }else{
- $this->sudoOption[$opt]['VALUE'][] = $value;
}
}
}
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);
break;
}
+ /*****
+ Remove options
+ *****/
if(preg_match("/^delOption_/",$name)){
-
- /*****
- Remove options
- *****/
$opt = preg_replace("/^delOption_/","",$name);
$opt = preg_replace("/_[^_]*$/","",$opt);
if(isset($this->sudoOption[$opt])){
}
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;
+ }
}
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;
}
}
}
}
}
+
+ /****
+ 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;
+ }
+ }
+ }
}
}
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 = "";
index c1dbe46da84f24553fb2f8d4ae92d9691f50ce71..832e8b69212faed480d0b0a63e0e33d5235b30b7 100644 (file)
<select name='option'>
{foreach from=$options item=item key=key}
- {if !isset($sudoOption.$key)}
+ {if !isset($sudoOption.$key) || ($sudoOption.$key && $item.TYPE == "LISTS")}
<option value='{$key}'>{$item.NAME} ({$map[$item.TYPE]})</option>
{/if}
{/foreach}
<table>
{foreach from=$sudoOption item=item key=key}
+
+ <!-- Special handling for lists
+ -->
+ {if $options[$key].TYPE == "LISTS"}
+ {foreach from=$item item=entry key=entry_key}
+ <tr>
+ <td>{$key} - <b>{t}List{/t}</b></td>
+ <td style="width:20px;">
+ {if $entry.NEGATE}
+ <img src='images/negate.png' alt="!">
+ {/if}
+ </td>
+ <td><input type='text' value="{$entry.VALUE.0}" name="list_value__{$key}_{$entry_key}"></td>
+ <td>
+ <input type='image' src='images/negate.png' name='negListOption_{$key}_{$entry_key}' class='center'>
+ <input type='image' src='images/edittrash.png' name='delListOption_{$key}_{$entry_key}' class='center'>
+ </td>
+ </tr>
+ {/foreach}
+ {else}
+
+ <!-- Default values flat values/single value
+ -->
<tr>
<td>{$key}</td>
<td style="width:20px;">
id="option_value__{$key}"
{if $item.VALUE.0 == "FALSE" || $item.VALUE.0 == "TRUE"} disabled {/if}>
</select>
- {else}
- {$options[$item.NAME].TYPE}
{/if}
</td>
<td style='width: 40px;'>
<input type='image' src='images/edittrash.png' name='delOption_{$key}' class='center'>
</td>
</tr>
+ {/if}
{/foreach}
</table>