mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-09 07:28:43 +01:00
methods to get/set current account_id taking care of necessary offset for groups
This commit is contained in:
parent
61e00e4ebc
commit
2b2938d2dd
@ -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
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user