From 48a17e28c1f3cd8adb9f8cd71f67cefbe4ae91b6 Mon Sep 17 00:00:00 2001 From: Lars Kneschke Date: Fri, 8 Feb 2008 11:27:54 +0000 Subject: [PATCH] added a singleton pattern to the accounts class --- phpgwapi/inc/class.accounts.inc.php | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/phpgwapi/inc/class.accounts.inc.php b/phpgwapi/inc/class.accounts.inc.php index 5618bec6a4..b6d21cdca2 100644 --- a/phpgwapi/inc/class.accounts.inc.php +++ b/phpgwapi/inc/class.accounts.inc.php @@ -124,6 +124,28 @@ class accounts extends accounts_backend 'start' => 'start with', 'exact' => 'exact', ); + + /** + * the instance of the accounts class + * + * @var accounts + */ + static $_instance = NULL; + + /** + * the singleton pattern + * + * @return accounts + */ + static function getInstance() + { + if (self::$_instance === NULL) { + self::$_instance = new accounts; + } + + return self::$_instance; + } + /** * Constructor * @@ -136,6 +158,18 @@ class accounts extends accounts_backend $this->accounts_backend(); // call constructor of extended class } + /** + * set the accountId used by this class + * + * @param int $accountId + */ + function setAccountId($accountId) + { + if($accountId && is_numeric($accountId)) { + $this->account_id = (int)$accountId; + } + } + /** * Searches / lists accounts: users and/or groups *