forked from extern/egroupware
added singelton pattern to the accounts class and added function to set accountId without needing to call the construtor
This commit is contained in:
parent
bec1c05070
commit
844936d19b
@ -132,12 +132,33 @@ class accounts
|
|||||||
*/
|
*/
|
||||||
var $config;
|
var $config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hold an instance of the accounts class
|
||||||
|
*
|
||||||
|
* @var accounts the instance of the accounts class
|
||||||
|
*/
|
||||||
|
private static $_instance = NULL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the singleton passtern
|
||||||
|
*
|
||||||
|
* @return accounts
|
||||||
|
*/
|
||||||
|
public static function getInstance()
|
||||||
|
{
|
||||||
|
if (self::$_instance === NULL) {
|
||||||
|
self::$_instance = new accounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::$_instance;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param string|array $backend=null string with backend 'sql'|'ldap', or whole config array, default read from global egw_info
|
* @param string|array $backend=null string with backend 'sql'|'ldap', or whole config array, default read from global egw_info
|
||||||
*/
|
*/
|
||||||
function __construct($backend=null)
|
public function __construct($backend=null)
|
||||||
{
|
{
|
||||||
if (is_numeric($backend)) // depricated use with account_id
|
if (is_numeric($backend)) // depricated use with account_id
|
||||||
{
|
{
|
||||||
@ -186,6 +207,18 @@ class accounts
|
|||||||
$this->__construct();
|
$this->__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the accountId
|
||||||
|
*
|
||||||
|
* @param int $accountId
|
||||||
|
*/
|
||||||
|
function setAccountId($accountId)
|
||||||
|
{
|
||||||
|
if($accountId && is_numeric($accountId)) {
|
||||||
|
$this->account_id = (int)$accountId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Searches / lists accounts: users and/or groups
|
* Searches / lists accounts: users and/or groups
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user