SF.net SVN: postfixadmin:[1594] trunk
Brought to you by:
christian_boltz,
gingerdog
From: <chr...@us...> - 2013-12-01 20:45:21
|
Revision: 1594 http://sourceforge.net/p/postfixadmin/code/1594 Author: christian_boltz Date: 2013-12-01 20:45:17 +0000 (Sun, 01 Dec 2013) Log Message: ----------- 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/ Modified Paths: -------------- trunk/edit.php trunk/list-virtual.php trunk/model/PFAHandler.php Modified: trunk/edit.php =================================================================== --- trunk/edit.php 2013-12-01 19:05:14 UTC (rev 1593) +++ trunk/edit.php 2013-12-01 20:45:17 UTC (rev 1594) @@ -60,13 +60,14 @@ 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 (isset($formconf['hardcoded_edit']) && $formconf['hardcoded_edit']) { $values[$id_field] = $form_fields[$id_field]['default']; } elseif ($edit != "") { @@ -139,11 +138,20 @@ 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; } } Modified: trunk/list-virtual.php =================================================================== --- trunk/list-virtual.php 2013-12-01 19:05:14 UTC (rev 1593) +++ trunk/list-virtual.php 2013-12-01 20:45:17 UTC (rev 1594) @@ -73,8 +73,13 @@ // 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 # Modified: trunk/model/PFAHandler.php =================================================================== --- trunk/model/PFAHandler.php 2013-12-01 19:05:14 UTC (rev 1593) +++ trunk/model/PFAHandler.php 2013-12-01 20:45:17 UTC (rev 1594) @@ -220,7 +220,9 @@ $func="_prefill_".$field; if (method_exists($this, $func) ) { $this->{$func}($field, $val); # call _missing_$fieldname() - } + } else { + $this->struct[$field]['default'] = $val; + } } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |