From: Michael M Slusarz Date: Tue, 21 Dec 2010 01:50:36 +0000 (-0700) Subject: Request #9457: Add request read receipt information to draft X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=688c87496e80b78bff040d3b1f449fe44a368490;p=horde.git Request #9457: Add request read receipt information to draft --- diff --git a/imp/compose-dimp.php b/imp/compose-dimp.php index 9fbd8a117..de83f3d80 100644 --- a/imp/compose-dimp.php +++ b/imp/compose-dimp.php @@ -186,6 +186,7 @@ case 'resume': } $header = array_merge($header, $result['header']); $fillform_opts['priority'] = $result['priority']; + $fillform_opts['readreceipt'] = $result['readreceipt']; } catch (IMP_Compose_Exception $e) { $notification->push($e); } diff --git a/imp/compose.php b/imp/compose.php index 7c959ed01..0058ad6e4 100644 --- a/imp/compose.php +++ b/imp/compose.php @@ -190,6 +190,9 @@ $priority = isset($vars->priority) ? $vars->priority : 'normal'; +/* Request read receipt? */ +$request_read_receipt = (bool)$vars->request_read_receipt; + /* Run through the action handlers. */ $title = _("New Message"); switch ($vars->actionID) { @@ -241,6 +244,7 @@ case 'draft': $sent_mail_folder = $identity->getValue('sent_mail_folder'); } $priority = $result['priority']; + $request_read_receipt = $result['readreceipt']; } catch (IMP_Compose_Exception $e) { $notification->push($e); } @@ -376,7 +380,8 @@ case 'send_message': try { $result = $imp_compose->saveDraft($header, $message, array( 'html' => $rtemode, - 'priority' => $priority + 'priority' => $priority, + 'readreceipt' => $request_read_receipt )); /* Closing draft if requested by preferences. */ @@ -430,7 +435,7 @@ case 'send_message': 'save_sent' => $save_sent_mail, 'sent_folder' => $sent_mail_folder, 'save_attachments' => $vars->save_attachments_select, - 'readreceipt' => $vars->request_read_receipt + 'readreceipt' => $request_read_receipt ); try { @@ -929,7 +934,7 @@ if ($redirect) { $d_read = $prefs->getValue('disposition_request_read'); $t->set('rrr', $conf['compose']['allow_receipts'] && ($d_read != 'never')); if ($t->get('rrr')) { - $t->set('rrr_selected', ($d_read != 'ask') || ($vars->request_read_receipt == 'on')); + $t->set('rrr_selected', ($d_read != 'ask') || $request_read_receipt); $t->set('rrr_label', Horde::label('rrr', _("Request a _Read Receipt"))); } diff --git a/imp/docs/CHANGES b/imp/docs/CHANGES index 171a64313..363cc70bb 100644 --- a/imp/docs/CHANGES +++ b/imp/docs/CHANGES @@ -2,7 +2,8 @@ v5.0-git -------- -[mms] Add priority information to saved draft (Request #9457). +[mms] Add priority and request read receipt information to saved drafts + (Request #9457). [mms] Added example in pre_sent hook to do forgotten attachment checking at send time (Request #9028). [mms] Add subfolder searching (subfolders dynamically determined at time of diff --git a/imp/js/compose-dimp.js b/imp/js/compose-dimp.js index ce2eb6472..116c10190 100644 --- a/imp/js/compose-dimp.js +++ b/imp/js/compose-dimp.js @@ -552,6 +552,10 @@ var DimpCompose = { this.setPopdownLabel('p', opts.priority); } + if (opts.readreceipt && $('request_read_receipt')) { + $('request_read_receipt').setValue(true); + } + this.processFwdList(opts.fwd_list); Field.focus(opts.focus || 'to'); diff --git a/imp/lib/Ajax/Application.php b/imp/lib/Ajax/Application.php index bf5d722e0..e8d022fa7 100644 --- a/imp/lib/Ajax/Application.php +++ b/imp/lib/Ajax/Application.php @@ -1625,7 +1625,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application * 'html' - (integer) In HTML compose mode? * 'message' - (string) The message text. * 'priority' - TODO - * 'request_read_receipt' - TODO + * 'request_read_receipt' - (boolean) Add request read receipt header? * 'save_attachments_select' - TODO * 'save_sent_mail' - TODO * 'save_sent_mail_folder' - (string) TODO @@ -1958,6 +1958,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application * 'html' - (integer) In HTML compose mode? * 'message' - (string) The message text. * 'priority' - (string) The priority of the message. + * 'request_read_receipt' - (boolean) Add request read receipt header? * * * @return object An object with the following entries: @@ -1976,7 +1977,8 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application try { $res = $imp_compose->saveDraft($headers, $this->_vars->message, array( 'html' => $this->_vars->html, - 'priority' => $this->_vars->priority + 'priority' => $this->_vars->priority, + 'readreceipt' => $this->_vars->request_read_receipt )); if ($this->_action == 'autoSaveDraft') { $GLOBALS['notification']->push(_("Draft automatically saved."), 'horde.message'); diff --git a/imp/lib/Compose.php b/imp/lib/Compose.php index 2e1467ac9..1dcd1a121 100644 --- a/imp/lib/Compose.php +++ b/imp/lib/Compose.php @@ -159,6 +159,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator *
      * html - (boolean) Is this an HTML message?
      * priority - (string) The message priority ('high', 'normal', 'low').
+     * readreceipt - (boolean) Add return receipt headers?
      * 
* * @return string Notification text on success. @@ -181,6 +182,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator *
      * html - (boolean) Is this an HTML message?
      * priority - (string) The message priority ('high', 'normal', 'low').
+     * readreceipt - (boolean) Add return receipt headers?
      * 
* * @return string The body text. @@ -306,12 +308,13 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator * * @return mixed An array with the following keys: *
-     * 'charset' - (string) The preferred sending charset.
-     * 'header' - (array) A list of headers to add to the outgoing message.
-     * 'identity' - (integer) The identity used to create the message.
-     * 'mode' - (string) 'html' or 'text'.
-     * 'msg' - (string) The message text.
-     * 'priority' - (string) The message priority.
+     * charset - (string) The preferred sending charset.
+     * header - (array) A list of headers to add to the outgoing message.
+     * identity - (integer) The identity used to create the message.
+     * mode - (string) 'html' or 'text'.
+     * msg - (string) The message text.
+     * priority - (string) The message priority.
+     * readreceipt - (boolean) Add return receipt headers?
      * 
* @throws IMP_Compose_Exception */ @@ -425,6 +428,9 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator $imp_ui_hdrs = new IMP_Ui_Headers(); $priority = $imp_ui_hdrs->getPriority($headers); + $mdn = new Horde_Mime_Mdn($headers); + $readreceipt = (bool)$mdn->getMdnReturnAddr(); + $this->_metadata['draft_uid_resume'] = $indices; $this->changed = 'changed'; @@ -434,7 +440,8 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator 'identity' => $identity_id, 'mode' => $mode, 'msg' => $message, - 'priority' => $priority + 'priority' => $priority, + 'readreceipt' => $readreceipt ); } @@ -479,7 +486,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator */ public function buildAndSendMessage($body, $header, array $opts = array()) { - global $conf, $notification, $prefs, $registry; + global $conf, $injector, $notification, $prefs, $session, $registry; /* We need at least one recipient & RFC 2822 requires that no 8-bit * characters can be in the address fields. */ @@ -500,7 +507,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator } } - $barefrom = Horde_Mime_Address::bareAddress($header['from'], $GLOBALS['session']->get('imp', 'maildomain')); + $barefrom = Horde_Mime_Address::bareAddress($header['from'], $session->get('imp', 'maildomain')); $encrypt = empty($opts['encrypt']) ? 0 : $opts['encrypt']; $recipients = implode(', ', $recip['list']); @@ -535,8 +542,8 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator /* Add a Received header for the hop from browser to server. */ $headers->addReceivedHeader(array( - 'dns' => $GLOBALS['injector']->getInstance('Net_DNS2_Resolver'), - 'server' => $GLOBALS['conf']['server']['name'] + 'dns' => $injector->getInstance('Net_DNS2_Resolver'), + 'server' => $conf['server']['name'] )); /* Add Reply-To header. */ @@ -545,17 +552,9 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator $headers->addHeader('Reply-to', $header['replyto']); } - /* Add Return Receipt Headers. */ - $mdn = null; - if (!empty($opts['readreceipt']) && - $conf['compose']['allow_receipts']) { - $mdn = new Horde_Mime_Mdn($headers); - $mdn->addMdnRequestHeaders($barefrom); - } - /* Add the 'User-Agent' header. */ if (empty($opts['useragent'])) { - $headers->setUserAgent('Internet Messaging Program (IMP) ' . $GLOBALS['registry']->getVersion()); + $headers->setUserAgent('Internet Messaging Program (IMP) ' . $registry->getVersion()); } else { $headers->setUserAgent($opts['useragent']); } @@ -566,7 +565,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator $reply_type = 'new'; } - $sentmail = $GLOBALS['injector']->getInstance('IMP_Sentmail'); + $sentmail = $injector->getInstance('IMP_Sentmail'); foreach ($send_msgs as $val) { try { @@ -591,7 +590,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator IMP_Maillog::log($reply_type, $this->getMetadata('in_reply_to'), $recipients); } - $imp_message = $GLOBALS['injector']->getInstance('IMP_Message'); + $imp_message = $injector->getInstance('IMP_Message'); $reply_uid = new IMP_Indices($this); switch ($reply_type) { @@ -611,7 +610,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator } } - $entry = sprintf("%s Message sent to %s from %s", $_SERVER['REMOTE_ADDR'], $recipients, $GLOBALS['registry']->getAuth()); + $entry = sprintf("%s Message sent to %s from %s", $_SERVER['REMOTE_ADDR'], $recipients, $registry->getAuth()); Horde::logMessage($entry, 'INFO'); /* Should we save this message in the sent mail folder? */ @@ -647,9 +646,9 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator } /* Generate the message string. */ - $fcc = $mime_message->toString(array('defserver' => $GLOBALS['session']->get('imp', 'maildomain'), 'headers' => $headers, 'stream' => true)); + $fcc = $mime_message->toString(array('defserver' => $session->get('imp', 'maildomain'), 'headers' => $headers, 'stream' => true)); - $imp_folder = $GLOBALS['injector']->getInstance('IMP_Folder'); + $imp_folder = $injector->getInstance('IMP_Folder'); if (!$imp_folder->exists($opts['sent_folder'])) { $imp_folder->create($opts['sent_folder'], $prefs->getValue('subscribe')); @@ -658,12 +657,15 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator $flags = array('\\seen'); /* RFC 3503 [3.3] - set $MDNSent flag on sent message. */ - if ($mdn) { - $flags[] = array('$MDNSent'); + if ($conf['compose']['allow_receipts']) { + $mdn = new Horde_Mime_Mdn($headers); + if ($mdn->getMdnReturnAddr()) { + $flags[] = array('$MDNSent'); + } } try { - $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->append($opts['sent_folder'], array(array('data' => $fcc, 'flags' => $flags))); + $injector->getInstance('IMP_Injector_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; @@ -747,6 +749,13 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator } } + /* Add Return Receipt Headers. */ + if (!empty($opts['readreceipt']) && + $GLOBALS['conf']['compose']['allow_receipts']) { + $mdn = new Horde_Mime_Mdn($ob); + $mdn->addMdnRequestHeaders(Horde_Mime_Address::bareAddress($ob->getValue('from'), $GLOBALS['session']->get('imp', 'maildomain'))); + } + return $ob; } @@ -2673,7 +2682,8 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator try { $body = $this->_saveDraftMsg($headers, $vars->message, array( 'html' => $vars->rtemode, - 'priority' => $vars->priority + 'priority' => $vars->priority, + 'readreceipt' => $vars->request_read_receipt )); } catch (IMP_Compose_Exception $e) { return; diff --git a/imp/templates/dimp/compose/compose.html b/imp/templates/dimp/compose/compose.html index e58e89cb5..106c1fc1e 100644 --- a/imp/templates/dimp/compose/compose.html +++ b/imp/templates/dimp/compose/compose.html @@ -32,7 +32,7 @@