PFAHandler.php:

- introduce public array $infomsg[] (for success messages)
- store(): write successmessage to $this->infomsg[]

edit.php:
- display $handler->infomsg instead of hardcoded success message

AdminHandler.php, AliasHandler.php, AliasdomainHandler.php,
DomainHandler.php, MailboxHandler.php:
- move successmsg from webformConfig() to initMsg()



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1428 a1433add-5e2c-0410-b055-b7f2511e0802
pull/2/head
Christian Boltz 12 years ago
parent 268dd5372d
commit 227eca6faf

@ -139,10 +139,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST" || $active != '') {
if (!$handler->store()) {
$errormsg = $handler->errormsg;
} else {
flash_info(Lang::read($formconf['successmessage']) . " (" . $values[$id_field] . ")");
# TODO: - use a sprintf string
# TODO: - get the success message from DomainHandler
# TODO: - use a different success message for create and edit
flash_info($handler->infomsg);
if (count($handler->errormsg)) { # might happen if domain_postcreation fails
flash_error($handler->errormsg);

@ -86,25 +86,20 @@ class AdminHandler extends PFAHandler {
if ($this->new) {
$this->msg['logname'] = 'create_admin';
$this->msg['store_error'] = 'pAdminCreate_admin_result_error';
$this->msg['successmessage'] = 'pAdminCreate_admin_result_success';
} else {
$this->msg['logname'] = 'edit_admin';
$this->msg['store_error'] = 'pAdminEdit_admin_result_error';
$this->msg['successmessage'] = 'pAdminEdit_admin_result_success';
}
}
public function webformConfig() {
if ($this->new) {
$successmsg = 'pAdminCreate_admin_result_success';
} else {
$successmsg = 'pAdminEdit_admin_result_success';
}
return array(
# $PALANG labels
'formtitle_create' => 'pAdminCreate_admin_welcome',
'formtitle_edit' => 'pAdminEdit_admin_welcome',
'create_button' => 'pAdminCreate_admin_button',
'successmessage' => $successmsg,
# various settings
'required_role' => 'global-admin',

@ -74,9 +74,11 @@ class AliasHandler extends PFAHandler {
if ($this->new) {
$this->msg['logname'] = 'create_alias';
$this->msg['store_error'] = 'pCreate_alias_result_error';
$this->msg['successmessage'] = 'pCreate_alias_result_success';
} else {
$this->msg['logname'] = 'edit_alias';
$this->msg['store_error'] = 'pEdit_alias_result_error';
$this->msg['successmessage'] = 'pCreate_alias_result_success'; # TODO: better message for edit
}
}
@ -93,7 +95,6 @@ class AliasHandler extends PFAHandler {
'formtitle_create' => 'pCreate_alias_welcome',
'formtitle_edit' => 'pEdit_alias_welcome',
'create_button' => 'pCreate_alias_button',
'successmessage' => 'pCreate_alias_result_success', # TODO: better message for edit
# various settings
'required_role' => 'admin',

@ -69,9 +69,11 @@ class AliasdomainHandler extends PFAHandler {
if ($this->new) {
$this->msg['logname'] = 'create_alias_domain';
$this->msg['store_error'] = 'pCreate_alias_domain_error3'; # TODO: error message could be better
$this->msg['successmessage'] = 'pCreate_alias_domain_success';
} else {
$this->msg['logname'] = 'edit_alias_domain';
$this->msg['store_error'] = 'pCreate_alias_domain_error3'; # TODO: error message could be better
$this->msg['successmessage'] = 'pCreate_alias_domain_success'; # TODO: better message for edit
}
}
@ -81,7 +83,6 @@ class AliasdomainHandler extends PFAHandler {
'formtitle_create' => 'pCreate_alias_domain_welcome',
'formtitle_edit' => 'pCreate_alias_domain_welcome',
'create_button' => 'pCreate_alias_domain_button',
'successmessage' => 'pCreate_alias_domain_success',
# various settings
'required_role' => 'admin',

@ -76,9 +76,11 @@ class DomainHandler extends PFAHandler {
if ($this->new) {
$this->msg['logname'] = 'create_domain';
$this->msg['store_error'] = 'pAdminCreate_domain_result_error';
$this->msg['successmessage'] = 'pAdminCreate_domain_result_success';
} else {
$this->msg['logname'] = 'edit_domain';
$this->msg['store_error'] = 'pAdminEdit_domain_result_error';
$this->msg['successmessage'] = 'pAdminCreate_domain_result_success'; # TODO: better message for edit
}
}
@ -88,7 +90,6 @@ class DomainHandler extends PFAHandler {
'formtitle_create' => 'pAdminCreate_domain_welcome',
'formtitle_edit' => 'pAdminEdit_domain_welcome',
'create_button' => 'pAdminCreate_domain_button',
'successmessage' => 'pAdminCreate_domain_result_success',
# various settings
'required_role' => 'global-admin',

@ -89,9 +89,11 @@ class MailboxHandler extends PFAHandler {
if ($this->new) {
$this->msg['logname'] = 'create_mailbox';
$this->msg['store_error'] = 'pCreate_mailbox_result_error';
$this->msg['successmessage'] = 'pCreate_mailbox_result_success';
} else {
$this->msg['logname'] = 'edit_mailbox';
$this->msg['store_error'] = 'pCreate_mailbox_result_error'; # TODO: better error message
$this->msg['successmessage'] = 'pCreate_mailbox_result_success'; # TODO: better message
}
}
@ -107,7 +109,6 @@ class MailboxHandler extends PFAHandler {
'formtitle_create' => 'pCreate_mailbox_welcome',
'formtitle_edit' => 'pEdit_mailbox_welcome',
'create_button' => 'pCreate_mailbox_button',
'successmessage' => 'pCreate_mailbox_result_success',
# various settings
'required_role' => 'admin',

@ -8,6 +8,8 @@ abstract class PFAHandler {
# array of error messages - if a method returns false, you'll find the error message(s) here
public $errormsg = array();
# array of info messages (for example success messages)
public $infomsg = array();
/**
* variables that must be defined in all *Handler classes
@ -341,8 +343,15 @@ abstract class PFAHandler {
$result = $this->storemore();
if ($result) {
# TODO: does it really make sense to skip logging if storemore() failed?
db_log ($this->id, $this->msg['logname'], "");
# return success message
# TODO: use sprintf to add $this->id
# TODO: add option to override the success message (for example to include autogenerated passwords)
$this->infomsg['success'] = sprintf(Lang::read($this->msg['successmessage']), $this->id);
}
return $result;
}

Loading…
Cancel
Save