*/
protected function _init()
{
- /* Add IMP-specific binders. */
- $binders = array(
- 'IMP_AuthImap' => new IMP_Injector_Binder_AuthImap(),
- 'IMP_Crypt_Pgp' => new IMP_Injector_Binder_Pgp(),
- 'IMP_Crypt_Smime' => new IMP_Injector_Binder_Smime(),
- 'IMP_Identity' => new IMP_Injector_Binder_Identity(),
- 'IMP_Imap_Tree' => new IMP_Injector_Binder_Imaptree(),
- 'IMP_Mail' => new IMP_Injector_Binder_Mail(),
- 'IMP_Quota' => new IMP_Injector_Binder_Quota(),
- 'IMP_Search' => new IMP_Injector_Binder_Search(),
- 'IMP_Sentmail' => new IMP_Injector_Binder_Sentmail()
+ /* Add IMP-specific factories. */
+ $factories = array(
+ 'IMP_AuthImap' => 'IMP_Injector_Factory_AuthImap',
+ 'IMP_Crypt_Pgp' => 'IMP_Injector_Factory_Pgp',
+ 'IMP_Crypt_Smime' => 'IMP_Injector_Factory_Smime',
+ 'IMP_Identity' => 'IMP_Injector_Factory_Identity',
+ 'IMP_Imap_Tree' => 'IMP_Injector_Factory_Imaptree',
+ 'IMP_Mail' => 'IMP_Injector_Factory_Mail',
+ 'IMP_Quota' => 'IMP_Injector_Factory_Quota',
+ 'IMP_Search' => 'IMP_Injector_Factory_Search',
+ 'IMP_Sentmail' => 'IMP_Injector_Factory_Sentmail'
);
- foreach ($binders as $key => $val) {
- $GLOBALS['injector']->addBinder($key, $val);
+ foreach ($factories as $key => $val) {
+ $GLOBALS['injector']->bindFactory($key, $val, 'create');
}
// Set default message character set.
+++ /dev/null
-<?php
-/**
- * Binder for Horde_Auth_Imap:: that uses IMP configuration.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @package IMP
- */
-class IMP_Injector_Binder_AuthImap implements Horde_Injector_Binder
-{
- /**
- * @throws IMP_Exception
- */
- public function create(Horde_Injector $injector)
- {
- $params = $GLOBALS['registry']->callByPackage('imp', 'server');
- if (is_null($params)) {
- throw new IMP_Exception('No mail parameters found.');
- }
-
- $params = array_merge(
- $params,
- $_SESSION['imp']['imap']['admin']['params'],
- array(
- 'default_user' => $GLOBALS['registry']->getAuth(),
- 'logger' => $injector->getInstance('Horde_Log_Logger')
- )
- );
-
- if (isset($params['admin_password'])) {
- $secret = $injector->getInstance('Horde_Secret');
- $params['admin_password'] = $secret->read($secret->getKey('imp'), $params['admin_password']);
- }
-
- return Horde_Auth::factory('imap', $params);
- }
-
- /**
- */
- public function equals(Horde_Injector_Binder $binder)
- {
- return false;
- }
-
-}
+++ /dev/null
-<?php
-/**
- * Binder for IMP's Identity object.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @package IMP
- */
-class IMP_Injector_Binder_Identity implements Horde_Injector_Binder
-{
- /**
- */
- public function create(Horde_Injector $injector)
- {
- return $injector->getInstance('Horde_Prefs_Identity')->getIdentity(null, 'imp');
- }
-
- /**
- */
- public function equals(Horde_Injector_Binder $binder)
- {
- return false;
- }
-
-}
+++ /dev/null
-<?php
-/**
- * Binder for IMP_Imap_Tree::.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @package IMP
- */
-class IMP_Injector_Binder_Imaptree implements Horde_Injector_Binder
-{
- /**
- * Injector.
- *
- * @var Horde_Injector
- */
- private $_injector;
-
- /**
- * If an IMP_Imap_Tree object is currently stored in the cache, re-create
- * that object. Else, create a new instance.
- */
- public function create(Horde_Injector $injector)
- {
- $this->_injector = $injector;
-
- $instance = null;
-
- if (empty($_SESSION['imp']['cache']['tree'])) {
- $_SESSION['imp']['cache']['tree'] = strval(new Horde_Support_Randomid());
- } else {
- /* Since IMAP tree generation is so expensive/time-consuming,
- * fallback to storing in the session even if no permanent cache
- * backend is setup. */
- $cache = $injector->getInstance('Horde_Cache');
- if ($cache instanceof Horde_Cache_Null) {
- $cache = $injector->getInstance('Horde_Cache_Session');
- }
- try {
- $instance = @unserialize($cache->get($_SESSION['imp']['cache']['tree'], 86400));
- } catch (Exception $e) {
- Horde::logMessage('Could not unserialize stored IMP_Imap_Tree object.', 'DEBUG');
- }
- }
-
- if (!($instance instanceof IMP_Imap_Tree)) {
- $instance = new IMP_Imap_Tree();
- }
-
- register_shutdown_function(array($this, 'shutdown'), $instance);
-
- return $instance;
- }
-
- /**
- * Store serialized version of object in the current session.
- */
- public function shutdown($instance)
- {
- /* Only need to store the object if the tree has changed. */
- if ($instance->changed) {
- $cache = $this->_injector->getInstance('Horde_Cache');
- if ($cache instanceof Horde_Cache_Null) {
- $cache = $this->_injector->getInstance('Horde_Cache_Session');
- }
- $cache->set($_SESSION['imp']['cache']['tree'], serialize($instance), 86400);
- }
- }
-
- public function equals(Horde_Injector_Binder $binder)
- {
- return false;
- }
-}
+++ /dev/null
-<?php
-/**
- * Binder for IMP's configuration of Horde_Mail::.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @package IMP
- */
-class IMP_Injector_Binder_Mail implements Horde_Injector_Binder
-{
- /**
- */
- public function create(Horde_Injector $injector)
- {
- /* We don't actually want to alter the contents of the $conf['mailer']
- * array, so we make a copy of the current settings. We will apply our
- * modifications (if any) to the copy, instead. */
- $params = $GLOBALS['conf']['mailer']['params'];
-
- /* Force the SMTP host and port value to the current SMTP server if
- * one has been selected for this connection. */
- if (!empty($_SESSION['imp']['smtp'])) {
- $params = array_merge($params, $_SESSION['imp']['smtp']);
- }
-
- /* If SMTP authentication has been requested, use either the username
- * and password provided in the configuration or populate the username
- * and password fields based on the current values for the user. Note
- * that we assume that the username and password values from the
- * current IMAP / POP3 connection are valid for SMTP authentication as
- * well. */
- if (!empty($params['auth']) && empty($params['username'])) {
- $imap_ob = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
- $params['username'] = $imap_ob->getParam('username');
- $params['password'] = $imap_ob->getParam('password');
- }
-
- $transport = $GLOBALS['conf']['mailer']['type'];
- $class = 'Horde_Mail_Transport_' . ucfirst($transport);
- if (class_exists($class)) {
- return new $class($params);
- }
- throw new Horde_Exception('Unable to find class for transport ' . $transport);
- }
-
- /**
- */
- public function equals(Horde_Injector_Binder $binder)
- {
- return false;
- }
-}
+++ /dev/null
-<?php
-/**
- * Binder for IMP_Crypt_Pgp.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @package IMP
- */
-class IMP_Injector_Binder_Pgp implements Horde_Injector_Binder
-{
- /**
- */
- public function create(Horde_Injector $injector)
- {
- $params = array(
- 'program' => $GLOBALS['conf']['gnupg']['path']
- );
-
- if (isset($GLOBALS['conf']['http']['proxy']['proxy_host'])) {
- $params['proxy_host'] = $GLOBALS['conf']['http']['proxy']['proxy_host'];
- if (isset($GLOBALS['conf']['http']['proxy']['proxy_port'])) {
- $params['proxy_port'] = $GLOBALS['conf']['http']['proxy']['proxy_port'];
- }
- }
-
- return $injector->getInstance('Horde_Core_Factory_Crypt')->create('IMP_Crypt_Pgp', $params);
- }
-
- /**
- */
- public function equals(Horde_Injector_Binder $binder)
- {
- return false;
- }
-
-}
+++ /dev/null
-<?php
-/**
- * Binder for IMP_Quota::.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @package IMP
- */
-class IMP_Injector_Binder_Quota implements Horde_Injector_Binder
-{
- /**
- */
- public function create(Horde_Injector $injector)
- {
- $driver = $_SESSION['imp']['imap']['quota']['driver'];
- $params = isset($_SESSION['imp']['imap']['quota']['params'])
- ? $_SESSION['imp']['imap']['quota']['params']
- : array();
-
- /* If 'password' exists in params, it has been encrypted in the
- * session so we need to decrypt. */
- if (isset($params['password'])) {
- $secret = $injector->getInstance('Horde_Secret');
- $params['password'] = $secret->read($secret->getKey('imp'), $params['password']);
- }
-
- switch (Horde_String::lower($driver)) {
- case 'imap':
- $params['imap_ob'] = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
- $params['mbox'] = $injector->getInstance('IMP_Search')->isSearchMbox(IMP::$mailbox)
- ? 'INBOX'
- : IMP::$mailbox;
- break;
-
- case 'maildir':
- $params['username'] = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->getParam('username');
- break;
-
- case 'sql':
- $params['db'] = $injector->getInstance('Horde_Core_Factory_Db')->create('imp', $params);
- break;
- }
-
- return IMP_Quota::factory($driver, $params);
- }
-
- /**
- */
- public function equals(Horde_Injector_Binder $binder)
- {
- return false;
- }
-
-}
+++ /dev/null
-<?php
-/**
- * Binder for IMP_Search::.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @package IMP
- */
-class IMP_Injector_Binder_Search implements Horde_Injector_Binder
-{
- /**
- * Injector.
- *
- * @var Horde_Injector
- */
- private $_injector;
-
- /**
- * If an IMP_Search object is currently stored in the session, re-create
- * that object. Else, create a new instance.
- *
- * @param Horde_Injecton $injector Parent injector.
- */
- public function create(Horde_Injector $injector)
- {
- $this->_injector = $injector;
-
- $instance = null;
-
- if (!empty($_SESSION['imp']['search'])) {
- try {
- $instance = @unserialize($_SESSION['imp']['search']);
- } catch (Exception $e) {
- Horde::logMessage('Could not unserialize stored IMP_Search object.', 'DEBUG');
- }
- }
-
- if (is_null($instance)) {
- $instance = new IMP_Search();
- }
-
- register_shutdown_function(array($this, 'shutdown'), $instance);
-
- return $instance;
- }
-
- /**
- * Store serialized version of object in the current session.
- */
- public function shutdown($instance)
- {
- /* Only need to store the object if the object has changed. */
- if ($instance->changed) {
- $_SESSION['imp']['search'] = serialize($instance);
- }
- }
-
- /**
- */
- public function equals(Horde_Injector_Binder $binder)
- {
- return false;
- }
-
-}
+++ /dev/null
-<?php
-/**
- * Binder for IMP_Sentmail::.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @package IMP
- */
-class IMP_Injector_Binder_Sentmail implements Horde_Injector_Binder
-{
- /**
- */
- public function create(Horde_Injector $injector)
- {
- $driver = empty($GLOBALS['conf']['sentmail']['driver'])
- ? 'Null'
- : $GLOBALS['conf']['sentmail']['driver'];
- $params = Horde::getDriverConfig('sentmail', $driver);
-
- if (strcasecmp($driver, 'Sql') === 0) {
- $params['db'] = $injector->getInstance('Horde_Core_Factory_Db')->create('imp', 'sentmail');
- } elseif (strcasecmp($driver, 'None') === 0) {
- $driver = 'Null';
- }
-
- return IMP_Sentmail::factory($driver, $params);
- }
-
- /**
- */
- public function equals(Horde_Injector_Binder $binder)
- {
- return false;
- }
-
-}
+++ /dev/null
-<?php
-/**
- * Binder for IMP_Crypt_Smime.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/gpl.html GPL
- * @package IMP
- */
-class IMP_Injector_Binder_Smime implements Horde_Injector_Binder
-{
- /**
- */
- public function create(Horde_Injector $injector)
- {
- return $injector->getInstance('Horde_Core_Factory_Crypt')->create('IMP_Crypt_Smime');
- }
-
- /**
- */
- public function equals(Horde_Injector_Binder $binder)
- {
- return false;
- }
-
-}
--- /dev/null
+<?php
+/**
+ * A Horde_Injector based Horde_Auth_Imap:: factory.
+ *
+ * PHP version 5
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+
+/**
+ * A Horde_Injector based Horde_Auth_Imap:: factory.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+class IMP_Injector_Factory_AuthImap
+{
+ /**
+ * Return the Horde_Auth_Imap:: instance that uses IMP configuration.
+ *
+ * @return Horde_Auth_Imap The singleton instance.
+ * @throws IMP_Exception
+ */
+ public function create(Horde_Injector $injector)
+ {
+ $params = $GLOBALS['registry']->callByPackage('imp', 'server');
+ if (is_null($params)) {
+ throw new IMP_Exception('No server parameters found.');
+ }
+
+ $params = array_merge(
+ $params,
+ $_SESSION['imp']['imap']['admin']['params'],
+ array(
+ 'default_user' => $GLOBALS['registry']->getAuth(),
+ 'logger' => $injector->getInstance('Horde_Log_Logger')
+ )
+ );
+
+ if (isset($params['admin_password'])) {
+ $secret = $injector->getInstance('Horde_Secret');
+ $params['admin_password'] = $secret->read($secret->getKey('imp'), $params['admin_password']);
+ }
+
+ return Horde_Auth::factory('imap', $params);
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * A Horde_Injector based factory for IMP's identity object.
+ *
+ * PHP version 5
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+
+/**
+ * A Horde_Injector based factory for IMP's identity object.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+class IMP_Injector_Factory_Identity
+{
+ /**
+ * Return the IMP identity instance.
+ *
+ * @return IMP_Prefs_Identity The singleton instance.
+ */
+ public function create(Horde_Injector $injector)
+ {
+ return $injector->getInstance('Horde_Prefs_Identity')->getIdentity(null, 'imp');
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * A Horde_Injector based factory for the IMP_Imap_Tree object.
+ *
+ * PHP version 5
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+
+/**
+ * A Horde_Injector based factory for the IMP_Imap_Tree object.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+class IMP_Injector_Factory_Imaptree
+{
+ /**
+ * Return the IMP_Imap_Tree object.
+ *
+ * @return IMP_Imap_Tree The singleton instance.
+ */
+ public function create(Horde_Injector $injector)
+ {
+ $instance = null;
+
+ /* If an IMP_Imap_Tree object is currently stored in the cache,
+ * re-create that object. Else, create a new instance. */
+ if (empty($_SESSION['imp']['cache']['tree'])) {
+ $_SESSION['imp']['cache']['tree'] = strval(new Horde_Support_Randomid());
+ } else {
+ /* Since IMAP tree generation is so expensive/time-consuming,
+ * fallback to storing in the session even if no permanent cache
+ * backend is setup. */
+ $cache = $injector->getInstance('Horde_Cache');
+ if ($cache instanceof Horde_Cache_Null) {
+ $cache = $injector->getInstance('Horde_Cache_Session');
+ }
+ try {
+ $instance = @unserialize($cache->get($_SESSION['imp']['cache']['tree'], 86400));
+ } catch (Exception $e) {
+ Horde::logMessage('Could not unserialize stored IMP_Imap_Tree object.', 'DEBUG');
+ }
+ }
+
+ if (!($instance instanceof IMP_Imap_Tree)) {
+ $instance = new IMP_Imap_Tree();
+ }
+
+ register_shutdown_function(array($this, 'shutdown'), $instance, $injector);
+
+ return $instance;
+ }
+
+ /**
+ * Store serialized version of object in the current session.
+ *
+ * @param IMP_Imap_Tree $instance Tree object.
+ * @param Horde_Injector $injector Injector object.
+ */
+ public function shutdown($instance, $injector)
+ {
+ /* Only need to store the object if the tree has changed. */
+ if ($instance->changed) {
+ $cache = $injector->getInstance('Horde_Cache');
+ if ($cache instanceof Horde_Cache_Null) {
+ $cache = $injector->getInstance('Horde_Cache_Session');
+ }
+ $cache->set($_SESSION['imp']['cache']['tree'], serialize($instance), 86400);
+ }
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * A Horde_Injector based factory for IMP's configuration of Horde_Mail::
+ *
+ * PHP version 5
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+
+/**
+ * A Horde_Injector based factory for IMP's configuration of Horde_Mail::
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+class IMP_Injector_Factory_Mail
+{
+ /**
+ * Return the Horde_Mail instance.
+ *
+ * @return Horde_Mail The singleton instance.
+ * @throws Horde_Exception
+ */
+ public function create(Horde_Injector $injector)
+ {
+ /* We don't actually want to alter the contents of the $conf['mailer']
+ * array, so we make a copy of the current settings. We will apply our
+ * modifications (if any) to the copy, instead. */
+ $params = $GLOBALS['conf']['mailer']['params'];
+
+ /* Force the SMTP host and port value to the current SMTP server if
+ * one has been selected for this connection. */
+ if (!empty($_SESSION['imp']['smtp'])) {
+ $params = array_merge($params, $_SESSION['imp']['smtp']);
+ }
+
+ /* If SMTP authentication has been requested, use either the username
+ * and password provided in the configuration or populate the username
+ * and password fields based on the current values for the user. Note
+ * that we assume that the username and password values from the
+ * current IMAP / POP3 connection are valid for SMTP authentication as
+ * well. */
+ if (!empty($params['auth']) && empty($params['username'])) {
+ $imap_ob = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+ $params['username'] = $imap_ob->getParam('username');
+ $params['password'] = $imap_ob->getParam('password');
+ }
+
+ $transport = $GLOBALS['conf']['mailer']['type'];
+ $class = 'Horde_Mail_Transport_' . ucfirst($transport);
+ if (class_exists($class)) {
+ return new $class($params);
+ }
+
+ throw new Horde_Exception('Unable to find class for transport ' . $transport);
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * A Horde_Injector based factory for the IMP_Crypt_Pgp object.
+ *
+ * PHP version 5
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+
+/**
+ * A Horde_Injector based factory for the IMP_Crypt_Pgp object.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+class IMP_Injector_Factory_Pgp
+{
+ /**
+ * Return the IMP_Crypt_Pgp instance.
+ *
+ * @return IMP_Crypt_Pgp The singleton instance.
+ */
+ public function create(Horde_Injector $injector)
+ {
+ $params = array(
+ 'program' => $GLOBALS['conf']['gnupg']['path']
+ );
+
+ if (isset($GLOBALS['conf']['http']['proxy']['proxy_host'])) {
+ $params['proxy_host'] = $GLOBALS['conf']['http']['proxy']['proxy_host'];
+ if (isset($GLOBALS['conf']['http']['proxy']['proxy_port'])) {
+ $params['proxy_port'] = $GLOBALS['conf']['http']['proxy']['proxy_port'];
+ }
+ }
+
+ return $injector->getInstance('Horde_Core_Factory_Crypt')->create('IMP_Crypt_Pgp', $params);
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * A Horde_Injector based factory for the IMP_Quota object.
+ *
+ * PHP version 5
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+
+/**
+ * A Horde_Injector based factory for the IMP_Quota object.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+class IMP_Injector_Factory_Quota
+{
+ /**
+ * Return the IMP_Quota instance.
+ *
+ * @return IMP_Quota The singleton instance.
+ */
+ public function create(Horde_Injector $injector)
+ {
+ $driver = $_SESSION['imp']['imap']['quota']['driver'];
+ $params = isset($_SESSION['imp']['imap']['quota']['params'])
+ ? $_SESSION['imp']['imap']['quota']['params']
+ : array();
+
+ /* If 'password' exists in params, it has been encrypted in the
+ * session so we need to decrypt. */
+ if (isset($params['password'])) {
+ $secret = $injector->getInstance('Horde_Secret');
+ $params['password'] = $secret->read($secret->getKey('imp'), $params['password']);
+ }
+
+ switch (Horde_String::lower($driver)) {
+ case 'imap':
+ $params['imap_ob'] = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
+ $params['mbox'] = $injector->getInstance('IMP_Search')->isSearchMbox(IMP::$mailbox)
+ ? 'INBOX'
+ : IMP::$mailbox;
+ break;
+
+ case 'maildir':
+ $params['username'] = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->getParam('username');
+ break;
+
+ case 'sql':
+ $params['db'] = $injector->getInstance('Horde_Core_Factory_Db')->create('imp', $params);
+ break;
+ }
+
+ return IMP_Quota::factory($driver, $params);
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * A Horde_Injector based factory for the IMP_Search object.
+ *
+ * PHP version 5
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+
+/**
+ * A Horde_Injector based factory for the IMP_Search object.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+class IMP_Injector_Factory_Search
+{
+ /**
+ * Return the IMP_Search instance.
+ *
+ * @return IMP_Search The singleton instance.
+ */
+ public function create(Horde_Injector $injector)
+ {
+ $instance = null;
+
+ if (!empty($_SESSION['imp']['search'])) {
+ try {
+ $instance = @unserialize($_SESSION['imp']['search']);
+ } catch (Exception $e) {
+ Horde::logMessage('Could not unserialize stored IMP_Search object.', 'DEBUG');
+ }
+ }
+
+ if (is_null($instance)) {
+ $instance = new IMP_Search();
+ }
+
+ register_shutdown_function(array($this, 'shutdown'), $instance, $injector);
+
+ return $instance;
+ }
+
+ /**
+ * Store serialized version of object in the current session.
+ *
+ * @param IMP_Search $instance Tree object.
+ * @param Horde_Injector $injector Injector object.
+ */
+ public function shutdown($instance, $injector)
+ {
+ /* Only need to store the object if the object has changed. */
+ if ($instance->changed) {
+ $_SESSION['imp']['search'] = serialize($instance);
+ }
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * A Horde_Injector based factory for the IMP_Sentmail object.
+ *
+ * PHP version 5
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+
+/**
+ * A Horde_Injector based factory for the IMP_Sentmail object.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+class IMP_Injector_Factory_Sentmail
+{
+ /**
+ * Return the IMP_Sentmail instance.
+ *
+ * @return IMP_Sentmail The singleton instance.
+ */
+ public function create(Horde_Injector $injector)
+ {
+ $driver = empty($GLOBALS['conf']['sentmail']['driver'])
+ ? 'Null'
+ : $GLOBALS['conf']['sentmail']['driver'];
+ $params = Horde::getDriverConfig('sentmail', $driver);
+
+ if (strcasecmp($driver, 'Sql') === 0) {
+ $params['db'] = $injector->getInstance('Horde_Core_Factory_Db')->create('imp', 'sentmail');
+ } elseif (strcasecmp($driver, 'None') === 0) {
+ $driver = 'Null';
+ }
+
+ return IMP_Sentmail::factory($driver, $params);
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * A Horde_Injector based factory for the IMP_Crypt_Smime object.
+ *
+ * PHP version 5
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+
+/**
+ * A Horde_Injector based factory for the IMP_Crypt_Smime object.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @link http://pear.horde.org/index.php?package=IMP
+ * @package IMP
+ */
+class IMP_Injector_Factory_Smime
+{
+ /**
+ * Return the IMP_Crypt_Smime instance.
+ *
+ * @return IMP_Crypt_Smime The singleton instance.
+ */
+ public function create(Horde_Injector $injector)
+ {
+ return $injector->getInstance('Horde_Core_Factory_Crypt')->create('IMP_Crypt_Smime');
+ }
+
+}