You've already forked postfixadmin
mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2025-07-31 10:04:20 +03:00
scripts/shells/domain.php:
- AddTask: - use $values[$field] instead of a short variable name for input - hand over $values array to __handle as array instead of dozens of variables - ViewTask: use $struct for printing the output model/DomainHandler.php: - use 'created' as label for created git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1259 a1433add-5e2c-0410-b055-b7f2511e0802
This commit is contained in:
@ -71,7 +71,7 @@ class DomainHandler extends PFAHandler {
|
|||||||
'backupmx' => pacol( 1, 1, 1, 'bool', 'pAdminEdit_domain_backupmx' , '' ),
|
'backupmx' => pacol( 1, 1, 1, 'bool', 'pAdminEdit_domain_backupmx' , '' ),
|
||||||
'active' => pacol( 1, 1, 1, 'bool', 'pAdminEdit_domain_active' , '' , 1 ),
|
'active' => pacol( 1, 1, 1, 'bool', 'pAdminEdit_domain_active' , '' , 1 ),
|
||||||
'default_aliases' => pacol( $this->new, $this->new, 0, 'bool', 'pAdminCreate_domain_defaultaliases', '' , 1,'', /*not in db*/ 1 ),
|
'default_aliases' => pacol( $this->new, $this->new, 0, 'bool', 'pAdminCreate_domain_defaultaliases', '' , 1,'', /*not in db*/ 1 ),
|
||||||
'created' => pacol( 0, 0, 1, 'ts', '' /* TODO: "created" label */ , '' ),
|
'created' => pacol( 0, 0, 1, 'ts', 'created' , '' ),
|
||||||
'modified' => pacol( 0, 0, 1, 'ts', 'pAdminList_domain_modified' , '' ),
|
'modified' => pacol( 0, 0, 1, 'ts', 'pAdminList_domain_modified' , '' ),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -96,19 +96,19 @@ class AddTask extends Shell {
|
|||||||
|
|
||||||
}
|
}
|
||||||
$question = "Description:";
|
$question = "Description:";
|
||||||
$desc = $this->in($question);
|
$values['description'] = $this->in($question);
|
||||||
|
|
||||||
$question = "Number of Aliases:";
|
$question = "Number of Aliases:";
|
||||||
$a = $this->in($question);
|
$values['aliases'] = $this->in($question);
|
||||||
|
|
||||||
$question = "Numer of Mailboxes:";
|
$question = "Numer of Mailboxes:";
|
||||||
$m = $this->in($question);
|
$values['mailboxes'] = $this->in($question);
|
||||||
|
|
||||||
$question = "Max Quota (in MB):";
|
$question = "Max Quota (in MB):";
|
||||||
$q = $this->in($question);
|
$values['maxquota'] = $this->in($question);
|
||||||
|
|
||||||
$question = "Domain Quota (in MB):";
|
$question = "Domain Quota (in MB):";
|
||||||
$d = $this->in($question);
|
$values['quota'] = $this->in($question);
|
||||||
|
|
||||||
$handler = new DomainHandler();
|
$handler = new DomainHandler();
|
||||||
$struct = $handler->getStruct();
|
$struct = $handler->getStruct();
|
||||||
@ -122,18 +122,18 @@ class AddTask extends Shell {
|
|||||||
|
|
||||||
$t = $this->in( join("\n", $qt) );
|
$t = $this->in( join("\n", $qt) );
|
||||||
|
|
||||||
$t = $transports[$t-1]; # convert int to transport name
|
$values['transport'] = $transports[$t-1]; # convert int to transport name
|
||||||
|
|
||||||
$question = "Add default Aliases:";
|
$question = "Add default Aliases:";
|
||||||
$default = $this->in($question, array('y','n'));
|
$values['default_aliases'] = $this->in($question, array('y','n'));
|
||||||
($default == 'y') ? $default = true : $default = false;
|
($values['default_aliases'] == 'y') ? $values['default_aliases'] = true : $values['default_aliases'] = false;
|
||||||
|
|
||||||
$question = "Use as Backup MX:";
|
$question = "Use as Backup MX:";
|
||||||
$backup = $this->in($question, array('y','n'));
|
$values['backupmx'] = $this->in($question, array('y','n'));
|
||||||
($backup == 'y') ? $backup = true : $backup = false;
|
($values['backupmx'] == 'y') ? $values['backupmx'] = true : $values['backupmx'] = false;
|
||||||
|
|
||||||
|
|
||||||
$this->__handle($domain, $desc, $a, $m, $t, $q, $d, $default, $backup);
|
$this->__handle($domain, $values);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -141,7 +141,7 @@ class AddTask extends Shell {
|
|||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function __handle($domain, $desc, $a, $m, $t, $q, $d, $default, $backup) {
|
function __handle($domain, $values) {
|
||||||
|
|
||||||
|
|
||||||
$handler = new DomainHandler(1);
|
$handler = new DomainHandler(1);
|
||||||
@ -150,18 +150,6 @@ class AddTask extends Shell {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$values = array(
|
|
||||||
'description' => $desc,
|
|
||||||
'aliases' => $a,
|
|
||||||
'mailboxes' => $m,
|
|
||||||
'maxquota' => $q,
|
|
||||||
'quota' => $d,
|
|
||||||
'transport' => $t,
|
|
||||||
'backupmx' => $backup,
|
|
||||||
'active' => 1,
|
|
||||||
'default_aliases' => $default,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!$handler->set($values)) {
|
if (!$handler->set($values)) {
|
||||||
$this->error("Error:", join("\n", $handler->errormsg));
|
$this->error("Error:", join("\n", $handler->errormsg));
|
||||||
}
|
}
|
||||||
@ -358,21 +346,30 @@ class ViewTask extends Shell {
|
|||||||
if (!$status) {
|
if (!$status) {
|
||||||
$this->error("Error:",join("\n", $handler->errormsg));
|
$this->error("Error:",join("\n", $handler->errormsg));
|
||||||
} else {
|
} else {
|
||||||
$result = $handler->return;
|
$result = $handler->result();
|
||||||
$this->out("Domain: \t".$result['domain']);
|
$struct = $handler->getStruct();
|
||||||
$this->out("Description: \t".$result['description']);
|
|
||||||
$this->out("Aliases: \t".$result['alias_count'] . " / " . $result['aliases']);
|
|
||||||
$this->out("Mailboxes: \t".$result['mailbox_count'] . " / " . $result['mailboxes']);
|
|
||||||
$this->out("Max. Quota: \t".$result['maxquota']);
|
|
||||||
$this->out("Domain Quota: \t".$result['total_quota'] . " / " . $result['quota']);
|
|
||||||
# TODO: show allocated domain quota (sum of mailbox quota)
|
|
||||||
$this->out("Transport: \t".$result['transport']);
|
|
||||||
$this->out("Backup MX: \t".$result['backupmx']);
|
|
||||||
$this->out("Active: \t".$result['active']);
|
|
||||||
$this->out("Modified: \t".$result['modified']);
|
|
||||||
$this->out("Created: \t".$result['created']);
|
|
||||||
|
|
||||||
return ;
|
# TODO: $totalfield should be in DomainHandler (in $struct or as separate array)
|
||||||
|
$totalfield = array(
|
||||||
|
'aliases' => 'alias_count',
|
||||||
|
'mailboxes' => 'mailbox_count',
|
||||||
|
'quota' => 'total_quota',
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach($struct as $key => $field) {
|
||||||
|
if ($field['display_in_list']) {
|
||||||
|
if (isset($totalfield[$key])) {
|
||||||
|
# TODO: format based on $field['type'] (also in the else section)
|
||||||
|
$this->out($field['label'] . ": \t" . $result[$totalfield[$key]] . " / " . $result[$key] );
|
||||||
|
} else {
|
||||||
|
if (!in_array($key, $totalfield)) { # skip if we already displayed the field as part of "x/y"
|
||||||
|
$this->out($field['label'] . ": \t" . $result[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user