From 19c67489886870195ad2169d62ac565aa6f1563c Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Mon, 9 Apr 2012 02:00:10 +0000 Subject: [PATCH] VacationHandler: - move getVacationAlias to AliasHandler (the only code that uses it) AliasHandler: - insert (and rewrite) function getVacationAlias() - change $vh->getVacationAlias() calls to $this->getVacationAlias. This also means we don't need to call VacationHandler anymore to get the vacation alias. git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1359 a1433add-5e2c-0410-b055-b7f2511e0802 --- model/AliasHandler.php | 21 ++++++++++++++------- model/VacationHandler.php | 13 ------------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/model/AliasHandler.php b/model/AliasHandler.php index 6b8f3b42..9d78697a 100644 --- a/model/AliasHandler.php +++ b/model/AliasHandler.php @@ -201,8 +201,7 @@ class AliasHandler extends PFAHandler { } if ($values['on_vacation']) { - $vh = new VacationHandler($this->id); - $values['goto'][] = $vh->getVacationAlias(); + $values['goto'][] = $this->getVacationAlias(); } if ($oldvalues['is_mailbox']) { # alias belongs to a mailbox - add/keep mailbox to/in goto @@ -228,12 +227,8 @@ class AliasHandler extends PFAHandler { foreach ($db_result as $key => $value) { $db_result[$key]['goto'] = explode(',', $db_result[$key]['goto']); - $vh = new VacationHandler($this->id); - $vacation_alias = $vh->getVacationAlias(); # TODO: move getVacationAlias to functions.inc.php to avoid the need - # for lots of VacationHandler instances (performance)? - # Vacation enabled? - list($db_result[$key]['on_vacation'], $db_result[$key]['goto']) = remove_from_array($db_result[$key]['goto'], $vacation_alias); + list($db_result[$key]['on_vacation'], $db_result[$key]['goto']) = remove_from_array($db_result[$key]['goto'], $this->getVacationAlias() ); # if it is a mailbox, does the alias point to the mailbox? if ($db_result[$key]['is_mailbox']) { @@ -291,6 +286,18 @@ class AliasHandler extends PFAHandler { } } + + /** + * Returns the vacation alias for this user. + * i.e. if this user's username was roger@example.com, and the autoreply domain was set to + * autoreply.fish.net in config.inc.php we'd return roger#example.com@autoreply.fish.net + * @return string an email alias. + */ + protected function getVacationAlias() { + $vacation_goto = str_replace('@', '#', $this->id); + return $vacation_goto . '@' . Config::read('vacation_domain'); + } + /********************************************************************************************************************************************************** old function from non-PFAHandler times of AliasHandler Will be replaced by a global delete() function in PFAHandler diff --git a/model/VacationHandler.php b/model/VacationHandler.php index 69495e83..508a74de 100644 --- a/model/VacationHandler.php +++ b/model/VacationHandler.php @@ -155,18 +155,5 @@ class VacationHandler { return true; } - /** - * Returns the vacation alias for this user. - * i.e. if this user's username was roger@example.com, and the autoreply domain was set to - * autoreply.fish.net in config.inc.php we'd return roger#example.com@autoreply.fish.net - * @return string an email alias. - */ - public function getVacationAlias() { - global $CONF; - $vacation_domain = $CONF['vacation_domain']; - $vacation_goto = str_replace('@', '#', $this->username); - $vacation_goto = "{$vacation_goto}@{$vacation_domain}"; - return $vacation_goto; - } } /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */