You've already forked postfixadmin
mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2025-08-09 05:02:44 +03:00
PFAHandler:
- set(): call $this->_missing_$fieldname() if a field is not set on $new - new function set_default_value() - typically called from _missing_$fieldname to set the default from $struct AliasHandler: - set default values on $new: - on_vacation and active from $struct default - localpart and domain based on address scripts/shells/alias.php: - convert AddTask to *Handler syntax. It was broken before, see https://sourceforge.net/tracker/?func=detail&aid=3232719&group_id=191583&atid=937964 git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1364 a1433add-5e2c-0410-b055-b7f2511e0802
This commit is contained in:
@@ -286,6 +286,23 @@ class AliasHandler extends PFAHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function _missing_on_vacation($field) { return $this->set_default_value($field); }
|
||||||
|
protected function _missing_active ($field) { return $this->set_default_value($field); }
|
||||||
|
|
||||||
|
protected function _missing_localpart ($field) {
|
||||||
|
if (isset($this->RAWvalues['address'])) {
|
||||||
|
$parts = explode('@', $this->RAWvalues['address']);
|
||||||
|
if (count($parts) == 2) $this->RAWvalues['localpart'] = $parts[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function _missing_domain ($field) {
|
||||||
|
if (isset($this->RAWvalues['address'])) {
|
||||||
|
$parts = explode('@', $this->RAWvalues['address']);
|
||||||
|
if (count($parts) == 2) $this->RAWvalues['domain'] = $parts[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the vacation alias for this user.
|
* Returns the vacation alias for this user.
|
||||||
|
@@ -98,6 +98,19 @@ class PFAHandler {
|
|||||||
$this->RAWvalues = $values; # allows comparison of two fields before the second field is checked
|
$this->RAWvalues = $values; # allows comparison of two fields before the second field is checked
|
||||||
# Warning: $this->RAWvalues contains unchecked input data - use it carefully!
|
# Warning: $this->RAWvalues contains unchecked input data - use it carefully!
|
||||||
|
|
||||||
|
if ($this->new) {
|
||||||
|
foreach($this->struct as $key=>$row) {
|
||||||
|
if ($row['editable'] && !isset($values[$key]) ) {
|
||||||
|
$func="_missing_".$key; # call $this->_missing_$fieldname()
|
||||||
|
if (method_exists($this, $func) ) {
|
||||||
|
$this->{$func}($key); # function can set $this->RAWvalues[$key] (or do nothing if it can't set a useful value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$values = $this->RAWvalues;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# base validation
|
# base validation
|
||||||
$this->values = array();
|
$this->values = array();
|
||||||
$this->values_valid = false;
|
$this->values_valid = false;
|
||||||
@@ -362,6 +375,18 @@ class PFAHandler {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set field to default value
|
||||||
|
* typically called from _missing_$fieldname()
|
||||||
|
* @param string $field - fieldname
|
||||||
|
*/
|
||||||
|
protected function set_default_value($field) {
|
||||||
|
if (isset($this->struct[$field]['default'])) {
|
||||||
|
$this->RAWvalues[$field] = $this->struct[$field]['default'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* functions for basic input validation
|
* functions for basic input validation
|
||||||
*/
|
*/
|
||||||
|
@@ -105,9 +105,13 @@ class AddTask extends Shell {
|
|||||||
|
|
||||||
$handler = new AliasHandler(1);
|
$handler = new AliasHandler(1);
|
||||||
$handler->init($address);
|
$handler->init($address);
|
||||||
$return = $handler->add($goto);
|
|
||||||
|
|
||||||
if($return == 1) {
|
$values = array(
|
||||||
|
'goto' => explode(',', $goto),
|
||||||
|
);
|
||||||
|
if (!$handler->set($values)) {
|
||||||
|
$this->error("Error:", join("\n", $handler->errormsg));
|
||||||
|
} elseif (!$handler->store()) {
|
||||||
$this->error("Error:", join("\n", $handler->errormsg));
|
$this->error("Error:", join("\n", $handler->errormsg));
|
||||||
} else {
|
} else {
|
||||||
$this->out("");
|
$this->out("");
|
||||||
|
Reference in New Issue
Block a user