Remove unneeded IMP_Compose binder
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 4 Oct 2010 19:24:03 +0000 (13:24 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 4 Oct 2010 19:30:05 +0000 (13:30 -0600)
imp/compose-dimp.php
imp/compose-mimp.php
imp/compose.php
imp/lib/Ajax/Application.php
imp/lib/Application.php
imp/lib/Auth.php
imp/lib/Injector/Binder/Compose.php [deleted file]
imp/lib/Injector/Factory/Compose.php
imp/lib/Spam.php
imp/lib/Views/Compose.php
imp/view.php

index 7f8fe8c..5402772 100644 (file)
@@ -62,7 +62,7 @@ if (!$prefs->isLocked('default_identity') && isset($vars->identity)) {
 }
 
 /* Init objects. */
-$imp_compose = $injector->getInstance('IMP_Compose')->getOb();
+$imp_compose = $injector->getInstance('IMP_Injector_Factory_Compose')->create();
 $imp_ui = new IMP_Ui_Compose();
 
 $show_editor = false;
index a36aa0c..a700544 100644 (file)
@@ -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_Compose')->getOb($vars->composeCache);
+$imp_compose = $injector->getInstance('IMP_Injector_Factory_Compose')->create($vars->composeCache);
 $imp_ui = new IMP_Ui_Compose();
 
 foreach (array_keys($display_hdrs) as $val) {
index a1cbee6..a8e71c2 100644 (file)
@@ -111,7 +111,7 @@ if ($readonly_sentmail) {
 }
 
 /* Initialize the IMP_Compose:: object. */
-$imp_compose = $injector->getInstance('IMP_Compose')->getOb($vars->composeCache);
+$imp_compose = $injector->getInstance('IMP_Injector_Factory_Compose')->create($vars->composeCache);
 $imp_compose->pgpAttachPubkey((bool) $vars->pgp_attach_pubkey);
 $imp_compose->userLinkAttachments((bool) $vars->link_attachments);
 
index 870a344..a28e579 100644 (file)
@@ -1222,7 +1222,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
      */
     public function cancelCompose()
     {
-        $imp_compose = $GLOBALS['injector']->getInstance('IMP_Compose')->getOb($this->_vars->imp_compose);
+        $imp_compose = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create($this->_vars->imp_compose);
         $imp_compose->destroy('cancel');
 
         return true;
@@ -1275,7 +1275,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
      */
     public function deleteDraft()
     {
-        $GLOBALS['injector']->getInstance('IMP_Compose')->getOb($this->_vars->imp_compose)->destroy('cancel');
+        $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create($this->_vars->imp_compose)->destroy('cancel');
         return true;
     }
 
@@ -1293,7 +1293,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_Compose')->getOb($this->_vars->imp_compose);
+            $imp_compose = $GLOBALS['injector']->getInstance('IMP_Injector_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]);
@@ -1528,7 +1528,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
      */
     public function addAttachment()
     {
-        $imp_compose = $GLOBALS['injector']->getInstance('IMP_Compose')->getOb($this->_vars->composeCache);
+        $imp_compose = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create($this->_vars->composeCache);
 
         $result = new stdClass;
         $result->action = 'addAttachment';
@@ -1725,7 +1725,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
         $result->success = 1;
 
         try {
-            $imp_compose = $GLOBALS['injector']->getInstance('IMP_Compose')->getOb($this->_vars->composeCache);
+            $imp_compose = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create($this->_vars->composeCache);
             $imp_compose->sendRedirectMessage($this->_vars->redirect_to);
 
             $result->mbox = $imp_compose->getMetadata('mailbox');
@@ -1803,7 +1803,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
         }
         $headers['subject'] = $this->_vars->subject;
 
-        $imp_compose = $GLOBALS['injector']->getInstance('IMP_Compose')->getOb($this->_vars->composeCache);
+        $imp_compose = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create($this->_vars->composeCache);
 
         return array($result, $imp_compose, $headers, $identity);
     }
@@ -1813,7 +1813,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
      */
     protected function _initCompose()
     {
-        $imp_compose = $GLOBALS['injector']->getInstance('IMP_Compose')->getOb($this->_vars->imp_compose);
+        $imp_compose = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create($this->_vars->imp_compose);
         if (!($imp_contents = $imp_compose->getContentsOb())) {
             $imp_contents = $this->_vars->uid
                 ? $GLOBALS['injector']->getInstance('IMP_Contents')->getOb(new IMP_Indices($this->_vars->uid))
index 26b81b4..65ffa57 100644 (file)
@@ -79,7 +79,7 @@ class IMP_Application extends Horde_Registry_Application
     {
         if (($e->getCode() == Horde_Registry::AUTH_FAILURE) &&
             Horde_Util::getFormData('composeCache')) {
-            $GLOBALS['injector']->getInstance('IMP_Compose')->getOb()->sessionExpireDraft(Horde_Variables::getDefaultVariables());
+            $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create()->sessionExpireDraft(Horde_Variables::getDefaultVariables());
         }
     }
 
@@ -91,7 +91,6 @@ class IMP_Application extends Horde_Registry_Application
         /* Add IMP-specific binders. */
         $binders = array(
             'IMP_AuthImap' => new IMP_Injector_Binder_AuthImap(),
-            'IMP_Compose' => new IMP_Injector_Binder_Compose(),
             'IMP_Contents' => new IMP_Injector_Binder_Contents(),
             'IMP_Crypt_Pgp' => new IMP_Injector_Binder_Pgp(),
             'IMP_Crypt_Smime' => new IMP_Injector_Binder_Smime(),
@@ -153,7 +152,7 @@ class IMP_Application extends Horde_Registry_Application
         /* Clean up dangling IMP_Compose objects. */
         if (!empty($_SESSION['imp']['cache']['compose'])) {
             foreach (array_keys($_SESSION['imp']['cache']['compose']) as $key) {
-                $GLOBALS['injector']->getInstance('IMP_Compose')->getOb($key)->destroy('cancel');
+                $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create($key)->destroy('cancel');
             }
         }
     }
index 65644e8..9970aec 100644 (file)
@@ -504,7 +504,7 @@ class IMP_Auth
         }
 
         /* Check for drafts due to session timeouts. */
-        $imp_compose = $GLOBALS['injector']->getInstance('IMP_Compose')->getOb()->recoverSessionExpireDraft();
+        $imp_compose = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create()->recoverSessionExpireDraft();
 
         self::_logMessage(true);
     }
diff --git a/imp/lib/Injector/Binder/Compose.php b/imp/lib/Injector/Binder/Compose.php
deleted file mode 100644 (file)
index e96a77e..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-/**
- * Binder for IMP_Compose::.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author   Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license  http://www.fsf.org/copyleft/gpl.html GPL
- * @package  IMP
- */
-class IMP_Injector_Binder_Compose implements Horde_Injector_Binder
-{
-    /**
-     */
-    public function create(Horde_Injector $injector)
-    {
-        return new IMP_Injector_Factory_Compose($injector);
-    }
-
-    /**
-     */
-    public function equals(Horde_Injector_Binder $binder)
-    {
-        return false;
-    }
-
-}
index 363a06b..53fedae 100644 (file)
@@ -61,12 +61,12 @@ class IMP_Injector_Factory_Compose
      * @return IMP_Compose  The singleton compose instance.
      * @throws IMP_Exception
      */
-    public function getOb($cacheid = null)
+    public function create($cacheid = null)
     {
         if (empty($cacheid)) {
             $cacheid = strval(new Horde_Support_Randomid());
         } elseif (!isset($this->_instances[$cacheid])) {
-            $obs = $GLOBALS['injector']->getInstance('Horde_SessionObjects');
+            $obs = $this->_injector->getInstance('Horde_SessionObjects');
             $this->_instances[$cacheid] = $obs->query($cacheid);
         }
 
@@ -82,7 +82,7 @@ class IMP_Injector_Factory_Compose
      */
     public function shutdown()
     {
-        $obs = $GLOBALS['injector']->getInstance('Horde_SessionObjects');
+        $obs = $this->_injector->getInstance('Horde_SessionObjects');
 
         foreach ($this->_instances as $key => $val) {
             switch ($val->changed) {
index 335f0d1..b56f439 100644 (file)
@@ -119,7 +119,7 @@ class IMP_Spam
                     }
 
                     if (!isset($imp_compose)) {
-                        $imp_compose = $GLOBALS['injector']->getInstance('IMP_Compose')->getOb();
+                        $imp_compose = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create();
                         try {
                             $from_line = $GLOBALS['injector']->getInstance('IMP_Identity')->getFromLine();
                         } catch (Horde_Exception $e) {
index a84d421..6e0b98f 100644 (file)
@@ -45,7 +45,7 @@ class IMP_Views_Compose
         $t->setOption('gettext', true);
 
         if (!empty($args['composeCache'])) {
-            $imp_compose = $injector->getInstance('IMP_Compose')->getOb($args['composeCache']);
+            $imp_compose = $injector->getInstance('IMP_Injector_Factory_Compose')->create($args['composeCache']);
             $t->set('composeCache', $args['composeCache']);
         }
 
index db0b152..51dcf48 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_Compose')->getOb($vars->composeCache);
+    $imp_compose = $injector->getInstance('IMP_Injector_Factory_Compose')->create($vars->composeCache);
     $mime = $imp_compose->buildAttachment($vars->id);
     $mime->setMimeId($vars->id);