Пример #1
0
 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);
 }
Пример #2
0
 /**
  * Attempts to return a concrete instance.
  *
  * @param string $renderer  Either the tree renderer driver or a full
  *                          class name to use.
  * @param array $params     Any additional parameters the constructor
  *                          needs. Either 'name' or 'tree' must be
  *                          specified. Common parameters are:
  *   - name: (string) The name of this tree instance.
  *   - tree: (Horde_Tree) An existing tree object.
  *   - session: (array) Callbacks used to store session data. Must define
  *              two keys: 'get' and 'set'. Function definitions:
  *              (string) = get([string - Instance], [string - ID]);
  *              set([string - Instance], [string - ID], [boolean - value]);
  *              DEFAULT: No session storage
  *
  * @return Horde_Tree  The newly created concrete instance.
  * @throws Horde_Tree_Exception
  */
 public static function factory($renderer, $params = array())
 {
     if (!isset($params['tree']) && !isset($params['name'])) {
         throw new BadFunctionCallException('Either "name" or "tree" parameters must be specified.');
     }
     if (isset($params['tree'])) {
         $tree = $params['tree'];
         unset($params['tree']);
     } else {
         $tree = new Horde_Tree($params['name'], isset($params['session']) ? $params['session'] : array());
         unset($params['name']);
     }
     unset($params['session']);
     $ob = null;
     /* Base drivers (in Tree/ directory). */
     $class = __CLASS__ . '_' . Horde_String::ucfirst($renderer);
     if (class_exists($class)) {
         $ob = new $class($tree, $params);
     } else {
         /* Explicit class name, */
         $class = $renderer;
         if (class_exists($class)) {
             $ob = new $class($tree, $params);
         }
     }
     if ($ob) {
         if ($ob->isSupported()) {
             return $ob;
         }
         $params['tree'] = $tree;
         return self::factory($ob->fallback(), $params);
     }
     throw new Horde_Tree_Exception('Horde_Tree renderer not found: ' . $renderer);
 }
Пример #3
0
 /**
  * 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);
 }
Пример #4
0
 /**
  * Return an Kolab_Driver instance.
  *
  * @return Kolab_Driver
  */
 public function create(Horde_Injector $injector)
 {
     $driver = Horde_String::ucfirst($GLOBALS['conf']['storage']['driver']);
     $signature = serialize(array($driver, $GLOBALS['conf']['storage']['params']['driverconfig']));
     if (empty($this->_instances[$signature])) {
         switch ($driver) {
             case 'Sql':
                 try {
                     if ($GLOBALS['conf']['storage']['params']['driverconfig'] == 'horde') {
                         $db = $injector->getInstance('Horde_Db_Adapter');
                     } else {
                         $db = $injector->getInstance('Horde_Core_Factory_Db')->create('kolab', 'storage');
                     }
                 } catch (Horde_Exception $e) {
                     throw new Kolab_Exception($e);
                 }
                 $params = array('db' => $db);
                 break;
             case 'Ldap':
                 try {
                     $params = array('ldap' => $injector->getIntance('Horde_Core_Factory_Ldap')->create('kolab', 'storage'));
                 } catch (Horde_Exception $e) {
                     throw new Kolab_Exception($e);
                 }
                 break;
         }
         $class = 'Kolab_Driver_' . $driver;
         $this->_instances[$signature] = new $class($params);
     }
     return $this->_instances[$signature];
 }
Пример #5
0
 /**
  * Return a Nag_Tasklists instance.
  *
  * @return Nag_Tasklists
  */
 public function create()
 {
     if (!isset($GLOBALS['conf']['tasklists']['driver'])) {
         $driver = 'Default';
     } else {
         $driver = Horde_String::ucfirst($GLOBALS['conf']['tasklists']['driver']);
     }
     if (empty($this->_instances[$driver])) {
         $class = 'Nag_Tasklists_' . $driver;
         if (class_exists($class)) {
             $params = array();
             if (!empty($GLOBALS['conf']['share']['auto_create'])) {
                 $params['auto_create'] = true;
             }
             switch ($driver) {
                 case 'Default':
                     $params['identity'] = $this->_injector->getInstance('Horde_Core_Factory_Identity')->create();
                     break;
             }
             $this->_instances[$driver] = new $class($GLOBALS['nag_shares'], $GLOBALS['registry']->getAuth(), $params);
         } else {
             throw new Nag_Exception(sprintf('Unable to load the definition of %s.', $class));
         }
     }
     return $this->_instances[$driver];
 }
 /**
  * Upgrade.
  */
 public function up()
 {
     $sql = 'UPDATE ulaform_forms SET form_action = ? WHERE form_id = ?';
     foreach ($this->select('SELECT form_id, form_action FROM ulaform_forms') as $form) {
         $values = array(Horde_String::ucfirst($form['form_action']), $form['form_id']);
         $this->execute($sql, $values);
     }
 }
Пример #7
0
 /**
  * Attempts to return a concrete instance based on $driver.
  *
  * @deprecated
  *
  * @param mixed $driver  The type of concrete subclass to return. This
  *                       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 subclass might need.
  *
  * @return VFS  The newly created concrete VFS instance.
  * @throws Horde_Vfs_Exception
  */
 public static function factory($driver, $params = array())
 {
     $class = 'Horde_Vfs_' . basename(Horde_String::ucfirst($driver));
     if (class_exists($class)) {
         return new $class($params);
     }
     throw new Horde_Vfs_Exception('Class definition of ' . $class . ' not found.');
 }
Пример #8
0
 /**
  * Attempts to return a concrete Horde_SpellChecker instance based on
  * $driver.
  *
  * @deprecated
  *
  * @param string $driver  The type of concrete subclass to return.
  * @param array $params   A hash containing any additional configuration
  *                        or connection parameters a subclass might need.
  *
  * @return Horde_SpellChecker  The newly created instance.
  * @throws Horde_Exception
  */
 public static function factory($driver, $params = array())
 {
     $class = 'Horde_SpellChecker_' . Horde_String::ucfirst(basename($driver));
     if (class_exists($class)) {
         return new $class($params);
     }
     throw new Horde_Exception('Driver ' . $driver . ' not found');
 }
Пример #9
0
 /**
  * Gets the configuration for a MIME type.
  *
  * @param string $type  The MIME type.
  * @param string $app   The current Horde application.
  *
  * @return array  The driver and a list of configuration parameters.
  */
 public function getViewerConfig($type, $app)
 {
     $config = $this->_getDriver($type, $app);
     $config['driver'] = Horde_String::ucfirst($config['driver']);
     $driver = $config['app'] == 'horde' ? $config['driver'] : $config['app'] . '_Mime_Viewer_' . $config['driver'];
     $params = array_merge($config, array('charset' => 'UTF-8', 'temp_file' => array('Horde', 'getTempFile'), 'text_filter' => array($this->_injector->getInstance('Horde_Core_Factory_TextFilter'), 'filter')));
     switch ($config['driver']) {
         case 'Deb':
         case 'Rpm':
             $params['monospace'] = 'fixed';
             break;
         case 'Html':
             $params['browser'] = $GLOBALS['browser'];
             $params['dns'] = $this->_injector->getInstance('Net_DNS2_Resolver');
             $params['external_callback'] = array('Horde', 'externalUrl');
             break;
         case 'Ooo':
             $params['temp_dir'] = Horde::getTempDir();
             $params['zip'] = Horde_Compress::factory('Zip');
             break;
         case 'Rar':
             $params['monospace'] = 'fixed';
             $params['rar'] = Horde_Compress::factory('Rar');
             break;
         case 'Report':
         case 'Security':
             $params['viewer_callback'] = array($this, 'getViewerCallback');
             break;
         case 'Syntaxhighlighter':
             if ($config['app'] == 'horde') {
                 $driver = 'Horde_Core_Mime_Viewer_Syntaxhighlighter';
             }
             $params['registry'] = $GLOBALS['registry'];
             break;
         case 'Tgz':
             $params['gzip'] = Horde_Compress::factory('Gzip');
             $params['monospace'] = 'fixed';
             $params['tar'] = Horde_Compress::factory('Tar');
             break;
         case 'Tnef':
             $params['tnef'] = Horde_Compress::factory('Tnef');
             break;
         case 'Vcard':
             if ($config['app'] == 'horde') {
                 $driver = 'Horde_Core_Mime_Viewer_Vcard';
             }
             $params['browser'] = $GLOBALS['browser'];
             $params['notification'] = $GLOBALS['notification'];
             $params['prefs'] = $GLOBALS['prefs'];
             $params['registry'] = $GLOBALS['registry'];
             break;
         case 'Zip':
             $params['monospace'] = 'fixed';
             $params['zip'] = Horde_Compress::factory('Zip');
             break;
     }
     return array($this->_getDriverName($driver, 'Horde_Mime_Viewer'), $params);
 }
Пример #10
0
 public function scanForUnits($token)
 {
     foreach ($this->unitScanner as $scannerItem => $scannerTag) {
         if (preg_match($scannerItem, $token->word)) {
             $class = 'Horde_Date_Repeater_' . Horde_String::ucfirst($scannerTag);
             return new $class($scannerTag);
         }
     }
 }
Пример #11
0
 /**
  * The main entry point for the application.
  *
  * @param array $parameters A list of named configuration parameters.
  * <pre>
  * 'parser'   - (array)     Parser configuration parameters.
  *   'class'  - (string)    The class name of the parser to use.
  * 'output'   - (Horde_Cli) The output handler.
  * </pre>
  */
 public static function main(array $parameters = array())
 {
     $modular = self::_prepareModular($parameters);
     if (empty($parameters['output'])) {
         if (!class_exists('Horde_Cli')) {
             throw new Horde_Kolab_Cli_Exception('The Horde_Cli package seems to be missing (Class Horde_Cli is missing)!');
         }
         $cli = Horde_Cli::init();
     } else {
         $cli = $parameters['output'];
     }
     $parser = $modular->createParser();
     list($options, $arguments) = $parser->parseArgs();
     if (count($arguments) == 0) {
         $parser->printHelp();
     } else {
         try {
             if (!empty($options['config'])) {
                 if (!file_exists($options['config'])) {
                     throw new Horde_Kolab_Cli_Exception(sprintf('The specified config file %s does not exist!', $options['config']));
                 }
                 global $conf;
                 include $options['config'];
                 foreach ($conf as $key => $value) {
                     $options->ensureValue($key, $value);
                 }
             }
             if (empty($options['host'])) {
                 $options['host'] = 'localhost';
             }
             if (empty($options['driver'])) {
                 $options['driver'] = 'horde';
             }
             $world = array();
             foreach ($modular->getModules() as $module) {
                 $modular->getProvider()->getModule($module)->handleArguments($options, $arguments, $world);
             }
             if (!empty($options['timed']) && class_exists('Horde_Support_Timer')) {
                 $timer = new Horde_Support_Timer();
                 $timer->push();
             } else {
                 $timer = false;
             }
             $modular->getProvider()->getModule(Horde_String::ucfirst($arguments[0]))->run($cli, $options, $arguments, $world);
             if (!empty($options['timed'])) {
                 if ($timer) {
                     $cli->message(floor($timer->pop() * 1000) . ' ms');
                 } else {
                     $cli->message('The class Horde_Support_Timer seems to be missing!');
                 }
             }
         } catch (Horde_Cli_Modular_Exception $e) {
             $parser->printHelp();
         }
     }
 }
Пример #12
0
 /**
  * Create a task handler.
  *
  * @param string $type      The task type.
  * @param array  $arguments The constructor arguments.
  *
  * @return Horde_Pear_Package_Task The task instance.
  */
 public function createTask($type, $arguments)
 {
     $class = 'Horde_Pear_Package_Task_' . Horde_String::ucfirst($type);
     if (class_exists($class)) {
         $reflectionObj = new ReflectionClass($class);
         return $reflectionObj->newInstanceArgs($arguments);
     } else {
         throw new InvalidArgumentException(sprintf('No task %s!', $type));
     }
 }
Пример #13
0
 /**
  * Attempts to return a concrete Horde_Kolab_Resource_Getfreebusy instance
  * based on $driver.
  *
  * @param mixed $driver The type of concrete
  *                      Horde_Kolab_Resource_Getfreebusy subclass to
  *                      return.
  * @param array $params A hash containing any additional configuration or
  *                      connection parameters a subclass might need.
  *
  * @return Horde_Kolab_Resource_Getfreebusy The newly created concrete
  *                                          Horde_Kolab_Resource_Getfreebusy
  *                                          instance, or false an error.
  */
 public static function factory($driver, $params = array())
 {
     $driver = Horde_String::ucfirst(basename($driver));
     $class = $driver == 'None' ? 'Horde_Kolab_Resource_Freebusy' : 'Horde_Kolab_Resource_Freebusy_' . $driver;
     require_once __DIR__ . '/Freebusy/' . $driver . '.php';
     if (!class_exists($class)) {
         $class = 'Horde_Kolab_Resource_Freebusy';
     }
     return new $class($params);
 }
Пример #14
0
 /**
  * Computes diffs between sequences of strings.
  *
  * @param string $engine     Name of the diffing engine to use.  'auto'
  *                           will automatically select the best.
  * @param array $params      Parameters to pass to the diffing engine.
  *                           Normally an array of two arrays, each
  *                           containing the lines from a file.
  */
 public function __construct($engine, $params)
 {
     if ($engine == 'auto') {
         $engine = extension_loaded('xdiff') ? 'Xdiff' : 'Native';
     } else {
         $engine = Horde_String::ucfirst(basename($engine));
     }
     $class = 'Horde_Text_Diff_Engine_' . $engine;
     $diff_engine = new $class();
     $this->_edits = call_user_func_array(array($diff_engine, 'diff'), $params);
 }
Пример #15
0
 /**
  *
  */
 protected function _setup()
 {
     parent::_setup();
     $view = $this->getView();
     $view->addTemplatePath(array($GLOBALS['fs_base'] . '/app/views/App', $GLOBALS['fs_base'] . '/app/views/App/apps/' . $this->_matchDict->app));
     $view->appname = $this->_matchDict->app;
     $view->hasAuthors = file_exists($GLOBALS['fs_base'] . '/app/views/App/apps/' . $this->_matchDict->app . '/appauthors.html.php');
     $view->hasDocs = file_exists($GLOBALS['fs_base'] . '/app/views/App/apps/' . $this->_matchDict->app . '/docs');
     $view->hasScreenshots = file_exists($GLOBALS['fs_base'] . '/app/views/App/apps/' . $this->_matchDict->app . '/appscreenshots.html.php');
     $view->hasRoadmap = file_exists($GLOBALS['fs_base'] . '/app/views/App/apps/' . $this->_matchDict->app . '/approadmap.html.php');
     // @TODO: Look this up in some kind of config/lookup array.
     $view->appnameHuman = in_array($this->_matchDict->app, array('imp', 'mimp', 'dimp')) ? Horde_String::upper($this->_matchDict->app) : Horde_String::ucfirst($this->_matchDict->app);
 }
Пример #16
0
 /**
  * Attempts to return a concrete Horde_Compress_Base instance based on
  * $driver.
  *
  * @param string $driver  Either a driver name, or the full class name to
  *                        use (class must extend Horde_Compress_Base).
  * @param array $params   Hash containing any additional configuration
  *                        or parameters a subclass needs.
  *
  * @return Horde_Compress_Base  The newly created concrete instance.
  * @throws Horde_Compress_Exception
  */
 public static function factory($driver, $params = null)
 {
     /* Base drivers (in Compress/ directory). */
     $class = __CLASS__ . '_' . Horde_String::ucfirst($driver);
     if (@class_exists($class)) {
         return new $class($params);
     }
     /* Explicit class name. */
     if (@class_exists($driver)) {
         return new $driver($params);
     }
     throw new Horde_Compress_Exception(__CLASS__ . ': Class definition of ' . $driver . ' not found.');
 }
Пример #17
0
 /**
  * Constructor.
  *
  * @param array $acl  The folder ACL as provided by the driver.
  */
 public function __construct(array $acl)
 {
     foreach ($acl as $user => $rights) {
         if (substr($user, 0, 6) == 'group:') {
             $this->_acl[] = new Horde_Perms_Permission_Kolab_Acl_Group($rights, substr($user, 6));
         } elseif ($user == 'anyone' || $user == 'anonymous') {
             $class = 'Horde_Perms_Permission_Kolab_Acl_' . Horde_String::ucfirst($user);
             $this->_acl[] = new $class($rights);
         } else {
             $this->_acl[] = new Horde_Perms_Permission_Kolab_Acl_User($rights, $user);
         }
     }
 }
Пример #18
0
 /**
  * Attempts to return a concrete instance based on $driver.
  *
  * @deprecated
  *
  * @param string $driver  Either a driver name, or the full class name to
  *                        use (class must extend Horde_Text_Filter_Base).
  * @param array $params   A hash containing any additional configuration
  *                        parameters a subclass might need.
  *
  * @return Horde_Text_Filter_Base  The newly created concrete instance.
  * @throws Horde_Text_Filter_Exception
  */
 public static function factory($driver, $params = array())
 {
     /* Base drivers (in Filter/ directory). */
     $class = __CLASS__ . '_' . Horde_String::ucfirst(basename($driver));
     if (class_exists($class)) {
         return new $class($params);
     }
     /* Explicit class name, */
     $class = $driver;
     if (class_exists($class)) {
         return new $class($params);
     }
     throw new Horde_Text_Filter_Exception(__CLASS__ . ': Class definition of ' . $driver . ' not found.');
 }
Пример #19
0
 public function getRequestConfiguration(Horde_Injector $injector)
 {
     $request = $injector->getInstance('Horde_Controller_Request');
     $registry = $injector->getInstance('Horde_Registry');
     $settingsFinder = $injector->getInstance('Horde_Core_Controller_SettingsFinder');
     $config = $injector->createInstance('Horde_Core_Controller_RequestConfiguration');
     $uri = substr($request->getPath(), strlen($registry->get('webroot', 'horde')));
     $uri = trim($uri, '/');
     if (strpos($uri, '/') === false) {
         $app = $uri;
     } else {
         list($app, ) = explode('/', $uri, 2);
     }
     $config->setApplication($app);
     // Check for route definitions.
     $fileroot = $registry->get('fileroot', $app);
     $routeFile = $fileroot . '/config/routes.php';
     if (!file_exists($routeFile)) {
         $config->setControllerName('Horde_Core_Controller_NotFound');
         return $config;
     }
     // Push $app onto the registry
     $registry->pushApp($app);
     // Application routes are relative only to the application. Let the
     // mapper know where they start.
     $this->_mapper->prefix = $registry->get('webroot', $app);
     // Set the application controller directory
     $this->_mapper->directory = $registry->get('fileroot', $app) . '/app/controllers';
     // Load application routes.
     $mapper = $this->_mapper;
     include $routeFile;
     if (file_exists($fileroot . '/config/routes.local.php')) {
         include $fileroot . '/config/routes.local.php';
     }
     // Match
     // @TODO Cache routes
     $path = $request->getPath();
     if (($pos = strpos($path, '?')) !== false) {
         $path = substr($path, 0, $pos);
     }
     $match = $this->_mapper->match($path);
     if (isset($match['controller'])) {
         $config->setControllerName(Horde_String::ucfirst($app) . '_' . Horde_String::ucfirst($match['controller']) . '_Controller');
         $config->setSettingsExporterName($settingsFinder->getSettingsExporterName($config->getControllerName()));
     } else {
         $config->setControllerName('Horde_Core_Controller_NotFound');
     }
     return $config;
 }
Пример #20
0
 /**
  * Return an Hermes_Driver instance.
  *
  * @return Hermes_Driver
  */
 public function create(Horde_Injector $injector)
 {
     $driver = $GLOBALS['conf']['storage']['driver'];
     $signature = serialize(array($driver, $GLOBALS['conf']['storage']['params']['driverconfig']));
     if (empty($this->_instances[$signature])) {
         if ($driver == 'sql' && $GLOBALS['conf']['storage']['params']['driverconfig'] == 'horde') {
             $params = array('db_adapter' => $injector->getInstance('Horde_Db_Adapter'));
         } else {
             throw new Horde_Exception('Using non-global db connection not yet supported.');
         }
         $class = 'Hermes_Driver_' . Horde_String::ucfirst($driver);
         $this->_instances[$signature] = new $class($params);
     }
     return $this->_instances[$signature];
 }
Пример #21
0
 /**
  * Creates a new mailbox driver instance.
  *
  * @param string $driver  The name of the driver to create an instance of.
  * @param array $params   Driver-specific parameters.
  *
  * @return Vilma_MailboxDriver  The new driver instance.
  * @throws Vilma_Exception
  */
 public static function factory($driver = null, $params = null)
 {
     if (is_null($driver)) {
         $driver = $GLOBALS['conf']['mailboxes']['driver'];
     }
     $driver = Horde_String::ucfirst(basename($driver));
     if (is_null($params)) {
         $params = $GLOBALS['conf']['mailboxes']['params'];
     }
     $class = 'Vilma_MailboxDriver_' . $driver;
     if (class_exists($class)) {
         return new $class($params);
     }
     throw new Vilma_Exception(sprintf('No such mailbox driver "%s" found', $driver));
 }
 /**
  * Computes diffs between sequences of strings.
  *
  * @param string $engine     Name of the diffing engine to use.  'auto'
  *                           will automatically select the best.
  * @param array $params      Parameters to pass to the diffing engine.
  *                           Normally an array of two arrays, each
  *                           containing the lines from a file.
  */
 public function __construct($engine, $params)
 {
     if ($engine == 'auto') {
         $engine = extension_loaded('xdiff') ? 'Xdiff' : 'Native';
     } else {
         $engine = Horde_String::ucfirst(basename($engine));
     }
     // Fugly; Include operational classes required for Text_Diff
     $classes = array('String.php', "Engine/{$engine}.php", 'Renderer/Inline.php', 'Op/Base.php', 'Op/Copy.php', 'Op/Change.php', 'Op/Add.php', 'Op/Delete.php');
     foreach ($classes as $class) {
         require_once MYBB_ROOT . "inc/3rdparty/diff/Diff/{$class}";
     }
     $class = 'Horde_Text_Diff_Engine_' . $engine;
     $diff_engine = new $class();
     $this->_edits = call_user_func_array(array($diff_engine, 'diff'), $params);
 }
Пример #23
0
 /**
  * Constructs a new instance.
  *
  * @param mixed $driver  This is the renderer subclass we will instantiate.
  *                       If an array is passed, the first element is the
  *                       library path and the second element is the driver
  *                       name.
  * @param array $params  Parameters specific to the subclass.
  *
  * @return Horde_Core_Ui_VarRenderer  A subclass instance.
  * @throws Horde_Exception
  */
 public static function factory($driver, $params = array())
 {
     if (is_array($driver)) {
         $app = $driver[0];
         $driver = $driver[1];
     }
     $driver = Horde_String::ucfirst(basename($driver));
     if (!empty($app)) {
         include_once $GLOBALS['registry']->get('fileroot', $app) . '/lib/Ui/VarRenderer/' . $driver . '.php';
     }
     $class = __CLASS__ . '_' . $driver;
     if (!class_exists($class)) {
         throw new LogicException('Class definition of ' . $class . ' not found.');
     }
     return new $class($params);
 }
Пример #24
0
 /**
  * Initialize the namespace elements.
  *
  * @return array The namespace elements.
  */
 private function _initializeData()
 {
     $namespace = array();
     foreach ($this->configuration as $element) {
         if ($element['type'] == Horde_Kolab_Storage_Folder_Namespace::SHARED && isset($element['prefix'])) {
             $namespace_element = new Horde_Kolab_Storage_Folder_Namespace_Element_SharedWithPrefix($element['name'], $element['delimiter'], $this->user, $element['prefix']);
         } else {
             $class = 'Horde_Kolab_Storage_Folder_Namespace_Element_' . Horde_String::ucfirst($element['type']);
             if (!class_exists($class)) {
                 throw new Horde_Kolab_Storage_Exception(sprintf('Unkown namespace type "%s"', $element['type']));
             }
             $namespace_element = new $class($element['name'], $element['delimiter'], $this->user);
         }
         $namespaces[] = $namespace_element;
     }
     return $namespaces;
 }
Пример #25
0
 /**
  * Return an Wicked_Driver instance.
  *
  * @param Horde_Injector $injector  An injector object.
  *
  * @return Wicked_Driver  A driver instance.
  * @throws Wicked_Exception
  */
 public function create(Horde_Injector $injector)
 {
     $driver = Horde_String::ucfirst($GLOBALS['conf']['storage']['driver']);
     if (empty($driver)) {
         throw new Wicked_Exception('Wicked is not configured');
     }
     $signature = serialize(array($driver, $GLOBALS['conf']['storage']['params']['driverconfig']));
     if (empty($this->_instances[$signature])) {
         switch ($driver) {
             case 'Sql':
                 $params = array('db' => $this->getDb($injector));
                 break;
         }
         $class = 'Wicked_Driver_' . $driver;
         $this->_instances[$signature] = new $class($params);
     }
     return $this->_instances[$signature];
 }
Пример #26
0
 /**
  * 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];
 }
Пример #27
0
 /**
  * Registers a listener with the notification object and includes
  * the necessary library file dynamically.
  *
  * @param string $listener  The name of the listener to attach. These
  *                          names must be unique; further listeners with
  *                          the same name will be ignored.
  * @param array $params     A hash containing any additional configuration
  *                          or connection parameters a listener driver
  *                          might need.
  * @param string $class     The class name from which the driver was
  *                          instantiated if not the default one. If given
  *                          you have to include the library file
  *                          containing this class yourself. This is useful
  *                          if you want the listener driver to be
  *                          overriden by an application's implementation
  *
  * @return Horde_Notification_Listener  The listener object.
  * @throws Horde_Exception
  */
 public function attach($listener, $params = null, $class = null)
 {
     if ($ob = $this->getListener($listener)) {
         return $ob;
     }
     if (is_null($class)) {
         $class = 'Horde_Notification_Listener_' . Horde_String::ucfirst(Horde_String::lower($listener));
     }
     if (class_exists($class)) {
         $this->_listeners[$listener] = new $class($params);
         if (!$this->_storage->exists($listener)) {
             $this->_storage->set($listener, array());
         }
         $this->_addTypes($listener);
         return $this->_listeners[$listener];
     }
     throw new Horde_Exception(sprintf('Notification listener %s not found.', $class));
 }
Пример #28
0
 /**
  * Attempts to return a concrete Horde_Crypt instance based on $driver.
  *
  * @param string $driver  Either a driver name, or the full class name to
  *                        use (class must extend Horde_Crypt).
  * @param array $params   A hash containing any additional configuration
  *                        or parameters a subclass might need.
  *
  * @return Horde_Crypt  The newly created concrete instance.
  * @throws Horde_Crypt_Exception
  */
 public static function factory($driver, $params = array())
 {
     /* Return a base Horde_Crypt object if no driver is specified. */
     if (empty($driver) || strcasecmp($driver, 'none') == 0) {
         return new Horde_Crypt();
     }
     /* Base drivers (in Crypt/ directory). */
     $class = __CLASS__ . '_' . Horde_String::ucfirst(basename($driver));
     if (class_exists($class)) {
         return new $class($params);
     }
     /* Explicit class name, */
     $class = $driver;
     if (class_exists($class)) {
         return new $class($params);
     }
     throw new Horde_Crypt_Exception(__CLASS__ . ': Class definition of ' . $driver . ' not found.');
 }
Пример #29
0
 /**
  * Purge old events.
  *
  * @throws Kronolith_Exception
  * @throws Horde_Exception_NotFound
  */
 public function execute()
 {
     /* Get the current time minus the number of days specified in
      * 'purge_events_keep'.  An event will be deleted if it has an end
      * time prior to this time. */
     $del_time = new Horde_Date($_SERVER['REQUEST_TIME']);
     $del_time->mday -= $GLOBALS['prefs']->getValue('purge_events_keep');
     /* Need to have Horde_Perms::DELETE on a calendar to delete events
      * from it */
     $calendars = Kronolith::listInternalCalendars(true, Horde_Perms::DELETE);
     /* Start building the search */
     $kronolith_driver = Kronolith::getDriver();
     $query = new StdClass();
     $query->start = null;
     $query->end = $del_time;
     $query->status = null;
     $query->calendars = array(Horde_String::ucfirst($GLOBALS['conf']['calendar']['driver']) => array_keys($calendars));
     $query->creator = $GLOBALS['registry']->getAuth();
     /* Perform the search */
     $days = Kronolith::search($query);
     $count = 0;
     foreach ($days as $events) {
         foreach ($events as $event) {
             /* Delete if no recurrence, or if we are past the last occurence */
             if (!$event->recurs() || $event->recurrence->nextRecurrence($del_time) == false) {
                 if ($event->calendar != $kronolith_driver->calendar) {
                     $kronolith_driver->open($event->calendar);
                 }
                 try {
                     $kronolith_driver->deleteEvent($event->id, true);
                     ++$count;
                 } catch (Exception $e) {
                     Horde::log($e, 'ERR');
                     throw $e;
                 }
             }
         }
     }
     $GLOBALS['notification']->push(sprintf(ngettext("Deleted %d event older than %d days.", "Deleted %d events older than %d days.", $count), $count, $GLOBALS['prefs']->getValue('purge_events_keep')));
 }
Пример #30
0
 /**
  * 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;
 }