From 4cba931280dddddf4497b0b94fa0d6a66cdea315 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 4 Oct 2010 13:24:03 -0600 Subject: [PATCH] Remove unneeded IMP_Compose binder --- imp/compose-dimp.php | 2 +- imp/compose-mimp.php | 2 +- imp/compose.php | 2 +- imp/lib/Ajax/Application.php | 14 +++++++------- imp/lib/Application.php | 5 ++--- imp/lib/Auth.php | 2 +- imp/lib/Injector/Binder/Compose.php | 31 ------------------------------- imp/lib/Injector/Factory/Compose.php | 6 +++--- imp/lib/Spam.php | 2 +- imp/lib/Views/Compose.php | 2 +- imp/view.php | 2 +- 11 files changed, 19 insertions(+), 51 deletions(-) delete mode 100644 imp/lib/Injector/Binder/Compose.php diff --git a/imp/compose-dimp.php b/imp/compose-dimp.php index 7f8fe8c27..540277213 100644 --- a/imp/compose-dimp.php +++ b/imp/compose-dimp.php @@ -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; diff --git a/imp/compose-mimp.php b/imp/compose-mimp.php index a36aa0cae..a7005445d 100644 --- a/imp/compose-mimp.php +++ b/imp/compose-mimp.php @@ -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) { diff --git a/imp/compose.php b/imp/compose.php index a1cbee65f..a8e71c2ad 100644 --- a/imp/compose.php +++ b/imp/compose.php @@ -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); diff --git a/imp/lib/Ajax/Application.php b/imp/lib/Ajax/Application.php index 870a344d6..a28e57942 100644 --- a/imp/lib/Ajax/Application.php +++ b/imp/lib/Ajax/Application.php @@ -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)) diff --git a/imp/lib/Application.php b/imp/lib/Application.php index 26b81b4c3..65ffa5785 100644 --- a/imp/lib/Application.php +++ b/imp/lib/Application.php @@ -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'); } } } diff --git a/imp/lib/Auth.php b/imp/lib/Auth.php index 65644e8d5..9970aecbd 100644 --- a/imp/lib/Auth.php +++ b/imp/lib/Auth.php @@ -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 index e96a77e59..000000000 --- a/imp/lib/Injector/Binder/Compose.php +++ /dev/null @@ -1,31 +0,0 @@ - - * @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; - } - -} diff --git a/imp/lib/Injector/Factory/Compose.php b/imp/lib/Injector/Factory/Compose.php index 363a06b4f..53fedae49 100644 --- a/imp/lib/Injector/Factory/Compose.php +++ b/imp/lib/Injector/Factory/Compose.php @@ -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) { diff --git a/imp/lib/Spam.php b/imp/lib/Spam.php index 335f0d140..b56f4392c 100644 --- a/imp/lib/Spam.php +++ b/imp/lib/Spam.php @@ -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) { diff --git a/imp/lib/Views/Compose.php b/imp/lib/Views/Compose.php index a84d4219b..6e0b98f21 100644 --- a/imp/lib/Views/Compose.php +++ b/imp/lib/Views/Compose.php @@ -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']); } diff --git a/imp/view.php b/imp/view.php index db0b152dc..51dcf482b 100644 --- a/imp/view.php +++ b/imp/view.php @@ -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); -- 2.11.0