From f51f7f5731d725f187c82b5211b8f6a41c6a7939 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 14 Nov 2013 15:33:12 +0000 Subject: [PATCH] allow to use "default" or "forced" as parameter to preferences::set_account() to load default or forced preferences --- phpgwapi/inc/class.preferences.inc.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/phpgwapi/inc/class.preferences.inc.php b/phpgwapi/inc/class.preferences.inc.php index 4299481e7f..04b70facc7 100644 --- a/phpgwapi/inc/class.preferences.inc.php +++ b/phpgwapi/inc/class.preferences.inc.php @@ -115,19 +115,29 @@ class preferences * * Takes care of offset for groups. * - * @param int $account_id + * @param int|string $account_id numeric account_id, "default", "forced" to load default or forced preferences + * or account_lid (only if !== "default" or "forced"!) */ function set_account_id($account_id) { + if ($account_id === 'default') + { + $this->account_id = self::DEFAULT_ID; + } + elseif ($account_id === 'forced') + { + $this->account_id = self::FORCED_ID; + } // if we got instancated for a group, need to set offset of DEFAULT_ID! - if ($account_id < 0 && $GLOBALS['egw']->accounts->exists($account_id) == 2) + elseif ($account_id < 0 || !is_numeric($account_id) && ($account_id = get_account_id($account_id)) < 0) { $this->account_id = $account_id + self::DEFAULT_ID; } else { - $this->account_id = get_account_id($account_id); + $this->account_id = $account_id; } + //error_log(__METHOD__."($account_id) setting this->account_id to $this->account_id"); } /**