AliasHandler.php:
- remove obsolete functions update(), is_mailbox_alias(),
is_vacation_address(), hasAliasRecord()
- updated delete() to use new *Handler syntax (most of it should be
moved to PFAHandler, but that's another story ;-)
users/edit-alias.php:
- replace $ah->update with $ah->set / $ah->store
- use 0/1 for $fForward_and_store instead of YES/NO
- use safepost instead of isset()
templates/users_edit-alias.tpl:
- use 0/1 for $fForward_and_store instead of YES/NO
xmlrpc.php:
- replace $ah->update with new *Handler syntax
Note: the changes in xmlrpc.php are untested again ;-)
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1358 a1433add-5e2c-0410-b055-b7f2511e0802
* @param array $addresses - list of aliases to set for the user.
* @param string flags - forward_and_store or remote_only or ''
* @param boolean $vacation_persist - set to false to stop the vacation address persisting across updates
* Set the user's aliases to those provided. If $addresses ends up being empty the alias record is removed. # TODO: deleting that's buggy behaviour, error out instead
*/
public function update($addresses, $flags = '', $vacation_persist=true) {
// find out if the user is on vacation or not; if they are,
// then the vacation alias needs adding to the db (as we strip it out in the get method)
// likewise with the alias_control address.
# TODO: move all validation from edit-alias/create-alias and users/edit-alias here
die("Invalid flag passed into update()... : $flag - valid options are :" . implode(',', $valid_flags));
}
$addresses = array_unique($addresses);
list (/*NULL*/, $domain) = explode('@', $this->id);
if ( ! $this->get(true) ) die("Alias not existing?"); # TODO: better error behaviour
foreach($this->return as $address) {
if($vacation_persist) {
if($this->is_vacation_address($address)) {
$addresses[] = $address;
}
}
if($flags != 'remote_only') {
if($this->is_mailbox_alias($address)) {
$addresses[] = $address;
}
}
}
$addresses = array_unique($addresses);
$new_list = array();
if($flags == 'remote_only') {
foreach($addresses as $address) { # TODO: write a remove_from_array function, see http://tech.petegraham.co.uk/2007/03/22/php-remove-values-from-array/
// strip out our username... if it's in the list given.
if($address != $this->id) {
$new_list[] = $address;
}
}
$addresses = $new_list;
}
if($flags == 'forward_and_store') {
if(!in_array($this->id, $addresses)) {
$addresses[] = $this->id;
}
}
$new_list = array();
foreach($addresses as $address) {
if($address != '') {
$new_list[] = $address; # TODO use remove_from_array, see above
}
}
$addresses = array_unique($new_list);
$E_username = escape_string($this->id);
$goto = implode(',', $addresses);
if(sizeof($addresses) == 0) {
# $result = db_delete('alias', 'address', $this->id); # '"DELETE FROM $table_alias WHERE address = '$username'"; # TODO: should never happen and causes broken behaviour
error_log("Alias set to empty / Attemp to delete: " . $this->id); # TODO: more/better error handling - maybe just return false?
}
if($this->hasAliasRecord() == false) { # TODO should never happen in update() - see also the comments on handling DELETE above