You've already forked postfixadmin
mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2025-08-07 17:42:53 +03:00
DomainHander: on the way to a common interface for all classes and
easy-to-edit field lists. With lots of inspiration from fetchmail.php and a base class I started 2.5 years ago. model/DomainHandler.php - base on PFAHandler (see below) - new protected variables - $id_field (column that contains $username) - $struct (field list) - $defaults (default values, option lists) - $new (switch between new and edit mode) - change $username to protected (preparation for move to PFAHandler) - add optional $new parameter to __construct. Targets (not yet implemented): - early validation of $username (domain name in this case) - if $new == 1, check that item does NOT exist and is a valid domain - else: check if item exists. error out if not. - new function initStruct to fill $id_field, $struct, $defaults - add(): - use an array as parameter instead of single parameters Advantage: this makes it easy to add another field - use _inp_* base validation - create default aliases only in create mode, not in edit mode - view(): fix error message - added various TODO notes. Some affect design questions - feedback welcome ;-) scripts/shells/domain.php: - change $handler->add call to array usage - add some TODO notes - some whitespace fixes in execute() model/PFAHandler.php: - new base class for *Handler classes - contains only some generic input validation for now - more code will be moved from DomainHandler to PFAHandler later git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@978 a1433add-5e2c-0410-b055-b7f2511e0802
This commit is contained in:
@@ -136,8 +136,20 @@ class AddTask extends Shell {
|
||||
function __handle($domain, $desc, $a, $m, $t, $q, $default, $backup) {
|
||||
|
||||
|
||||
$handler = new DomainHandler($domain);
|
||||
$return = $handler->add($desc, $a, $m, $t, $q, $default, $backup);
|
||||
$handler = new DomainHandler($domain, 1);
|
||||
$values = array(
|
||||
'domain' => $domain,
|
||||
'description' => $desc,
|
||||
'aliases' => $a,
|
||||
'mailboxes' => $m,
|
||||
'maxquota' => $q,
|
||||
# 'quota' =>
|
||||
'transport' => $handler->getTransport($t),
|
||||
'backupmx' => $backup,
|
||||
'active' => $a,
|
||||
'default_aliases' => $default,
|
||||
);
|
||||
$return = $handler->add($values);
|
||||
|
||||
if(!$return) {
|
||||
$this->error("Error:", join("\n", $handler->errormsg));
|
||||
@@ -154,6 +166,7 @@ class AddTask extends Shell {
|
||||
* @access public
|
||||
*/
|
||||
function help() {
|
||||
# TODO: this is the DOMAIN shell...
|
||||
$this->hr();
|
||||
$this->out("Usage: postfixadmin-cli user add <address> [<password>] <name> <quota> [-g]");
|
||||
$this->hr();
|
||||
@@ -216,12 +229,12 @@ class DeleteTask extends Shell {
|
||||
function execute() {
|
||||
|
||||
if (empty($this->args)) {
|
||||
$this->__interactive();
|
||||
$this->__interactive();
|
||||
}
|
||||
|
||||
if (!empty($this->args[0])) {
|
||||
$output = $this->__handle($this->args[0]);
|
||||
$this->out($output);
|
||||
$output = $this->__handle($this->args[0]);
|
||||
$this->out($output);
|
||||
}
|
||||
}
|
||||
/**
|
||||
@@ -342,6 +355,7 @@ class ViewTask extends Shell {
|
||||
* @access public
|
||||
*/
|
||||
function help() {
|
||||
# TODO: this is the DOMAIN shell...
|
||||
$this->out("");
|
||||
$this->hr();
|
||||
$this->out("Usage: postfixadmin-cli user view <address>");
|
||||
@@ -354,3 +368,4 @@ class ViewTask extends Shell {
|
||||
}
|
||||
|
||||
}
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
|
Reference in New Issue
Block a user