class IMP_IMAP_ACL
{
/**
+ * Singleton instance.
+ *
+ * @var IMP_IMAP_ACL
+ */
+ static protected $_instance = null;
+
+ /**
* Hash containing the list of possible rights and a human readable
* description of each.
*
* Attempts to return a reference to a concrete object instance.
* It will only create a new instance if no instance currently exists.
*
- * This method must be invoked as:
- * $var = &IMP_IMAP_ACL::singleton()
- *
* @return IMP_IMAP_ACL The created concrete instance.
*/
- static public function &singleton($driver, $params = array())
+ static public function singleton()
{
- static $instance;
-
- if (!isset($instance)) {
- $instances = new IMP_IMAP_ACL();
+ if (!self::$_instance) {
+ self::$_instance = new IMP_IMAP_ACL();
}
- return $instances[$signature];
+ return self::$_instance;
}
/**
* Constructor.
*/
- function __construct()
+ protected function __construct()
{
if ($_SESSION['imp']['protocol'] != 'imap') {
throw new Exception(_("ACL requires an IMAP server."));
class IMP_Quota
{
/**
+ * Singleton instances.
+ *
+ * @var array
+ */
+ static protected $_instances = array();
+
+ /**
* Hash containing connection parameters.
*
* @var array
*
* @return mixed The created concrete instance, or false on error.
*/
- static public function &singleton($driver, $params = array())
+ static public function singleton($driver, $params = array())
{
- static $instances = array();
+ ksort($params);
+ $signature = md5(serialize(array($driver, $params)));
- $signature = serialize(array($driver, $params));
- if (!isset($instances[$signature])) {
- $instances[$signature] = IMP_Quota::factory($driver, $params);
+ if (!isset(self::$_instances[$signature])) {
+ self::$_instances[$signature] = IMP_Quota::factory($driver, $params);
}
- return $instances[$signature];
+ return self::$_instances[$signature];
}
/**