/** * Returns an instance of a storage Container class. * * @param array configuration array to pass to the storage container * @param string Prefix of the class that will be used. * @return object|false will return an instance of a Storage container * or false upon error * * @access protected */ function &storageFactory(&$confArray, $classprefix = 'LiveUser_Perm_') { end($confArray); $key = key($confArray); $count = count($confArray); $storageName = $classprefix . 'Storage_' . $key; if (!LiveUser::loadClass($storageName, true)) { if ($count <= 1) { $storage = false; return $storage; // if the storage container does not exist try the next one in the stack } elseif ($count > 1) { // since we are using pass by ref we cannot pop from the original array $keys = array_keys($confArray); array_pop($keys); $newConfArray = array(); foreach ($keys as $key) { $newConfArray[$key] =& $confArray[$key]; } $storage =& LiveUser::storageFactory($newConfArray, $classprefix); return $storage; } } $storageConf =& $confArray[$key]; $newConfArray = array(); foreach ($confArray as $keyNew => $foo) { if ($key !== $keyNew) { $newConfArray[$keyNew] =& $confArray[$keyNew]; } } $storage =& new $storageName(); if ($storage->init($storageConf, $newConfArray) === false) { $storage = false; } return $storage; }
/** * Initialize the storage container * * @param array array containing the configuration. * @return bool true on success or false on failure * * @access public */ function init(&$conf) { // Sanity check, is there a storage container defined in the configuration. if (!array_key_exists('storage', $conf)) { $this->stack->push(LIVEUSER_ADMIN_ERROR, 'exception', array('msg' => 'Missing storage configuration array')); return false; } // Set the config to class vars. if (is_array($conf)) { $keys = array_keys($conf); foreach ($keys as $key) { if (isset($this->{$key})) { $this->{$key} =& $conf[$key]; } } } // Create the storage class, if and error occures, add it to the stack and return false. $this->_storage =& LiveUser::storageFactory($conf['storage'], 'LiveUser_Admin_Perm_'); if ($this->_storage === false) { end($conf['storage']); $key = key($conf['storage']); $this->stack->push(LIVEUSER_ERROR, 'exception', array('msg' => 'Could not instanciate perm storage container: ' . $key)); return false; } return true; }
/** * Initialize the storage container * * @access public * @param array contains configuration of the container * @param string name of container * @return bool true on success or false on failure */ function init(&$conf, $containerName) { $this->containerName = $containerName; if (!array_key_exists('storage', $conf)) { $this->stack->push(LIVEUSER_ADMIN_ERROR, 'exception', array('msg' => 'Missing storage configuration array')); return false; } if (is_array($conf)) { $keys = array_keys($conf); foreach ($keys as $key) { if (isset($this->{$key})) { $this->{$key} =& $conf[$key]; } } } $storageConf = array(); $storageConf[$conf['type']] =& $conf['storage']; $this->_storage = LiveUser::storageFactory($storageConf, 'LiveUser_Admin_Auth_'); if ($this->_storage === false) { $this->stack->push(LIVEUSER_ADMIN_ERROR, 'exception', array('msg' => 'Could not instanciate auth storage container: ' . $conf['type'])); return false; } return true; }
/** * Load and initialize the storage container. * * @param array Array with the configuration * @return bool true on success or false on failure * * @access public */ function init(&$conf) { if (!array_key_exists('storage', $conf)) { $this->stack->push(LIVEUSER_ERROR, 'exception', array('msg' => 'Missing storage configuration array')); return false; } if (is_array($conf)) { $keys = array_keys($conf); foreach ($keys as $key) { if (isset($this->{$key})) { $this->{$key} =& $conf[$key]; } } } $this->_storage =& LiveUser::storageFactory($conf['storage']); if ($this->_storage === false) { end($conf['storage']); $key = key($conf['storage']); $this->stack->push(LIVEUSER_ERROR, 'exception', array('msg' => 'Could not instanciate perm storage container: ' . $key)); return false; } return true; }