edit.php:

- use prefill values from $_SESSION (if not provided in GET/POST)
- remember prefill values for next usage of the form

list-virtual.php
- set prefill values for edit.php

PFAHandler.php:
- let prefill() store the value in $struct if no prefill_$field()
  function exists

This fixes the remaining parts of
http://sourceforge.net/p/postfixadmin/bugs/298/



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1594 a1433add-5e2c-0410-b055-b7f2511e0802
pull/2/head
Christian Boltz 11 years ago
parent 1a35cccf5e
commit bafd2f1f58

@ -60,13 +60,14 @@ 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) {
if (isset ($_GET[$field])) {
$form_fields[$field]['default'] = safeget($field);
$handler->prefill($field, safeget($field));
$prefillvalue = safeget($field, safesession("prefill:$table:$field"));
if ($prefillvalue != '') {
$form_fields[$field]['default'] = $prefillvalue;
$handler->prefill($field, $prefillvalue);
}
}
}
$form_fields = $handler->getStruct(); # refresh $form_fields - a prefill field might have changed something
$form_fields = $handler->getStruct(); # refresh $form_fields - a prefill field might have changed something
} else { # edit mode - read values from database
if (!$handler->view()) {
flash_error($handler->errormsg);
@ -104,9 +105,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
}
}
}
}
if ($_SERVER['REQUEST_METHOD'] == "POST") {
if (isset($formconf['hardcoded_edit']) && $formconf['hardcoded_edit']) {
$values[$id_field] = $form_fields[$id_field]['default'];
} elseif ($edit != "") {
@ -139,11 +138,20 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
flash_error($handler->errormsg);
}
# remember prefill values for next usage of the form
if ( isset($formconf['prefill']) ) {
foreach ($formconf['prefill'] as $field) {
if (isset($values[$field])) {
$_SESSION["prefill:$table:$field"] = $values[$field];
}
}
}
if ($edit != "") {
header ("Location: " . $formconf['listview']);
exit;
} else {
header("Location: edit.php?table=$table"); # TODO: hand over last used domain etc. ($formconf['prefill'] ?)
header("Location: edit.php?table=$table");
exit;
}
}

@ -73,8 +73,13 @@ if (!check_owner(authentication_get_username(), $fDomain)) {
// store domain and page browser offset in $_SESSION so after adding/editing aliases/mailboxes we can
// take the user back to the appropriate domain listing.
$_SESSION['list-virtual:domain'] = $fDomain;
$_SESSION['prefill:alias:domain'] = $fDomain;
$_SESSION['prefill:mailbox:domain'] = $fDomain;
$_SESSION['prefill:aliasdomain:target_domain'] = $fDomain;
$_SESSION['list-virtual:limit'] = $fDisplay;
#
# alias domain
#

@ -220,7 +220,9 @@ abstract class PFAHandler {
$func="_prefill_".$field;
if (method_exists($this, $func) ) {
$this->{$func}($field, $val); # call _missing_$fieldname()
}
} else {
$this->struct[$field]['default'] = $val;
}
}
/**

Loading…
Cancel
Save