edit.php:

- implement switching active status using *Handler
  (uses additional 'active' url parameter, which must be 0 or 1)
- document GET parameters


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1305 a1433add-5e2c-0410-b055-b7f2511e0802
pull/2/head
Christian Boltz 13 years ago
parent d73e59fd8f
commit 2beac12971

@ -14,6 +14,11 @@
* *
* File: edit.php * File: edit.php
* This file implements the handling of edit forms. * This file implements the handling of edit forms.
*
* GET parameters:
* table what to edit (*Handler)
* edit item to edit
* active only change active state to given value (which must be 0 or 1) and return to listview
*/ */
require_once('common.php'); require_once('common.php');
@ -34,6 +39,8 @@ $edit = safepost('edit', safeget('edit'));
$new = 0; $new = 0;
if ($edit == "") $new = 1; if ($edit == "") $new = 1;
$active = safeget('active');
$handler = new $handlerclass($new, $username); $handler = new $handlerclass($new, $username);
$formconf = $handler->webformConfig(); $formconf = $handler->webformConfig();
@ -43,8 +50,11 @@ authentication_require_role($formconf['required_role']);
$form_fields = $handler->getStruct(); $form_fields = $handler->getStruct();
$id_field = $handler->getId_field(); $id_field = $handler->getId_field();
if ($active != '0' && $active != '1') {
$active = ''; # ignore invalid values
}
if ($edit != "" || $formconf['early_init']) { if ($edit != '' || $active != '' || $formconf['early_init']) {
if (!$handler->init($edit)) { if (!$handler->init($edit)) {
flash_error(join("<br />", $handler->errormsg)); flash_error(join("<br />", $handler->errormsg));
header ("Location: " . $formconf['listview']); header ("Location: " . $formconf['listview']);
@ -54,7 +64,7 @@ if ($edit != "" || $formconf['early_init']) {
if ($edit != "") { if ($edit != "") {
$mode = 'edit'; $mode = 'edit';
if ($_SERVER['REQUEST_METHOD'] == "GET") { # read values from database if ($_SERVER['REQUEST_METHOD'] == "GET" && $active == '') { # read values from database (except if $active is set to save some CPU cycles)
if (!$handler->view()) { if (!$handler->view()) {
flash_error(join("<br />", $handler->errormsg)); flash_error(join("<br />", $handler->errormsg));
header ("Location: " . $formconf['listview']); header ("Location: " . $formconf['listview']);
@ -80,7 +90,13 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
} }
} }
} }
}
if ($active != '') {
$values['active'] = $active;
}
if ($_SERVER['REQUEST_METHOD'] == "POST" || $active != '') {
if ($edit != "") $values[$id_field] = $edit; if ($edit != "") $values[$id_field] = $edit;
if (!$handler->init($values[$id_field])) { if (!$handler->init($values[$id_field])) {

Loading…
Cancel
Save