mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-22 16:03:47 +01:00
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
@ -131,13 +131,34 @@ class accounts
|
||||
* @var array
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @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
|
||||
{
|
||||
@ -185,7 +206,19 @@ class accounts
|
||||
|
||||
$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
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user