diff --git a/configs/menu.conf b/configs/menu.conf index 7a24b7c3..5a75acc0 100644 --- a/configs/menu.conf +++ b/configs/menu.conf @@ -1,4 +1,5 @@ url_main = main.php +url_editactive = editactive.php?table= # list_admin url_list_admin = list-admin.php url_create_admin = edit.php?table=admin diff --git a/edit.php b/edit.php index 192fa8e5..ae776069 100644 --- a/edit.php +++ b/edit.php @@ -19,7 +19,6 @@ * GET parameters: * table what to edit (*Handler) * edit item to edit (if net given: a new item will be created) - * active if given: only change active state to given value (which must be 0 or 1) and return to listview * additional parameters will be accepted if specified in *Handler->webformConfig()[prefill] when creating a new item */ @@ -40,19 +39,13 @@ $edit = safepost('edit', safeget('edit')); $new = 0; if ($edit == "") $new = 1; -$active = safeget('active'); - $handler = new $handlerclass($new, $username); $formconf = $handler->webformConfig(); authentication_require_role($formconf['required_role']); -if ($active != '0' && $active != '1') { - $active = ''; # ignore invalid values -} - -if ($edit != '' || $active != '' || $formconf['early_init']) { +if ($edit != '' || $formconf['early_init']) { if (!$handler->init($edit)) { flash_error($handler->errormsg); header ("Location: " . $formconf['listview']); @@ -63,7 +56,7 @@ if ($edit != '' || $active != '' || $formconf['early_init']) { $form_fields = $handler->getStruct(); $id_field = $handler->getId_field(); -if ($_SERVER['REQUEST_METHOD'] == "GET" && $active == '') { +if ($_SERVER['REQUEST_METHOD'] == "GET") { if ($edit == '') { # new - prefill fields from URL parameters if allowed in $formconf['prefill'] if ( isset($formconf['prefill']) ) { foreach ($formconf['prefill'] as $field) { @@ -113,11 +106,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { } } -if ($active != '') { - $values['active'] = $active; -} - -if ($_SERVER['REQUEST_METHOD'] == "POST" || $active != '') { +if ($_SERVER['REQUEST_METHOD'] == "POST") { if (isset($formconf['hardcoded_edit']) && $formconf['hardcoded_edit']) { $values[$id_field] = $form_fields[$id_field]['default']; } elseif ($edit != "") { diff --git a/editactive.php b/editactive.php new file mode 100644 index 00000000..c71683c3 --- /dev/null +++ b/editactive.php @@ -0,0 +1,61 @@ +webformConfig(); + +authentication_require_role($formconf['required_role']); + +if ($handler->init($id)) { # errors will be displayed as last step anyway, no need for duplicated code ;-) + if ($active != '0' && $active != '1') { + die(Config::Lang('invalid_parameter')); + } + + $values['active'] = $active; + + if ( $handler->set(array('active' => $active)) ) { + $handler->store(); + } +} + +flash_error($handler->errormsg); +flash_info($handler->infomsg); + +header ("Location: " . $formconf['listview']); +exit; + +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ +?> diff --git a/templates/adminlistadmin.tpl b/templates/adminlistadmin.tpl index 46a0f81c..382dbd40 100644 --- a/templates/adminlistadmin.tpl +++ b/templates/adminlistadmin.tpl @@ -18,8 +18,8 @@ {/if} {$admin.modified} - {$admin._active} - {$PALANG.edit} + {$admin._active} + {$PALANG.edit} {$PALANG.del} diff --git a/templates/adminlistdomain.tpl b/templates/adminlistdomain.tpl index 93047663..3643dab8 100644 --- a/templates/adminlistdomain.tpl +++ b/templates/adminlistdomain.tpl @@ -33,7 +33,7 @@ {if $CONF.transport==YES}{$domain.transport}{/if} {$domain._backupmx} {$domain.modified} - {$domain._active} + {$domain._active} {$PALANG.edit} {$PALANG.del} diff --git a/templates/list-virtual_alias.tpl b/templates/list-virtual_alias.tpl index 1b04ad4a..24dd25cb 100644 --- a/templates/list-virtual_alias.tpl +++ b/templates/list-virtual_alias.tpl @@ -37,7 +37,7 @@ {/if} {$item.modified} {if $check_alias_owner[$i]==true} - {if $item.active==1}{$PALANG.YES}{else}{$PALANG.NO}{/if} {$PALANG.edit} {/if} {$item.modified} - {if $item.active==1}{$PALANG.YES}{else}{$PALANG.NO}{/if} + {if $item.active==1}{$PALANG.YES}{else}{$PALANG.NO}{/if} {$PALANG.edit} {$PALANG.del} diff --git a/templates/list-virtual_mailbox.tpl b/templates/list-virtual_mailbox.tpl index d48a8471..9042eb5e 100644 --- a/templates/list-virtual_mailbox.tpl +++ b/templates/list-virtual_mailbox.tpl @@ -66,7 +66,7 @@ {/if} {$item.modified} - {if $item.active==1}{$PALANG.YES}{else}{$PALANG.NO}{/if} {if $CONF.vacation_control_admin===YES && $CONF.vacation===YES} {if $item.v_active!==-1}