diff --git a/phpgwapi/inc/class.preferences.inc.php b/phpgwapi/inc/class.preferences.inc.php index 4c9f207ca5..f453813e99 100644 --- a/phpgwapi/inc/class.preferences.inc.php +++ b/phpgwapi/inc/class.preferences.inc.php @@ -107,6 +107,18 @@ class preferences $this->db = $GLOBALS['egw_setup']->db; $this->table = $GLOBALS['egw_setup']->prefs_table; } + $this->set_account_id($account_id); + } + + /** + * Set account_id for class + * + * Takes care of offset for groups. + * + * @param int $account_id + */ + function set_account_id($account_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) { @@ -118,6 +130,25 @@ class preferences } } + /** + * Return account_id class is instanciated for or "default" or "forced" + * + * Takes care of offset for groups. + * + * @return string|int + */ + function get_account_id() + { + switch ($this->account_id) + { + case self::DEFAULT_ID: + return 'default'; + case self::FORCED_ID: + return 'forced'; + } + return $this->account_id < self::DEFAULT_ID ? $this->account_id-self::DEFAULT_ID : $this->account_id; + } + /** * Old PHP4 contstructor *