- add initStruct() (not the final version, but works for now)
- add initMsg()
- replace $this->username with $this->id everywhere
- drop __construct() - default __construct will be used now
users/edit-alias.php, xmlrpc.php, VacationHandler.php, scripts/shells/alias.php:
- use default init sequence for AliasHandler (new, then ->init())
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1310 a1433add-5e2c-0410-b055-b7f2511e0802
* (may be an empty list, especially if $CONF['alias_control'] is turned off...)
* (may be an empty list, especially if $CONF['alias_control'] is turned off...)
* @param boolean - by default we don't return special addresses (e.g. vacation and mailbox alias); pass in true here if you wish to.
* @param boolean - by default we don't return special addresses (e.g. vacation and mailbox alias); pass in true here if you wish to.
*/
*/
public function get($all=false) {
public function get($all=false) {
$E_username = escape_string($this->username);
$E_username = escape_string($this->id);
$table_alias = table_by_key('alias');
$table_alias = table_by_key('alias');
$sql = "SELECT * FROM $table_alias WHERE address='$E_username'";
$sql = "SELECT * FROM $table_alias WHERE address='$E_username'";
@ -71,7 +94,7 @@ class AliasHandler extends PFAHandler {
public function is_mailbox_alias($address) {
public function is_mailbox_alias($address) {
global $CONF;
global $CONF;
if($address != $this->username) { # avoid false positives if $address is a mailbox
if($address != $this->id) { # avoid false positives if $address is a mailbox
return false;
return false;
}
}
@ -120,7 +143,7 @@ class AliasHandler extends PFAHandler {
}
}
$addresses = array_unique($addresses);
$addresses = array_unique($addresses);
list (/*NULL*/, $domain) = explode('@', $this->username);
list (/*NULL*/, $domain) = explode('@', $this->id);
if ( ! $this->get(true) ) die("Alias not existing?"); # TODO: better error behaviour
if ( ! $this->get(true) ) die("Alias not existing?"); # TODO: better error behaviour
@ -142,7 +165,7 @@ class AliasHandler extends PFAHandler {
if($flags == 'remote_only') {
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/
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.
// strip out our username... if it's in the list given.
if($address != $this->username) {
if($address != $this->id) {
$new_list[] = $address;
$new_list[] = $address;
}
}
}
}
@ -150,8 +173,8 @@ class AliasHandler extends PFAHandler {
}
}
if($flags == 'forward_and_store') {
if($flags == 'forward_and_store') {
if(!in_array($this->username, $addresses)) {
if(!in_array($this->id, $addresses)) {
$addresses[] = $this->username;
$addresses[] = $this->id;
}
}
}
}
$new_list = array();
$new_list = array();
@ -161,15 +184,15 @@ class AliasHandler extends PFAHandler {
}
}
}
}
$addresses = array_unique($new_list);
$addresses = array_unique($new_list);
$E_username = escape_string($this->username);
$E_username = escape_string($this->id);
$goto = implode(',', $addresses);
$goto = implode(',', $addresses);
if(sizeof($addresses) == 0) {
if(sizeof($addresses) == 0) {
# $result = db_delete('alias', 'address', $this->username); # '"DELETE FROM $table_alias WHERE address = '$username'"; # TODO: should never happen and causes broken behaviour
# $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->username); # TODO: more/better error handling - maybe just return false?
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
if($this->hasAliasRecord() == false) { # TODO should never happen in update() - see also the comments on handling DELETE above
$alias_data = array(
$alias_data = array(
'address' => $this->username,
'address' => $this->id,
'goto' => $goto,
'goto' => $goto,
'domain' => $domain,
'domain' => $domain,
'active' => db_get_boolean(True),
'active' => db_get_boolean(True),
@ -179,7 +202,7 @@ class AliasHandler extends PFAHandler {