From a46bcc955c72c59d9f0ea0f6e3e647a7a44c03fd Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Sun, 27 Jan 2013 19:52:19 +0000 Subject: [PATCH] edit.php: - prefill all $formconf['prefill'] fields from URL parameters (typically used for the domain) model/AliasdomainHandler.php: - allow to prefill alias_domain and target_domain from URL parameters model/AliasHandler.php: - allow to prefill domain from URL parameters - some whitespace changes - add storemore() with a TODO note model/MailboxHandler.php: - allow to prefill domain from URL parameters - some whitespace changes - add some TODO notes git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1422 a1433add-5e2c-0410-b055-b7f2511e0802 --- edit.php | 12 +++++++++--- model/AliasHandler.php | 10 ++++++++-- model/AliasdomainHandler.php | 1 + model/MailboxHandler.php | 9 +++++++-- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/edit.php b/edit.php index 6414ba97..7c5e10ff 100644 --- a/edit.php +++ b/edit.php @@ -63,8 +63,14 @@ if ($edit != '' || $active != '' || $formconf['early_init']) { $form_fields = $handler->getStruct(); $id_field = $handler->getId_field(); -if ($edit != "") { - if ($_SERVER['REQUEST_METHOD'] == "GET" && $active == '') { # read values from database (except if $active is set to save some CPU cycles) +if ($_SERVER['REQUEST_METHOD'] == "GET" && $active == '') { + 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); + } + } + } else { # edit mode - read values from database if (!$handler->view()) { flash_error($handler->errormsg); header ("Location: " . $formconf['listview']); @@ -141,7 +147,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST" || $active != '') { header ("Location: " . $formconf['listview']); exit; } else { - header("Location: edit.php?table=$table"); + header("Location: edit.php?table=$table"); # TODO: hand over last used domain etc. ($formconf['prefill'] ?) exit; } } diff --git a/model/AliasHandler.php b/model/AliasHandler.php index b96b95ee..049c21b3 100644 --- a/model/AliasHandler.php +++ b/model/AliasHandler.php @@ -95,8 +95,9 @@ class AliasHandler extends PFAHandler { # various settings 'required_role' => 'admin', - 'listview' => 'list-virtual.php', - 'early_init' => 0, + 'listview' => 'list-virtual.php', + 'early_init' => 0, + 'prefill' => array('domain'), ); } @@ -237,6 +238,11 @@ class AliasHandler extends PFAHandler { $this->values['goto'] = join(',', $values['goto']); } + protected function storemore() { + # TODO: if alias belongs to a mailbox, update mailbox active status + return true; + } + protected function read_from_db_postprocess($db_result) { foreach ($db_result as $key => $value) { # split comma-separated 'goto' into an array diff --git a/model/AliasdomainHandler.php b/model/AliasdomainHandler.php index 72942d3f..45a685c5 100644 --- a/model/AliasdomainHandler.php +++ b/model/AliasdomainHandler.php @@ -87,6 +87,7 @@ class AliasdomainHandler extends PFAHandler { 'required_role' => 'admin', 'listview' => 'list-virtual.php', 'early_init' => 1, # 0 for create-domain + 'prefill' => array('alias_domain', 'target_domain'), ); } diff --git a/model/MailboxHandler.php b/model/MailboxHandler.php index bd7b734f..4e61aa8d 100644 --- a/model/MailboxHandler.php +++ b/model/MailboxHandler.php @@ -89,8 +89,9 @@ class MailboxHandler extends PFAHandler { # various settings 'required_role' => 'admin', - 'listview' => 'list-virtual.php', - 'early_init' => 0, + 'listview' => 'list-virtual.php', + 'early_init' => 0, + 'prefill' => array('domain'), ); } @@ -161,10 +162,14 @@ class MailboxHandler extends PFAHandler { protected function storemore() { if ($this->new) { +# TODO: create alias # TODO: postcreate hook # TODO: send welcome mail # TODO: create mailbox subfolders +# TODO: --- most of this is probably already in $this->add() already --- } else { +# TODO: update alias (active status) + # postedit hook # TODO: implement a poststore() function? - would make handling of old and new values much easier... list(/*NULL*/,$domain) = explode('@', $this->id);