mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-07-01 07:01:12 +02:00
methods to get/set current account_id taking care of necessary offset for groups
This commit is contained in:
@ -107,6 +107,18 @@ class preferences
|
|||||||
$this->db = $GLOBALS['egw_setup']->db;
|
$this->db = $GLOBALS['egw_setup']->db;
|
||||||
$this->table = $GLOBALS['egw_setup']->prefs_table;
|
$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 we got instancated for a group, need to set offset of DEFAULT_ID!
|
||||||
if ($account_id < 0 && $GLOBALS['egw']->accounts->exists($account_id) == 2)
|
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
|
* Old PHP4 contstructor
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user