summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6b71c69)
raw | patch | inline | side by side (parent: 6b71c69)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 3 Apr 2008 09:14:43 +0000 (09:14 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 3 Apr 2008 09:14:43 +0000 (09:14 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10132 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/gosa-core/plugins/admin/sudo/class_sudoGeneric.inc b/gosa-core/plugins/admin/sudo/class_sudoGeneric.inc
index a14d87c8f6cfa11449928fee5044725bcbc7b2cc..6f62286b597e8c7eca0cc0463ca459539912c739 100644 (file)
var $sudoUser = array();
var $sudoCommand= array();
- var $sudoOption = array();
var $sudoHost = array();
var $sudoRunas = array();
var $objectclasses = array("top","sudoRole");
- var $attributes = array("cn","description","sudoUser","sudoCommand","sudoOption","sudoHost","sudoRunas");
+ var $attributes = array("cn","description","sudoUser","sudoCommand","sudoHost","sudoRunas");
var $is_account = TRUE;
{
plugin::plugin ($config, $dn);
- foreach(array("sudoUser","sudoCommand","sudoOption","sudoHost","sudoRunas") as $attr){
+ foreach(array("sudoUser","sudoCommand","sudoHost","sudoRunas") as $attr){
$this->$attr = array();
if(isset($this->attrs[$attr])){
$tmp = array();
$divlist_sudoHost->Setheight("90");
$divlist_sudoRunas = new divSelectBox("divlist_sudoRunas");
$divlist_sudoRunas->Setheight("90");
- $divlist_sudoOption = new divSelectBox("divlist_sudoOption");
- $divlist_sudoOption->Setheight("90");
$divlist_sudoCommand = new divSelectBox("divlist_sudoCommand");
$divlist_sudoCommand->Setheight("90");
$neg_img= "<img src='images/negate.png' alt='!' class='center'>";
$option = "<input type='image' src='images/negate.png' name='neg_%ATTR%_%KEY%' class='center'>";
$option.= "<input type='image' src='images/edittrash.png' name='del_%ATTR%_%KEY%' class='center'>";
- foreach(array("sudoUser","sudoCommand","sudoOption","sudoHost","sudoRunas") as $attr){
+ foreach(array("sudoUser","sudoCommand","sudoHost","sudoRunas") as $attr){
foreach($this->$attr as $key => $entry){
$entry = preg_replace("/^!/",$neg_img,$entry);
$list_name = "divlist_".$attr;
$smarty->assign("divlist_sudoUser",$divlist_sudoUser->DrawList());
$smarty->assign("divlist_sudoHost",$divlist_sudoHost->DrawList());
$smarty->assign("divlist_sudoRunas",$divlist_sudoRunas->DrawList());
- $smarty->assign("divlist_sudoOption",$divlist_sudoOption->DrawList());
$smarty->assign("divlist_sudoCommand",$divlist_sudoCommand->DrawList());
return($smarty->fetch(get_template_path('generic.tpl', TRUE)));
"sudoUser" => _("Users"),
"sudoHost" => _("Host"),
"sudoCommand" => _("Command"),
- "sudoRunas" => _("Run as user"),
- "sudoOption" => _("Flags"))
+ "sudoRunas" => _("Run as user"))
));
}
}
diff --git a/gosa-core/plugins/admin/sudo/class_sudoOptions.inc b/gosa-core/plugins/admin/sudo/class_sudoOptions.inc
index 8c003e4a9a5c2c0c7f3d81337092e170c002297e..0b1572211b94b18e4d0da7e5706c217ed6201ad9 100644 (file)
$option['VALUE'] = array($value);
$option['NEGATE'] = $negation;
+ /* Special handling for mixed flag types.
+ Some attributes like (BOOL_INTEGER) can be TRUE/FALSE and INTEGER.
+ This means, if the value is empty it is BOOL and $negation defines its boolean value.
+ */
+ if(in_array($this->options[$opt]['TYPE'],array("BOOL_INTEGER","STRING_BOOL"))){
+ if(empty($value)){
+ $option['NEGATE'] = FALSE;
+ if($negation){
+ $option['VALUE'] = array(0 => "FALSE");
+ }else{
+ $option['VALUE'] = array(0 => "TRUE");
+ }
+ }
+ }
+
+ if(in_array($this->options[$opt]['TYPE'],array("BOOLEAN"))){
+ $option['NEGATE'] = FALSE;
+ if($negation){
+ $option['VALUE'] = array(0 => "FALSE");
+ }else{
+ $option['VALUE'] = array(0 => "TRUE");
+ }
+ }
+
if(!isset($this->sudoOption[$opt])){
$this->sudoOption[$opt] = $option;
}else{
{
/* Call parent execute */
plugin::execute();
+
+ foreach($_POST as $name => $value){
+ if(preg_match("/^negOption_/",$name)){
+ $opt = preg_replace("/^negOption_/","",$name);
+ $opt = preg_replace("/_[^_]*$/","",$opt);
+ if(isset($this->sudoOption[$opt])){
+ $val = $this->sudoOption[$opt]['VALUE'][0];
+
+ /*****
+ 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]['VALUE'][0] = "FALSE";
+ }else{
+ $this->sudoOption[$opt]['VALUE'][0] = "TRUE";
+ }
+ }else{
+ $this->sudoOption[$opt]['NEGATE'] = !$this->sudoOption[$opt]['NEGATE'];
+ }
+ }
+
+ /*****
+ Negate STRING / INTEGER
+ *****/
+ if(in_array($this->options[$opt]['TYPE'],array('STRING','INTEGER'))){
+ $this->sudoOption[$opt]['NEGATE'] = !$this->sudoOption[$opt]['NEGATE'];
+ }
+
+ /*****
+ Negate BOOLEAN
+ *****/
+ if(in_array($this->options[$opt]['TYPE'],array('BOOLEAN'))){
+ if($val == "TRUE"){
+ $this->sudoOption[$opt]['VALUE'][0] = "FALSE";
+ }else{
+ $this->sudoOption[$opt]['VALUE'][0] = "TRUE";
+ }
+ }
+ }
+ break;
+ }
+ }
+
$smarty = get_smarty();
$smarty->assign("map", array("STRINGS" => _("string"), "BOOLEAN" => _("bool"),
plugin::save_object();
foreach($this->sudoOption as $name => $opt){
+
+ /****
+ Get posted value for BOOLEAN
+ ****/
+ if(in_array($this->options[$name]['TYPE'],array("BOOLEAN"))){
+ $this->sudoOption[$name]['VALUE'][0] = get_post('option_value__'.$name);
+ }
+
+ /****
+ Get posted value for STRING / INTEGER
+ ****/
if(in_array($this->options[$name]['TYPE'],array("STRING","INTEGER"))){
if(isset($_POST['option_value__'.$name])){
- $this->sudoOption[$name]['VALUE'] = get_post('option_value__'.$name);
+ $this->sudoOption[$name]['VALUE'][0] = get_post('option_value__'.$name);
+ }
+ }
+
+ /****
+ 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])){
+ $sel = get_post('option_selection__'.$name);
+ $val = "";
+ if(isset($_POST['option_value__'.$name])){
+ $val = get_post('option_value__'.$name);
+ }
+
+ if($sel == "FALSE" || $sel == "TRUE"){
+ $this->sudoOption[$name]['VALUE'] = array($sel);
+ $this->sudoOption[$name]['NEGATE'] = FALSE;
+ }else{
+ $this->sudoOption[$name]['VALUE'] = array($val);
+ }
}
}
}
function save()
{
plugin::save();
+
+ $this->attrs['sudoOption'] = array();
+ foreach($this->sudoOption as $name => $opt){
+
+ $type = $this->options[$name]['TYPE'];
+ $neg = $opt['NEGATE'];
+ $value = $opt['VALUE'][0];
+ $option = "";
+
+ /****
+ Save BOOLEAN
+ ****/
+ if(in_array($type,array("BOOLEAN"))){
+ $option = $name;
+ if($value == "FALSE"){
+ $option = "!".$option;
+ }
+ }
+
+ /****
+ Save STRING / INTEGER
+ ****/
+ if(in_array($type,array("STRING","INTEGER"))){
+ $option = $name."=".$value;
+ if($neg){
+ $option = "!".$option;
+ }
+ }
+
+ /****
+ Save STRING_BOOL / BOOL_INTEGER
+ ****/
+ if(in_array($type,array("STRING_BOOL","BOOL_INTEGER"))){
+ if($value == "FALSE"){
+ $option = "!".$name;
+ }elseif($value == "TRUE"){
+ $option = $name;
+ }else{
+ $option = $name."=".$value;
+ if($neg){
+ $option = "!".$option;
+ }
+ }
+ }
+
+ $this->attrs['sudoOption'][] = $option;
+ }
$this->cleanup();
$ldap = $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
$ldap->cd($this->dn);
$ldap->modify($this->attrs);;
}
index e0849e8dba41a5043fe84a0e664e55206cc86702..be45c1709dcd613dad0c3a374bc80132c0bd6978 100644 (file)
</td>
</tr>
<tr><td style="width:100%;"colspan="2"><p class="seperator"> </p></td></tr>
- <tr>
- <td colspan="2"><b>Flags</b>
- {$divlist_sudoOption}
- <input type='submit' name='list_sudoOption' value='{t}Add from list{/t}'>
- </td>
- </tr>
- <tr><td style="width:100%;"colspan="2"><p class="seperator"> </p></td></tr>
<tr>
<td><b>Hosts</b>
{$divlist_sudoHost}
index 2cac4f0e07bd99676e73cea3884e954a389d63c2..94685e32e3988ebc431f6f0acd9308b7a5cd9d30 100644 (file)
<td>
{if $options[$item.NAME].TYPE == "STRING"}
+ <!-- STRING
+ -->
<input type='text' name='option_value__{$key}' value="{$item.VALUE.0}" style='width:280px;'>
{elseif $options[$item.NAME].TYPE == "INTEGER"}
+ <!-- INTEGER
+ -->
<input type='text' name='option_value__{$key}' value="{$item.VALUE.0}" style='width:280px;'>
{elseif $options[$item.NAME].TYPE == "BOOLEAN"}
- <input type='checkbox' value="1" name='option_value__{$key}'>
+ <!-- BOOLEAN
+ -->
+ <select name="option_value__{$key}">
+ <option {if $item.VALUE.0 == "FALSE"} selected {/if}value="FALSE">FALSE</option>
+ <option {if $item.VALUE.0 == "TRUE"} selected {/if}value="TRUE">TRUE</option>
+ </select>
{elseif $options[$item.NAME].TYPE == "BOOL_INTEGER"}
- <select name="option_selection__{$key}">
- <option {if $item.VALUE == "FALSE"} selected {/if}value="FALSE">FALSE</option>
- <option {if $item.VALUE == "TRUE"} selected {/if}value="TRUE">TRUE</option>
- <option {if $item.VALUE != "TRUE" && $item.VALUE != "FALSE"} selected {/if}value="STRING">STRING</option>
- <input type='text' value="{$item.VALUE.0}" style='width:280px;' name='option_value__{$key}'>
+ <!-- BOOLEAN_INTEGER
+ -->
+ <select name="option_selection__{$key}" id="option_selection__{$key}"
+ onChange="toggle_bool_fields('option_selection__{$key}','option_value__{$key}');">
+ <option {if $item.VALUE.0 == "FALSE"} selected {/if}value="FALSE">FALSE</option>
+ <option {if $item.VALUE.0 == "TRUE"} selected {/if}value="TRUE">TRUE</option>
+ <option {if $item.VALUE.0 != "TRUE" && $item.VALUE.0 != "FALSE"} selected {/if}
+ value="STRING">STRING</option>
+ <input type='text' value="{$item.VALUE.0}" style='width:280px;' name='option_value__{$key}'
+ id="option_value__{$key}"
+ {if $item.VALUE.0 == "FALSE" || $item.VALUE.0 == "TRUE"} disabled {/if}>
</select>
{elseif $options[$item.NAME].TYPE == "STRING_BOOL"}
- <select name="option_selection__{$key}">
- <option {if $item.VALUE == "FALSE"} selected {/if}value="FALSE">FALSE</option>
- <option {if $item.VALUE == "TRUE"} selected {/if}value="TRUE">TRUE</option>
- <option {if $item.VALUE != "TRUE" && $item.VALUE != "FALSE"} selected {/if}value="STRING">STRING</option>
- <input type='text' value="{$item.VALUE.0}" style='width:280px;' name='option_value__{$key}'>
+ <!-- STRING_BOOLEAN
+ -->
+ <select name="option_selection__{$key}" id="option_selection__{$key}"
+ onChange="toggle_bool_fields('option_selection__{$key}','option_value__{$key}');">
+ <option {if $item.VALUE.0 == "FALSE"} selected {/if}value="FALSE">FALSE</option>
+ <option {if $item.VALUE.0 == "TRUE"} selected {/if}value="TRUE">TRUE</option>
+ <option {if $item.VALUE.0 != "TRUE" && $item.VALUE.0 != "FALSE"} selected {/if}
+ value="STRING">STRING</option>
+ <input type='text' value="{$item.VALUE.0}" style='width:280px;' name='option_value__{$key}'
+ 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/negate.png' name='negOption_{$key}' class='center'>
+ <input type='image' src='images/edittrash.png' name='delOption_{$key}' class='center'>
+ </td>
</tr>
{/foreach}
</table>
+
+<script language="JavaScript" type="text/javascript">
+ <!--
+ {literal}
+ function toggle_bool_fields(source_select,target_input)
+ {
+ var select= document.getElementById(source_select);
+ var input = document.getElementById(target_input);
+ if(select.value == "TRUE" || select.value == "FALSE"){
+ input.disabled = true;
+ input.value = select.value;
+ }else{
+ input.disabled = false;
+ input.value = "";
+ }
+ }
+ {/literal}
+ -->
+</script>
+
+