Returns the driver parameters for the specified backend.
public static getDriverConfig ( mixed $backend, string $type = 'sql' ) : array | ||
$backend | mixed | The backend system (e.g. 'prefs', 'categories', 'contacts') being used. The used configuration array will be $conf[$backend]. If an array gets passed, it will be $conf[$key1][$key2]. |
$type | string | The type of driver. If null, will not merge with base config. |
return | array | The connection parameters. |
/** * Return the Agora_Driver:: instance. * * @param string $scope Instance scope * @param int $forum_id Forum to link to * * @return Agora_Driver The singleton instance. * @throws Agora_Exception */ public function create($scope = 'agora', $forum_id = 0) { if (!isset($this->_instances[$scope])) { $driver = $GLOBALS['conf']['threads']['split'] ? 'SplitSql' : 'Sql'; $params = Horde::getDriverConfig('sql'); $class = 'Agora_Driver_' . $driver; if (!class_exists($class)) { throw new Agora_Exception(sprintf('Unable to load the definition of %s.', $class)); } $params = array('db' => $this->_injector->getInstance('Horde_Db_Adapter'), 'charset' => $params['charset']); $driver = new $class($scope, $params); $this->_instances[$scope] = $driver; } if ($forum_id) { /* Check if there was a valid forum object to get. */ try { $forum = $this->_instances[$scope]->getForum($forum_id); } catch (Horde_Exception $e) { throw new Agora_Exception($e->getMessage()); } /* Set current forum id and forum data */ $this->_instances[$scope]->_forum = $forum; $this->_instances[$scope]->_forum_id = (int) $forum_id; } return $this->_instances[$scope]; }
public function create(Horde_Injector $injector) { $driver = Horde_String::ucfirst($GLOBALS['conf']['group']['driver']); $params = Horde::getDriverConfig('group', $driver); if (!empty($GLOBALS['conf']['group']['cache'])) { $params['cache'] = $injector->getInstance('Horde_Cache'); } switch ($driver) { case 'Contactlists': $class = 'Horde_Group_Contactlists'; $params['api'] = $GLOBALS['registry']->contacts; break; case 'Kolab': $class = 'Horde_Group_Kolab'; $params['ldap'] = $injector->getInstance('Horde_Core_Factory_Ldap')->create('horde', 'group'); break; case 'Ldap': $class = 'Horde_Core_Group_Ldap'; $params['ldap'] = $injector->getInstance('Horde_Core_Factory_Ldap')->create('horde', 'group'); break; case 'Sql': $class = 'Horde_Group_Sql'; $params['db'] = $injector->getInstance('Horde_Core_Factory_Db')->create('horde', 'group'); break; default: $class = $this->_getDriverName($driver, 'Horde_Group'); break; } return new $class($params); }
/** * Returns the spellchecker instance. * * @param array $args Configuration arguments to override the * defaults. * @param string $input Input text. If set, allows language detection * if not automatically set. * * @return Horde_SpellChecker The spellchecker instance. * @throws Horde_Exception */ public function create(array $args = array(), $input = null) { global $conf, $language, $registry; if (empty($conf['spell']['driver'])) { throw new Horde_Exception('No spellcheck driver configured.'); } $args = array_merge(array('localDict' => array()), Horde::getDriverConfig('spell', null), $args); if (empty($args['locale'])) { if (!is_null($input)) { try { $args['locale'] = $this->_injector->getInstance('Horde_Core_Factory_LanguageDetect')->getLanguageCode($input); } catch (Horde_Exception $e) { } } if (empty($args['locale']) && isset($language)) { $args['locale'] = $language; } } /* Add local dictionary words. */ try { $args['localDict'] = array_merge($args['localDict'], $registry->loadConfigFile('spelling.php', 'ignore_list', 'horde')->config['ignore_list']); } catch (Horde_Exception $e) { } $classname = 'Horde_SpellChecker_' . Horde_String::ucfirst(basename($conf['spell']['driver'])); if (!class_exists($classname)) { throw new Horde_Exception('Spellcheck driver does not exist.'); } return new $classname($args); }
/** * A Factory for the Sesha_Driver. Currently only Rdo is implemented * @param string name An arbitrary name string to identify the driver instance * @param array params a hash of driver parameters. For the Rdo driver, these are the parameters for creating a Horde_Db_Adapter * @return Horde_Rdo_Driver A concrete instance of Horde_Rdo_Driver with all necessary dependencies injected */ public function create($name = '', $params = array()) { if (!isset($this->_instances[$name])) { if (!empty($params['driver'])) { $driver = $params['driver']; unset($params['driver']); } else { $driver = $GLOBALS['conf']['storage']['driver']; $params = Horde::getDriverConfig('storage', $driver); } $class = 'Sesha_Driver_' . ucfirst(basename($driver)); if (!class_exists($class)) { throw new Sesha_Exception(sprintf('Unable to load the definition of %s.', $class)); } switch ($class) { case 'Sesha_Driver_Rdo': if (empty($params['db'])) { $params['db'] = $this->_injector->getInstance('Horde_Core_Factory_Db')->create('sesha', $params); } break; } $this->_instances[$name] = new $class($params); } return $this->_instances[$name]; }
/** * Return the Mnemo_Driver:: instance. * * @param mixed $name The notepad to open * * @return Mnemo_Driver * @throws Mnemo_Exception */ public function create($name = '') { if (!isset($this->_instances[$name])) { $driver = $GLOBALS['conf']['storage']['driver']; $params = Horde::getDriverConfig('storage', $driver); $class = 'Mnemo_Driver_' . ucfirst(basename($driver)); if (!class_exists($class)) { throw new Mnemo_Exception(sprintf('Unable to load the definition of %s.', $class)); } switch ($class) { case 'Mnemo_Driver_Sql': if ($params['driverconfig'] != 'horde') { $customParams = $params; unset($customParams['driverconfig'], $customParams['table']); $params['db'] = $this->_injector->getInstance('Horde_Core_Factory_Db')->create('mnemo', $customParams); } else { $params['db'] = $this->_injector->getInstance('Horde_Db_Adapter'); } break; case 'Mnemo_Driver_Kolab': $params = array('storage' => $this->_injector->getInstance('Horde_Kolab_Storage')); } $driver = new $class($name, $params); $this->_instances[$name] = $driver; } return $this->_instances[$name]; }
/** * Return the Ingo_Storage instance. * * @param string $driver Driver name. * @param array $params Configuration parameters. * * @return Ingo_Storage The singleton instance. * * @throws Ingo_Exception */ public function create($driver = null, $params = null) { if (is_null($driver)) { $driver = $GLOBALS['conf']['storage']['driver']; } $driver = ucfirst(basename($driver)); if (!isset($this->_instances[$driver])) { if (is_null($params)) { $params = Horde::getDriverConfig('storage', $driver); } switch ($driver) { case 'Sql': $params['db'] = $GLOBALS['injector']->getInstance('Horde_Db_Adapter'); $params['table_forwards'] = 'ingo_forwards'; $params['table_lists'] = 'ingo_lists'; $params['table_rules'] = 'ingo_rules'; $params['table_spam'] = 'ingo_spam'; $params['table_vacations'] = 'ingo_vacations'; break; } $class = 'Ingo_Storage_' . $driver; if (class_exists($class)) { $this->_instances[$driver] = new $class($params); } else { throw new Ingo_Exception(sprintf(_("Unable to load the storage driver \"%s\"."), $class)); } } return $this->_instances[$driver]; }
public function create(Horde_Injector $injector) { global $conf, $session; $driver = empty($conf['token']) ? 'null' : $conf['token']['driver']; $params = empty($conf['token']) ? array() : Horde::getDriverConfig('token', $conf['token']['driver']); $params['logger'] = $injector->getInstance('Horde_Log_Logger'); if (!$session->exists('horde', 'token_secret_key')) { $session->set('horde', 'token_secret_key', strval(new Horde_Support_Randomid())); } $params['secret'] = $session->get('horde', 'token_secret_key'); switch (Horde_String::lower($driver)) { case 'none': $driver = 'null'; break; case 'nosql': $nosql = $injector->getInstance('Horde_Core_Factory_Nosql')->create('horde', 'token'); if ($nosql instanceof Horde_Mongo_Client) { $params['mongo_db'] = $nosql; $driver = 'Horde_Token_Mongo'; } break; case 'sql': $params['db'] = $injector->getInstance('Horde_Core_Factory_Db')->create('horde', 'token'); break; } if (isset($conf['urls']['token_lifetime'])) { $params['token_lifetime'] = $conf['urls']['token_lifetime'] * 60; } $class = $this->_getDriverName($driver, 'Horde_Token'); return new $class($params); }
/** * Return a Horde_Alarm instance. * * @return Horde_Alarm * @throws Horde_Exception */ public function create() { global $conf; if (isset($this->_alarm)) { return $this->_alarm; } $driver = empty($conf['alarms']['driver']) ? 'null' : $conf['alarms']['driver']; $params = Horde::getDriverConfig('alarms', $driver); switch (Horde_String::lower($driver)) { case 'sql': $params['db'] = $this->_injector->getInstance('Horde_Core_Factory_Db')->create('horde', 'alarms'); break; } $params['logger'] = $this->_injector->getInstance('Horde_Log_Logger'); $params['loader'] = array($this, 'load'); $this->_ttl = isset($params['ttl']) ? $params['ttl'] : 300; $class = $this->_getDriverName($driver, 'Horde_Alarm'); $this->_alarm = new $class($params); $this->_alarm->initialize(); $this->_alarm->gc(); /* Add those handlers that need configuration and can't be auto-loaded * through Horde_Alarms::handlers(). */ $this->_alarm->addHandler('notify', new Horde_Core_Alarm_Handler_Notify()); $this->_alarm->addHandler('desktop', new Horde_Core_Alarm_Handler_Desktop(array('icon' => new Horde_Core_Alarm_Handler_Desktop_Icon('alerts/alarm.png'), 'js_notify' => array($this->_injector->getInstance('Horde_PageOutput'), 'addInlineScript')))); $this->_alarm->addHandler('mail', new Horde_Alarm_Handler_Mail(array('identity' => $this->_injector->getInstance('Horde_Core_Factory_Identity'), 'mail' => $this->_injector->getInstance('Horde_Mail')))); return $this->_alarm; }
/** */ public function __construct($params = array()) { if (!isset($params['db'])) { throw new Passwd_Exception('Missing required Horde_Db_Adapter object'); } $this->_db = $params['db']; unset($params['db']); /* Use defaults from Horde. */ parent::__construct(array_merge(Horde::getDriverConfig('', 'sql'), array('clear_passwd' => 'pw_clear_passwd', 'domain' => 'pw_domain', 'encryption' => 'crypt', 'name' => 'pw_name', 'passwd' => 'pw_passwd', 'show_encryption' => false, 'table' => 'horde_users', 'use_clear_passwd' => false), $params)); }
public function create(Horde_Injector $injector) { $driver = $GLOBALS['conf']['davstorage']['driver']; $params = Horde::getDriverConfig('davstorage', $driver); switch ($driver) { case 'Sql': $class = 'Horde_Dav_Storage_Sql'; $params['db'] = $injector->getInstance('Horde_Core_Factory_Db')->create('horde', 'davstorage'); break; default: throw new Horde_Exception('A storage backend for DAV has not been configured.'); break; } return new $class($params); }
/** * Attempts to return a concrete instance based on $driver. * * @return Horde_Perms The newly created concrete instance. * @throws Horde_Exception */ public function create(Horde_Injector $injector) { global $conf; $driver = empty($conf['perms']['driver']) ? 'null' : $conf['perms']['driver']; $params = isset($conf['perms']) ? Horde::getDriverConfig('perms', $driver) : array(); switch (Horde_String::lower($driver)) { case 'sql': $params['db'] = $injector->getInstance('Horde_Core_Factory_Db')->create('horde', 'perms'); break; } $params['cache'] = new Horde_Cache(new Horde_Cache_Storage_Stack(array('stack' => array(new Horde_Cache_Storage_Memory(), $injector->getInstance('Horde_Cache'))))); $params['logger'] = $injector->getInstance('Horde_Log_Logger'); $class = $this->_getDriverName($driver, 'Horde_Perms'); return new $class($params); }
/** * Return the Ulaform_Driver:: instance. * * @param mixed $name Instance name * * @return Ulaform_Driver * @throws Ulaform_Exception */ public function create($name = '') { if (!isset($this->_instances[$name])) { $driver = 'Sql'; $params = Horde::getDriverConfig('sql', $driver); $class = 'Ulaform_Driver_' . $driver; if (!class_exists($class)) { throw new Ulaform_Exception(sprintf('Unable to load the definition of %s.', $class)); } $params = array('db' => $this->_injector->getInstance('Horde_Db_Adapter'), 'charset' => $params['charset']); $driver = new $class($params); $this->_instances[$name] = $driver; } return $this->_instances[$name]; }
/** * Gets a concrete Klutz_Driver instance. * * @param string $driver The type of concrete Klutz_Driver subclass to * return. The code for the driver is dynamically * included. * * @param array $params A hash containing any additional configuration or * connection parameters a subclass might need * * @return object Klutz_Driver The newly created concrete instance, or * false on error. */ function factory($driver = null, $params = null) { if (is_null($driver)) { $driver = $GLOBALS['conf']['storage']['driver']; } $driver = ucfirst(basename($driver)); if (is_null($params)) { $params = Horde::getDriverConfig('storage', $driver); } $class = 'Klutz_Driver_' . $driver; if (class_exists($class)) { return new $class($params); } return new Klutz_Driver($params); }
/** * Return the driver instance. * * @param string $tasklist The name of the tasklist to load. * * @return Nag_Driver * @throws Nag_Exception */ public function create($tasklist) { $driver = null; $params = array(); if (!empty($tasklist)) { $signature = $tasklist; try { $share = $GLOBALS['nag_shares']->getShare($tasklist); if ($share->get('issmart')) { $driver = 'Smartlist'; } } catch (Horde_Exception $e) { throw new Nag_Exception($e); } } if (!$driver) { $driver = $GLOBALS['conf']['storage']['driver']; $params = Horde::getDriverConfig('storage', $driver); $signature = serialize(array($tasklist, $driver, $params)); } if (isset($this->_instances[$signature])) { return $this->_instances[$signature]; } $driver = ucfirst(basename($driver)); $class = 'Nag_Driver_' . $driver; switch ($driver) { case 'Sql': $params['db'] = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Db')->create('nag', 'storage'); break; case 'Kolab': $params['kolab'] = $GLOBALS['injector']->getInstance('Horde_Kolab_Storage'); break; case 'Smartlist': $params['driver'] = $this->create(''); } if (class_exists($class)) { try { $nag = new $class($tasklist, $params); } catch (Nag_Exception $e) { $nag = new Nag_Driver($params, sprintf(_("The Tasks backend is not currently available: %s"), $e->getMessage())); } } else { $nag = new Nag_Driver($params, sprintf(_("Unable to load the definition of %s."), $class)); } $this->_instances[$signature] = $nag; return $nag; }
/** * Attempts to return a concrete instance based on $driver. * * @return Horde_SessionHandler_Driver The newly created concrete * instance. * @throws Horde_SessionHandler_Exception */ public function create(Horde_Injector $injector) { global $conf; if (empty($conf['sessionhandler']['type'])) { $driver = 'Builtin'; } else { $driver = $conf['sessionhandler']['type']; if (!strcasecmp($driver, 'None')) { $driver = 'Builtin'; } } $params = Horde::getDriverConfig('sessionhandler', $driver); $driver = basename(Horde_String::lower($driver)); $noset = false; switch ($driver) { case 'builtin': $noset = true; break; case 'hashtable': // DEPRECATED // DEPRECATED case 'memcache': $params['hashtable'] = $injector->getInstance('Horde_HashTable'); $driver = 'hashtable'; break; case 'nosql': $nosql = $injector->getInstance('Horde_Core_Factory_Nosql')->create('horde', 'sessionhandler'); if ($nosql instanceof Horde_Mongo_Client) { $params['mongo_db'] = $nosql; $driver = 'Horde_SessionHandler_Storage_Mongo'; } break; case 'sql': $factory = $injector->getInstance('Horde_Core_Factory_Db'); $config = $factory->getConfig('sessionhandler'); unset($config['umask'], $config['driverconfig']); $params['db'] = $factory->createDb($config); break; } $class = $this->_getDriverName($driver, 'Horde_SessionHandler_Storage'); $storage = $this->storage = new $class($params); if ((!empty($conf['sessionhandler']['hashtable']) || !empty($conf['sessionhandler']['memcache'])) && !in_array($driver, array('builtin', 'hashtable'))) { $storage = new Horde_SessionHandler_Storage_Stack(array('stack' => array(new Horde_SessionHandler_Storage_Hashtable(array('hashtable' => $injector->getInstance('Horde_HashTable'))), $this->storage))); } return new Horde_SessionHandler($storage, array('logger' => $injector->getInstance('Horde_Log_Logger'), 'no_md5' => true, 'noset' => $noset, 'parse' => array($this, 'readSessionData'))); }
/** * Attempts to return a concrete Luxor_Driver instance based on $driver. * * @param string $driver The type of concrete Luxor_Driver subclass * to return. The is based on the storage * driver ($driver). The code is dynamically * included. * * @param array $params (optional) A hash containing any additional * configuration or connection parameters a * subclass might need. * * @return mixed The newly created concrete Luxor_Driver instance, or * false on an error. */ function factory($source, $driver = null, $params = null) { if (is_null($driver)) { $driver = $GLOBALS['conf']['storage']['driver']; } $driver = basename($driver); if (is_null($params)) { $params = Horde::getDriverConfig('storage', $driver); } $class = 'Luxor_Driver_' . $driver; if (class_exists($class)) { $luxor = new $class($source, $params); } else { $luxor = false; } return $luxor; }
function NWNSettings($name, $properties = null) { parent::DataTreeObject($name); // dto settings $this->data['type'] = 'nwnsettings'; $this->data['name'] = isset($properties['name']) ? $properties['name'] : ''; // datatree initialization for persistent storage global $conf; $driver = $conf['datatree']['driver']; $params = Horde::getDriverConfig('datatree', $driver); $params = array_merge($params, array('group' => 'nwnadmin.settings')); $this->_datatree =& DataTree::singleton($driver, $params); // create the neccessary datatree node if it does not exist if (!$this->_datatree->exists($this)) { $this->_datatree->add($this); } }
/** * Return an Sam_Driver_Base instance. * * @return Sam_Driver_Base * @throws Sam_Exception */ public function create(Horde_Injector $injector) { $backend = Sam::getPreferredBackend(); $signature = hash('md5', serialize($backend)); if (empty($this->_instances[$signature])) { $user = Sam::mapUser($backend['hordeauth']); switch ($backend['driver']) { case 'Amavisd_Sql': case 'Spamd_Sql': $db_params = array_merge(Horde::getDriverConfig(null, 'sql'), $backend['params']); unset($db_params['table_map']); try { $db = $injector->getInstance('Horde_Core_Factory_Db')->create('sam', $db_params); } catch (Horde_Exception $e) { throw new Sam_Exception($e); } $params = array_merge($backend['params'], array('db' => $db)); break; case 'Spamd_Ldap': $params = array_merge(array('binddn' => sprintf('%s=%s,%s', $backend['params']['uid'], $user, $backend['params']['basedn']), 'bindpw' => $GLOBALS['registry']->getAuthCredential('password')), $backend['params']); try { $ldap = $injector->getInstance('Horde_Core_Factory_Ldap')->create('sam', $params); } catch (Horde_Exception $e) { throw new Sam_Exception($e); } $params = array_merge($backend['params'], array('ldap' => $ldap)); break; case 'Spamd_Ftp': $params = array_merge(array('username' => $user, 'password' => $GLOBALS['registry']->getAuthCredential('password')), $backend['params']); try { $vfs = $injector->getInstance('Horde_Core_Factory_Vfs')->create('sam', array('type' => 'ftp', 'params' => $params)); } catch (Horde_Exception $e) { throw new Sam_Exception($e); } $params = array_merge($backend['params'], array('vfs' => $vfs)); break; default: $params = $backend['params']; break; } $class = 'Sam_Driver_' . $backend['driver']; $this->_instances[$signature] = new $class($user, $params); } return $this->_instances[$signature]; }
/** * Return the driver instance. * * @param string $driver The concrete driver to return * @param array $params An array of additional driver parameters. * * @return Jonah_Driver * @throws Jonah_Exception */ public function create(Horde_Injector $injector) { $driver = Horde_String::ucfirst($GLOBALS['conf']['news']['storage']['driver']); $driver = basename($driver); $params = Horde::getDriverConfig(array('news', 'storage'), $driver); $sig = md5($driver . serialize($params)); if (isset($this->_instances[$sig])) { return $this->_instances[$sig]; } $class = 'Jonah_Driver_' . $driver; if (class_exists($class)) { $object = new $class($params); $this->_instances[$sig] = $object; } else { throw new Jonah_Exception(sprintf(_("No such backend \"%s\" found"), $driver)); } return $this->_instances[$sig]; }
/** * Return the global Horde_Cache instance. * * @return Horde_Cache Cache object. * @throws Horde_Cache_Exception */ public function create(Horde_Injector $injector) { global $conf; $params = array('compress' => true, 'logger' => $injector->getInstance('Horde_Core_Log_Wrapper')); if (isset($conf['cache']['default_lifetime'])) { $params['lifetime'] = $conf['cache']['default_lifetime']; } $driver = $this->getDriverName(); $sparams = Horde::getDriverConfig('cache', $driver); switch ($driver) { case 'hashtable': // DEPRECATED // DEPRECATED case 'memcache': $sparams['hashtable'] = $injector->getInstance('Horde_Core_HashTable_Wrapper'); $driver = 'Horde_Cache_Storage_Hashtable'; unset($sparams['driverconfig'], $sparams['umask']); break; case 'nosql': $nosql = $injector->getInstance('Horde_Core_Factory_Nosql')->create('horde', 'cache'); if ($nosql instanceof Horde_Mongo_Client) { $sparams['mongo_db'] = $nosql; $driver = 'Horde_Cache_Storage_Mongo'; } else { $driver = 'Horde_Cache_Storage_Null'; } unset($sparams['driverconfig'], $sparams['umask']); break; case 'sql': $sparams['db'] = $injector->getInstance('Horde_Core_Factory_Db')->create('horde', 'cache'); unset($sparams['driverconfig'], $sparams['umask']); break; } $storage = $this->storage = $this->_getStorage($driver, $sparams); if (!empty($conf['cache']['use_memorycache']) && in_array($driver, array('file', 'sql'))) { switch (Horde_String::lower($conf['cache']['use_memorycache'])) { case 'hashtable': case 'memcache': $storage = new Horde_Cache_Storage_Stack(array('stack' => array($this->_getStorage($conf['cache']['use_memorycache'], array('hashtable' => $injector->getInstance('Horde_Core_HashTable_Wrapper'))), $storage))); break; } } return new Horde_Cache($storage, $params); }
/** * Attempts to return a concrete Folks_Driver instance based on $driver. * * @param string $driver The type of the concrete Folks_Driver subclas * to return. The clas name is based on the * storage driver ($driver). The code is * dynamically included. * * @param array $params A hash containing any additional configuration * or connection parameters a subclas might need. * * @return Folks_Driver The newly created concrete Folks_Driver * instance, or false on an error. */ public function factory($driver = null, $params = null) { if ($driver === null) { $driver = $GLOBALS['conf']['storage']['driver']; } $driver = basename($driver); if ($params === null) { $params = Horde::getDriverConfig('storage', $driver); } $clas = 'Folks_Driver_' . $driver; if (!class_exists($clas)) { include __DIR__ . '/Driver/' . $driver . '.php'; } if (class_exists($clas)) { return new $clas($params); } else { return false; } }
/** * Return the Mnemo_Driver:: instance. * * @param mixed $name The notepad to open * * @return Mnemo_Driver * @throws Mnemo_Exception */ public function create($name = '') { if (!isset($this->_instances[$name])) { $driver = $GLOBALS['conf']['storage']['driver']; $params = Horde::getDriverConfig('storage', $driver); $class = 'Mnemo_Driver_' . ucfirst(basename($driver)); if (!class_exists($class)) { throw new Mnemo_Exception(sprintf('Unable to load the definition of %s.', $class)); } switch ($class) { case 'Mnemo_Driver_Sql': $params = array('db' => $this->_injector->getInstance('Horde_Db_Adapter'), 'table' => 'mnemo_memos', 'charset' => $params['charset']); break; case 'Mnemo_Driver_Kolab': $params = array('storage' => $this->_injector->getInstance('Horde_Kolab_Storage')); } $driver = new $class($name, $params); $this->_instances[$name] = $driver; } return $this->_instances[$name]; }
/** * Return the driver instance. * * @return Kronolith_Storage * @throws Kronolith_Exception */ public function create($params = array()) { if (empty($params['user'])) { $user = $GLOBALS['registry']->getAuth(); } else { $user = $params['user']; unset($params['user']); } if (empty($params['driver'])) { $driver = Horde_String::ucfirst($GLOBALS['conf']['storage']['driver']); } else { $driver = $params['driver']; unset($params['driver']); } $driver = basename($driver); $class = 'Kronolith_Storage_' . $driver; $driver_params = Horde::getDriverConfig('storage', 'Sql'); if ($driver == 'Sql') { if ($driver_params != 'Horde') { // Custom DB config $params['db'] = $this->_injector->getInstance('Horde_Core_Factory_Db')->create('kronolith', Horde::getDriverConfig('storage', 'Sql')); } else { // Horde default DB config $params['db'] = $this->_injector->getInstance('Horde_Db_Adapter'); } $params['table'] = $driver_params['table']; } if (class_exists($class)) { $driver = new $class($user, $params); } else { throw new Kronolith_Exception(sprintf(_("Unable to load the definition of %s."), $class)); } try { $driver->initialize(); } catch (Exception $e) { $driver = new Kronolith_Storage($params); } return $driver; }
/** * Return the IMP_Sentmail instance. * * @return IMP_Sentmail The singleton instance. * @throws IMP_Exception */ public function create(Horde_Injector $injector) { $driver = empty($GLOBALS['conf']['sentmail']['driver']) ? 'null' : $GLOBALS['conf']['sentmail']['driver']; $params = Horde::getDriverConfig('sentmail', $driver); switch (Horde_String::lower($driver)) { case 'nosql': $nosql = $injector->getInstance('Horde_Core_Factory_Nosql')->create('imp', 'sentmail'); if ($nosql instanceof Horde_Mongo_Client) { $params['mongo_db'] = $nosql; $driver = 'Mongo'; } break; case 'sql': $params['db'] = $injector->getInstance('Horde_Core_Factory_Db')->create('imp', 'sentmail'); break; default: $driver = 'null'; break; } $class = $this->_getDriverName($driver, 'IMP_Sentmail'); return new $class($params); }
/** * Return the Ulaform_Action:: instance. * * @param string $action The action to use * * @return Ulaform_Action * @throws Ulaform_Exception */ public function create($action) { $action = basename($action); if (!empty($this->_instances[$action])) { return $this->_instances[$action]; } $class = 'Ulaform_Action_' . $action; if (!class_exists($class)) { throw new Ulaform_Exception(sprintf('Unable to load the definition of %s.', $class)); } switch ($class) { case 'Ulaform_Action_Sql': $params = Horde::getDriverConfig('sql', $action); $params = array('db' => $this->_injector->getInstance('Horde_Db_Adapter'), 'charset' => $params['charset']); break; case 'Ulaform_Action_Mailto': $params = array(); break; } $this->_instances[$action] = new $class($params); return $this->_instances[$action]; }
/** */ public function create(Horde_Injector $injector) { global $conf; $logger = $injector->getInstance('Horde_Core_Log_Wrapper'); // DEPRECATED: BC config if (!empty($conf['memcache']['enabled'])) { return new Horde_HashTable_Memcache(array('logger' => $logger, 'memcache' => $injector->getInstance('Horde_Memcache'))); } $driver = empty($conf['hashtable']['driver']) ? 'memory' : $conf['hashtable']['driver']; $lc_driver = Horde_String::lower($driver); $params = Horde::getDriverConfig('hashtable', $driver); switch ($lc_driver) { case 'memcache': return new Horde_HashTable_Memcache(array('logger' => $logger, 'memcache' => new Horde_Memcache(array_merge($params, array('logger' => $logger))))); case 'predis': $params = array_merge(array('hostspec' => array(), 'password' => null, 'port' => '', 'protocol' => 'tcp'), $params); $redis_params = array(); $common = array_filter(array('password' => strlen($params['password']) ? $params['password'] : null, 'persistent' => !empty($params['persistent']))); switch ($params['protocol']) { case 'tcp': foreach ($params['hostspec'] as $key => $val) { $redis_params[] = array_merge($common, array_filter(array('host' => trim($val), 'port' => isset($params['port'][$key]) ? trim($params['port'][$key]) : null, 'scheme' => 'tcp'))); } break; case 'unix': $redis_params[] = array_merge($common, array('path' => trim($params['socket']), 'scheme' => 'unix')); break; } /* No need to use complex clustering if not needed. */ if (count($redis_params) === 1) { $redis_params = reset($redis_params); } return new Horde_HashTable_Predis(array('logger' => $logger, 'predis' => new Predis\Client($redis_params))); case 'memory': default: return new Horde_HashTable_Memory(array('logger' => $logger)); } }
/** * Return the Ingo_Storage instance. * * @param string $driver Driver name. * @param array $params Configuration parameters. * * @return Ingo_Storage The singleton instance. * * @throws Ingo_Exception */ public function create($driver = null, $params = null) { global $conf, $injector; if (is_null($driver)) { $driver = $conf['storage']['driver']; } $driver = ucfirst(basename($driver)); if (!isset($this->_instances[$driver])) { if (is_null($params)) { $params = Horde::getDriverConfig('storage', $driver); } switch ($driver) { case 'Nosql': $nosql = $injector->getInstance('Horde_Core_Factory_Nosql')->create('ingo', 'storage'); if ($nosql instanceof Horde_Mongo_Client) { $params['mongo_db'] = $nosql; $driver = 'Mongo'; } break; case 'Sql': $params['db'] = $injector->getInstance('Horde_Db_Adapter'); $params['table_forwards'] = 'ingo_forwards'; $params['table_lists'] = 'ingo_lists'; $params['table_rules'] = 'ingo_rules'; $params['table_spam'] = 'ingo_spam'; $params['table_vacations'] = 'ingo_vacations'; break; } $class = 'Ingo_Storage_' . $driver; if (class_exists($class)) { $this->_instances[$driver] = new $class($params); } else { throw new Ingo_Exception(sprintf(_("Unable to load the storage driver \"%s\"."), $class)); } } return $this->_instances[$driver]; }
/** * Upgrade. */ public function up() { // shares ng $this->addColumn('kronolith_sharesng', 'attribute_email', 'text'); $this->addColumn('kronolith_sharesng', 'attribute_members', 'text'); $this->addColumn('kronolith_sharesng', 'attribute_response_type', 'integer'); $this->addColumn('kronolith_sharesng', 'attribute_type', 'integer', array('default' => Kronolith::SHARE_TYPE_USER)); $this->addColumn('kronolith_sharesng', 'attribute_isgroup', 'integer', array('default' => 0)); // legacy shares $this->addColumn('kronolith_shares', 'attribute_email', 'text'); $this->addColumn('kronolith_shares', 'attribute_members', 'text'); $this->addColumn('kronolith_shares', 'attribute_response_type', 'integer'); $this->addColumn('kronolith_shares', 'attribute_type', 'integer', array('default' => Kronolith::SHARE_TYPE_USER)); $this->addColumn('kronolith_shares', 'attribute_isgroup', 'integer', array('default' => 0)); /** Migrate existing resources to shares */ $columns = $this->_connection->columns('kronolith_resources'); /** Try to get existing data charset **/ $config = Horde::getDriverConfig('resource', 'sql'); $charset = empty($config['charset']) ? 'utf-8' : $config['charset']; $rows = $this->_connection->select('SELECT * FROM kronolith_resources'); $shares = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Share')->create('kronolith'); foreach ($rows as $row) { $share = $shares->newShare(null, $row['resource_calendar'], Horde_String::convertCharset($row['resource_name'], $charset, 'utf-8')); $share->set('desc', $columns['resource_description']->binaryToString($row['resource_description'])); $share->set('email', $row['resource_email']); $share->set('response_type', $row['resource_response_type']); $share->set('calendar_type', Kronolith::SHARE_TYPE_RESOURCE); $share->set('isgroup', $row['resource_type'] == 'Group'); $share->set('members', $columns['resource_members']->binaryToString($row['resource_members'])); /* Perms to match existing behavior */ $share->addDefaultPermission(Horde_Perms::SHOW); $share->addDefaultPermission(Horde_Perms::READ); $share->addDefaultPermission(Horde_Perms::EDIT); $share->save(); } }
/** * Attempts to return a concrete instance based on the configured driver. * * @return Horde_Lock The newly created concrete instance. * @throws Horde_Exception */ public function create(Horde_Injector $injector) { global $conf; $driver = empty($conf['lock']['driver']) ? 'null' : $conf['lock']['driver']; $params = Horde::getDriverConfig('lock', $driver); $params['logger'] = $injector->getInstance('Horde_Log_Logger'); switch (Horde_String::lower($driver)) { case 'none': $driver = 'null'; break; case 'nosql': $nosql = $injector->getInstance('Horde_Core_Factory_Nosql')->create('horde', 'cache'); if ($nosql instanceof Horde_Mongo_Client) { $params['mongo_db'] = $nosql; $driver = 'mongo'; } break; case 'sql': $params['db'] = $injector->getInstance('Horde_Core_Factory_Db')->create('horde', 'lock'); break; } $class = $this->_getDriverName($driver, 'Horde_Lock'); return new $class($params); }
/** * Return the driver instance. * * @param string $driver The storage backend to use * @param array $params Driver params * * @return Kronolith_Driver * @throws Kronolith_Exception */ public function create($driver = null, $params = array()) { if (is_null($driver)) { $driver = $GLOBALS['conf']['tickets']['driver']; } if (!empty($this->_instances[$driver])) { return $this->_instances[$driver]; } $driver = basename($driver); $class = 'Whups_Driver_' . $driver; if (class_exists($class)) { if (is_null($params)) { $params = Horde::getDriverConfig('tickets', $driver); } $this->_instances[$driver] = new $class($params); switch ($driver) { case 'Sql': $this->_instances[$driver]->setStorage($GLOBALS['injector']->getInstance('Horde_Core_Factory_Db')->create('whups', 'tickets')); } return $this->_instances[$driver]; } else { throw new Whups_Exception(sprintf('No such backend "%s" found', $driver)); } }