Move app Injector/Factory to just Factory/
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 26 Jan 2011 19:20:45 +0000 (12:20 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 27 Jan 2011 03:43:32 +0000 (20:43 -0700)
Mirrors use of Horde_Core_Factory.
Additionally, these factory injectors don't extend any Horde_Injector
class.

134 files changed:
ansel/lib/Application.php
ansel/lib/Factory/Faces.php [new file with mode: 0644]
ansel/lib/Factory/Storage.php [new file with mode: 0644]
ansel/lib/Factory/Styles.php [new file with mode: 0644]
ansel/lib/Injector/Factory/Faces.php [deleted file]
ansel/lib/Injector/Factory/Storage.php [deleted file]
ansel/lib/Injector/Factory/Styles.php [deleted file]
hermes/lib/Application.php
hermes/lib/Factory/Driver.php [new file with mode: 0644]
hermes/lib/Injector/Factory/Driver.php [deleted file]
imp/bin/query_imap_cache
imp/compose-dimp.php
imp/compose-mimp.php
imp/compose.php
imp/config/hooks.php.dist
imp/folders-mimp.php
imp/folders.php
imp/lib/Ajax/Application.php
imp/lib/Api.php
imp/lib/Application.php
imp/lib/Auth.php
imp/lib/Block/Newmail.php
imp/lib/Compose.php
imp/lib/Contents.php
imp/lib/Factory/AuthImap.php [new file with mode: 0644]
imp/lib/Factory/Compose.php [new file with mode: 0644]
imp/lib/Factory/Contents.php [new file with mode: 0644]
imp/lib/Factory/Flags.php [new file with mode: 0644]
imp/lib/Factory/Identity.php [new file with mode: 0644]
imp/lib/Factory/Imap.php [new file with mode: 0644]
imp/lib/Factory/Imaptree.php [new file with mode: 0644]
imp/lib/Factory/Mail.php [new file with mode: 0644]
imp/lib/Factory/MailboxList.php [new file with mode: 0644]
imp/lib/Factory/MimeViewer.php [new file with mode: 0644]
imp/lib/Factory/Pgp.php [new file with mode: 0644]
imp/lib/Factory/Quota.php [new file with mode: 0644]
imp/lib/Factory/Search.php [new file with mode: 0644]
imp/lib/Factory/Sentmail.php [new file with mode: 0644]
imp/lib/Factory/Smime.php [new file with mode: 0644]
imp/lib/Filter.php
imp/lib/Flag/User.php
imp/lib/Flags.php
imp/lib/Folder.php
imp/lib/IMP.php
imp/lib/Imap/Acl.php
imp/lib/Imap/Tree.php
imp/lib/Imap/Tree/Element.php
imp/lib/Indices.php
imp/lib/Injector/Factory/AuthImap.php [deleted file]
imp/lib/Injector/Factory/Compose.php [deleted file]
imp/lib/Injector/Factory/Contents.php [deleted file]
imp/lib/Injector/Factory/Flags.php [deleted file]
imp/lib/Injector/Factory/Identity.php [deleted file]
imp/lib/Injector/Factory/Imap.php [deleted file]
imp/lib/Injector/Factory/Imaptree.php [deleted file]
imp/lib/Injector/Factory/Mail.php [deleted file]
imp/lib/Injector/Factory/MailboxList.php [deleted file]
imp/lib/Injector/Factory/MimeViewer.php [deleted file]
imp/lib/Injector/Factory/Pgp.php [deleted file]
imp/lib/Injector/Factory/Quota.php [deleted file]
imp/lib/Injector/Factory/Search.php [deleted file]
imp/lib/Injector/Factory/Sentmail.php [deleted file]
imp/lib/Injector/Factory/Smime.php [deleted file]
imp/lib/LoginTasks/SystemTask/UpgradeFromImp4Auth.php
imp/lib/Mailbox/List.php
imp/lib/Message.php
imp/lib/Mime/Viewer/Partial.php
imp/lib/Notification/Handler/Decorator/Imap.php
imp/lib/Prefs/Identity.php
imp/lib/Prefs/Ui.php
imp/lib/Quota/Mdaemon.php
imp/lib/Search.php
imp/lib/Spam.php
imp/lib/Ui/Block.php
imp/lib/Ui/Compose.php
imp/lib/Ui/Message.php
imp/lib/Views/Compose.php
imp/lib/Views/ListMessages.php
imp/lib/Views/ShowMessage.php
imp/mailbox-mimp.php
imp/mailbox.php
imp/message-dimp.php
imp/message-mimp.php
imp/message.php
imp/mobile.php
imp/pgp.php
imp/rss.php
imp/saveimage.php
imp/smime.php
imp/templates/dimp/index.inc
imp/thread.php
imp/view.php
jonah/lib/Application.php
jonah/lib/Factory/Driver.php [new file with mode: 0644]
jonah/lib/Injector/Factory/Driver.php [deleted file]
kronolith/lib/Ajax/Application.php
kronolith/lib/Application.php
kronolith/lib/Factory/Driver.php [new file with mode: 0644]
kronolith/lib/Factory/Geo.php [new file with mode: 0644]
kronolith/lib/Factory/Storage.php [new file with mode: 0644]
kronolith/lib/FreeBusy.php
kronolith/lib/Injector/Factory/Driver.php [deleted file]
kronolith/lib/Injector/Factory/Geo.php [deleted file]
kronolith/lib/Injector/Factory/Storage.php [deleted file]
kronolith/lib/Kronolith.php
turba/add.php
turba/contact.php
turba/data.php
turba/delete.php
turba/deletefile.php
turba/edit.php
turba/lib/Api.php
turba/lib/Application.php
turba/lib/Driver/Share.php
turba/lib/Driver/Vbook.php
turba/lib/Factory/Driver.php [new file with mode: 0644]
turba/lib/Form/CreateAddressBook.php
turba/lib/Form/DeleteAddressBook.php
turba/lib/Injector/Factory/Driver.php [deleted file]
turba/lib/List.php
turba/lib/LoginTasks/SystemTask/UpgradeLists.php
turba/lib/Object/Group.php
turba/lib/Turba.php
turba/lib/View/Browse.php
turba/lib/View/List.php
turba/lib/tests/KolabTest.php
turba/merge.php
turba/minisearch.php
turba/scripts/import_squirrelmail_file_abook.php
turba/scripts/import_squirrelmail_sql_abook.php
turba/scripts/upgrades/public_to_horde_share.php
turba/search.php
turba/vcard.php
turba/view.php

index c1f16b9..4cb6e8e 100644 (file)
@@ -66,12 +66,12 @@ class Ansel_Application extends Horde_Registry_Application
         }
 
         $factories = array(
-            'Ansel_Styles' => array('Ansel_Injector_Factory_Styles', 'create'),
-            'Ansel_Faces' => array('Ansel_Injector_Factory_Faces', 'create'),
-            'Ansel_Storage' => array('Ansel_Injector_Factory_Storage', 'create'),
+            'Ansel_Styles' => 'Ansel_Factory_Styles',
+            'Ansel_Faces' => 'Ansel_Factory_Faces',
+            'Ansel_Storage' => 'Ansel_Factory_Storage',
         );
         foreach ($factories as $interface => $v) {
-            $GLOBALS['injector']->bindFactory($interface, $v[0], $v[1]);
+            $GLOBALS['injector']->bindFactory($interface, $v, 'create');
         }
 
         // Create db, share, and vfs instances.
diff --git a/ansel/lib/Factory/Faces.php b/ansel/lib/Factory/Faces.php
new file mode 100644 (file)
index 0000000..4d013dd
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+/**
+ * Factory for Ansel_Faces
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/gpl.html GPL
+ * @package  Ansel
+ */
+class Ansel_Factory_Faces
+{
+    public function create (Horde_Injector $injector)
+    {
+        $driver = $GLOBALS['conf']['faces']['driver'];
+        $params = $GLOBALS['conf']['faces'];
+        $class_name = 'Ansel_Faces_' . ucfirst($driver);
+
+        return new $class_name($params);
+    }
+
+}
diff --git a/ansel/lib/Factory/Storage.php b/ansel/lib/Factory/Storage.php
new file mode 100644 (file)
index 0000000..fca1a53
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+/**
+ * Factory for Ansel_Storage.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org)
+ *
+ * @author   Michael J. Rubinsky <mrubinsk@horde.org>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/gpl.html GPL
+ * @package  Ansel
+ */
+class Ansel_Factory_Storage
+{
+    /**
+     * Array of already instantiated instances
+     *
+     * @var array
+     */
+    private $_instances = array();
+
+    /**
+     *
+     * @var Horde_Injector
+     */
+    private $_injector;
+
+    /**
+     * Constructor
+     *
+     * @param Horde_Injector $injector
+     */
+    public function __construct(Horde_Injector $injector)
+    {
+        $this->_injector = $injector;
+    }
+
+    /**
+     * Return an Ansel_Storage instance scoped for the current Ansel scope.
+     * Scope is determined by the current value of Ansel_Config::scope
+     *
+     * @return Ansel_Storage
+     */
+    public function create()
+    {
+        $scope = $this->_injector->getInstance('Ansel_Config')->get('scope');
+        if (empty($this->_instances[$scope])) {
+            $this->_instances[$scope] = new Ansel_Storage($this->_injector->getInstance('Horde_Core_Factory_Share')->create($scope, 'Sql'));
+        }
+
+        return $this->_instances[$scope];
+    }
+
+}
diff --git a/ansel/lib/Factory/Styles.php b/ansel/lib/Factory/Styles.php
new file mode 100644 (file)
index 0000000..72c0129
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+/**
+ * Factory for getting list of all available pre-defined styles.
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/gpl.html GPL
+ * @package  Ansel
+ */
+class Ansel_Factory_Styles
+{
+    public function create (Horde_Injector $injector)
+    {
+        /* Brings in the $styles array in this scope only */
+        $styles = Horde::loadConfiguration('styles.php', 'styles', 'ansel');
+
+        /* No prettythumbs allowed at all by admin choice */
+        if (empty($GLOBALS['conf']['image']['prettythumbs'])) {
+            $test = $styles;
+            foreach ($test as $key => $style) {
+                if ($style['thumbstyle'] != 'Thumb') {
+                    unset($styles[$key]);
+                }
+            }
+        }
+
+        /* Check if the browser / server has png support */
+        if ($GLOBALS['browser']->hasQuirk('png_transparency') ||
+            $GLOBALS['conf']['image']['type'] != 'png') {
+
+            $test = $styles;
+            foreach ($test as $key => $style) {
+                if (!empty($style['requires_png'])) {
+                    if (!empty($style['fallback'])) {
+                        $styles[$key] = $styles[$style['fallback']];
+                    } else {
+                        unset($styles[$key]);
+                    }
+                }
+            }
+        }
+
+        return $styles;
+    }
+
+}
diff --git a/ansel/lib/Injector/Factory/Faces.php b/ansel/lib/Injector/Factory/Faces.php
deleted file mode 100644 (file)
index 513c676..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<?php
-/**
- * Factory for Ansel_Faces
- *
- * @author Michael J. Rubinsky <mrubinsk@horde.org>
- * @category Horde
- * @license  http://www.fsf.org/copyleft/gpl.html GPL
- * @package  Ansel
- */
-class Ansel_Injector_Factory_Faces
-{
-    public function create (Horde_Injector $injector)
-    {
-        $driver = $GLOBALS['conf']['faces']['driver'];
-        $params = $GLOBALS['conf']['faces'];
-        $class_name = 'Ansel_Faces_' . ucfirst($driver);
-
-        return new $class_name($params);
-    }
-
-}
\ No newline at end of file
diff --git a/ansel/lib/Injector/Factory/Storage.php b/ansel/lib/Injector/Factory/Storage.php
deleted file mode 100644 (file)
index c22cfb3..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-/**
- * Factory for Ansel_Storage.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org)
- *
- * @author   Michael J. Rubinsky <mrubinsk@horde.org>
- * @category Horde
- * @license  http://www.fsf.org/copyleft/gpl.html GPL
- * @package  Ansel
- */
-class Ansel_Injector_Factory_Storage
-{
-    /**
-     * Array of already instantiated instances
-     *
-     * @var array
-     */
-    private $_instances = array();
-
-    /**
-     *
-     * @var Horde_Injector
-     */
-    private $_injector;
-
-    /**
-     * Constructor
-     *
-     * @param Horde_Injector $injector
-     */
-    public function __construct(Horde_Injector $injector)
-    {
-        $this->_injector = $injector;
-    }
-
-    /**
-     * Return an Ansel_Storage instance scoped for the current Ansel scope.
-     * Scope is determined by the current value of Ansel_Config::scope
-     *
-     * @return Ansel_Storage
-     */
-    public function create()
-    {
-        $scope = $this->_injector->getInstance('Ansel_Config')->get('scope');
-        if (empty($this->_instances[$scope])) {
-            $this->_instances[$scope] = new Ansel_Storage($this->_injector->getInstance('Horde_Core_Factory_Share')->create($scope, 'Sql'));
-        }
-
-        return $this->_instances[$scope];
-    }
-
-}
diff --git a/ansel/lib/Injector/Factory/Styles.php b/ansel/lib/Injector/Factory/Styles.php
deleted file mode 100644 (file)
index d4527cd..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php
-/**
- * Factory for getting list of all available pre-defined styles.
- *
- * @author Michael J. Rubinsky <mrubinsk@horde.org>
- * @category Horde
- * @license  http://www.fsf.org/copyleft/gpl.html GPL
- * @package  Ansel
- */
-class Ansel_Injector_Factory_Styles
-{
-    public function create (Horde_Injector $injector)
-    {
-        /* Brings in the $styles array in this scope only */
-        $styles = Horde::loadConfiguration('styles.php', 'styles', 'ansel');
-
-        /* No prettythumbs allowed at all by admin choice */
-        if (empty($GLOBALS['conf']['image']['prettythumbs'])) {
-            $test = $styles;
-            foreach ($test as $key => $style) {
-                if ($style['thumbstyle'] != 'Thumb') {
-                    unset($styles[$key]);
-                }
-            }
-        }
-
-        /* Check if the browser / server has png support */
-        if ($GLOBALS['browser']->hasQuirk('png_transparency') ||
-            $GLOBALS['conf']['image']['type'] != 'png') {
-
-            $test = $styles;
-            foreach ($test as $key => $style) {
-                if (!empty($style['requires_png'])) {
-                    if (!empty($style['fallback'])) {
-                        $styles[$key] = $styles[$style['fallback']];
-                    } else {
-                        unset($styles[$key]);
-                    }
-                }
-            }
-        }
-
-        return $styles;
-    }
-
-}
\ No newline at end of file
index f3df91c..d1ca70c 100644 (file)
@@ -51,7 +51,7 @@ class Hermes_Application extends Horde_Registry_Application
      */
     protected function _init()
     {
-        $GLOBALS['injector']->bindFactory('Hermes_Driver', 'Hermes_Injector_Factory_Driver', 'create');
+        $GLOBALS['injector']->bindFactory('Hermes_Driver', 'Hermes_Factory_Driver', 'create');
     }
 
     /**
diff --git a/hermes/lib/Factory/Driver.php b/hermes/lib/Factory/Driver.php
new file mode 100644 (file)
index 0000000..ffa5b1d
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+/**
+ * Hermes_Driver:: factory
+ *
+ * @author   Michael J. Rubinsky <mrubinsk@horde.org>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/gpl.html GPL
+ * @package  Hermes
+ */
+class Hermes_Factory_Driver
+{
+    /**
+     *
+     * @var array
+     */
+    private $_instances = array();
+
+    /**
+     *
+     * @var Horde_Injector
+     */
+    private $_injector;
+
+    public function __construct(Horde_Injector $injector)
+    {
+        $this->_injector = $injector;
+    }
+
+    /**
+     * Return an Hermes_Storage instance.
+     *
+     * @return Ansel_Storage
+     */
+    public function create()
+    {
+        $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' => $this->_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];
+    }
+
+}
diff --git a/hermes/lib/Injector/Factory/Driver.php b/hermes/lib/Injector/Factory/Driver.php
deleted file mode 100644 (file)
index 46c55f7..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-<?php
-/**
- * Hermes_Driver:: factory
- *
- * @author   Michael J. Rubinsky <mrubinsk@horde.org>
- * @category Horde
- * @license  http://www.fsf.org/copyleft/gpl.html GPL
- * @package  Hermes
- */
-class Hermes_Injector_Factory_Driver
-{
-    /**
-     *
-     * @var array
-     */
-    private $_instances = array();
-
-    /**
-     *
-     * @var Horde_Injector
-     */
-    private $_injector;
-
-    public function __construct(Horde_Injector $injector)
-    {
-        $this->_injector = $injector;
-    }
-
-    /**
-     * Return an Hermes_Storage instance.
-     *
-     * @return Ansel_Storage
-     */
-    public function create()
-    {
-        $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' => $this->_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];
-    }
-
-}
index c135123..93c2e02 100755 (executable)
@@ -46,7 +46,7 @@ foreach ($options[0] as $val) {
     }
 }
 
-$imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
+$imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
 
 if (is_null($server)) {
     /* Set first entry to 1, not 0. */
index de83f3d..62c349e 100644 (file)
@@ -62,7 +62,7 @@ if (!$prefs->isLocked('default_identity') && isset($vars->identity)) {
 }
 
 /* Init objects. */
-$imp_compose = $injector->getInstance('IMP_Injector_Factory_Compose')->create();
+$imp_compose = $injector->getInstance('IMP_Factory_Compose')->create();
 $imp_ui = new IMP_Ui_Compose();
 
 $show_editor = false;
index 16f5c8d..306a8f0 100644 (file)
@@ -64,7 +64,7 @@ $sent_mail_folder = $identity->getValue('sent_mail_folder');
 
 /* Determine if mailboxes are readonly. */
 $readonly_drafts = false;
-$imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
+$imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
 if (!empty($draft)) {
     $draft = IMP::folderPref($draft, true);
     $readonly_drafts = $imp_folder->exists($draft) &&
@@ -78,7 +78,7 @@ $save_sent_mail = ($imp_folder->exists($sent_mail_folder) && $imp_imap->isReadOn
 $compose_disable = !IMP::canCompose();
 
 /* Initialize objects. */
-$imp_compose = $injector->getInstance('IMP_Injector_Factory_Compose')->create($vars->composeCache);
+$imp_compose = $injector->getInstance('IMP_Factory_Compose')->create($vars->composeCache);
 $imp_ui = new IMP_Ui_Compose();
 
 foreach (array_keys($display_hdrs) as $val) {
index a878b8c..3a1c63d 100644 (file)
@@ -101,7 +101,7 @@ $compose_disable = !IMP::canCompose();
 $imp_folder = $injector->getInstance('IMP_Folder');
 $readonly_drafts = $readonly_sentmail = false;
 $draft = $prefs->getValue('drafts_folder');
-$imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
+$imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
 if (!empty($draft)) {
     $draft = IMP::folderPref($draft, true);
     $readonly_drafts = $imp_folder->exists($draft) &&
@@ -114,7 +114,7 @@ if ($readonly_sentmail) {
 }
 
 /* Initialize the IMP_Compose:: object. */
-$imp_compose = $injector->getInstance('IMP_Injector_Factory_Compose')->create($vars->composeCache);
+$imp_compose = $injector->getInstance('IMP_Factory_Compose')->create($vars->composeCache);
 $imp_compose->pgpAttachPubkey((bool) $vars->pgp_attach_pubkey);
 $imp_compose->userLinkAttachments((bool) $vars->link_attachments);
 
index 4d2ab82..cea61ef 100644 (file)
@@ -651,7 +651,7 @@ class IMP_Hooks
 //        // Requires the 'command' parameter to be defined in backends.php,
 //        // which defines the quota reporting function to run on the SSH
 //        // host.
-//        $imap_ob = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+//        $imap_ob = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
 //        $host = $imap_ob->ob->getParam('hostspec');
 //        $user = $params['host'];
 //        $pass = $imap_ob->ob->getParam('password');
index 927f99a..f12dc5e 100644 (file)
@@ -22,7 +22,7 @@ require_once dirname(__FILE__) . '/lib/Application.php';
 Horde_Registry::appInit('imp', array('impmode' => 'mimp'));
 
 /* Redirect back to the mailbox if folder use is not allowed. */
-if (!$injector->getInstance('IMP_Injector_Factory_Imap')->create()->allowFolders()) {
+if (!$injector->getInstance('IMP_Factory_Imap')->create()->allowFolders()) {
     $notification->push(_("Folder use is not enabled."), 'horde.error');
     Horde::url('mailbox-mimp.php', true)->redirect();
 }
index 9fd5f5e..061e0bd 100644 (file)
@@ -23,7 +23,7 @@ Horde_Registry::appInit('imp', array(
 Horde::addScriptFile('folders.js', 'imp');
 
 /* Redirect back to the mailbox if folder use is not allowed. */
-$imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
+$imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
 if (!$imp_imap->allowFolders()) {
     $notification->push(_("Folder use is not enabled."), 'horde.error');
     Horde::url('mailbox.php', true)->redirect();
@@ -251,7 +251,7 @@ case 'folders_empty_mailbox_confirm':
             }
 
             try {
-                $elt_info = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->status($val, Horde_Imap_Client::STATUS_MESSAGES);
+                $elt_info = $injector->getInstance('IMP_Factory_Imap')->create()->status($val, Horde_Imap_Client::STATUS_MESSAGES);
             } catch (Horde_Imap_Client_Exception $e) {
                 $elt_info = null;
             }
@@ -427,7 +427,7 @@ if (!empty($imaptree->recent)) {
     /* Open the mailbox R/W so we ensure the 'recent' flags are cleared from
      * the current mailbox. */
     foreach ($imaptree->recent as $mbox => $nm) {
-        $injector->getInstance('IMP_Injector_Factory_Imap')->create()->openMailbox($mbox, Horde_Imap_Client::OPEN_READWRITE);
+        $injector->getInstance('IMP_Factory_Imap')->create()->openMailbox($mbox, Horde_Imap_Client::OPEN_READWRITE);
     }
 
     IMP::newmailAlerts($imaptree->recent);
index 0d1f2d3..8080c4e 100644 (file)
@@ -500,7 +500,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
         if ($this->_vars->add) {
             $imptree->addPollList($this->_vars->mbox);
             try {
-                if ($info = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->status($this->_vars->mbox, Horde_Imap_Client::STATUS_UNSEEN)) {
+                if ($info = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->status($this->_vars->mbox, Horde_Imap_Client::STATUS_UNSEEN)) {
                     $result->poll = array($this->_vars->mbox => intval($info['unseen']));
                 }
             } catch (Horde_Imap_Client_Exception $e) {}
@@ -739,7 +739,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
             $result->ViewPort = $this->_viewPortData(true);
         } else {
             $result->ViewPort = new stdClass;
-            $result->ViewPort->updatecacheid = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_MailboxList')->create($this->_vars->view)->getCacheID($this->_vars->view);
+            $result->ViewPort->updatecacheid = $GLOBALS['injector']->getInstance('IMP_Factory_MailboxList')->create($this->_vars->view)->getCacheID($this->_vars->view);
             $result->ViewPort->view = $this->_vars->view;
         }
 
@@ -986,7 +986,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
                 $result = $this->_checkUidvalidity($result);
             } elseif (!$change) {
                 /* Only update cacheid info if it changed. */
-                $cacheid = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_MailboxList')->create($this->_vars->view)->getCacheID($this->_vars->view);
+                $cacheid = $GLOBALS['injector']->getInstance('IMP_Factory_MailboxList')->create($this->_vars->view)->getCacheID($this->_vars->view);
                 if ($cacheid != $this->_vars->cacheid) {
                     $result->ViewPort = new stdClass;
                     $result->ViewPort->updatecacheid = $cacheid;
@@ -1272,7 +1272,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
      */
     public function cancelCompose()
     {
-        $imp_compose = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create($this->_vars->imp_compose);
+        $imp_compose = $GLOBALS['injector']->getInstance('IMP_Factory_Compose')->create($this->_vars->imp_compose);
         $imp_compose->destroy('cancel');
 
         return true;
@@ -1325,7 +1325,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
      */
     public function deleteDraft()
     {
-        $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create($this->_vars->imp_compose)->destroy('cancel');
+        $GLOBALS['injector']->getInstance('IMP_Factory_Compose')->create($this->_vars->imp_compose)->destroy('cancel');
         return true;
     }
 
@@ -1343,7 +1343,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
     public function deleteAttach()
     {
         if (isset($this->_vars->atc_indices)) {
-            $imp_compose = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create($this->_vars->imp_compose);
+            $imp_compose = $GLOBALS['injector']->getInstance('IMP_Factory_Compose')->create($this->_vars->imp_compose);
             foreach ($this->_vars->atc_indices as $val) {
                 $GLOBALS['notification']->push(sprintf(_("Deleted attachment \"%s\"."), Horde_Mime::decode($imp_compose[$val]['part']->getName(true))), 'horde.success');
                 unset($imp_compose[$val]);
@@ -1494,7 +1494,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
         }
 
         try {
-            $fetch_ret = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->fetch($this->_vars->folder, array(
+            $fetch_ret = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->fetch($this->_vars->folder, array(
                 Horde_Imap_Client::FETCH_HEADERTEXT => array(array('parse' => true, 'peek' => false))
             ), array('ids' => array($this->_vars->uid)));
         } catch (Horde_Imap_Client_Exception $e) {
@@ -1578,7 +1578,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
      */
     public function addAttachment()
     {
-        $imp_compose = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create($this->_vars->composeCache);
+        $imp_compose = $GLOBALS['injector']->getInstance('IMP_Factory_Compose')->create($this->_vars->composeCache);
 
         $result = new stdClass;
         $result->action = 'addAttachment';
@@ -1783,7 +1783,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
         $result->success = 1;
 
         try {
-            $imp_compose = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create($this->_vars->composeCache);
+            $imp_compose = $GLOBALS['injector']->getInstance('IMP_Factory_Compose')->create($this->_vars->composeCache);
             $imp_compose->sendRedirectMessage($this->_vars->redirect_to);
 
             $result->mbox = $imp_compose->getMetadata('mailbox');
@@ -1864,7 +1864,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
 
         if (is_null($mbox)) {
             $result = array();
-            foreach ($GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->statusMultiple($imaptree->getPollList(), Horde_Imap_Client::STATUS_UNSEEN) as $key => $val) {
+            foreach ($GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->statusMultiple($imaptree->getPollList(), Horde_Imap_Client::STATUS_UNSEEN) as $key => $val) {
                 $result[$key] = intval($val['unseen']);
             }
             return $result;
@@ -1929,7 +1929,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
         }
         $headers['subject'] = $this->_vars->subject;
 
-        $imp_compose = $injector->getInstance('IMP_Injector_Factory_Compose')->create($this->_vars->composeCache);
+        $imp_compose = $injector->getInstance('IMP_Factory_Compose')->create($this->_vars->composeCache);
 
         return array($result, $imp_compose, $headers, $identity);
     }
@@ -1939,10 +1939,10 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
      */
     protected function _initCompose()
     {
-        $imp_compose = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create($this->_vars->imp_compose);
+        $imp_compose = $GLOBALS['injector']->getInstance('IMP_Factory_Compose')->create($this->_vars->imp_compose);
         if (!($imp_contents = $imp_compose->getContentsOb())) {
             $imp_contents = $this->_vars->uid
-                ? $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($this->_vars->uid))
+                ? $GLOBALS['injector']->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($this->_vars->uid))
                 : null;
         }
 
@@ -2007,7 +2007,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
     protected function _checkUidvalidity($result = false)
     {
         try {
-            $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->checkUidvalidity($this->_vars->view);
+            $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->checkUidvalidity($this->_vars->view);
         } catch (IMP_Exception $e) {
             if (!is_object($result)) {
                 $result = new stdClass;
@@ -2062,7 +2062,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
             $result->ViewPort = $this->_viewPortData(true);
         } else {
             $result->ViewPort = new stdClass;
-            $result->ViewPort->updatecacheid = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_MailboxList')->create($this->_vars->view)->getCacheID($this->_vars->view);
+            $result->ViewPort->updatecacheid = $GLOBALS['injector']->getInstance('IMP_Factory_MailboxList')->create($this->_vars->view)->getCacheID($this->_vars->view);
             $result->ViewPort->view = $this->_vars->view;
         }
 
@@ -2103,7 +2103,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
          * on the IMAP server (saves some STATUS calls). */
         if (!is_null($rw)) {
             try {
-                $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->openMailbox($this->_vars->view, $rw ? Horde_Imap_Client::OPEN_READWRITE : Horde_Imap_Client::OPEN_AUTO);
+                $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->openMailbox($this->_vars->view, $rw ? Horde_Imap_Client::OPEN_READWRITE : Horde_Imap_Client::OPEN_AUTO);
             } catch (Horde_Imap_Client_Exception $e) {
                 if ($e->getCode() == Horde_Imap_Client_Exception::MAILBOX_NOOPEN) {
                     $GLOBALS['notification']->push(sprintf(_("Could not open mailbox \"%s\"."), $this->_vars->view), 'horde.error');
@@ -2114,7 +2114,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
             }
         }
 
-        return ($GLOBALS['injector']->getInstance('IMP_Injector_Factory_MailboxList')->create($this->_vars->view)->getCacheID($this->_vars->view) != $this->_vars->cacheid);
+        return ($GLOBALS['injector']->getInstance('IMP_Factory_MailboxList')->create($this->_vars->view)->getCacheID($this->_vars->view) != $this->_vars->cacheid);
     }
 
     /**
index e787edf..1afd38d 100644 (file)
@@ -88,7 +88,7 @@ class IMP_Api extends Horde_Registry_Api
      */
     public function createFolder($folder)
     {
-        $fname = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->appendNamespace($folder);
+        $fname = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->appendNamespace($folder);
         return $GLOBALS['injector']->getInstance('IMP_Folder')->create($fname, $GLOBALS['prefs']->getValue('subscribe'))
             ? $fname
             : false;
@@ -181,7 +181,7 @@ class IMP_Api extends Horde_Registry_Api
      */
     public function server()
     {
-        $imap_ob = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+        $imap_ob = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
 
         return array(
             'hostspec' => $imap_ob->ob->getParam('hostspec'),
@@ -214,7 +214,7 @@ class IMP_Api extends Horde_Registry_Api
      */
     public function imapOb()
     {
-        return $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->ob;
+        return $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->ob;
     }
 
     /**
index a4cb88b..b334278 100644 (file)
@@ -86,7 +86,7 @@ class IMP_Application extends Horde_Registry_Application
     {
         if (($e->getCode() == Horde_Registry::AUTH_FAILURE) &&
             Horde_Util::getFormData('composeCache')) {
-            $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create()->sessionExpireDraft(Horde_Variables::getDefaultVariables());
+            $GLOBALS['injector']->getInstance('IMP_Factory_Compose')->create()->sessionExpireDraft(Horde_Variables::getDefaultVariables());
         }
     }
 
@@ -97,16 +97,16 @@ class IMP_Application extends Horde_Registry_Application
     {
         /* 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_Flags' => 'IMP_Injector_Factory_Flags',
-            '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'
+            'IMP_AuthImap' => 'IMP_Factory_AuthImap',
+            'IMP_Crypt_Pgp' => 'IMP_Factory_Pgp',
+            'IMP_Crypt_Smime' => 'IMP_Factory_Smime',
+            'IMP_Flags' => 'IMP_Factory_Flags',
+            'IMP_Identity' => 'IMP_Factory_Identity',
+            'IMP_Imap_Tree' => 'IMP_Factory_Imaptree',
+            'IMP_Mail' => 'IMP_Factory_Mail',
+            'IMP_Quota' => 'IMP_Factory_Quota',
+            'IMP_Search' => 'IMP_Factory_Search',
+            'IMP_Sentmail' => 'IMP_Factory_Sentmail'
         );
 
         foreach ($factories as $key => $val) {
@@ -162,7 +162,7 @@ class IMP_Application extends Horde_Registry_Application
     {
         /* Clean up dangling IMP_Compose objects. */
         foreach (array_keys($GLOBALS['session']->get('imp', 'compose_cache', Horde_Session::TYPE_ARRAY)) as $key) {
-            $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create($key)->destroy('cancel');
+            $GLOBALS['injector']->getInstance('IMP_Factory_Compose')->create($key)->destroy('cancel');
         }
 
         /* No need to keep Tree object in cache - it will be recreated next
@@ -260,7 +260,7 @@ class IMP_Application extends Horde_Registry_Application
                 $trash_folder = IMP::folderPref($trash_folder, true);
 
                 if ($injector->getInstance('IMP_Search')->isVTrash($trash_folder) ||
-                    !$injector->getInstance('IMP_Injector_Factory_Imap')->create()->isReadOnly($trash_folder)) {
+                    !$injector->getInstance('IMP_Factory_Imap')->create()->isReadOnly($trash_folder)) {
                     $menu->addArray(array(
                         'class' => '__noselection',
                         'icon' => 'empty_trash.png',
@@ -292,7 +292,7 @@ class IMP_Application extends Horde_Registry_Application
             ));
         }
 
-        if ($injector->getInstance('IMP_Injector_Factory_Imap')->create()->allowFolders()) {
+        if ($injector->getInstance('IMP_Factory_Imap')->create()->allowFolders()) {
             $menu->addArray(array(
                 'icon' => 'folders/folder.png',
                 'text' => _("_Folders"),
index 1e684f5..e78ce04 100644 (file)
@@ -80,7 +80,7 @@ class IMP_Auth
             $credentials['server'] = self::getAutoLoginServer();
         }
 
-        $imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create($credentials['server']);
+        $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create($credentials['server']);
 
         // Check for valid IMAP Client object.
         if (!$imp_imap->ob) {
@@ -264,7 +264,7 @@ class IMP_Auth
      */
     static protected function _canAutoLogin($server_key = null, $force = false)
     {
-        if (($servers = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->loadServerConfig()) === false) {
+        if (($servers = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->loadServerConfig()) === false) {
             return false;
         }
 
@@ -351,7 +351,7 @@ class IMP_Auth
     {
         global $browser, $conf, $injector, $prefs, $registry, $session;
 
-        $imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create(null, true);
+        $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create(null, true);
         $ptr = $imp_imap->loadServerConfig($session->get('imp', 'server_key'));
         if ($ptr === false) {
             throw new Horde_Auth_Exception('', Horde_Auth::REASON_FAILED);
@@ -487,7 +487,7 @@ class IMP_Auth
         }
 
         /* Check for drafts due to session timeouts. */
-        $imp_compose = $injector->getInstance('IMP_Injector_Factory_Compose')->create()->recoverSessionExpireDraft();
+        $imp_compose = $injector->getInstance('IMP_Factory_Compose')->create()->recoverSessionExpireDraft();
 
         self::_logMessage(true, $imp_imap);
     }
index 4f69d6c..62acd02 100644 (file)
@@ -39,7 +39,7 @@ class IMP_Block_Newmail extends Horde_Block
                 : $this->_params['msgs_shown'];
 
             try {
-                $fetch_ret = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->fetch('INBOX', array(
+                $fetch_ret = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->fetch('INBOX', array(
                     Horde_Imap_Client::FETCH_ENVELOPE => true
                 ), array('ids' => array_slice($indices, 0, $shown)));
                 reset($fetch_ret);
index 5a823a0..c8d6e25 100644 (file)
@@ -219,7 +219,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
         /* Add information necessary to log replies/forwards when finally
          * sent. */
         if ($this->getMetadata('reply_type')) {
-            $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+            $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
             try {
                 $imap_url = $imp_imap->getUtils()->createUrl(array(
                     'type' => $GLOBALS['session']->get('imp', 'protocol'),
@@ -287,7 +287,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
 
         /* Add the message to the mailbox. */
         try {
-            $ids = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->append($drafts_mbox, array(array('data' => $data, 'flags' => $append_flags)));
+            $ids = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->append($drafts_mbox, array(array('data' => $data, 'flags' => $append_flags)));
 
             if ($old_uid) {
                 $GLOBALS['injector']->getInstance('IMP_Message')->delete($old_uid, array('nuke' => true));
@@ -322,7 +322,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
         global $injector, $prefs;
 
         try {
-            $contents = $injector->getInstance('IMP_Injector_Factory_Contents')->create($indices);
+            $contents = $injector->getInstance('IMP_Factory_Contents')->create($indices);
         } catch (IMP_Exception $e) {
             throw new IMP_Compose_Exception($e);
         }
@@ -419,7 +419,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
         }
 
         if ($val) {
-            $imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
+            $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
             $imap_url = $imp_imap->getUtils()->parseUrl(rtrim(ltrim($val, '<'), '>'));
 
             try {
@@ -429,7 +429,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
                     // even though the server is the same. UIDVALIDITY should
                     // catch any true server/backend changes.
                     ($imp_imap->checkUidvalidity($imap_url['mailbox']) == $imap_url['uidvalidity']) &&
-                    $injector->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($imap_url['mailbox'], $imap_url['uid']))) {
+                    $injector->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($imap_url['mailbox'], $imap_url['uid']))) {
                     $this->_metadata['mailbox'] = $imap_url['mailbox'];
                     $this->_metadata['reply_type'] = $reply_type;
                     $this->_metadata['uid'] = $imap_url['uid'];
@@ -678,7 +678,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
             }
 
             try {
-                $injector->getInstance('IMP_Injector_Factory_Imap')->create()->append($opts['sent_folder'], array(array('data' => $fcc, 'flags' => $flags)));
+                $injector->getInstance('IMP_Factory_Imap')->create()->append($opts['sent_folder'], array(array('data' => $fcc, 'flags' => $flags)));
             } catch (Horde_Imap_Client_Exception $e) {
                 $notification->push(sprintf(_("Message sent successfully, but not saved to %s"), IMP::displayFolder($opts['sent_folder'])));
                 $sent_saved = false;
@@ -1381,7 +1381,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
         $subject = $h->getValue('subject');
         $header['subject'] = empty($subject)
             ? 'Re: '
-            : 'Re: ' . $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->getUtils()->getBaseSubject($subject, array('keepblob' => true));
+            : 'Re: ' . $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->getUtils()->getBaseSubject($subject, array('keepblob' => true));
 
         $force = false;
         if (in_array($type, array('reply', 'reply_auto', '*'))) {
@@ -1665,7 +1665,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
 
         $header['subject'] = $h->getValue('subject');
         if (!empty($header['subject'])) {
-            $subject = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->getUtils()->getBaseSubject($header['subject'], array('keepblob' => true));
+            $subject = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->getUtils()->getBaseSubject($header['subject'], array('keepblob' => true));
             $header['title'] = _("Forward") . ': ' . $subject;
             $header['subject'] = 'Fwd: ' . $subject;
         } else {
@@ -1861,7 +1861,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
         $attached = 0;
         foreach ($indices as $mbox => $idx) {
             ++$attached;
-             $contents = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($mbox, $idx));
+             $contents = $GLOBALS['injector']->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($mbox, $idx));
              $headerob = $contents->getHeaderOb();
 
              $part = new Horde_Mime_Part();
@@ -1880,7 +1880,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
             } else {
                 $name = Horde_String::truncate($name, 80);
             }
-            return 'Fwd: ' . $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->getUtils()->getBaseSubject($name, array('keepblob' => true));
+            return 'Fwd: ' . $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->getUtils()->getBaseSubject($name, array('keepblob' => true));
         }
 
         return 'Fwd: ' . sprintf(_("%u Forwarded Messages"), $attached);
@@ -2753,7 +2753,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
     public function getContentsOb()
     {
         return $this->getMetadata('reply_type')
-            ? $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($this->getMetadata('mailbox'), $this->getMetadata('uid')))
+            ? $GLOBALS['injector']->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($this->getMetadata('mailbox'), $this->getMetadata('uid')))
             : null;
     }
 
index 40ac984..c9c0a14 100644 (file)
@@ -99,7 +99,7 @@ class IMP_Contents
 
             /* Get the Horde_Mime_Part object for the given UID. */
             try {
-                $ret = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->fetch($this->_mailbox, array(
+                $ret = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->fetch($this->_mailbox, array(
                     Horde_Imap_Client::FETCH_STRUCTURE => array('parse' => true)
                 ), array('ids' => array($this->_uid)));
             } catch (Horde_Imap_Client_Exception $e) {
@@ -153,7 +153,7 @@ class IMP_Contents
         }
 
         try {
-            $res = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->fetch($this->_mailbox, array(
+            $res = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->fetch($this->_mailbox, array(
                 Horde_Imap_Client::FETCH_BODYTEXT => array(array('peek' => true, 'stream' => !empty($options['stream'])))
             ), array('ids' => array($this->_uid)));
             return $res[$this->_uid]['bodytext'][0];
@@ -212,7 +212,7 @@ class IMP_Contents
         }
 
         try {
-            $res = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->fetch($this->_mailbox, $query, array('ids' => array($this->_uid)));
+            $res = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->fetch($this->_mailbox, $query, array('ids' => array($this->_uid)));
             if (empty($options['mimeheaders'])) {
                 if (!empty($res[$this->_uid]['bodypartdecode'][$id])) {
                     $this->lastBodyPartDecode = $res[$this->_uid]['bodypartdecode'][$id];
@@ -250,7 +250,7 @@ class IMP_Contents
         }
 
         try {
-            $res = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->fetch($this->_mailbox, array(
+            $res = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->fetch($this->_mailbox, array(
                 Horde_Imap_Client::FETCH_HEADERTEXT => array(array('peek' => true)),
                 Horde_Imap_Client::FETCH_BODYTEXT => array(array('peek' => true, 'stream' => !empty($options['stream'])))
             ), array('ids' => array($this->_uid)));
@@ -284,7 +284,7 @@ class IMP_Contents
         }
 
         try {
-            $res = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->fetch($this->_mailbox, array(
+            $res = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->fetch($this->_mailbox, array(
                 Horde_Imap_Client::FETCH_HEADERTEXT => array(array('parse' => $parse, 'peek' => true))
             ), array('ids' => array($this->_uid)));
             return $res[$this->_uid]['headertext'][0];
@@ -385,7 +385,7 @@ class IMP_Contents
             ? null
             : $options['type'];
 
-        $viewer = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_MimeViewer')->create($mime_part, $this, $type);
+        $viewer = $GLOBALS['injector']->getInstance('IMP_Factory_MimeViewer')->create($mime_part, $this, $type);
 
         switch ($mode) {
         case self::RENDER_FULL:
@@ -678,7 +678,7 @@ class IMP_Contents
         if ($is_atc &&
             $download_zip &&
             ($part['bytes'] > 204800)) {
-            $viewer = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_MimeViewer')->create($mime_part, $this, $mime_type);
+            $viewer = $GLOBALS['injector']->getInstance('IMP_Factory_MimeViewer')->create($mime_part, $this, $mime_type);
             if (!$viewer->getMetadata('compressed')) {
                 $part['download_zip'] = $this->linkView($mime_part, 'download_attach', null, array('class' => 'iconImg downloadZipAtc', 'dload' => true, 'jstext' => sprintf(_("Download %s in .zip Format"), $mime_part->getDescription(true)), 'params' => array('zip' => 1)));
             }
@@ -896,7 +896,7 @@ class IMP_Contents
             $last_id = null;
 
             $mime_part = $this->getMIMEPart($id, array('nocontents' => true));
-            $viewer = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_MimeViewer')->create($mime_part, $this);
+            $viewer = $GLOBALS['injector']->getInstance('IMP_Factory_MimeViewer')->create($mime_part, $this);
             if ($viewer->embeddedMimeParts()) {
                 $mime_part = $this->getMIMEPart($id);
                 $viewer->setMIMEPart($mime_part);
@@ -931,7 +931,7 @@ class IMP_Contents
         if (!is_object($part)) {
             $part = $this->getMIMEPart($part, array('nocontents' => true));
         }
-        $viewer = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_MimeViewer')->create($part, $this, $type);
+        $viewer = $GLOBALS['injector']->getInstance('IMP_Factory_MimeViewer')->create($part, $this, $type);
 
         if ($mask & self::RENDER_INLINE_AUTO) {
             $mask |= self::RENDER_INLINE | self::RENDER_INFO;
diff --git a/imp/lib/Factory/AuthImap.php b/imp/lib/Factory/AuthImap.php
new file mode 100644 (file)
index 0000000..8cf7477
--- /dev/null
@@ -0,0 +1,62 @@
+<?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_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.');
+        }
+
+        $aparams = $GLOBALS['session']->get('imp', 'imap_admin', Horde_Session::TYPE_ARRAY);
+
+        $params = array_merge(
+            $params,
+            (isset($aparams['params']) ? $aparams['params'] : array()),
+            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);
+    }
+
+}
diff --git a/imp/lib/Factory/Compose.php b/imp/lib/Factory/Compose.php
new file mode 100644 (file)
index 0000000..5a5f7fa
--- /dev/null
@@ -0,0 +1,112 @@
+<?php
+/**
+ * A Horde_Injector:: based IMP_Compose:: 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 IMP_Compose:: 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_Factory_Compose
+{
+    /**
+     * Instances.
+     *
+     * @var array
+     */
+    private $_instances = array();
+
+    /**
+     * The injector.
+     *
+     * @var Horde_Injector
+     */
+    private $_injector;
+
+    /**
+     * Constructor.
+     *
+     * @param Horde_Injector $injector  The injector to use.
+     */
+    public function __construct(Horde_Injector $injector)
+    {
+        $this->_injector = $injector;
+
+        register_shutdown_function(array($this, 'shutdown'));
+    }
+
+    /**
+     * Return the IMP_Compose:: instance.
+     *
+     * @param string $cacheid  The cache ID string.
+     *
+     * @return IMP_Compose  The singleton compose instance.
+     * @throws IMP_Exception
+     */
+    public function create($cacheid = null)
+    {
+        if (empty($cacheid)) {
+            $cacheid = strval(new Horde_Support_Randomid());
+        } elseif (!isset($this->_instances[$cacheid])) {
+            $this->_instances[$cacheid] = $GLOBALS['session']->retrieve($cacheid);
+        }
+
+        if (empty($this->_instances[$cacheid])) {
+            $this->_instances[$cacheid] = new IMP_Compose($cacheid);
+        }
+
+        return $this->_instances[$cacheid];
+    }
+
+    /**
+     * Tasks to perform on shutdown.
+     */
+    public function shutdown()
+    {
+        global $session;
+
+        $cache = $session->get('imp', 'compose_cache', Horde_Session::TYPE_ARRAY);
+        $changed = false;
+
+        foreach ($this->_instances as $key => $val) {
+            switch ($val->changed) {
+            case 'changed':
+                $val->changed = '';
+                $session->store($val, false, $key);
+                $cache[$key] = 1;
+                $changed = true;
+                break;
+
+            case 'deleted':
+                unset($cache[$key]);
+                $session->purge($key);
+                $changed = true;
+                break;
+            }
+
+        }
+
+        if ($changed) {
+            $session->set('imp', 'compose_cache', $cache);
+        }
+    }
+
+}
diff --git a/imp/lib/Factory/Contents.php b/imp/lib/Factory/Contents.php
new file mode 100644 (file)
index 0000000..5161007
--- /dev/null
@@ -0,0 +1,56 @@
+<?php
+/**
+ * A Horde_Injector:: based IMP_Contents:: 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 IMP_Contents:: 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_Factory_Contents
+{
+    /**
+     * Instances.
+     *
+     * @var array
+     */
+    private $_instances = array();
+
+    /**
+     * Return the IMP_Contents:: instance.
+     *
+     * @param IMP_Indices $indices  An indices object.
+     *
+     * @return IMP_Contents  The singleton contents instance.
+     * @throws IMP_Exception
+     */
+    public function create($indices)
+    {
+        $key = strval($indices);
+
+        if (!isset($this->_instances[$key])) {
+            $this->_instances[$key] = new IMP_Contents($indices);
+        }
+
+        return $this->_instances[$key];
+    }
+
+}
diff --git a/imp/lib/Factory/Flags.php b/imp/lib/Factory/Flags.php
new file mode 100644 (file)
index 0000000..e454465
--- /dev/null
@@ -0,0 +1,66 @@
+<?php
+/**
+ * A Horde_Injector based factory for the IMP_Flags 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_Flags 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_Factory_Flags
+{
+    /**
+     * Return the IMP_Flags instance.
+     *
+     * @return IMP_Flags  The singleton instance.
+     */
+    public function create(Horde_Injector $injector)
+    {
+        try {
+            $instance = $GLOBALS['session']->get('imp', 'flags');
+        } catch (Exception $e) {
+            Horde::logMessage('Could not unserialize stored IMP_Flags object.', 'DEBUG');
+            $instance = null;
+        }
+
+        if (is_null($instance)) {
+            $instance = new IMP_Flags();
+        }
+
+        register_shutdown_function(array($this, 'shutdown'), $instance);
+
+        return $instance;
+    }
+
+    /**
+     * Store serialized version of object in the current session.
+     *
+     * @param IMP_Flags $instance  Flags object.
+     */
+    public function shutdown($instance)
+    {
+        /* Only need to store the object if the object has changed. */
+        if ($instance->changed) {
+            $GLOBALS['session']->set('imp', 'flags', $instance);
+        }
+    }
+
+}
diff --git a/imp/lib/Factory/Identity.php b/imp/lib/Factory/Identity.php
new file mode 100644 (file)
index 0000000..41b69c4
--- /dev/null
@@ -0,0 +1,40 @@
+<?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_Factory_Identity
+{
+    /**
+     * Return the IMP identity instance.
+     *
+     * @return IMP_Prefs_Identity  The singleton instance.
+     */
+    public function create(Horde_Injector $injector)
+    {
+        return $injector->getInstance('Horde_Core_Factory_Identity')->create(null, 'imp');
+    }
+
+}
diff --git a/imp/lib/Factory/Imap.php b/imp/lib/Factory/Imap.php
new file mode 100644 (file)
index 0000000..9a21b8a
--- /dev/null
@@ -0,0 +1,90 @@
+<?php
+/**
+ * A Horde_Injector:: based IMP_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 IMP_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_Factory_Imap
+{
+    /**
+     * Instances.
+     *
+     * @var array
+     */
+    private $_instances = array();
+
+    /**
+     * The list of instances to save.
+     *
+     * @var array
+     */
+    private $_save = array();
+
+    /**
+     * Return the IMP_Imap:: instance.
+     *
+     * @param string $id     The server ID.
+     * @param boolean $save  Save the instance in the session?
+     *
+     * @return IMP_Imap  The singleton instance.
+     * @throws IMP_Exception
+     */
+    public function create($id = null, $save = false)
+    {
+        global $session;
+
+        if (is_null($id) &&
+            !($id = $session->get('imp', 'server_key'))) {
+            $id = 'default';
+        }
+
+        if (!isset($this->_instances[$id])) {
+            if (!($ob = $session->get('imp', 'imap_ob/' . $id))) {
+                $ob = new IMP_Imap();
+            }
+
+            $this->_instances[$id] = $ob;
+        }
+
+        if ($save && !$session->exists('imp', 'imap_ob/' . $id)) {
+            if (empty($this->_save)) {
+                register_shutdown_function(array($this, 'shutdown'));
+            }
+            $this->_save[] = $id;
+        }
+
+        return $this->_instances[$id];
+    }
+
+    /**
+     * Saves IMP_Imap instances to the session.
+     */
+    public function shutdown()
+    {
+        foreach (array_unique($this->_save) as $id) {
+            $GLOBALS['session']->set('imp', 'imap_ob/' . $id, $this->_instances[$id]);
+        }
+    }
+
+}
diff --git a/imp/lib/Factory/Imaptree.php b/imp/lib/Factory/Imaptree.php
new file mode 100644 (file)
index 0000000..73082cb
--- /dev/null
@@ -0,0 +1,91 @@
+<?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_Factory_Imaptree
+{
+    /**
+     * Return the IMP_Imap_Tree object.
+     *
+     * @return IMP_Imap_Tree  The singleton instance.
+     */
+    public function create(Horde_Injector $injector)
+    {
+        global $session;
+
+        $instance = null;
+
+        /* If an IMP_Imap_Tree object is currently stored in the cache,
+         * re-create that object.  Else, create a new instance. */
+        if ($session->exists('imp', 'treeob')) {
+            /* 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) {
+                $instance = $session->retrieve('imp_imaptree');
+            } else {
+                try {
+                    $instance = @unserialize($cache->get($session->get('imp', 'treeob'), 86400));
+                } catch (Exception $e) {
+                    Horde::logMessage('Could not unserialize stored IMP_Imap_Tree object.', 'DEBUG');
+                }
+            }
+        } else {
+            $session->set('imp', 'treeob', strval(new Horde_Support_Randomid()));
+        }
+
+        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)
+    {
+        global $session;
+
+        /* 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) {
+                $session->store($instance, true, 'imp_imaptree');
+            } else {
+                $cache->set($GLOBALS['session']->get('imp', 'treeob'), serialize($instance), 86400);
+            }
+        }
+    }
+
+}
diff --git a/imp/lib/Factory/Mail.php b/imp/lib/Factory/Mail.php
new file mode 100644 (file)
index 0000000..ebe350d
--- /dev/null
@@ -0,0 +1,68 @@
+<?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_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. */
+        $params = array_merge($params, $GLOBALS['session']->get('imp', 'smtp', Horde_Session::TYPE_ARRAY));
+
+        /* 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_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);
+    }
+
+}
diff --git a/imp/lib/Factory/MailboxList.php b/imp/lib/Factory/MailboxList.php
new file mode 100644 (file)
index 0000000..14cc786
--- /dev/null
@@ -0,0 +1,119 @@
+<?php
+/**
+ * A Horde_Injector:: based IMP_Mailbox_List:: 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 IMP_Mailbox_List:: 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_Factory_MailboxList
+{
+    /**
+     * Instances.
+     *
+     * @var array
+     */
+    private $_instances = array();
+
+    /**
+     * Constructor.
+     *
+     * @param Horde_Injector $injector  The injector to use.
+     */
+    public function __construct(Horde_Injector $injector)
+    {
+        register_shutdown_function(array($this, 'shutdown'));
+    }
+
+    /**
+     * Return the mailbox list instance.
+     * For IMP/MIMP, returns an IMP_Mailbox_List_Track object.
+     * For DIMP/Mobile, returns an IMP_Mailbox_List object.
+     *
+     * @param string $mailbox       The mailbox name.
+     * @param IMP_Indices $indices  An indices object. Only used for 'imp' and
+     *                              'mimp' views.
+     *
+     * @return IMP_Mailbox_List  The singleton instance.
+     * @throws IMP_Exception
+     */
+    public function create($mailbox, $indices = null)
+    {
+        $mode = IMP::getViewMode();
+
+        if (!isset($this->_instances[$mailbox])) {
+            switch ($mode) {
+            case 'dimp':
+            case 'mobile':
+                $ob = new IMP_Mailbox_List($mailbox);
+                break;
+
+            case 'imp':
+            case 'mimp':
+                try {
+                    $ob = $GLOBALS['session']->get('imp', 'imp_mailbox/' . $mailbox);
+                } catch (Exception $e) {
+                    $ob = null;
+                }
+
+                if (is_null($ob)) {
+                    $ob = new IMP_Mailbox_List_Track($mailbox);
+                }
+                break;
+            }
+
+            $this->_instances[$mailbox] = $ob;
+        }
+
+        switch ($mode) {
+        case 'imp':
+        case 'mimp':
+            $this->_instances[$mailbox]->setIndex($indices);
+            $this->_instance[$mailbox]->checkcache = is_null($indices);
+            break;
+        }
+
+        return $this->_instances[$mailbox];
+    }
+
+    /**
+     * Tasks to perform on shutdown.
+     */
+    public function shutdown()
+    {
+        switch (IMP::getViewMode()) {
+        case 'imp':
+        case 'mimp':
+            /* Cache mailbox information if viewing in standard (IMP) message
+             * mode. Needed to keep navigation consistent when moving through
+             * the message list, and to ensure messages aren't marked as
+             * missing in search mailboxes (e.g. if search is dependent on
+             * unseen flag). */
+            foreach ($this->_instances as $key => $val) {
+                if ($val->changed) {
+                    $GLOBALS['session']->set('imp', 'imp_mailbox/' . $key, $val);
+                }
+            }
+        }
+    }
+
+}
diff --git a/imp/lib/Factory/MimeViewer.php b/imp/lib/Factory/MimeViewer.php
new file mode 100644 (file)
index 0000000..7998c01
--- /dev/null
@@ -0,0 +1,96 @@
+<?php
+/**
+ * A Horde_Injector:: based Horde_Mime_Viewer factory for IMP drivers.
+ *
+ * PHP version 5
+ *
+ * @category Horde
+ * @package  IMP
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @license  http://www.fsf.org/copyleft/gpl.html GPL
+ * @link     http://pear.horde.org/index.php?package=IMP
+ */
+
+/**
+ * A Horde_Injector:: based Horde_Mime_Viewer factory for IMP drivers.
+ *
+ * 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.
+ *
+ * @category Horde
+ * @package  IMP
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @license  http://www.fsf.org/copyleft/gpl.html GPL
+ * @link     http://pear.horde.org/index.php?package=IMP
+ */
+class IMP_Factory_MimeViewer
+{
+    /**
+     * The injector.
+     *
+     * @var Horde_Injector
+     */
+    private $_injector;
+
+    /**
+     * Constructor.
+     *
+     * @param Horde_Injector $injector  The injector to use.
+     */
+    public function __construct(Horde_Injector $injector)
+    {
+        $this->_injector = $injector;
+    }
+
+    /**
+     * Attempts to return a concrete Horde_Mime_Viewer object based on the
+     * MIME type.
+     *
+     * @param Horde_Mime_Part $mime   An object with the data to be rendered.
+     * @param IMP_Contents $contents  The IMP_Contents object associated with
+     *                                $mime.
+     * @param string $type            The MIME type to use for loading.
+     *
+     * @return Horde_Mime_Viewer_Base  The newly created instance.
+     * @throws Horde_Mime_Viewer_Exception
+     */
+    public function create(Horde_Mime_Part $mime,
+                           IMP_Contents $contents = null, $type = null)
+    {
+        list($driver, $params) = $this->_injector->getInstance('Horde_Core_Factory_MimeViewer')->getViewerConfig($type ? $type : $mime->getType(), 'imp');
+
+        switch ($driver) {
+        case 'Report':
+        case 'Security':
+            $params['viewer_callback'] = array($this, 'createCallback');
+            break;
+        }
+
+        $params['imp_contents'] = $contents;
+
+        return Horde_Mime_Viewer::factory($driver, $mime, $params);
+    }
+
+    /**
+     * Callback used to return a MIME Viewer object from within certain
+     * Viewer drivers.
+     *
+     * @param Horde_Mime_Viewer_Base $viewer  The MIME Viewer driver
+     *                                        requesting the new object.
+     * @param Horde_Mime_Part $mime           An object with the data to be
+     *                                        rendered.
+     * @param string $type                    The MIME type to use for
+     *                                        rendering.
+     *
+     * @return Horde_Mime_Viewer_Base  The newly created instance.
+     * @throws Horde_Mime_Viewer_Exception
+     */
+    public function createCallback(Horde_Mime_Viewer_Base $viewer,
+                                   Horde_Mime_Part $mime, $type)
+    {
+        return $this->create($mime, $viewer->getConfigParam('imp_contents'), $type);
+    }
+
+}
diff --git a/imp/lib/Factory/Pgp.php b/imp/lib/Factory/Pgp.php
new file mode 100644 (file)
index 0000000..205ffb7
--- /dev/null
@@ -0,0 +1,51 @@
+<?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_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);
+    }
+
+}
diff --git a/imp/lib/Factory/Quota.php b/imp/lib/Factory/Quota.php
new file mode 100644 (file)
index 0000000..a526eec
--- /dev/null
@@ -0,0 +1,75 @@
+<?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_Factory_Quota
+{
+    /**
+     * Return the IMP_Quota instance.
+     *
+     * @return IMP_Quota  The singleton instance.
+     * @throws IMP_Exception
+     */
+    public function create(Horde_Injector $injector)
+    {
+        $qparams = $GLOBALS['session']->get('imp', 'imap_quota');
+
+        if (!isset($qparams['driver'])) {
+            throw new IMP_Exception('Quota config missing driver parameter.');
+        }
+        $driver = $qparams['driver'];
+        $params = isset($qparams['params'])
+            ? $qparams['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']);
+        }
+
+        $imap_ob = $injector->getInstance('IMP_Factory_Imap')->create();
+
+        switch (Horde_String::lower($driver)) {
+        case 'imap':
+            $params['imap_ob'] = $imap_ob;
+            $params['mbox'] = $injector->getInstance('IMP_Search')->isSearchMbox(IMP::$mailbox)
+                ? 'INBOX'
+                : IMP::$mailbox;
+            break;
+
+        case 'sql':
+            $params['db'] = $injector->getInstance('Horde_Core_Factory_Db')->create('imp', $params);
+            break;
+        }
+
+        $params['username'] = $imap_ob->getParam('username');
+
+        return IMP_Quota::factory($driver, $params);
+    }
+
+}
diff --git a/imp/lib/Factory/Search.php b/imp/lib/Factory/Search.php
new file mode 100644 (file)
index 0000000..12677a0
--- /dev/null
@@ -0,0 +1,66 @@
+<?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_Factory_Search
+{
+    /**
+     * Return the IMP_Search instance.
+     *
+     * @return IMP_Search  The singleton instance.
+     */
+    public function create(Horde_Injector $injector)
+    {
+        try {
+            $instance = $GLOBALS['session']->get('imp', 'search');
+        } catch (Exception $e) {
+            Horde::logMessage('Could not unserialize stored IMP_Search object.', 'DEBUG');
+            $instance = null;
+        }
+
+        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.
+     *
+     * @param IMP_Search $instance  Search object.
+     */
+    public function shutdown($instance)
+    {
+        /* Only need to store the object if the object has changed. */
+        if ($instance->changed) {
+            $GLOBALS['session']->set('imp', 'search', $instance);
+        }
+    }
+
+}
diff --git a/imp/lib/Factory/Sentmail.php b/imp/lib/Factory/Sentmail.php
new file mode 100644 (file)
index 0000000..e2333f2
--- /dev/null
@@ -0,0 +1,51 @@
+<?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_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);
+    }
+
+}
diff --git a/imp/lib/Factory/Smime.php b/imp/lib/Factory/Smime.php
new file mode 100644 (file)
index 0000000..1e3c752
--- /dev/null
@@ -0,0 +1,40 @@
+<?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_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');
+    }
+
+}
index b9affce..ca3fac5 100644 (file)
@@ -111,7 +111,7 @@ class IMP_Filter
         }
 
         $addr = array();
-        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
 
         foreach (array_keys($indices) as $mbox) {
             $imp_imap->checkUidvalidity($mbox);
@@ -119,7 +119,7 @@ class IMP_Filter
 
         /* Get the list of from addresses. */
         foreach ($indices as $mbox => $idx) {
-            $contents = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($mbox, $idx));
+            $contents = $GLOBALS['injector']->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($mbox, $idx));
             $hdr = $contents->getHeaderOb();
             $addr[] = Horde_Mime_Address::bareAddress($hdr->getValue('from'));
         }
index b2b6e23..a00e256 100644 (file)
@@ -55,7 +55,7 @@ class IMP_Flag_User extends IMP_Flag_Imap
         case 'imapflag':
             /* IMAP keywords must conform to RFC 3501 [9] (flag-keyword).
              * Convert whitespace to underscore. */
-            $this->_imapflag = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->getUtils()->stripNonAtomChars(Horde_String::convertCharset(strtr($value, ' ', '_'), 'UTF-8', 'UTF7-IMAP'));
+            $this->_imapflag = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->getUtils()->stripNonAtomChars(Horde_String::convertCharset(strtr($value, ' ', '_'), 'UTF-8', 'UTF7-IMAP'));
             break;
 
         case 'label':
index 371ccf0..6f2d468 100644 (file)
@@ -117,7 +117,7 @@ class IMP_Flags implements ArrayAccess, Serializable
         try {
             /* Make sure we are in R/W mailbox mode (SELECT). No flags are
              * allowed in EXAMINE mode. */
-            $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+            $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
             $imp_imap->openMailbox($opts['mailbox'], Horde_Imap_Client::OPEN_READWRITE);
             $status = $imp_imap->status($opts['mailbox'], Horde_Imap_Client::STATUS_PERMFLAGS);
         } catch (Horde_Imap_Client_Exception $e) {
index 3d6eeda..6f95a6e 100644 (file)
@@ -55,7 +55,7 @@ class IMP_Folder
             }
 
             try {
-                $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->deleteMailbox($folder);
+                $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->deleteMailbox($folder);
                 $notification->push(sprintf(_("The folder \"%s\" was successfully deleted."), IMP::displayFolder($folder)), 'horde.success');
                 $deleted[] = $folder;
             } catch (Horde_Imap_Client_Exception $e) {
@@ -143,7 +143,7 @@ class IMP_Folder
 
         /* Attempt to create the mailbox. */
         try {
-            $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->createMailbox($folder, array('special_use' => $special_use));
+            $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->createMailbox($folder, array('special_use' => $special_use));
         } catch (Horde_Imap_Client_Exception $e) {
             $notification->push(sprintf(_("The folder \"%s\" was not created. This is what the server said"), IMP::displayFolder($folder)) . ': ' . $e->getMessage(), 'horde.error');
             return false;
@@ -177,7 +177,7 @@ class IMP_Folder
         }
 
         try {
-            $ret = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->listMailboxes($folder, array('flat' => true));
+            $ret = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->listMailboxes($folder, array('flat' => true));
             return !empty($ret);
         } catch (Horde_Imap_Client_Exception $e) {
             return false;
@@ -214,7 +214,7 @@ class IMP_Folder
         $all_folders = $this->getAllSubfolders($old);
 
         try {
-            $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->renameMailbox($old, $new);
+            $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->renameMailbox($old, $new);
         } catch (Horde_Imap_Client_Exception $e) {
             $GLOBALS['notification']->push(sprintf(_("Renaming \"%s\" to \"%s\" failed. This is what the server said"), IMP::displayFolder($old), IMP::displayFolder($new)) . ': ' . $e->getMessage(), 'horde.error');
             return false;
@@ -258,7 +258,7 @@ class IMP_Folder
 
         foreach (array_filter($folders) as $folder) {
             try {
-                $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->subscribeMailbox($folder, true);
+                $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->subscribeMailbox($folder, true);
                 $notification->push(sprintf(_("You were successfully subscribed to \"%s\""), IMP::displayFolder($folder)), 'horde.success');
                 $subscribed[] = $folder;
             } catch (Horde_Imap_Client_Exception $e) {
@@ -298,7 +298,7 @@ class IMP_Folder
                 $notification->push(sprintf(_("You cannot unsubscribe from \"%s\"."), IMP::displayFolder($folder)), 'horde.error');
             } else {
                 try {
-                    $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->subscribeMailbox($folder, false);
+                    $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->subscribeMailbox($folder, false);
                     $notification->push(sprintf(_("You were successfully unsubscribed from \"%s\""), IMP::displayFolder($folder)), 'horde.success');
                     $unsubscribed[] = $folder;
                 } catch (Horde_Imap_Client_Exception $e) {
@@ -339,7 +339,7 @@ class IMP_Folder
 
         foreach ($folder_list as $folder) {
             try {
-                $status = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->status($folder, Horde_Imap_Client::STATUS_MESSAGES);
+                $status = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->status($folder, Horde_Imap_Client::STATUS_MESSAGES);
             } catch (Horde_Imap_Client_Exception $e) {
                 continue;
             }
@@ -347,7 +347,7 @@ class IMP_Folder
                 /* Download one message at a time to save on memory
                  * overhead. */
                 try {
-                    $res = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->fetch($folder, array(
+                    $res = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->fetch($folder, array(
                         Horde_Imap_Client::FETCH_FULLMSG => array('peek' => true, 'stream' => true),
                         Horde_Imap_Client::FETCH_ENVELOPE => true,
                         Horde_Imap_Client::FETCH_DATE => true,
@@ -392,7 +392,7 @@ class IMP_Folder
     {
         $message = '';
         $msgcount = 0;
-        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
 
         $fd = fopen($mbox, 'r');
         while (!feof($fd)) {
index 53d8c33..38ee230 100644 (file)
@@ -348,7 +348,7 @@ class IMP
             return $cache[$folder];
         }
 
-        $ns_info = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->getNamespace($folder);
+        $ns_info = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->getNamespace($folder);
         $delimiter = is_null($ns_info) ? '' : $ns_info['delimiter'];
 
         /* Substitute any translated prefix text. */
@@ -418,7 +418,7 @@ class IMP
     {
         $t = $GLOBALS['injector']->createInstance('Horde_Template');
         $t->set('forminput', Horde_Util::formInput());
-        $t->set('use_folders', $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->allowFolders(), true);
+        $t->set('use_folders', $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->allowFolders(), true);
         if ($t->get('use_folders')) {
             Horde::addScriptFile('imp.js', 'imp');
             $menu_view = $GLOBALS['prefs']->getValue('menu_view');
@@ -547,7 +547,7 @@ class IMP
      */
     static public function folderPref($folder, $append)
     {
-        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
         $def_ns = $imp_imap->defaultNamespace();
         $empty_ns = $imp_imap->getNamespace('');
 
index d565dad..a6a4425 100644 (file)
@@ -45,7 +45,7 @@ class IMP_Imap_Acl
             throw new IMP_Exception(_("ACLs not configured for this server."));
         }
 
-        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
         if (!$imp_imap->queryCapability('ACL')) {
             throw new IMP_Exception(_("IMAP server does not support ACLs."));
         }
@@ -129,7 +129,7 @@ class IMP_Imap_Acl
     public function getACL($mbox)
     {
         try {
-            return $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->getACL($mbox);
+            return $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->getACL($mbox);
         } catch (Horde_Imap_Client_Exception $e) {
             throw new IMP_Exception(_("Could not retrieve ACL"));
         }
@@ -147,7 +147,7 @@ class IMP_Imap_Acl
     public function editACL($mbox, $user, $acl)
     {
         try {
-            $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->setACL($mbox, $user, array('remove' => empty($acl), 'rights' => implode('', $acl)));
+            $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->setACL($mbox, $user, array('remove' => empty($acl), 'rights' => implode('', $acl)));
         } catch (Horde_Imap_Client_Exception $e) {
             throw new IMP_Exception(sprintf(_("Couldn't give user \"%s\" the following rights for the folder \"%s\": %s"), $user, $mbox, implode('', $acl)));
         }
@@ -164,7 +164,7 @@ class IMP_Imap_Acl
     public function canEdit($mbox, $user)
     {
         try {
-            $rights = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->listACLRights($mbox, $user);
+            $rights = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->listACLRights($mbox, $user);
             $rights = array_merge($rights['required'], $rights['optional']);
             foreach ($rights as $val) {
                 if (strpos($val, 'a') !== false) {
index fdd7959..ec19652 100644 (file)
@@ -187,7 +187,7 @@ class IMP_Imap_Tree implements ArrayAccess, Iterator, Serializable
         unset($this->_cache['fulllist'], $this->_cache['subscribed']);
 
         /* Do IMAP specific initialization. */
-        $imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
+        $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
         if ($session->get('imp', 'protocol') == 'imap') {
             $ns = $imp_imap->getNamespaceList();
             $ptr = reset($ns);
@@ -264,7 +264,7 @@ class IMP_Imap_Tree implements ArrayAccess, Iterator, Serializable
         }
 
         try {
-            $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+            $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
             $result = $imp_imap->listMailboxes($searches, $showunsub ? Horde_Imap_Client::MBOX_ALL : Horde_Imap_Client::MBOX_SUBSCRIBED_EXISTS, array('attributes' => true, 'delimiter' => true, 'sort' => true));
 
             /* INBOX must always appear. */
@@ -470,7 +470,7 @@ class IMP_Imap_Tree implements ArrayAccess, Iterator, Serializable
 
         if (!empty($id)) {
             try {
-                $this->_insert($GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->listMailboxes($id, Horde_Imap_Client::MBOX_ALL, array('attributes' => true, 'delimiter' => true, 'sort' => true)));
+                $this->_insert($GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->listMailboxes($id, Horde_Imap_Client::MBOX_ALL, array('attributes' => true, 'delimiter' => true, 'sort' => true)));
             } catch (Horde_Imap_Client_Exception $e) {}
         }
     }
@@ -1262,7 +1262,7 @@ class IMP_Imap_Tree implements ArrayAccess, Iterator, Serializable
     {
         if (!in_array($mailbox, array(self::OTHER_KEY, self::SHARED_KEY, self::VFOLDER_KEY)) &&
             (strpos($mailbox, self::VFOLDER_KEY . $this->_delimiter) !== 0)) {
-            return $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->getNamespace($mailbox);
+            return $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->getNamespace($mailbox);
         }
         return null;
     }
@@ -1324,7 +1324,7 @@ class IMP_Imap_Tree implements ArrayAccess, Iterator, Serializable
             $this->changed = true;
         }
 
-        if (!$GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->allowFolders()) {
+        if (!$GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->allowFolders()) {
             return;
         }
 
@@ -1429,7 +1429,7 @@ class IMP_Imap_Tree implements ArrayAccess, Iterator, Serializable
     public function createMailboxName($parent, $new)
     {
         $ns_info = empty($parent)
-            ? $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->defaultNamespace()
+            ? $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->defaultNamespace()
             : $this->_getNamespace($parent);
 
         if (is_null($ns_info)) {
index 3c6485c..7a1874b 100644 (file)
@@ -157,7 +157,7 @@ class IMP_Imap_Tree_Element
             $info->unseen = 0;
 
             try {
-                if ($msgs_info = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->status($this->value, Horde_Imap_Client::STATUS_RECENT | Horde_Imap_Client::STATUS_UNSEEN | Horde_Imap_Client::STATUS_MESSAGES)) {
+                if ($msgs_info = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->status($this->value, Horde_Imap_Client::STATUS_RECENT | Horde_Imap_Client::STATUS_UNSEEN | Horde_Imap_Client::STATUS_MESSAGES)) {
                     if (!empty($msgs_info['recent'])) {
                         $info->recent = intval($msgs_info['recent']);
                     }
index f24a12f..44903d8 100644 (file)
@@ -81,7 +81,7 @@ class IMP_Indices implements Countable, Iterator
                     }
                 }
             } elseif (is_string($data)) {
-                $indices = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->getUtils()->fromSequenceString($data);
+                $indices = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->getUtils()->fromSequenceString($data);
             } elseif ($data instanceof IMP_Compose) {
                 $indices = array(
                     $data->getMetadata('mailbox') => array($data->getMetadata('uid'))
@@ -184,7 +184,7 @@ class IMP_Indices implements Countable, Iterator
      */
     public function __toString()
     {
-        return $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->getUtils()->toSequenceString($this->_indices, array('mailbox' => true));
+        return $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->getUtils()->toSequenceString($this->_indices, array('mailbox' => true));
     }
 
     /* Iterator methods. */
diff --git a/imp/lib/Injector/Factory/AuthImap.php b/imp/lib/Injector/Factory/AuthImap.php
deleted file mode 100644 (file)
index 0233160..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-<?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.');
-        }
-
-        $aparams = $GLOBALS['session']->get('imp', 'imap_admin', Horde_Session::TYPE_ARRAY);
-
-        $params = array_merge(
-            $params,
-            (isset($aparams['params']) ? $aparams['params'] : array()),
-            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);
-    }
-
-}
diff --git a/imp/lib/Injector/Factory/Compose.php b/imp/lib/Injector/Factory/Compose.php
deleted file mode 100644 (file)
index 3b19517..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-<?php
-/**
- * A Horde_Injector:: based IMP_Compose:: 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 IMP_Compose:: 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_Compose
-{
-    /**
-     * Instances.
-     *
-     * @var array
-     */
-    private $_instances = array();
-
-    /**
-     * The injector.
-     *
-     * @var Horde_Injector
-     */
-    private $_injector;
-
-    /**
-     * Constructor.
-     *
-     * @param Horde_Injector $injector  The injector to use.
-     */
-    public function __construct(Horde_Injector $injector)
-    {
-        $this->_injector = $injector;
-
-        register_shutdown_function(array($this, 'shutdown'));
-    }
-
-    /**
-     * Return the IMP_Compose:: instance.
-     *
-     * @param string $cacheid  The cache ID string.
-     *
-     * @return IMP_Compose  The singleton compose instance.
-     * @throws IMP_Exception
-     */
-    public function create($cacheid = null)
-    {
-        if (empty($cacheid)) {
-            $cacheid = strval(new Horde_Support_Randomid());
-        } elseif (!isset($this->_instances[$cacheid])) {
-            $this->_instances[$cacheid] = $GLOBALS['session']->retrieve($cacheid);
-        }
-
-        if (empty($this->_instances[$cacheid])) {
-            $this->_instances[$cacheid] = new IMP_Compose($cacheid);
-        }
-
-        return $this->_instances[$cacheid];
-    }
-
-    /**
-     * Tasks to perform on shutdown.
-     */
-    public function shutdown()
-    {
-        global $session;
-
-        $cache = $session->get('imp', 'compose_cache', Horde_Session::TYPE_ARRAY);
-        $changed = false;
-
-        foreach ($this->_instances as $key => $val) {
-            switch ($val->changed) {
-            case 'changed':
-                $val->changed = '';
-                $session->store($val, false, $key);
-                $cache[$key] = 1;
-                $changed = true;
-                break;
-
-            case 'deleted':
-                unset($cache[$key]);
-                $session->purge($key);
-                $changed = true;
-                break;
-            }
-
-        }
-
-        if ($changed) {
-            $session->set('imp', 'compose_cache', $cache);
-        }
-    }
-
-}
diff --git a/imp/lib/Injector/Factory/Contents.php b/imp/lib/Injector/Factory/Contents.php
deleted file mode 100644 (file)
index 5447df6..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-/**
- * A Horde_Injector:: based IMP_Contents:: 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 IMP_Contents:: 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_Contents
-{
-    /**
-     * Instances.
-     *
-     * @var array
-     */
-    private $_instances = array();
-
-    /**
-     * Return the IMP_Contents:: instance.
-     *
-     * @param IMP_Indices $indices  An indices object.
-     *
-     * @return IMP_Contents  The singleton contents instance.
-     * @throws IMP_Exception
-     */
-    public function create($indices)
-    {
-        $key = strval($indices);
-
-        if (!isset($this->_instances[$key])) {
-            $this->_instances[$key] = new IMP_Contents($indices);
-        }
-
-        return $this->_instances[$key];
-    }
-
-}
diff --git a/imp/lib/Injector/Factory/Flags.php b/imp/lib/Injector/Factory/Flags.php
deleted file mode 100644 (file)
index f4f255e..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-<?php
-/**
- * A Horde_Injector based factory for the IMP_Flags 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_Flags 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_Flags
-{
-    /**
-     * Return the IMP_Flags instance.
-     *
-     * @return IMP_Flags  The singleton instance.
-     */
-    public function create(Horde_Injector $injector)
-    {
-        try {
-            $instance = $GLOBALS['session']->get('imp', 'flags');
-        } catch (Exception $e) {
-            Horde::logMessage('Could not unserialize stored IMP_Flags object.', 'DEBUG');
-            $instance = null;
-        }
-
-        if (is_null($instance)) {
-            $instance = new IMP_Flags();
-        }
-
-        register_shutdown_function(array($this, 'shutdown'), $instance);
-
-        return $instance;
-    }
-
-    /**
-     * Store serialized version of object in the current session.
-     *
-     * @param IMP_Flags $instance  Flags object.
-     */
-    public function shutdown($instance)
-    {
-        /* Only need to store the object if the object has changed. */
-        if ($instance->changed) {
-            $GLOBALS['session']->set('imp', 'flags', $instance);
-        }
-    }
-
-}
diff --git a/imp/lib/Injector/Factory/Identity.php b/imp/lib/Injector/Factory/Identity.php
deleted file mode 100644 (file)
index 16fd85f..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?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_Core_Factory_Identity')->create(null, 'imp');
-    }
-
-}
diff --git a/imp/lib/Injector/Factory/Imap.php b/imp/lib/Injector/Factory/Imap.php
deleted file mode 100644 (file)
index c5389d0..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-<?php
-/**
- * A Horde_Injector:: based IMP_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 IMP_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_Imap
-{
-    /**
-     * Instances.
-     *
-     * @var array
-     */
-    private $_instances = array();
-
-    /**
-     * The list of instances to save.
-     *
-     * @var array
-     */
-    private $_save = array();
-
-    /**
-     * Return the IMP_Imap:: instance.
-     *
-     * @param string $id     The server ID.
-     * @param boolean $save  Save the instance in the session?
-     *
-     * @return IMP_Imap  The singleton instance.
-     * @throws IMP_Exception
-     */
-    public function create($id = null, $save = false)
-    {
-        global $session;
-
-        if (is_null($id) &&
-            !($id = $session->get('imp', 'server_key'))) {
-            $id = 'default';
-        }
-
-        if (!isset($this->_instances[$id])) {
-            if (!($ob = $session->get('imp', 'imap_ob/' . $id))) {
-                $ob = new IMP_Imap();
-            }
-
-            $this->_instances[$id] = $ob;
-        }
-
-        if ($save && !$session->exists('imp', 'imap_ob/' . $id)) {
-            if (empty($this->_save)) {
-                register_shutdown_function(array($this, 'shutdown'));
-            }
-            $this->_save[] = $id;
-        }
-
-        return $this->_instances[$id];
-    }
-
-    /**
-     * Saves IMP_Imap instances to the session.
-     */
-    public function shutdown()
-    {
-        foreach (array_unique($this->_save) as $id) {
-            $GLOBALS['session']->set('imp', 'imap_ob/' . $id, $this->_instances[$id]);
-        }
-    }
-
-}
diff --git a/imp/lib/Injector/Factory/Imaptree.php b/imp/lib/Injector/Factory/Imaptree.php
deleted file mode 100644 (file)
index af54478..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-<?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)
-    {
-        global $session;
-
-        $instance = null;
-
-        /* If an IMP_Imap_Tree object is currently stored in the cache,
-         * re-create that object.  Else, create a new instance. */
-        if ($session->exists('imp', 'treeob')) {
-            /* 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) {
-                $instance = $session->retrieve('imp_imaptree');
-            } else {
-                try {
-                    $instance = @unserialize($cache->get($session->get('imp', 'treeob'), 86400));
-                } catch (Exception $e) {
-                    Horde::logMessage('Could not unserialize stored IMP_Imap_Tree object.', 'DEBUG');
-                }
-            }
-        } else {
-            $session->set('imp', 'treeob', strval(new Horde_Support_Randomid()));
-        }
-
-        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)
-    {
-        global $session;
-
-        /* 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) {
-                $session->store($instance, true, 'imp_imaptree');
-            } else {
-                $cache->set($GLOBALS['session']->get('imp', 'treeob'), serialize($instance), 86400);
-            }
-        }
-    }
-
-}
diff --git a/imp/lib/Injector/Factory/Mail.php b/imp/lib/Injector/Factory/Mail.php
deleted file mode 100644 (file)
index 39ab5a5..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-<?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. */
-        $params = array_merge($params, $GLOBALS['session']->get('imp', 'smtp', Horde_Session::TYPE_ARRAY));
-
-        /* 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);
-    }
-
-}
diff --git a/imp/lib/Injector/Factory/MailboxList.php b/imp/lib/Injector/Factory/MailboxList.php
deleted file mode 100644 (file)
index 406db46..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-<?php
-/**
- * A Horde_Injector:: based IMP_Mailbox_List:: 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 IMP_Mailbox_List:: 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_MailboxList
-{
-    /**
-     * Instances.
-     *
-     * @var array
-     */
-    private $_instances = array();
-
-    /**
-     * Constructor.
-     *
-     * @param Horde_Injector $injector  The injector to use.
-     */
-    public function __construct(Horde_Injector $injector)
-    {
-        register_shutdown_function(array($this, 'shutdown'));
-    }
-
-    /**
-     * Return the mailbox list instance.
-     * For IMP/MIMP, returns an IMP_Mailbox_List_Track object.
-     * For DIMP/Mobile, returns an IMP_Mailbox_List object.
-     *
-     * @param string $mailbox       The mailbox name.
-     * @param IMP_Indices $indices  An indices object. Only used for 'imp' and
-     *                              'mimp' views.
-     *
-     * @return IMP_Mailbox_List  The singleton instance.
-     * @throws IMP_Exception
-     */
-    public function create($mailbox, $indices = null)
-    {
-        $mode = IMP::getViewMode();
-
-        if (!isset($this->_instances[$mailbox])) {
-            switch ($mode) {
-            case 'dimp':
-            case 'mobile':
-                $ob = new IMP_Mailbox_List($mailbox);
-                break;
-
-            case 'imp':
-            case 'mimp':
-                try {
-                    $ob = $GLOBALS['session']->get('imp', 'imp_mailbox/' . $mailbox);
-                } catch (Exception $e) {
-                    $ob = null;
-                }
-
-                if (is_null($ob)) {
-                    $ob = new IMP_Mailbox_List_Track($mailbox);
-                }
-                break;
-            }
-
-            $this->_instances[$mailbox] = $ob;
-        }
-
-        switch ($mode) {
-        case 'imp':
-        case 'mimp':
-            $this->_instances[$mailbox]->setIndex($indices);
-            $this->_instance[$mailbox]->checkcache = is_null($indices);
-            break;
-        }
-
-        return $this->_instances[$mailbox];
-    }
-
-    /**
-     * Tasks to perform on shutdown.
-     */
-    public function shutdown()
-    {
-        switch (IMP::getViewMode()) {
-        case 'imp':
-        case 'mimp':
-            /* Cache mailbox information if viewing in standard (IMP) message
-             * mode. Needed to keep navigation consistent when moving through
-             * the message list, and to ensure messages aren't marked as
-             * missing in search mailboxes (e.g. if search is dependent on
-             * unseen flag). */
-            foreach ($this->_instances as $key => $val) {
-                if ($val->changed) {
-                    $GLOBALS['session']->set('imp', 'imp_mailbox/' . $key, $val);
-                }
-            }
-        }
-    }
-
-}
diff --git a/imp/lib/Injector/Factory/MimeViewer.php b/imp/lib/Injector/Factory/MimeViewer.php
deleted file mode 100644 (file)
index 3be0227..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-<?php
-/**
- * A Horde_Injector:: based Horde_Mime_Viewer factory for IMP drivers.
- *
- * PHP version 5
- *
- * @category Horde
- * @package  IMP
- * @author   Michael Slusarz <slusarz@horde.org>
- * @license  http://www.fsf.org/copyleft/gpl.html GPL
- * @link     http://pear.horde.org/index.php?package=IMP
- */
-
-/**
- * A Horde_Injector:: based Horde_Mime_Viewer factory for IMP drivers.
- *
- * 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.
- *
- * @category Horde
- * @package  IMP
- * @author   Michael Slusarz <slusarz@horde.org>
- * @license  http://www.fsf.org/copyleft/gpl.html GPL
- * @link     http://pear.horde.org/index.php?package=IMP
- */
-class IMP_Injector_Factory_MimeViewer
-{
-    /**
-     * The injector.
-     *
-     * @var Horde_Injector
-     */
-    private $_injector;
-
-    /**
-     * Constructor.
-     *
-     * @param Horde_Injector $injector  The injector to use.
-     */
-    public function __construct(Horde_Injector $injector)
-    {
-        $this->_injector = $injector;
-    }
-
-    /**
-     * Attempts to return a concrete Horde_Mime_Viewer object based on the
-     * MIME type.
-     *
-     * @param Horde_Mime_Part $mime   An object with the data to be rendered.
-     * @param IMP_Contents $contents  The IMP_Contents object associated with
-     *                                $mime.
-     * @param string $type            The MIME type to use for loading.
-     *
-     * @return Horde_Mime_Viewer_Base  The newly created instance.
-     * @throws Horde_Mime_Viewer_Exception
-     */
-    public function create(Horde_Mime_Part $mime,
-                           IMP_Contents $contents = null, $type = null)
-    {
-        list($driver, $params) = $this->_injector->getInstance('Horde_Core_Factory_MimeViewer')->getViewerConfig($type ? $type : $mime->getType(), 'imp');
-
-        switch ($driver) {
-        case 'Report':
-        case 'Security':
-            $params['viewer_callback'] = array($this, 'createCallback');
-            break;
-        }
-
-        $params['imp_contents'] = $contents;
-
-        return Horde_Mime_Viewer::factory($driver, $mime, $params);
-    }
-
-    /**
-     * Callback used to return a MIME Viewer object from within certain
-     * Viewer drivers.
-     *
-     * @param Horde_Mime_Viewer_Base $viewer  The MIME Viewer driver
-     *                                        requesting the new object.
-     * @param Horde_Mime_Part $mime           An object with the data to be
-     *                                        rendered.
-     * @param string $type                    The MIME type to use for
-     *                                        rendering.
-     *
-     * @return Horde_Mime_Viewer_Base  The newly created instance.
-     * @throws Horde_Mime_Viewer_Exception
-     */
-    public function createCallback(Horde_Mime_Viewer_Base $viewer,
-                                   Horde_Mime_Part $mime, $type)
-    {
-        return $this->create($mime, $viewer->getConfigParam('imp_contents'), $type);
-    }
-
-}
diff --git a/imp/lib/Injector/Factory/Pgp.php b/imp/lib/Injector/Factory/Pgp.php
deleted file mode 100644 (file)
index 6a5f41c..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-<?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);
-    }
-
-}
diff --git a/imp/lib/Injector/Factory/Quota.php b/imp/lib/Injector/Factory/Quota.php
deleted file mode 100644 (file)
index f5f6c26..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-<?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.
-     * @throws IMP_Exception
-     */
-    public function create(Horde_Injector $injector)
-    {
-        $qparams = $GLOBALS['session']->get('imp', 'imap_quota');
-
-        if (!isset($qparams['driver'])) {
-            throw new IMP_Exception('Quota config missing driver parameter.');
-        }
-        $driver = $qparams['driver'];
-        $params = isset($qparams['params'])
-            ? $qparams['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']);
-        }
-
-        $imap_ob = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
-
-        switch (Horde_String::lower($driver)) {
-        case 'imap':
-            $params['imap_ob'] = $imap_ob;
-            $params['mbox'] = $injector->getInstance('IMP_Search')->isSearchMbox(IMP::$mailbox)
-                ? 'INBOX'
-                : IMP::$mailbox;
-            break;
-
-        case 'sql':
-            $params['db'] = $injector->getInstance('Horde_Core_Factory_Db')->create('imp', $params);
-            break;
-        }
-
-        $params['username'] = $imap_ob->getParam('username');
-
-        return IMP_Quota::factory($driver, $params);
-    }
-
-}
diff --git a/imp/lib/Injector/Factory/Search.php b/imp/lib/Injector/Factory/Search.php
deleted file mode 100644 (file)
index 17bcaea..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-<?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)
-    {
-        try {
-            $instance = $GLOBALS['session']->get('imp', 'search');
-        } catch (Exception $e) {
-            Horde::logMessage('Could not unserialize stored IMP_Search object.', 'DEBUG');
-            $instance = null;
-        }
-
-        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.
-     *
-     * @param IMP_Search $instance  Search object.
-     */
-    public function shutdown($instance)
-    {
-        /* Only need to store the object if the object has changed. */
-        if ($instance->changed) {
-            $GLOBALS['session']->set('imp', 'search', $instance);
-        }
-    }
-
-}
diff --git a/imp/lib/Injector/Factory/Sentmail.php b/imp/lib/Injector/Factory/Sentmail.php
deleted file mode 100644 (file)
index a315058..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-<?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);
-    }
-
-}
diff --git a/imp/lib/Injector/Factory/Smime.php b/imp/lib/Injector/Factory/Smime.php
deleted file mode 100644 (file)
index bb49da5..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?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');
-    }
-
-}
index 4c6920e..9d8bbe7 100644 (file)
@@ -40,7 +40,7 @@ class IMP_LoginTasks_SystemTask_UpgradeFromImp4Auth extends Horde_LoginTasks_Sys
     protected function _upgradeExpireImapCache()
     {
         try {
-            $ob = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->ob;
+            $ob = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->ob;
 
             if ($cache = $ob->getCache()) {
                 $ob->login();
index bcfd927..fb34475 100644 (file)
@@ -164,7 +164,7 @@ class IMP_Mailbox_List implements Countable, Serializable
             ));
         }
 
-        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
 
         if (empty($options['preview'])) {
             $cache = null;
@@ -201,7 +201,7 @@ class IMP_Mailbox_List implements Countable, Serializable
                           !in_array('\\seen', $v['flags'])))) {
                         if (empty($preview_info[$k])) {
                             try {
-                                $imp_contents = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($mbox, $k));
+                                $imp_contents = $GLOBALS['injector']->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($mbox, $k));
                                 $prev = $imp_contents->generatePreview();
                                 $preview_info[$k] = array('IMPpreview' => $prev['text'], 'IMPpreviewc' => $prev['cut']);
                                 if (!is_null($cache)) {
@@ -352,7 +352,7 @@ class IMP_Mailbox_List implements Countable, Serializable
         }
 
         $criteria = new Horde_Imap_Client_Search_Query();
-        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
 
         if (IMP::hideDeletedMsgs($this->_mailbox)) {
             $criteria->flag('\\deleted', false);
@@ -455,7 +455,7 @@ class IMP_Mailbox_List implements Countable, Serializable
         $ret['anymsg'] = true;
         if (!$ret['msgcount'] && !$this->_searchmbox) {
             try {
-                $status = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->status($this->_mailbox, Horde_Imap_Client::STATUS_MESSAGES);
+                $status = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->status($this->_mailbox, Horde_Imap_Client::STATUS_MESSAGES);
                 $ret['anymsg'] = (bool)$status['messages'];
             } catch (Horde_Imap_Client_Exception $e) {
                 $ret['anymsg'] = false;
@@ -496,7 +496,7 @@ class IMP_Mailbox_List implements Countable, Serializable
              * information is returned via a SELECT/EXAMINE call. */
             if ($sortpref['by'] == Horde_Imap_Client::SORT_SEQUENCE) {
                 try {
-                    $res = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->status($this->_mailbox, Horde_Imap_Client::STATUS_FIRSTUNSEEN);
+                    $res = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->status($this->_mailbox, Horde_Imap_Client::STATUS_FIRSTUNSEEN);
                     if (!is_null($res['firstunseen'])) {
                         return $res['firstunseen'];
                     }
@@ -528,7 +528,7 @@ class IMP_Mailbox_List implements Countable, Serializable
     {
         if (is_null($this->_threadob)) {
             try {
-                $this->_threadob = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->thread($this->_mailbox, array('criteria' => $GLOBALS['session']->get('imp', 'imap_thread')));
+                $this->_threadob = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->thread($this->_mailbox, array('criteria' => $GLOBALS['session']->get('imp', 'imap_thread')));
             } catch (Horde_Imap_Client_Exception $e) {
                 $GLOBALS['notification']->push($e);
                 return new Horde_Imap_Client_Thread(array(), 'uid');
@@ -665,7 +665,7 @@ class IMP_Mailbox_List implements Countable, Serializable
         if (!$this->_searchmbox) {
             $sortpref = IMP::getSort($this->_mailbox, true);
             try {
-                return $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->getCacheId($this->_mailbox, array($sortpref['by'], $sortpref['dir']));
+                return $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->getCacheId($this->_mailbox, array($sortpref['by'], $sortpref['dir']));
             } catch (Horde_Imap_Client_Exception $e) {}
         }
 
index 0f359b3..9809687 100644 (file)
@@ -100,7 +100,7 @@ class IMP_Message
             break;
         }
 
-        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
 
         foreach ($indices->indices() as $mbox => $msgIndices) {
             $error = null;
@@ -202,7 +202,7 @@ class IMP_Message
             }
         }
 
-        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
 
         foreach ($indices->indices() as $mbox => $msgIndices) {
             $error = null;
@@ -330,7 +330,7 @@ class IMP_Message
 
         foreach ($indices as $folder => $index) {
             /* Fetch the message contents. */
-            $imp_contents = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($folder, $index));
+            $imp_contents = $GLOBALS['injector']->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($folder, $index));
 
             /* Fetch the message headers. */
             $imp_headers = $imp_contents->getHeaderOb();
@@ -477,7 +477,7 @@ class IMP_Message
             return;
         }
 
-        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
 
         if ($imp_imap->isReadOnly($mbox)) {
             throw new IMP_Exception(_("Cannot strip the MIME part as the mailbox is read-only."));
@@ -485,7 +485,7 @@ class IMP_Message
 
         $uidvalidity = $imp_imap->checkUidvalidity($mbox);
 
-        $contents = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Contents')->create($indices);
+        $contents = $GLOBALS['injector']->getInstance('IMP_Factory_Contents')->create($indices);
         $message = $contents->getMIMEMessage();
         $boundary = trim($message->getContentTypeParameter('boundary'), '"');
 
@@ -615,7 +615,7 @@ class IMP_Message
         $action_array = $action
             ? array('add' => $flags)
             : array('remove' => $flags);
-        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
 
         foreach ($indices->indices() as $mbox => $msgIndices) {
             $error = null;
@@ -670,7 +670,7 @@ class IMP_Message
         $action_array = $action
             ? array('add' => $flags)
             : array('remove' => $flags);
-        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
 
         foreach ($mboxes as $val) {
             try {
@@ -710,7 +710,7 @@ class IMP_Message
             return $msg_list ? new IMP_Indices() : null;
         }
 
-        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
         $imp_search = $GLOBALS['injector']->getInstance('IMP_Search');
         $process_list = $update_list = array();
 
@@ -761,7 +761,7 @@ class IMP_Message
     {
         global $notification, $prefs;
 
-        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
         $imp_search = $GLOBALS['injector']->getInstance('IMP_Search');
         $trash_folder = ($prefs->getValue('use_trash'))
             ? IMP::folderPref($prefs->getValue('trash_folder'), true)
@@ -815,7 +815,7 @@ class IMP_Message
     public function sizeMailbox($mbox, $formatted = true)
     {
         try {
-            $res = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->fetch($mbox, array(Horde_Imap_Client::FETCH_SIZE => true), array('sequence' => true));
+            $res = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->fetch($mbox, array(Horde_Imap_Client::FETCH_SIZE => true), array('sequence' => true));
 
             $size = 0;
             reset($res);
index 245f617..8776264 100644 (file)
@@ -109,7 +109,7 @@ class IMP_Mime_Viewer_Partial extends Horde_Mime_Viewer_Base
             if ($val == $number) {
                 $parts[$number] = $this->_mimepart->getContents();
             } else {
-                $ic = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($mbox, $val));
+                $ic = $GLOBALS['injector']->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($mbox, $val));
                 $parts[$ic->getMIMEMessage()->getContentTypeParameter('number')] = $ic->getBody();
             }
         }
index bc090cc..7d5765d 100644 (file)
@@ -25,7 +25,7 @@ extends Horde_Notification_Handler_Decorator_Base
     public function notify($options)
     {
         if (in_array('status', $options['listeners']) &&
-            ($ob = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()) &&
+            ($ob = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()) &&
             $ob->ob) {
             /* Display IMAP alerts. */
             foreach ($ob->alerts() as $alert) {
index 40ff5e4..c140539 100644 (file)
@@ -563,7 +563,7 @@ class Imp_Prefs_Identity extends Horde_Core_Prefs_Identity
      */
     public function saveSentmail($ident = null)
     {
-        return $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->allowFolders()
+        return $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->allowFolders()
             ? $this->getValue('save_sent_mail', $ident)
             : false;
     }
index cac8e98..b48a56f 100644 (file)
@@ -66,7 +66,7 @@ class IMP_Prefs_Ui
             $ui->suppressGroups[] = 'smime';
         }
 
-        if (!$injector->getInstance('IMP_Injector_Factory_Imap')->create()->allowFolders()) {
+        if (!$injector->getInstance('IMP_Factory_Imap')->create()->allowFolders()) {
             $ui->suppressGroups[] = 'searches';
         }
 
@@ -129,7 +129,7 @@ class IMP_Prefs_Ui
             case 'alternative_display':
                 $mock_part = new Horde_Mime_Part();
                 $mock_part->setType('text/html');
-                $v = $injector->getInstance('IMP_Injector_Factory_MimeViewer')->create($mock_part);
+                $v = $injector->getInstance('IMP_Factory_MimeViewer')->create($mock_part);
 
                 if (!$v->canRender('inline')) {
                     $ui->suppress[] = 'alternative_display';
@@ -1020,7 +1020,7 @@ class IMP_Prefs_Ui
         $t = $injector->createInstance('Horde_Template');
         $t->setOption('gettext', true);
 
-        if (!$injector->getInstance('IMP_Injector_Factory_Imap')->create()->allowFolders()) {
+        if (!$injector->getInstance('IMP_Factory_Imap')->create()->allowFolders()) {
             $t->set('nofolder', true);
         } else {
             $mailbox_selected = $prefs->getValue('initial_page');
@@ -1441,7 +1441,7 @@ class IMP_Prefs_Ui
     {
         global $injector, $prefs;
 
-        $imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
+        $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
 
         if (!$imp_imap->allowFolders() ||
             $prefs->isLocked('sent_mail_folder')) {
@@ -1932,7 +1932,7 @@ class IMP_Prefs_Ui
     {
         global $injector, $prefs;
 
-        $imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
+        $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
 
         if (!$imp_imap->allowFolders() ||
             $prefs->isLocked($pref)) {
@@ -1947,7 +1947,7 @@ class IMP_Prefs_Ui
             $folder = substr($folder, strlen(self::PREF_SPECIALUSE));
         } elseif (!empty($new)) {
             $new = Horde_String::convertCharset($new, 'UTF-8', 'UTF7-IMAP');
-            $folder = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->appendNamespace($new);
+            $folder = $injector->getInstance('IMP_Factory_Imap')->create()->appendNamespace($new);
             if (!$injector->getInstance('IMP_Folder')->create($folder, $prefs->getValue('subscribe'), array($type => true))) {
                 $folder = null;
             }
@@ -1968,7 +1968,7 @@ class IMP_Prefs_Ui
     protected function _getSpecialUse($use)
     {
         if (is_null($this->_cache)) {
-            $this->_cache = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->listMailboxes('*', Horde_Imap_Client::MBOX_ALL, array(
+            $this->_cache = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->listMailboxes('*', Horde_Imap_Client::MBOX_ALL, array(
                 'attributes' => true,
                 'special_use' => true,
                 'sort' => true
index fb7721d..c5fd114 100644 (file)
@@ -43,7 +43,7 @@ class IMP_Quota_Mdaemon extends IMP_Quota_Base
      */
     public function getQuota()
     {
-        $imap_ob = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+        $imap_ob = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
         $userDetails = $this->_getUserDetails(
             $this->_params['username'],
             $GLOBALS['session']->get('imp', 'maildomain')
index 70fcc1b..37f3082 100644 (file)
@@ -154,7 +154,7 @@ class IMP_Search implements ArrayAccess, Iterator, Serializable
      */
     public function imapSearch($mailbox, $query, $opts = array())
     {
-        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
 
         /* If doing a from/to search, use display sorting if possible.
          * Although there is a fallback to a PHP-based display sort, for
index d00bcce..be3b554 100644 (file)
@@ -43,7 +43,7 @@ class IMP_Spam
             return 0;
         }
 
-        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
         $report_count = $result = 0;
 
         foreach ($indices->indices() as $mbox => $msgIndices) {
@@ -57,7 +57,7 @@ class IMP_Spam
                 /* Fetch the raw message contents (headers and complete
                  * body). */
                 try {
-                    $imp_contents = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($mbox, $idx));
+                    $imp_contents = $GLOBALS['injector']->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($mbox, $idx));
                 } catch (IMP_Exception $e) {
                     continue;
                 }
@@ -119,7 +119,7 @@ class IMP_Spam
                     }
 
                     if (!isset($imp_compose)) {
-                        $imp_compose = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create();
+                        $imp_compose = $GLOBALS['injector']->getInstance('IMP_Factory_Compose')->create();
                         try {
                             $from_line = $GLOBALS['injector']->getInstance('IMP_Identity')->getFromLine();
                         } catch (Horde_Exception $e) {
index c52c155..80c5470 100644 (file)
@@ -32,7 +32,7 @@ class IMP_Ui_Block
             $GLOBALS['injector']->getInstance('IMP_Filter')->filter('INBOX');
         }
 
-        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
 
         /* Get list of mailboxes to poll. */
         $poll = $GLOBALS['injector']->getInstance('IMP_Imap_Tree')->getPollList(true);
index e0fc957..fe03fb6 100644 (file)
@@ -171,7 +171,7 @@ class IMP_Ui_Compose
 
         if (!is_null($indices)) {
             try {
-                $ob = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Contents')->create($indices);
+                $ob = $GLOBALS['injector']->getInstance('IMP_Factory_Contents')->create($indices);
             } catch (Horde_Exception $e) {}
         }
 
index dc06cc1..196b21c 100644 (file)
@@ -70,7 +70,7 @@ class IMP_Ui_Message
      */
     public function MDNCheck($mailbox, $uid, $headers, $confirmed = false)
     {
-        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
         $pref_val = $GLOBALS['prefs']->getValue('send_mdn');
 
         if (!$pref_val || $imp_imap->isReadOnly($mailbox)) {
index 342e11e..a8cf806 100644 (file)
@@ -45,7 +45,7 @@ class IMP_Views_Compose
         $t->setOption('gettext', true);
 
         if (!empty($args['composeCache'])) {
-            $imp_compose = $injector->getInstance('IMP_Injector_Factory_Compose')->create($args['composeCache']);
+            $imp_compose = $injector->getInstance('IMP_Factory_Compose')->create($args['composeCache']);
             $t->set('composeCache', $args['composeCache']);
         }
 
@@ -140,7 +140,7 @@ class IMP_Views_Compose
                 $t->set('read_receipt_set', ($d_read != 'ask'));
             }
 
-            $imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
+            $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
             $t->set('save_sent_mail', ($imp_imap->allowFolders() && !$prefs->isLocked('save_sent_mail')));
             $t->set('priority', $prefs->getValue('set_priority'));
             if (!$prefs->isLocked('default_encrypt') &&
index 71db094..4622eaa 100644 (file)
@@ -106,7 +106,7 @@ class IMP_Views_ListMessages
         }
 
         /* Generate the sorted mailbox list now. */
-        $imp_mailbox = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_MailboxList')->create($mbox);
+        $imp_mailbox = $GLOBALS['injector']->getInstance('IMP_Factory_MailboxList')->create($mbox);
         $sorted_list = $imp_mailbox->getSortedList();
         $msgcount = count($sorted_list['s']);
 
@@ -173,7 +173,7 @@ class IMP_Views_ListMessages
             }
         }
 
-        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+        $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create();
 
         /* These entries may change during a session, so always need to
          * update them. */
index 3a4d31b..2465e54 100644 (file)
@@ -110,14 +110,14 @@ class IMP_Views_ShowMessage
          * view. */
         $imp_contents = null;
         try {
-            $fetch_ret = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->fetch($mailbox, array(
+            $fetch_ret = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->fetch($mailbox, array(
                 Horde_Imap_Client::FETCH_ENVELOPE => true,
                 Horde_Imap_Client::FETCH_HEADERTEXT => array(array('parse' => true, 'peek' => false))
             ), array('ids' => array($uid)));
 
             if (isset($fetch_ret[$uid]['headertext'])) {
                 /* Parse MIME info and create the body of the message. */
-                $imp_contents = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($mailbox, $uid));
+                $imp_contents = $GLOBALS['injector']->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($mailbox, $uid));
             }
         } catch (Horde_Imap_Client_Exception $e) {
         } catch (IMP_Exception $e) {}
index 24fb4fe..fc2cb13 100644 (file)
@@ -37,7 +37,7 @@ $t = $injector->createInstance('Horde_Template');
 $t->setOption('gettext', true);
 
 /* Determine if mailbox is readonly. */
-$imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
+$imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
 $readonly = $imp_imap->isReadOnly(IMP::$mailbox);
 
 /* Get the base URL for this page. */
@@ -125,7 +125,7 @@ case 'rs':
 }
 
 /* Build the list of messages in the mailbox. */
-$imp_mailbox = $injector->getInstance('IMP_Injector_Factory_MailboxList')->create(IMP::$mailbox);
+$imp_mailbox = $injector->getInstance('IMP_Factory_MailboxList')->create(IMP::$mailbox);
 $pageOb = $imp_mailbox->buildMailboxPage($vars->p, $vars->s);
 
 /* Generate page title. */
index 3ae3c51..d22c927 100644 (file)
@@ -65,7 +65,7 @@ if (!Horde_Util::nonInputVar('from_message_page')) {
 
 $do_filter = false;
 $imp_flags = $injector->getInstance('IMP_Flags');
-$imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
+$imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
 $indices = new IMP_Indices($vars->indices);
 
 /* Run through the action handlers */
@@ -235,7 +235,7 @@ if ($imp_imap->allowFolders()) {
 }
 
 /* Build the list of messages in the mailbox. */
-$imp_mailbox = $injector->getInstance('IMP_Injector_Factory_MailboxList')->create(IMP::$mailbox);
+$imp_mailbox = $injector->getInstance('IMP_Factory_MailboxList')->create(IMP::$mailbox);
 $pageOb = $imp_mailbox->buildMailboxPage($vars->page, $start);
 $show_preview = $prefs->getValue('preview_enabled');
 
index 618caf1..bc2e9f3 100644 (file)
@@ -23,7 +23,7 @@ if (!$vars->uid || !$vars->folder) {
 
 $imp_ui = new IMP_Ui_Message();
 $js_onload = $js_vars = array();
-$readonly = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->isReadOnly($vars->folder);
+$readonly = $injector->getInstance('IMP_Factory_Imap')->create()->isReadOnly($vars->folder);
 
 switch ($vars->actionID) {
 case 'strip_attachment':
index bc76cf6..f2d7370 100644 (file)
@@ -29,12 +29,12 @@ Horde_Registry::appInit('imp', array(
 $vars = Horde_Variables::getDefaultVariables();
 
 /* Make sure we have a valid index. */
-$imp_mailbox = $injector->getInstance('IMP_Injector_Factory_MailboxList')->create(IMP::$mailbox, new IMP_Indices(IMP::$thismailbox, IMP::$uid));
+$imp_mailbox = $injector->getInstance('IMP_Factory_MailboxList')->create(IMP::$mailbox, new IMP_Indices(IMP::$thismailbox, IMP::$uid));
 if (!$imp_mailbox->isValidIndex()) {
     IMP::generateIMPUrl('mailbox-mimp.php', IMP::$mailbox)->add('a', 'm')->redirect();
 }
 
-$readonly = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->isReadOnly(IMP::$mailbox);
+$readonly = $injector->getInstance('IMP_Factory_Imap')->create()->isReadOnly(IMP::$mailbox);
 
 $imp_ui_mimp = $injector->getInstance('IMP_Ui_Mimp');
 $imp_hdr_ui = new IMP_Ui_Headers();
@@ -100,10 +100,10 @@ $uid = $index_ob['uid'];
 try {
     /* Need to fetch flags before HEADERTEXT, because SEEN flag might be set
      * before we can grab it. */
-    $flags_ret = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->fetch($mailbox_name, array(
+    $flags_ret = $injector->getInstance('IMP_Factory_Imap')->create()->fetch($mailbox_name, array(
         Horde_Imap_Client::FETCH_FLAGS => true,
     ), array('ids' => array($uid)));
-    $fetch_ret = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->fetch($mailbox_name, array(
+    $fetch_ret = $injector->getInstance('IMP_Factory_Imap')->create()->fetch($mailbox_name, array(
         Horde_Imap_Client::FETCH_ENVELOPE => true,
         Horde_Imap_Client::FETCH_HEADERTEXT => array(array('parse' => true, 'peek' => $readonly))
     ), array('ids' => array($uid)));
@@ -118,7 +118,7 @@ $use_pop = ($session->get('imp', 'protocol') == 'pop');
 
 /* Parse the message. */
 try {
-    $imp_contents = $injector->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($imp_mailbox));
+    $imp_contents = $injector->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($imp_mailbox));
 } catch (IMP_Exception $e) {
     IMP::generateIMPUrl('mailbox-mimp.php', $mailbox_name)->add('a', 'm')->redirect();
 }
index 1b1e0e7..07ff984 100644 (file)
@@ -32,11 +32,11 @@ $registry->setTimeZone();
  * select it on the IMAP server (saves some STATUS calls). Open R/W to clear
  * the RECENT flag. */
 if (!($search_mbox = $injector->getInstance('IMP_Search')->isSearchMbox(IMP::$mailbox))) {
-    $injector->getInstance('IMP_Injector_Factory_Imap')->create()->openMailbox(IMP::$mailbox, Horde_Imap_Client::OPEN_READWRITE);
+    $injector->getInstance('IMP_Factory_Imap')->create()->openMailbox(IMP::$mailbox, Horde_Imap_Client::OPEN_READWRITE);
 }
 
 /* Make sure we have a valid index. */
-$imp_mailbox = $injector->getInstance('IMP_Injector_Factory_MailboxList')->create(IMP::$mailbox, new IMP_Indices(IMP::$thismailbox, IMP::$uid));
+$imp_mailbox = $injector->getInstance('IMP_Factory_MailboxList')->create(IMP::$mailbox, new IMP_Indices(IMP::$thismailbox, IMP::$uid));
 if (!$imp_mailbox->isValidIndex()) {
     _returnToMailbox(null, 'message_missing');
     require IMP_BASE . '/mailbox.php';
@@ -61,7 +61,7 @@ if ($vars->actionID) {
 }
 
 /* Determine if mailbox is readonly. */
-$peek = $readonly = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->isReadOnly(IMP::$mailbox);
+$peek = $readonly = $injector->getInstance('IMP_Factory_Imap')->create()->isReadOnly(IMP::$mailbox);
 
 /* Get mailbox/UID of message. */
 $index_array = $imp_mailbox->getIMAPIndex();
@@ -211,7 +211,7 @@ $uid = $index_array['uid'];
 
 /* Parse the message. */
 try {
-    $imp_contents = $injector->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($imp_mailbox));
+    $imp_contents = $injector->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($imp_mailbox));
 } catch (IMP_Exception $e) {
     $imp_mailbox->removeMsgs(true);
     _returnToMailbox(null, 'message_missing');
@@ -223,10 +223,10 @@ try {
 try {
     /* Need to fetch flags before HEADERTEXT, because SEEN flag might be set
      * before we can grab it. */
-    $flags_ret = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->fetch($mailbox_name, array(
+    $flags_ret = $injector->getInstance('IMP_Factory_Imap')->create()->fetch($mailbox_name, array(
         Horde_Imap_Client::FETCH_FLAGS => true,
     ), array('ids' => array($uid)));
-    $fetch_ret = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->fetch($mailbox_name, array(
+    $fetch_ret = $injector->getInstance('IMP_Factory_Imap')->create()->fetch($mailbox_name, array(
         Horde_Imap_Client::FETCH_ENVELOPE => true,
         Horde_Imap_Client::FETCH_HEADERTEXT => array(array('parse' => true, 'peek' => $peek))
     ), array('ids' => array($uid)));
@@ -473,7 +473,7 @@ if (!$use_pop) {
     $n_template->set('flaglist_set', $form_set);
     $n_template->set('flaglist_unset', $form_unset);
 
-    if ($injector->getInstance('IMP_Injector_Factory_Imap')->create()->allowFolders()) {
+    if ($injector->getInstance('IMP_Factory_Imap')->create()->allowFolders()) {
         $n_template->set('move', Horde::widget('#', _("Move to folder"), 'widget moveAction', '', '', _("Move"), true));
         $n_template->set('copy', Horde::widget('#', _("Copy to folder"), 'widget copyAction', '', '', _("Copy"), true));
         $n_template->set('options', IMP::flistSelect(array('heading' => _("This message to"), 'new_folder' => true, 'inc_tasklists' => true, 'inc_notepads' => true)));
index 48330fe..ada77ae 100644 (file)
@@ -22,7 +22,7 @@ require $registry->get('templates', 'horde') . '/common-header-mobile.inc';
 $view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/mobile'));
 new Horde_View_Helper_Text($view);
 
-if (!$injector->getInstance('IMP_Injector_Factory_Imap')->create()->allowFolders()) {
+if (!$injector->getInstance('IMP_Factory_Imap')->create()->allowFolders()) {
     $view->allowFolders = false;
 } else {
     $view->allowFolders = true;
index 4cc7eb7..eb44e1f 100644 (file)
@@ -158,7 +158,7 @@ case 'info_personal_private_key':
 
 case 'save_attachment_public_key':
     /* Retrieve the key from the message. */
-    $contents = $injector->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($vars->mailbox, $vars->uid));
+    $contents = $injector->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($vars->mailbox, $vars->uid));
     $mime_part = $contents->getMIMEPart($vars->mime_id);
     if (empty($mime_part)) {
         throw new IMP_Exception('Cannot retrieve public key from message.');
index b5cc21b..cf6d8c0 100644 (file)
@@ -46,7 +46,7 @@ if (!empty($request)) {
     $new_mail = (isset($request_parts[1]) && ($request_parts[1] === 'new'));
 }
 
-$imp_mailbox = $injector->getInstance('IMP_Injector_Factory_MailboxList')->create($mailbox);
+$imp_mailbox = $injector->getInstance('IMP_Factory_MailboxList')->create($mailbox);
 $imp_search = $injector->getInstance('IMP_Search');
 
 /* Obtain some information describing the mailbox state. */
index 1cb8cf5..11be59d 100644 (file)
@@ -21,7 +21,7 @@ $vars = Horde_Variables::getDefaultVariables();
 /* Run through the action handlers. */
 switch ($vars->actionID) {
 case 'save_image':
-    $contents = $injector->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($vars->mbox, $vars->uid));
+    $contents = $injector->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($vars->mbox, $vars->uid));
     $mime_part = $contents->getMIMEPart($vars->id);
     $image_data = array(
         'data' => $mime_part->getContents(),
index 6175c70..3249ade 100644 (file)
@@ -102,7 +102,7 @@ case 'process_import_personal_certs':
 
 case 'save_attachment_public_key':
     /* Retrieve the key from the message. */
-    $contents = $injector->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($vars->mailbox, $vars->uid));
+    $contents = $injector->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($vars->mailbox, $vars->uid));
     $mime_part = $contents->getMIMEPart($vars->mime_id);
     if (empty($mime_part)) {
         throw new IMP_Exception(_("Cannot retrieve public key from message."));
index 575d1ad..11af1db 100644 (file)
@@ -14,7 +14,7 @@ $use_trash = $prefs->getValue('use_trash');
 $has_blacklist = $registry->hasMethod('mail/blacklistFrom');
 $has_whitelist = $registry->hasMethod('mail/whitelistFrom');
 
-$imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
+$imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
 
 // Quota information
 $show_quota = $session->get('imp', 'imap_quota')
index 895f01c..1a4b310 100644 (file)
@@ -28,8 +28,8 @@ $mode = $vars->mode
     ? $vars->mode
     : 'thread';
 
-$imp_imap = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
-$imp_mailbox = $injector->getInstance('IMP_Injector_Factory_MailboxList')->create(IMP::$mailbox, new IMP_Indices(IMP::$thismailbox, IMP::$uid));
+$imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
+$imp_mailbox = $injector->getInstance('IMP_Factory_MailboxList')->create(IMP::$mailbox, new IMP_Indices(IMP::$thismailbox, IMP::$uid));
 
 $error = false;
 if ($mode == 'thread') {
@@ -95,7 +95,7 @@ foreach ($imp_indices->indices() as $mbox => $idxlist) {
 
         /* Get the body of the message. */
         $curr_msg = $curr_tree = array();
-        $contents = $injector->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($mbox, $idx));
+        $contents = $injector->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($mbox, $idx));
         $mime_id = $contents->findBody();
         if ($contents->canDisplay($mime_id, IMP_Contents::RENDER_INLINE)) {
             $ret = $contents->renderMIMEPart($mime_id, IMP_Contents::RENDER_INLINE);
index 1fc717e..619767a 100644 (file)
@@ -57,7 +57,7 @@ Horde_Registry::appInit('imp', array(
  * message data. Rather, we must use the IMP_Compose object to get the
  * necessary data for Horde_Mime_Part. */
 if ($vars->actionID == 'compose_attach_preview') {
-    $imp_compose = $injector->getInstance('IMP_Injector_Factory_Compose')->create($vars->composeCache);
+    $imp_compose = $injector->getInstance('IMP_Factory_Compose')->create($vars->composeCache);
     $mime = $imp_compose->buildAttachment($vars->id);
     $mime->setMimeId($vars->id);
 
@@ -68,7 +68,7 @@ if ($vars->actionID == 'compose_attach_preview') {
     if (!$vars->uid || !$vars->mailbox) {
         exit;
     }
-    $contents = $injector->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($vars->mailbox, $vars->uid));
+    $contents = $injector->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($vars->mailbox, $vars->uid));
 }
 
 /* Run through action handlers */
index 1506cd8..feff531 100644 (file)
@@ -35,7 +35,7 @@ class Jonah_Application extends Horde_Registry_Application
      */
     protected function _init()
     {
-        $GLOBALS['injector']->bindFactory('Jonah_Driver', 'Jonah_Injector_Factory_Driver', 'create');
+        $GLOBALS['injector']->bindFactory('Jonah_Driver', 'Jonah_Factory_Driver', 'create');
 
         if ($channel_id = Horde_Util::getFormData('channel_id')) {
             $url = Horde::url('delivery/rss.php', true, -1)
diff --git a/jonah/lib/Factory/Driver.php b/jonah/lib/Factory/Driver.php
new file mode 100644 (file)
index 0000000..b760dc5
--- /dev/null
@@ -0,0 +1,70 @@
+<?php
+/**
+ * Jonah_Driver factory.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file LICENSE for license information (BSD). If you did not
+ * did not receive this file, see http://cvs.horde.org/co.php/jonah/LICENSE.
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @author Ben Klang <ben@alkaloid.net>
+ * @package Jonah
+ */
+class Jonah_Factory_Driver
+{
+    /**
+     * Instances.
+     *
+     * @var array
+     */
+    private $_instances = array();
+
+    /**
+     * The injector.
+     *
+     * @var Horde_Injector
+     */
+    private $_injector;
+
+    /**
+     * Constructor.
+     *
+     * @param Horde_Injector $injector  The injector to use.
+     */
+    public function __construct(Horde_Injector $injector)
+    {
+        $this->_injector = $injector;
+    }
+
+    /**
+     * 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()
+    {
+        $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];
+    }
+}
diff --git a/jonah/lib/Injector/Factory/Driver.php b/jonah/lib/Injector/Factory/Driver.php
deleted file mode 100644 (file)
index aba88bf..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-<?php
-/**
- * Jonah_Driver factory.
- * 
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file LICENSE for license information (BSD). If you did not
- * did not receive this file, see http://cvs.horde.org/co.php/jonah/LICENSE.
- *
- * @author Michael J. Rubinsky <mrubinsk@horde.org>
- * @author Ben Klang <ben@alkaloid.net>
- * @package Jonah
- */
-class Jonah_Injector_Factory_Driver
-{
-    /**
-     * Instances.
-     *
-     * @var array
-     */
-    private $_instances = array();
-
-    /**
-     * The injector.
-     *
-     * @var Horde_Injector
-     */
-    private $_injector;
-    
-    /**
-     * Constructor.
-     *
-     * @param Horde_Injector $injector  The injector to use.
-     */
-    public function __construct(Horde_Injector $injector)
-    {
-        $this->_injector = $injector;
-    }
-
-    /**
-     * 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()
-    {
-        $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];
-    }
-}
\ No newline at end of file
index bff402d..97e07fb 100644 (file)
@@ -850,7 +850,7 @@ class Kronolith_Ajax_Application extends Horde_Core_Ajax_Application
 
         $result = new stdClass;
         try {
-            $driver = $GLOBALS['injector']->getInstance('Kronolith_Injector_Factory_Driver')->create('Ical', $params);
+            $driver = $GLOBALS['injector']->getInstance('Kronolith_Factory_Driver')->create('Ical', $params);
             $driver->open($this->_vars->url);
             $ical = $driver->getRemoteCalendar(false);
             $result->success = true;
index 08b182b..9501418 100644 (file)
@@ -72,7 +72,7 @@ class Kronolith_Application extends Horde_Registry_Application
             throw new Horde_Exception('The Content_Tagger class could not be found. Make sure the registry entry for the Content system is present.');
         }
 
-        $GLOBALS['injector']->bindFactory('Kronolith_Geo', 'Kronolith_Injector_Factory_Geo', 'create');
+        $GLOBALS['injector']->bindFactory('Kronolith_Geo', 'Kronolith_Factory_Geo', 'create');
 
         /* Set the timezone variable, if available. */
         $GLOBALS['registry']->setTimeZone();
diff --git a/kronolith/lib/Factory/Driver.php b/kronolith/lib/Factory/Driver.php
new file mode 100644 (file)
index 0000000..ac67b55
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+/**
+ * Horde_Injector based factory for Kronolith_Driver
+ */
+class Kronolith_Factory_Driver
+{
+    /**
+     * Instances.
+     *
+     * @var array
+     */
+    private $_instances = array();
+
+    /**
+     * The injector.
+     *
+     * @var Horde_Injector
+     */
+    private $_injector;
+
+    /**
+     * Constructor.
+     *
+     * @param Horde_Injector $injector  The injector to use.
+     */
+    public function __construct(Horde_Injector $injector)
+    {
+        $this->_injector = $injector;
+    }
+
+    /**
+     * 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, $params = array())
+    {
+        $driver = basename($driver);
+        if (!empty($this->_instances[$driver])) {
+            return $this->_instances[$driver];
+        }
+        $key = $driver;
+        $class = 'Kronolith_Driver_' . $driver;
+        if (class_exists($class)) {
+            $driver = new $class($params);
+            try {
+                $driver->initialize();
+            } catch (Exception $e) {
+                $driver = new Kronolith_Driver($params, sprintf(_("The Calendar backend is not currently available: %s"), $e->getMessage()));
+            }
+        } else {
+            $driver = new Kronolith_Driver($params, sprintf(_("Unable to load the definition of %s."), $class));
+        }
+        $this->_instances[$key] = $driver;
+
+        return $driver;
+    }
+
+}
diff --git a/kronolith/lib/Factory/Geo.php b/kronolith/lib/Factory/Geo.php
new file mode 100644 (file)
index 0000000..73fe624
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Horde_Injector based factory for Kronolith_Geo drivers
+ *
+ * @author Michael J Rubinsky <mrubinsk@horde.org>
+ * @package Kronolith
+ */
+class Kronolith_Factory_Geo
+{
+    /**
+     * Instances.
+     *
+     * @var array
+     */
+    private $_instances = array();
+
+    /**
+     * Return the driver instance.
+     *
+     * @return Kronolith_Storage
+     * @throws Kronolith_Exception
+     */
+    public function create(Horde_Injector $injector)
+    {
+        if (empty($this->_instances[$GLOBALS['conf']['maps']['geodriver']])) {
+            if (!empty($GLOBALS['conf']['maps']['geodriver'])) {
+                $class = 'Kronolith_Geo_' . $GLOBALS['conf']['maps']['geodriver'];
+                $db = $injector->getInstance('Horde_Db_Adapter');
+                $this->_instances[$GLOBALS['conf']['maps']['geodriver']] = new $class($db);
+            } else {
+                throw new Kronolith_Exception(_("Geospatial support not configured."));
+            }
+        }
+
+        return $this->_instances[$GLOBALS['conf']['maps']['geodriver']];
+    }
+
+}
diff --git a/kronolith/lib/Factory/Storage.php b/kronolith/lib/Factory/Storage.php
new file mode 100644 (file)
index 0000000..ba88b42
--- /dev/null
@@ -0,0 +1,80 @@
+<?php
+
+class Kronolith_Factory_Storage
+{
+    /**
+     * Instances.
+     *
+     * @var array
+     */
+    private $_instances = array();
+
+    /**
+     * The injector.
+     *
+     * @var Horde_Injector
+     */
+    private $_injector;
+
+    /**
+     * Constructor.
+     *
+     * @param Horde_Injector $injector  The injector to use.
+     */
+    public function __construct(Horde_Injector $injector)
+    {
+        $this->_injector = $injector;
+    }
+
+    /**
+     * 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;
+    }
+
+}
index 4d4bef0..2c99ae7 100644 (file)
@@ -209,7 +209,7 @@ class Kronolith_FreeBusy
         }
 
         /* Check storage driver. */
-        $storage = $GLOBALS['injector']->getInstance('Kronolith_Injector_Factory_Storage')->create();
+        $storage = $GLOBALS['injector']->getInstance('Kronolith_Factory_Storage')->create();
 
         try {
             $fb = $storage->search($email);
diff --git a/kronolith/lib/Injector/Factory/Driver.php b/kronolith/lib/Injector/Factory/Driver.php
deleted file mode 100644 (file)
index d8ea70f..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-<?php
-/**
- * Horde_Injector based factory for Kronolith_Driver
- */
-class Kronolith_Injector_Factory_Driver
-{
-    /**
-     * Instances.
-     *
-     * @var array
-     */
-    private $_instances = array();
-
-    /**
-     * The injector.
-     *
-     * @var Horde_Injector
-     */
-    private $_injector;
-
-    /**
-     * Constructor.
-     *
-     * @param Horde_Injector $injector  The injector to use.
-     */
-    public function __construct(Horde_Injector $injector)
-    {
-        $this->_injector = $injector;
-    }
-
-    /**
-     * 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, $params = array())
-    {
-        $driver = basename($driver);
-        if (!empty($this->_instances[$driver])) {
-            return $this->_instances[$driver];
-        }
-        $key = $driver;
-        $class = 'Kronolith_Driver_' . $driver;
-        if (class_exists($class)) {
-            $driver = new $class($params);
-            try {
-                $driver->initialize();
-            } catch (Exception $e) {
-                $driver = new Kronolith_Driver($params, sprintf(_("The Calendar backend is not currently available: %s"), $e->getMessage()));
-            }
-        } else {
-            $driver = new Kronolith_Driver($params, sprintf(_("Unable to load the definition of %s."), $class));
-        }
-        $this->_instances[$key] = $driver;
-
-        return $driver;
-    }
-
-}
\ No newline at end of file
diff --git a/kronolith/lib/Injector/Factory/Geo.php b/kronolith/lib/Injector/Factory/Geo.php
deleted file mode 100644 (file)
index 56e8e4a..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-<?php
-/**
- * Horde_Injector based factory for Kronolith_Geo drivers
- *
- * @author Michael J Rubinsky <mrubinsk@horde.org>
- * @package Kronolith
- */
-class Kronolith_Injector_Factory_Geo
-{
-    /**
-     * Instances.
-     *
-     * @var array
-     */
-    private $_instances = array();
-
-    /**
-     * Return the driver instance.
-     *
-     * @return Kronolith_Storage
-     * @throws Kronolith_Exception
-     */
-    public function create(Horde_Injector $injector)
-    {
-        if (empty($this->_instances[$GLOBALS['conf']['maps']['geodriver']])) {
-            if (!empty($GLOBALS['conf']['maps']['geodriver'])) {
-                $class = 'Kronolith_Geo_' . $GLOBALS['conf']['maps']['geodriver'];
-                $db = $injector->getInstance('Horde_Db_Adapter');
-                $this->_instances[$GLOBALS['conf']['maps']['geodriver']] = new $class($db);
-            } else {
-                throw new Kronolith_Exception(_("Geospatial support not configured."));
-            }
-        }
-
-        return $this->_instances[$GLOBALS['conf']['maps']['geodriver']];
-    }
-
-}
\ No newline at end of file
diff --git a/kronolith/lib/Injector/Factory/Storage.php b/kronolith/lib/Injector/Factory/Storage.php
deleted file mode 100644 (file)
index b2174a4..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-<?php
-
-class Kronolith_Injector_Factory_Storage
-{
-    /**
-     * Instances.
-     *
-     * @var array
-     */
-    private $_instances = array();
-
-    /**
-     * The injector.
-     *
-     * @var Horde_Injector
-     */
-    private $_injector;
-
-    /**
-     * Constructor.
-     *
-     * @param Horde_Injector $injector  The injector to use.
-     */
-    public function __construct(Horde_Injector $injector)
-    {
-        $this->_injector = $injector;
-    }
-
-    /**
-     * 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;
-    }
-
-}
\ No newline at end of file
index 670b5e6..0fe7c1c 100644 (file)
@@ -2753,7 +2753,7 @@ class Kronolith
                 break;
             }
 
-            self::$_instances[$driver] = $GLOBALS['injector']->getInstance('Kronolith_Injector_Factory_Driver')->create($driver, $params);
+            self::$_instances[$driver] = $GLOBALS['injector']->getInstance('Kronolith_Factory_Driver')->create($driver, $params);
         }
 
         if (!is_null($calendar)) {
index 734200e..d6dbf89 100644 (file)
@@ -34,7 +34,7 @@ if (!$addSources) {
 /* A source has been selected, connect and set up the fields. */
 if ($source) {
     try {
-        $driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source);
+        $driver = $injector->getInstance('Turba_Factory_Driver')->create($source);
     } catch (Turba_Exception $e) {
         $notification->push($e, 'horde.error');
         $driver = null;
index 56c747a..6f33421 100644 (file)
@@ -22,7 +22,7 @@ if (!isset($GLOBALS['cfgSources'][$source])) {
 
 /* Set the contact from the key requested. */
 try {
-    $driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source);
+    $driver = $injector->getInstance('Turba_Factory_Driver')->create($source);
 } catch (Turba_Exception $e) {
     $notification->push($e, 'horde.error');
     Horde::url($prefs->getValue('initial_page'), true)->redirect();
index e635a30..eee4ec0 100644 (file)
@@ -242,7 +242,7 @@ case 'export':
     foreach ($sources as $source => $objectkeys) {
         /* Create a Turba storage instance. */
         try {
-            $driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source);
+            $driver = $injector->getInstance('Turba_Factory_Driver')->create($source);
         } catch (Turba_Exception $e) {
             $notification->push($e, 'horde.error');
             $error = true;
@@ -335,7 +335,7 @@ case 'export':
 case Horde_Data::IMPORT_FILE:
     $dest = Horde_Util::getFormData('dest');
     try {
-        $driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($dest);
+        $driver = $injector->getInstance('Turba_Factory_Driver')->create($dest);
     } catch (Turba_Exception $e) {
         $notification->push($e, 'horde.error');
         $error = true;
@@ -423,7 +423,7 @@ if (is_array($next_step)) {
     /* Create a Turba storage instance. */
     $dest = $session->get('horde', 'import_data/target');
     try {
-        $driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($dest);
+        $driver = $injector->getInstance('Turba_Factory_Driver')->create($dest);
     } catch (Turba_Exception $e) {
         $notification->push($e, 'horde.error');
         $driver = null;
index 8f37d86..4628413 100644 (file)
@@ -18,7 +18,7 @@ Horde_Registry::appInit('turba');
 
 $source = Horde_Util::getFormData('source');
 $key = Horde_Util::getFormData('key');
-$driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source);
+$driver = $injector->getInstance('Turba_Factory_Driver')->create($source);
 
 if ($conf['documents']['type'] != 'none') {
     try {
index 778499e..ff4d495 100644 (file)
@@ -23,7 +23,7 @@ if ($source === null || !isset($cfgSources[$source])) {
     Horde::url($prefs->getValue('initial_page'), true)->redirect();
 }
 
-$driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source);
+$driver = $injector->getInstance('Turba_Factory_Driver')->create($source);
 
 try {
     $contact = $driver->getObject(Horde_Util::getPost('key'));
index b60ccfb..d0335e9 100644 (file)
@@ -45,7 +45,7 @@ if ($source === null || !isset($cfgSources[$source])) {
     $url->redirect();
 }
 
-$driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source);
+$driver = $injector->getInstance('Turba_Factory_Driver')->create($source);
 
 /* Set the contact from the requested key. */
 try {
index f23e902..bc6ae86 100644 (file)
@@ -51,7 +51,7 @@ class Turba_Api extends Horde_Registry_Api
         @list($source, $key) = explode('.', $id, 2);
         if (isset($GLOBALS['cfgSources'][$source]) && $key) {
             try {
-                $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+                $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
                 $object = $driver->getObject($key)->getValue('name');
             } catch (Turba_Exception $e) {}
         }
@@ -134,7 +134,7 @@ class Turba_Api extends Horde_Registry_Api
                 }
 
                 try {
-                    $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($params['source']);
+                    $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($params['source']);
                     if ($driver->checkDefaultShare($share, $cfgSources[$params['source']])) {
                         return $uid;
                     }
@@ -322,7 +322,7 @@ class Turba_Api extends Horde_Registry_Api
             }
 
             // Load the Turba driver.
-            $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($parts[1]);
+            $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($parts[1]);
 
             $contacts = $driver->search(array());
 
@@ -371,7 +371,7 @@ class Turba_Api extends Horde_Registry_Api
             }
 
             // Load the Turba driver.
-            $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($parts[1]);
+            $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($parts[1]);
 
             $contact = $driver->getObject($parts[2]);
 
@@ -418,7 +418,7 @@ class Turba_Api extends Horde_Registry_Api
         }
 
         // Load the Turba driver.
-        $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($parts[1]);
+        $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($parts[1]);
 
         return $driver->delete($parts[2]);
     }
@@ -458,7 +458,7 @@ class Turba_Api extends Horde_Registry_Api
                 throw new Turba_Exception(sprintf(_("Invalid address book: %s"), $source));
             }
 
-            $storage = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+            $storage = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
 
             try {
                 $results = $storage->search(array());
@@ -518,7 +518,7 @@ class Turba_Api extends Horde_Registry_Api
                 throw new Turba_Exception(sprintf(_("Invalid address book: %s"), $source));
             }
 
-            $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+            $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
 
             $histories = $history->getByTimestamp(
                 '>', $timestamp, $filter,
@@ -589,7 +589,7 @@ class Turba_Api extends Horde_Registry_Api
                 throw new Turba_Exception(sprintf(_("Invalid address book: %s"), $source));
             }
 
-            $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+            $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
 
             $ts = $history->getActionTimestamp('turba:' . $driver->getName()
                 . ':' . $uid,
@@ -635,7 +635,7 @@ class Turba_Api extends Horde_Registry_Api
             throw new Turba_Exception(sprintf(_("Invalid address book: %s"), $import_source));
         }
 
-        $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($import_source);
+        $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($import_source);
 
         if (!$driver->hasPermission(Horde_Perms::EDIT)) {
             throw new Turba_Exception(_("Permission denied"));
@@ -763,7 +763,7 @@ class Turba_Api extends Horde_Registry_Api
                 throw new Turba_Exception(_("Invalid ID"));
             }
 
-            $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+            $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
 
             if (!$driver->hasPermission(Horde_Perms::READ)) {
                 continue;
@@ -827,7 +827,7 @@ class Turba_Api extends Horde_Registry_Api
     public function ownVCard()
     {
         $contact = $this->getOwnContactObject();
-        $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($contact['source']);
+        $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($contact['source']);
 
         $vcard = $driver->tovCard($contact['contact'], '3.0', null, true);
         $vcard->setAttribute('VERSION', '3.0');
@@ -868,7 +868,7 @@ class Turba_Api extends Horde_Registry_Api
             throw new Turba_Exception(_("The address book with your own contact doesn't exist anymore."));
         }
 
-        $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+        $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
 
         if (!$driver->hasPermission(Horde_Perms::READ)) {
             throw new Turba_Exception(_("You don't have sufficient permissions to read the address book that contains your own contact."));
@@ -933,7 +933,7 @@ class Turba_Api extends Horde_Registry_Api
                 throw new Turba_Exception(_("Invalid ID"));
             }
 
-            $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+            $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
 
             if (!$GLOBALS['registry']->isAdmin() &&
                 !$driver->hasPermission(Horde_Perms::DELETE)) {
@@ -996,7 +996,7 @@ class Turba_Api extends Horde_Registry_Api
             }
 
             // Check permissions.
-            $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+            $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
             if (!$driver->hasPermission(Horde_Perms::EDIT)) {
                 continue;
             }
@@ -1121,7 +1121,7 @@ class Turba_Api extends Horde_Registry_Api
                     continue;
                 }
 
-            $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+            $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
 
             // Determine the name of the column to sort by.
             $columns = isset($sort_columns[$source])
@@ -1274,7 +1274,7 @@ class Turba_Api extends Horde_Registry_Api
         }
 
         if (isset($cfgSources[$source])) {
-            $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+            $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
 
             $object = $driver->getObject($objectId);
 
@@ -1310,7 +1310,7 @@ class Turba_Api extends Horde_Registry_Api
         }
 
         if (isset($cfgSources[$source])) {
-            $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+            $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
 
             $objects = $driver->getObjects($objectIds);
 
@@ -1351,7 +1351,7 @@ class Turba_Api extends Horde_Registry_Api
         $results = array();
         foreach ($sources as $source) {
             if (isset($cfgSources[$source])) {
-                $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+                $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
 
                 $res = $driver->search(array());
                 if (!($res instanceof Turba_List)) {
@@ -1419,7 +1419,7 @@ class Turba_Api extends Horde_Registry_Api
         $objects = array();
         foreach ($time_categories as $category) {
             list($category, $source) = explode('/', $category, 2);
-            $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+            $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
             $objects = array_merge($objects, $driver->listTimeObjects($start, $end, $category));
         }
 
@@ -1563,7 +1563,7 @@ class Turba_Api extends Horde_Registry_Api
             throw new Turba_Exception(_("Invalid entry"));
         }
 
-        $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+        $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
 
         if (!$driver->hasPermission(Horde_Perms::EDIT)) {
             throw new Turba_Exception(_("Permission denied"));
@@ -1654,7 +1654,7 @@ class Turba_Api extends Horde_Registry_Api
                 continue;
             }
 
-            $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+            $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
             $criterium = array('email' => $address);
             if (!isset($driver->map['email'])) {
                 if (isset($driver->map['emails'])) {
@@ -1719,7 +1719,7 @@ class Turba_Api extends Horde_Registry_Api
 
         foreach ($sources as $source) {
             if (isset($cfgSources[$source])) {
-                $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+                $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
                 if (!$driver->hasPermission(Horde_Perms::EDIT)) {
                     continue;
                 }
index a42b018..463d14e 100644 (file)
@@ -400,7 +400,7 @@ class Turba_Application extends Horde_Registry_Application
             if (empty($source['use_shares'])) {
                 // Shares not enabled for this source
                 try {
-                    $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+                    $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
                 } catch (Turba_Exception $e) {
                     Horde::logMessage($e, 'ERR');
                     throw new Turba_Exception(sprintf(_("There was an error removing an address book for %s"), $user));
@@ -433,7 +433,7 @@ class Turba_Application extends Horde_Registry_Application
             if (!empty($params['default'])) {
                 $config = Turba::getSourceFromShare($share);
                 try {
-                    $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($config);
+                    $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($config);
                 } catch (Turba_Exception $e) {
                     continue;
                 }
index 57023a5..da5f2e8 100644 (file)
@@ -44,7 +44,7 @@ class Turba_Driver_Share extends Turba_Driver
     {
         parent::__construct($name, $params);
         $this->_share = $this->_params['config']['params']['share'];
-        $this->_driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($this->_params['config']);
+        $this->_driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($this->_params['config']);
     }
 
     /**
index 0aea115..afffabe 100644 (file)
@@ -41,7 +41,7 @@ class Turba_Driver_Vbook extends Turba_Driver
         $this->_share = $this->_params['share'];
 
         /* Load the underlying driver. */
-        $this->_driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($this->_params['source']);
+        $this->_driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($this->_params['source']);
 
         $this->searchCriteria = empty($this->_params['criteria'])
             ? array()
diff --git a/turba/lib/Factory/Driver.php b/turba/lib/Factory/Driver.php
new file mode 100644 (file)
index 0000000..168a669
--- /dev/null
@@ -0,0 +1,140 @@
+<?php
+/**
+ * A Horde_Injector:: based Turba_Driver:: factory.
+ *
+ * PHP version 5
+ *
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license  http://www.horde.org/licenses/apl.html APL
+ * @link     http://pear.horde.org/index.php?package=Turba
+ * @package  Turba
+ */
+
+/**
+ * A Horde_Injector:: based Turba_Driver:: factory.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (APL). If you
+ * did not receive this file, see http://www.horde.org/licenses/apl.html.
+ *
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license  http://www.horde.org/licenses/apl.html APL
+ * @link     http://pear.horde.org/index.php?package=Turba
+ * @package  Turba
+ */
+class Turba_Factory_Driver
+{
+    /**
+     * Instances.
+     *
+     * @var array
+     */
+    private $_instances = array();
+
+    /**
+     * The injector.
+     *
+     * @var Horde_Injector
+     */
+    private $_injector;
+
+    /**
+     * Constructor.
+     *
+     * @param Horde_Injector $injector  The injector to use.
+     */
+    public function __construct(Horde_Injector $injector)
+    {
+        $this->_injector = $injector;
+    }
+
+    /**
+     * Return the Turba_Driver:: instance.
+     *
+     * @param mixed $name  Either a string containing the internal name of this
+     *                     source, or a config array describing the source.
+     *
+     * @return Turba_Driver  The singleton instance.
+     * @throws Turba_Exception
+     */
+    public function create($name)
+    {
+        if (is_array($name)) {
+            $key = md5(serialize($name));
+            $srcName = '';
+            $srcConfig = $name;
+        } else {
+            $key = $name;
+            $srcName = $name;
+            if (empty($GLOBALS['cfgSources'][$name])) {
+                throw new Turba_Exception(sprintf(_("The address book \"%s\" does not exist."), $name));
+            }
+            $srcConfig = $GLOBALS['cfgSources'][$name];
+        }
+
+        if (!isset($this->_instances[$key])) {
+            $class = 'Turba_Driver_' . ucfirst(basename($srcConfig['type']));
+            if (!class_exists($class)) {
+                throw new Turba_Exception(sprintf(_("Unable to load the definition of %s."), $class));
+            }
+
+            if (empty($srcConfig['params'])) {
+                $srcConfig['params'] = array();
+            }
+
+            switch ($class) {
+            case 'Turba_Driver_Sql':
+                try {
+                    $srcConfig['params']['db'] = empty($srcConfig['params']['sql'])
+                        ? $GLOBALS['injector']->getInstance('Horde_Db_Adapter')
+                        : $GLOBALS['injector']->getInstance('Horde_Core_Factory_Db')->create('turba', $this->_params['sql']);
+                } catch (Horde_Db_Exception $e) {
+                    throw new Turba_Exception($e);
+                }
+                break;
+            }
+
+            $driver = new $class($srcName, $srcConfig['params']);
+
+            // Title
+            $driver->title = $srcConfig['title'];
+
+            /* Initialize */
+            //$driver->_init();
+
+            /* Store and translate the map at the Source level. */
+            $driver->map = $srcConfig['map'];
+            foreach ($driver->map as $key => $val) {
+                if (!is_array($val)) {
+                    $driver->fields[$key] = $val;
+                }
+            }
+
+            /* Store tabs. */
+            if (isset($srcConfig['tabs'])) {
+                $driver->tabs = $srcConfig['tabs'];
+            }
+
+            /* Store remaining fields. */
+            if (isset($srcConfig['strict'])) {
+                $driver->strict = $srcConfig['strict'];
+            }
+            if (isset($srcConfig['approximate'])) {
+                $driver->approximate = $srcConfig['approximate'];
+            }
+            if (isset($srcConfig['list_name_field'])) {
+                $driver->listNameField = $srcConfig['list_name_field'];
+            }
+            if (isset($srcConfig['alternative_name'])) {
+                $driver->alternativeName = $srcConfig['alternative_name'];
+            }
+            $this->_instances[$key] = $driver;
+        }
+
+        return $this->_instances[$key];
+    }
+
+}
index c0a6bef..985d245 100644 (file)
@@ -35,7 +35,7 @@ class Turba_Form_CreateAddressBook extends Horde_Form
         // Need a clean cfgSources array
         include TURBA_BASE . '/config/backends.php';
 
-        $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($cfgSources[$GLOBALS['conf']['shares']['source']]);
+        $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($cfgSources[$GLOBALS['conf']['shares']['source']]);
 
         $params = array(
             'params' => array('source' => $GLOBALS['conf']['shares']['source']),
index 3bae3e7..6fe2f91 100644 (file)
@@ -50,7 +50,7 @@ class Turba_Form_DeleteAddressBook extends Horde_Form
             throw new Turba_Exception(_("You do not have permissions to delete this address book."));
         }
 
-        $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($this->_addressbook->getName());
+        $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($this->_addressbook->getName());
 
         // We have a Turba_Driver, try to delete the address book.
         $driver->deleteAll();
diff --git a/turba/lib/Injector/Factory/Driver.php b/turba/lib/Injector/Factory/Driver.php
deleted file mode 100644 (file)
index 74ce00a..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-<?php
-/**
- * A Horde_Injector:: based Turba_Driver:: factory.
- *
- * PHP version 5
- *
- * @author   Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license  http://www.horde.org/licenses/apl.html APL
- * @link     http://pear.horde.org/index.php?package=Turba
- * @package  Turba
- */
-
-/**
- * A Horde_Injector:: based Turba_Driver:: factory.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (APL). If you
- * did not receive this file, see http://www.horde.org/licenses/apl.html.
- *
- * @author   Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license  http://www.horde.org/licenses/apl.html APL
- * @link     http://pear.horde.org/index.php?package=Turba
- * @package  Turba
- */
-class Turba_Injector_Factory_Driver
-{
-    /**
-     * Instances.
-     *
-     * @var array
-     */
-    private $_instances = array();
-
-    /**
-     * The injector.
-     *
-     * @var Horde_Injector
-     */
-    private $_injector;
-
-    /**
-     * Constructor.
-     *
-     * @param Horde_Injector $injector  The injector to use.
-     */
-    public function __construct(Horde_Injector $injector)
-    {
-        $this->_injector = $injector;
-    }
-
-    /**
-     * Return the Turba_Driver:: instance.
-     *
-     * @param mixed $name  Either a string containing the internal name of this
-     *                     source, or a config array describing the source.
-     *
-     * @return Turba_Driver  The singleton instance.
-     * @throws Turba_Exception
-     */
-    public function create($name)
-    {
-        if (is_array($name)) {
-            $key = md5(serialize($name));
-            $srcName = '';
-            $srcConfig = $name;
-        } else {
-            $key = $name;
-            $srcName = $name;
-            if (empty($GLOBALS['cfgSources'][$name])) {
-                throw new Turba_Exception(sprintf(_("The address book \"%s\" does not exist."), $name));
-            }
-            $srcConfig = $GLOBALS['cfgSources'][$name];
-        }
-
-        if (!isset($this->_instances[$key])) {
-            $class = 'Turba_Driver_' . ucfirst(basename($srcConfig['type']));
-            if (!class_exists($class)) {
-                throw new Turba_Exception(sprintf(_("Unable to load the definition of %s."), $class));
-            }
-
-            if (empty($srcConfig['params'])) {
-                $srcConfig['params'] = array();
-            }
-
-            switch ($class) {
-            case 'Turba_Driver_Sql':
-                try {
-                    $srcConfig['params']['db'] = empty($srcConfig['params']['sql'])
-                        ? $GLOBALS['injector']->getInstance('Horde_Db_Adapter')
-                        : $GLOBALS['injector']->getInstance('Horde_Core_Factory_Db')->create('turba', $this->_params['sql']);
-                } catch (Horde_Db_Exception $e) {
-                    throw new Turba_Exception($e);
-                }
-                break;
-            }
-
-            $driver = new $class($srcName, $srcConfig['params']);
-
-            // Title
-            $driver->title = $srcConfig['title'];
-
-            /* Initialize */
-            //$driver->_init();
-
-            /* Store and translate the map at the Source level. */
-            $driver->map = $srcConfig['map'];
-            foreach ($driver->map as $key => $val) {
-                if (!is_array($val)) {
-                    $driver->fields[$key] = $val;
-                }
-            }
-
-            /* Store tabs. */
-            if (isset($srcConfig['tabs'])) {
-                $driver->tabs = $srcConfig['tabs'];
-            }
-
-            /* Store remaining fields. */
-            if (isset($srcConfig['strict'])) {
-                $driver->strict = $srcConfig['strict'];
-            }
-            if (isset($srcConfig['approximate'])) {
-                $driver->approximate = $srcConfig['approximate'];
-            }
-            if (isset($srcConfig['list_name_field'])) {
-                $driver->listNameField = $srcConfig['list_name_field'];
-            }
-            if (isset($srcConfig['alternative_name'])) {
-                $driver->alternativeName = $srcConfig['alternative_name'];
-            }
-            $this->_instances[$key] = $driver;
-        }
-
-        return $this->_instances[$key];
-    }
-
-}
index 9781526..ee07d81 100644 (file)
@@ -38,7 +38,7 @@ class Turba_List implements Countable
         foreach ($ids as $value) {
             list($source, $key) = explode(':', $value);
             try {
-                $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+                $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
                 $this->insert($driver->getObject($key));
             } catch (Turba_Exception $e) {}
         }
index 6c4adeb..cdfc377 100644 (file)
@@ -40,7 +40,7 @@ class Turba_LoginTasks_SystemTask_UpgradeLists extends Horde_LoginTasks_SystemTa
             $sources = array_keys($GLOBALS['cfgSources']);
             foreach ($sources as $sourcekey) {
                 try {
-                    $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($sourcekey);
+                    $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($sourcekey);
                     $lists = $driver->search($criteria);
                 } catch (Turba_Exception $e) {
                     return false;
index b2502f1..9077442 100644 (file)
@@ -69,7 +69,7 @@ class Turba_Object_Group extends Turba_Object
         if ($sourceId == $this->getSource()) {
             $contact = $this->driver->getObject($contactId);
         } else {
-            $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($sourceId);
+            $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($sourceId);
             $contact = $driver->getObject($contactId);
         }
 
@@ -172,7 +172,7 @@ class Turba_Object_Group extends Turba_Object
                 }
 
                 try {
-                    $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($sourceId);
+                    $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($sourceId);
                 } catch (Turba_Exception $e) {
                     continue;
                 }
index 48b0a9a..e94c84d 100644 (file)
@@ -367,7 +367,7 @@ class Turba
 
         foreach ($in as $sourceId => $source) {
             try {
-                $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($sourceId);
+                $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($sourceId);
             } catch (Turba_Exception $e) {
                 Horde::logMessage($e, 'ERR');
                 continue;
@@ -454,7 +454,7 @@ class Turba
             if ($GLOBALS['registry']->getAuth() && !$personal) {
                 // User's default share is missing.
                 try {
-                    $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
+                    $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
                 } catch (Turba_Exception $e) {
                     $GLOBALS['notification']->push($driver, 'horde.error');
                     continue;
index 9c69e7b..75a15d7 100644 (file)
@@ -68,7 +68,7 @@ class Turba_View_Browse
         } else {
             try {
                 $driver = $GLOBALS['injector']
-                    ->getInstance('Turba_Injector_Factory_Driver')
+                    ->getInstance('Turba_Factory_Driver')
                     ->create($source);
             } catch (Turba_Exception $e) {
                 $notification->push($e, 'horde.error');
@@ -160,7 +160,7 @@ class Turba_View_Browse
 
                 try {
                     $targetDriver = $GLOBALS['injector']
-                        ->getInstance('Turba_Injector_Factory_Driver')
+                        ->getInstance('Turba_Factory_Driver')
                         ->create($targetSource);
                 } catch (Turba_Exception $e) {
                     $notification->push($e, 'horde.error');
@@ -191,7 +191,7 @@ class Turba_View_Browse
                     // Try and load the driver for the source.
                     try {
                         $sourceDriver = $GLOBALS['injector']
-                            ->getInstance('Turba_Injector_Factory_Driver')
+                            ->getInstance('Turba_Factory_Driver')
                             ->create($objectSource);
                     } catch (Turba_Exception $e) {
                         $notification->push($e, 'horde.error');
@@ -303,7 +303,7 @@ class Turba_View_Browse
 
                     try {
                         $targetDriver = $GLOBALS['injector']
-                            ->getInstance('Turba_Injector_Factory_Driver')
+                            ->getInstance('Turba_Factory_Driver')
                             ->create($targetSource);
                     } catch (Turba_Exception $e) {
                         $notification->push($e, 'horde.error');
@@ -320,7 +320,7 @@ class Turba_View_Browse
                     $targetSource = $vars->get('targetAddressbook');
                     try {
                         $targetDriver = $GLOBALS['injector']
-                            ->getInstance('Turba_Injector_Factory_Driver')
+                            ->getInstance('Turba_Factory_Driver')
                             ->create($targetSource);
                     } catch (Turba_Exception $e) {
                         $notification->push($e, 'horde.error');
index 02020eb..5ac193d 100644 (file)
@@ -161,7 +161,7 @@ class Turba_View_List implements Countable
         global $prefs, $session, $default_source, $copymove_source_options;
 
         $driver = $GLOBALS['injector']
-            ->getInstance('Turba_Injector_Factory_Driver')
+            ->getInstance('Turba_Factory_Driver')
             ->create($default_source);
         $hasDelete = $driver->hasPermission(Horde_Perms::DELETE);
         $hasEdit = $driver->hasPermission(Horde_Perms::EDIT);
@@ -424,7 +424,7 @@ class Turba_View_List implements Countable
                                             'name' => '&nbsp;&nbsp;' . htmlspecialchars($srcConfig['title']),
                                             'source' => htmlspecialchars($src));
 
-                $srcDriver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($src);
+                $srcDriver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($src);
                 try {
                     $listList = $srcDriver->search(
                         array('__type' => 'Group'),
index 38188c3..5a5e6e4 100644 (file)
@@ -47,14 +47,14 @@ class Turba_KolabTest extends Turba_KolabTestBase {
         $this->_kolab->_storage->save($object);
 
         // Check that the driver can be created
-        $turba = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create('wrobel@example.org');
+        $turba = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create('wrobel@example.org');
         //$this->assertNoError($turba);
 
         $result = $turba->search(array(), array('last-name'));
         $this->assertNoError($result);
         $this->assertEquals(2, count($result));
 
-        $turba = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create('INBOX%2Ftest2');
+        $turba = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create('INBOX%2Ftest2');
         $result = $turba->search(array(), array('last-name'));
 
         $this->assertEquals(0, count($result));
@@ -75,7 +75,7 @@ class Turba_KolabTest extends Turba_KolabTestBase {
         );
 
         // Save the contact
-        $turba = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create('wrobel@example.org');
+        $turba = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create('wrobel@example.org');
         //$this->assertNoError($turba);
 
         $this->assertNoError($turba->_add($object));
@@ -102,7 +102,7 @@ class Turba_KolabTest extends Turba_KolabTestBase {
         );
 
         // Save the contact
-        $turba = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create('wrobel@example.org');
+        $turba = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create('wrobel@example.org');
         //$this->assertNoError($turba);
 
         $this->assertNoError($turba->_add($object));
index b288a17..deb7d30 100644 (file)
@@ -16,7 +16,7 @@ Horde_Registry::appInit('turba');
 $source = Horde_Util::getFormData('source');
 $key = Horde_Util::getFormData('key');
 $mergeInto = Horde_Util::getFormData('merge_into');
-$driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source);
+$driver = $injector->getInstance('Turba_Factory_Driver')->create($source);
 
 if ($url = Horde_Util::getFormData('url')) {
     $url = new Horde_Url($url, true);
index 66a7e21..e304a0e 100644 (file)
@@ -22,7 +22,7 @@ $source = Horde_Util::getFormData('source', Turba::getDefaultAddressBook());
 // Do the search if we have one.
 if (!is_null($search)) {
     try {
-        $driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source);
+        $driver = $injector->getInstance('Turba_Factory_Driver')->create($source);
         $criteria['name'] = trim($search);
         $res = $driver->search($criteria);
 
index 5d848eb..53e6d2d 100755 (executable)
@@ -83,7 +83,7 @@ foreach($files as $file) {
 
     // Initiate driver
     try {
-        $driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($import_source);
+        $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($import_source);
     } catch (Turba_Exception $e) {
         PEAR::raiseError(sprintf(_("Connection failed: %s"), $e->getMessage()), 'horde.error', null, null, $import_source);
         continue;
index bc97bf7..5f370a6 100755 (executable)
@@ -92,7 +92,7 @@ while ($row = $handle->fetchRow(DB_FETCHMODE_ASSOC)) {
 
         // Initiate driver
         try {
-            $driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($import_source);
+            $driver = $injector->getInstance('Turba_Factory_Driver')->create($import_source);
         } catch (Turba_Exception $e) {
             $cli->message('  ' . sprintf(_("Connection failed: %s"), $e->getMessage()), 'cli.error');
             continue;
index e832fd9..5c55b24 100755 (executable)
@@ -68,7 +68,7 @@ $share->save();
 $CLI->message('Created new Horde_Share object for the shared address book.', 'cli.success');
 
 // Share created, now get a Turba_Driver and make the changes.
-$driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($sourceKey);
+$driver = $injector->getInstance('Turba_Factory_Driver')->create($sourceKey);
 
 $db = &$driver->_db;
 
index 8238fdb..5e6d8b4 100644 (file)
@@ -85,7 +85,7 @@ $val = Horde_Util::getFormData('val');
 $action = Horde_Util::getFormData('actionID');
 
 try {
-    $driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source);
+    $driver = $injector->getInstance('Turba_Factory_Driver')->create($source);
 } catch (Turba_Exception $e) {
     $notification->push($e, 'horde.error');
     $driver = null;
index eaa6c15..417ee2f 100644 (file)
@@ -19,7 +19,7 @@ if (!isset($cfgSources[$source])) {
     Horde::url($prefs->getValue('initial_page'), true)->redirect();
 }
 
-$driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source);
+$driver = $injector->getInstance('Turba_Factory_Driver')->create($source);
 
 /* Set the contact from the key requested. */
 try {
index 377640a..c2f9b57 100644 (file)
@@ -28,7 +28,7 @@ if (!isset($cfgSources[$source])) {
     throw new Turba_Exception(_("The contact you requested does not exist."));
 }
 
-$driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source);
+$driver = $injector->getInstance('Turba_Factory_Driver')->create($source);
 $object = $driver->getObject($key);
 
 /* Check permissions. */