mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2024-09-20 03:36:20 +02:00
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
This commit is contained in:
parent
d73e59fd8f
commit
2beac12971
20
edit.php
20
edit.php
@ -14,6 +14,11 @@
|
||||
*
|
||||
* File: edit.php
|
||||
* 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');
|
||||
@ -34,6 +39,8 @@ $edit = safepost('edit', safeget('edit'));
|
||||
$new = 0;
|
||||
if ($edit == "") $new = 1;
|
||||
|
||||
$active = safeget('active');
|
||||
|
||||
$handler = new $handlerclass($new, $username);
|
||||
|
||||
$formconf = $handler->webformConfig();
|
||||
@ -43,8 +50,11 @@ authentication_require_role($formconf['required_role']);
|
||||
$form_fields = $handler->getStruct();
|
||||
$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)) {
|
||||
flash_error(join("<br />", $handler->errormsg));
|
||||
header ("Location: " . $formconf['listview']);
|
||||
@ -54,7 +64,7 @@ if ($edit != "" || $formconf['early_init']) {
|
||||
|
||||
if ($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()) {
|
||||
flash_error(join("<br />", $handler->errormsg));
|
||||
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 (!$handler->init($values[$id_field])) {
|
||||
|
Loading…
Reference in New Issue
Block a user