From: Michael M Slusarz Date: Wed, 14 Apr 2010 09:55:33 +0000 (-0600) Subject: Add Identity binder in IMP X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=c4a8bbfa852ae49c87acf4806c51b8c241af2f12;p=horde.git Add Identity binder in IMP --- diff --git a/imp/compose-dimp.php b/imp/compose-dimp.php index 2c02791c0..109e61ee6 100644 --- a/imp/compose-dimp.php +++ b/imp/compose-dimp.php @@ -51,7 +51,7 @@ if ($vars->popup) { $js[] = 'DIMP.conf_compose.popup = 1'; } -$identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); +$identity = $injector->getInstance('IMP_Identity'); if (!$prefs->isLocked('default_identity') && isset($vars->identity)) { $identity->setDefault($vars->identity); } diff --git a/imp/compose-mimp.php b/imp/compose-mimp.php index 74304d28d..29b0b41e1 100644 --- a/imp/compose-mimp.php +++ b/imp/compose-mimp.php @@ -50,7 +50,7 @@ if ($prefs->getValue('compose_bcc')) { } /* Set the current identity. */ -$identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); +$identity = $injector->getInstance('IMP_Identity'); if (!$prefs->isLocked('default_identity') && isset($vars->identity)) { $identity->setDefault($vars->identity); } diff --git a/imp/compose.php b/imp/compose.php index 5999fba13..69044c7c6 100644 --- a/imp/compose.php +++ b/imp/compose.php @@ -28,7 +28,7 @@ $oldrtemode = $rtemode = null; $vars = Horde_Variables::getDefaultVariables(); /* Set the current identity. */ -$identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); +$identity = $injector->getInstance('IMP_Identity'); if (!$prefs->isLocked('default_identity')) { if (!is_null($vars->identity)) { $identity->setDefault($vars->identity); diff --git a/imp/lib/Ajax/Application.php b/imp/lib/Ajax/Application.php index abfa4a8a5..8909cb83e 100644 --- a/imp/lib/Ajax/Application.php +++ b/imp/lib/Ajax/Application.php @@ -1497,7 +1497,7 @@ class IMP_Ajax_Application extends Horde_Ajax_Application_Base $result->success = 1; /* Set up identity. */ - $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); + $identity = $GLOBALS['injector']->getInstance('IMP_Identity'); if (isset($this->_vars->identity) && !$GLOBALS['prefs']->isLocked('default_identity')) { $identity->setDefault($this->_vars->identity); diff --git a/imp/lib/Application.php b/imp/lib/Application.php index ba8e50261..5d430c7e8 100644 --- a/imp/lib/Application.php +++ b/imp/lib/Application.php @@ -97,6 +97,7 @@ class IMP_Application extends Horde_Registry_Application 'IMP_Crypt_Pgp' => new IMP_Injector_Binder_Pgp(), 'IMP_Crypt_Smime' => new IMP_Injector_Binder_Smime(), 'IMP_Folder' => new IMP_Injector_Binder_Folder(), + 'IMP_Identity' => new IMP_Injector_Binder_Identity(), 'IMP_Imap_Tree' => new IMP_Injector_Binder_Imaptree(), 'IMP_Sentmail' => new IMP_Injector_Binder_Sentmail() ); diff --git a/imp/lib/Compose.php b/imp/lib/Compose.php index e302089de..0306de8dd 100644 --- a/imp/lib/Compose.php +++ b/imp/lib/Compose.php @@ -399,7 +399,7 @@ class IMP_Compose $identity_id = null; $headers = $contents->getHeaderOb(); if (($fromaddr = Horde_Mime_Address::bareAddress($headers->getValue('from')))) { - $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); + $identity = $GLOBALS['injector']->getInstance('IMP_Identity'); $identity_id = $identity->getMatchingIdentity($fromaddr); } @@ -1354,7 +1354,7 @@ class IMP_Compose } /* Filter out our own address from the addresses we reply to. */ - $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); + $identity = $GLOBALS['injector']->getInstance('IMP_Identity'); $all_addrs = array_keys($identity->getAllFromAddresses(true)); /* Build the To: header. It is either: @@ -1627,7 +1627,7 @@ class IMP_Compose $recip = $this->recipientList(array('to' => $to)); $recipients = implode(', ', $recip['list']); - $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); + $identity = $GLOBALS['injector']->getInstance('IMP_Identity'); $from_addr = $identity->getFromAddress(); $contents = $this->getContentsOb(); @@ -1681,7 +1681,7 @@ class IMP_Compose $msgAddresses[] = $h->getValue($val); } - return Horde_Prefs_Identity::singleton(array('imp', 'imp'))->getMatchingIdentity($msgAddresses); + return $GLOBALS['injector']->getInstance('IMP_Identity')->getMatchingIdentity($msgAddresses); } /** diff --git a/imp/lib/Crypt/Pgp.php b/imp/lib/Crypt/Pgp.php index d6c115c09..1d77a3110 100644 --- a/imp/lib/Crypt/Pgp.php +++ b/imp/lib/Crypt/Pgp.php @@ -184,7 +184,7 @@ class IMP_Crypt_Pgp extends Horde_Crypt_Pgp /* TODO: Retrieve by ID. */ /* See if the address points to the user's public key. */ - $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); + $identity = $GLOBALS['injector']->getInstance('IMP_Identity'); $personal_pubkey = $this->getPersonalPublicKey(); if (!empty($personal_pubkey) && $identity->hasAddress($address)) { $result = $personal_pubkey; diff --git a/imp/lib/Crypt/Smime.php b/imp/lib/Crypt/Smime.php index 5b2b0fb3d..da172d76a 100644 --- a/imp/lib/Crypt/Smime.php +++ b/imp/lib/Crypt/Smime.php @@ -168,7 +168,7 @@ class IMP_Crypt_Smime extends Horde_Crypt_Smime $key = $GLOBALS['registry']->call('contacts/getField', array($address, self::PUBKEY_FIELD, $params['sources'], false, true)); } catch (Horde_Exception $e) { /* See if the address points to the user's public key. */ - $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); + $identity = $GLOBALS['injector']->getInstance('IMP_Identity'); $personal_pubkey = $this->getPersonalPublicKey(); if (!empty($personal_pubkey) && $identity->hasAddress($address)) { return $personal_pubkey; diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index d2ed50118..34d4964d9 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -1017,7 +1017,7 @@ class IMP static public function isSpecialFolder($mbox) { /* Get the identities. */ - $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); + $identity = $GLOBALS['injector']->getInstance('IMP_Identity'); return (($mbox == self::folderPref($GLOBALS['prefs']->getValue('drafts_folder'), true)) || in_array($mbox, $identity->getAllSentmailFolders())); } diff --git a/imp/lib/Imap/Flags.php b/imp/lib/Imap/Flags.php index f24826f26..77f9222ee 100644 --- a/imp/lib/Imap/Flags.php +++ b/imp/lib/Imap/Flags.php @@ -265,7 +265,7 @@ class IMP_Imap_Flags if (isset($options['personal'])) { if (is_array($options['personal'])) { - $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); + $identity = $GLOBALS['injector']->getInstance('IMP_Identity'); foreach ($options['personal'] as $val) { if ($identity->hasAddress($val['inner'])) { $process['personal'] = $f['personal']; diff --git a/imp/lib/Imap/Tree.php b/imp/lib/Imap/Tree.php index 87df48d31..ddd2b3dde 100644 --- a/imp/lib/Imap/Tree.php +++ b/imp/lib/Imap/Tree.php @@ -1799,7 +1799,7 @@ class IMP_Imap_Tree */ public function getSpecialMailboxes() { - $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); + $identity = $GLOBALS['injector']->getInstance('IMP_Identity'); return array( 'draft' => IMP::folderPref($GLOBALS['prefs']->getValue('drafts_folder'), true), 'sent' => $identity->getAllSentmailFolders(), diff --git a/imp/lib/Injector/Binder/Identity.php b/imp/lib/Injector/Binder/Identity.php new file mode 100644 index 000000000..bf91a11a9 --- /dev/null +++ b/imp/lib/Injector/Binder/Identity.php @@ -0,0 +1,29 @@ + + * @package IMP + */ +class IMP_Injector_Binder_Identity implements Horde_Injector_Binder +{ + /** + */ + public function create(Horde_Injector $injector) + { + return Horde_Prefs_Identity::singleton(array('imp', 'imp')); + } + + /** + */ + public function equals(Horde_Injector_Binder $binder) + { + return false; + } + +} diff --git a/imp/lib/LoginTasks/Task/DeleteSentmailMonthly.php b/imp/lib/LoginTasks/Task/DeleteSentmailMonthly.php index 78eef0f59..a33884dc8 100644 --- a/imp/lib/LoginTasks/Task/DeleteSentmailMonthly.php +++ b/imp/lib/LoginTasks/Task/DeleteSentmailMonthly.php @@ -34,7 +34,7 @@ class IMP_LoginTasks_Task_DeleteSentmailMonthly extends Horde_LoginTasks_Task /* Get list of all folders, parse through and get the list of all old sent-mail folders. Then sort this array according to the date. */ - $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); + $identity = $GLOBALS['injector']->getInstance('IMP_Identity'); $imp_folder = $GLOBALS['injector']->getInstance('IMP_Folder'); $sent_mail_folders = $identity->getAllSentmailFolders(); diff --git a/imp/lib/LoginTasks/Task/PurgeSentmail.php b/imp/lib/LoginTasks/Task/PurgeSentmail.php index b3b2250a7..9f81531c0 100644 --- a/imp/lib/LoginTasks/Task/PurgeSentmail.php +++ b/imp/lib/LoginTasks/Task/PurgeSentmail.php @@ -96,7 +96,7 @@ class IMP_LoginTasks_Task_PurgeSentmail extends Horde_LoginTasks_Task */ protected function _getFolders() { - return Horde_Prefs_Identity::singleton(array('imp', 'imp'))->getAllSentmailfolders(); + return $GLOBALS['injector']->getInstance('IMP_Identity')->getAllSentmailfolders(); } } diff --git a/imp/lib/LoginTasks/Task/RenameSentmailMonthly.php b/imp/lib/LoginTasks/Task/RenameSentmailMonthly.php index 0a04e0c87..efa886ade 100644 --- a/imp/lib/LoginTasks/Task/RenameSentmailMonthly.php +++ b/imp/lib/LoginTasks/Task/RenameSentmailMonthly.php @@ -33,7 +33,7 @@ class IMP_LoginTasks_Task_RenameSentmailMonthly extends Horde_LoginTasks_Task { $success = true; - $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); + $identity = $GLOBALS['injector']->getInstance('IMP_Identity'); $imp_folder = $GLOBALS['injector']->getInstance('IMP_Folder'); foreach ($identity->getAllSentmailfolders() as $sent_folder) { @@ -64,7 +64,7 @@ class IMP_LoginTasks_Task_RenameSentmailMonthly extends Horde_LoginTasks_Task */ public function describe() { - $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); + $identity = $GLOBALS['injector']->getInstance('IMP_Identity'); $new_folders = $old_folders = array(); foreach ($identity->getAllSentmailfolders() as $folder) { diff --git a/imp/lib/Mime/Viewer/Itip.php b/imp/lib/Mime/Viewer/Itip.php index 29e73bcbc..d45172ebc 100644 --- a/imp/lib/Mime/Viewer/Itip.php +++ b/imp/lib/Mime/Viewer/Itip.php @@ -263,7 +263,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver $vEvent_reply->setAttribute('ORGANIZER', $vEvent->getAttribute('ORGANIZER'), array_pop($organizer)); // Find out who we are and update status. - $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); + $identity = $GLOBALS['injector']->getInstance('IMP_Identity'); $attendees = $vEvent->getAttribute('ATTENDEE'); if (!is_array($attendees)) { $attendees = array($attendees); @@ -401,7 +401,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver array('startStamp' => $startStamp, 'endStamp' => $endStamp)); // Find out who we are and update status. - $identity = Horde_Prefs_Identity::singleton(); + $identity = $GLOBALS['injector']->getInstance('IMP_Identity'); $email = $identity->getFromAddress(); // Build the reply. @@ -645,7 +645,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver // Check that you are one of the attendees here. $is_attendee = false; if (!($attendees instanceof PEAR_Error) && !empty($attendees)) { - $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); + $identity = $GLOBALS['injector']->getInstance('IMP_Identity'); for ($i = 0, $c = count($attendees); $i < $c; ++$i) { $attendee = parse_url($attendees[$i]); if (!empty($attendee['path']) && diff --git a/imp/lib/Prefs/Ui.php b/imp/lib/Prefs/Ui.php index 69eded858..01cac397a 100644 --- a/imp/lib/Prefs/Ui.php +++ b/imp/lib/Prefs/Ui.php @@ -401,7 +401,7 @@ class IMP_Prefs_Ui return false; case 'signature_html_select': - return Horde_Prefs_Identity::singleton(array('imp', 'imp'))->setValue('signature_html', $ui->vars->signature_html); + return $GLOBALS['injector']->getInstance('IMP_Identity')->setValue('signature_html', $ui->vars->signature_html); case 'soundselect': return $prefs->setValue('nav_audio', $ui->vars->nav_audio); @@ -994,7 +994,7 @@ class IMP_Prefs_Ui $t->set('deletekeypair', addslashes(_("Are you sure you want to delete your keypair? (This is NOT recommended!)"))); $t->set('personalkey-delete-help', Horde_Help::link('imp', 'pgp-personalkey-delete')); } else { - $imp_identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); + $imp_identity = $GLOBALS['injector']->getInstance('IMP_Identity'); $t->set('fullname', $imp_identity->getFullname()); $t->set('personalkey-create-name-help', Horde_Help::link('imp', 'pgp-personalkey-create-name')); $t->set('personalkey-create-comment-help', Horde_Help::link('imp', 'pgp-personalkey-create-comment')); @@ -1140,7 +1140,7 @@ class IMP_Prefs_Ui */ protected function _sentmail() { - $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); + $identity = $GLOBALS['injector']->getInstance('IMP_Identity'); $js = array(); foreach (array_keys($identity->getAll('id')) as $key) { @@ -1200,8 +1200,7 @@ class IMP_Prefs_Ui $imp_folder->create($sent_mail_folder, $prefs->getValue('subscribe')); } - $imp_identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); - $imp_identity->setValue('sent_mail_folder', IMP::folderPref($sent_mail_folder, false)); + $GLOBALS['injector']->getInstance('IMP_Identity')->setValue('sent_mail_folder', IMP::folderPref($sent_mail_folder, false)); return true; } @@ -1349,7 +1348,7 @@ class IMP_Prefs_Ui */ protected function _signatureHtml() { - $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); + $identity = $GLOBALS['injector']->getInstance('IMP_Identity'); $js = array(); foreach (array_keys($identity->getAll('id')) as $key) { diff --git a/imp/lib/Spam.php b/imp/lib/Spam.php index 2378e7310..df2127486 100644 --- a/imp/lib/Spam.php +++ b/imp/lib/Spam.php @@ -110,9 +110,8 @@ class IMP_Spam if (!isset($imp_compose)) { $imp_compose = IMP_Compose::singleton(); - $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); try { - $from_line = $identity->getFromLine(); + $from_line = $GLOBALS['injector']->getInstance('IMP_Identity')->getFromLine(); } catch (Horde_Exception $e) { $from_line = null; } diff --git a/imp/lib/Ui/Compose.php b/imp/lib/Ui/Compose.php index c6c6f57b8..d0ea5df5e 100644 --- a/imp/lib/Ui/Compose.php +++ b/imp/lib/Ui/Compose.php @@ -271,7 +271,7 @@ class IMP_Ui_Compose public function identityJs() { $identities = array(); - $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); + $identity = $GLOBALS['injector']->getInstance('IMP_Identity'); $html_sigs = $identity->getAllSignatures('html'); @@ -308,7 +308,7 @@ class IMP_Ui_Compose */ public function convertComposeText($data, $to, $identity) { - $imp_identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); + $imp_identity = $GLOBALS['injector']->getInstance('IMP_Identity'); $replaced = 0; $html_sig = $imp_identity->getSignature('html', $identity); diff --git a/imp/lib/Ui/Mailbox.php b/imp/lib/Ui/Mailbox.php index f3f290e28..25334d3bb 100644 --- a/imp/lib/Ui/Mailbox.php +++ b/imp/lib/Ui/Mailbox.php @@ -78,8 +78,7 @@ class IMP_Ui_Mailbox $ret['from'] = _("Invalid Address"); $ret['error'] = true; } else { - $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); - if ($identity->hasAddress($from['inner'])) { + if ($GLOBALS['injector']->getInstance('IMP_Identity')->hasAddress($from['inner'])) { /* This message was sent by one of the user's identity * addresses - show To: information instead. */ if (empty($ob['to'])) { diff --git a/imp/lib/Views/Compose.php b/imp/lib/Views/Compose.php index 0dd89fde4..1ae6c1362 100644 --- a/imp/lib/Views/Compose.php +++ b/imp/lib/Views/Compose.php @@ -47,7 +47,7 @@ class IMP_Views_Compose if (empty($args['redirect'])) { /* Load Identity. */ - $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); + $identity = $GLOBALS['injector']->getInstance('IMP_Identity'); $selected_identity = $identity->getDefault(); /* Generate identities list. */ diff --git a/imp/message-mimp.php b/imp/message-mimp.php index fa231c713..5a697b4bb 100644 --- a/imp/message-mimp.php +++ b/imp/message-mimp.php @@ -166,7 +166,7 @@ if (($vars->a == 'pa') && } /* Create the Identity object. */ -$user_identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); +$user_identity = $injector->getInstance('IMP_Identity'); /* Develop the list of headers to display. */ $basic_headers = $imp_ui->basicHeaders(); diff --git a/imp/message.php b/imp/message.php index 6da7b52da..3a1166c1d 100644 --- a/imp/message.php +++ b/imp/message.php @@ -43,7 +43,7 @@ if (!$imp_mailbox->isValidIndex(false)) { $imp_message = $injector->getInstance('IMP_Message'); /* Initialize the user's identities. */ -$user_identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); +$user_identity = $injector->getInstance('IMP_Identity'); /* Run through action handlers. */ $vars = Horde_Variables::getDefaultVariables(); diff --git a/imp/view.php b/imp/view.php index 7f0d6517c..2d548c1fd 100644 --- a/imp/view.php +++ b/imp/view.php @@ -234,7 +234,7 @@ case 'print_attach': } if (!empty($conf['print']['add_printedby'])) { - $user_identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); + $user_identity = $injector->getInstance('IMP_Identity'); $headers[] = array( 'header' => htmlspecialchars(_("Printed By")), 'value' => htmlspecialchars($user_identity->getFullname() ? $user_identity->getFullname() : Horde_Auth::getAuth())