/usr/share/horde/nag/lib/Factory/Driver.php is in php-horde-nag 4.2.7-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | <?php
/**
* Horde_Injector based factory for Nag_Driver.
*/
class Nag_Factory_Driver extends Horde_Core_Factory_Base
{
/**
* Instances.
*
* @var array
*/
private $_instances = array();
/**
* 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;
}
}
|