}
}
+/* Get message priority. */
+$priority = isset($vars->priority)
+ ? $vars->priority
+ : 'normal';
+
/* Run through the action handlers. */
$title = _("New Message");
switch ($vars->actionID) {
$identity->setDefault($result['identity']);
$sent_mail_folder = $identity->getValue('sent_mail_folder');
}
+ $priority = $result['priority'];
} catch (IMP_Compose_Exception $e) {
$notification->push($e);
}
if (in_array($vars->actionID, array('auto_save_draft', 'save_draft'))) {
if (!$readonly_drafts) {
try {
- $result = $imp_compose->saveDraft($header, $message, $rtemode);
+ $result = $imp_compose->saveDraft($header, $message, array(
+ 'html' => $rtemode,
+ 'priority' => $priority
+ ));
/* Closing draft if requested by preferences. */
if ($vars->actionID == 'save_draft') {
'encrypt' => $prefs->isLocked('default_encrypt') ? $prefs->getValue('default_encrypt') : $vars->encrypt_options,
'html' => $rtemode,
'identity' => $identity,
- 'priority' => $vars->priority,
+ 'priority' => $priority,
'save_sent' => $save_sent_mail,
'sent_folder' => $sent_mail_folder,
'save_attachments' => $vars->save_attachments_select,
$t->set('priority_label', Horde::label('priority', _("_Priority")));
$t->set('priority_tabindex', ++$tabindex);
- $priority = isset($vars->priority) ? $vars->priority : 'normal';
$priorities = array(
'high' => _("High"),
'normal' => _("Normal"),
/**
* Saves a message to the draft folder.
*
- * @param array $header List of message headers (UTF-8).
- * @param mixed $message Either the message text (string) or a
- * Horde_Mime_Part object that contains the
- * text to send.
- * @param boolean $html Whether this is an HTML message.
+ * @param array $header List of message headers (UTF-8).
+ * @param mixed $message Either the message text (string) or a
+ * Horde_Mime_Part object that contains the text
+ * to send.
+ * @param array $opts An array of options w/the following keys:
+ * <pre>
+ * html - (boolean) Is this an HTML message?
+ * priority - (string) The message priority ('high', 'normal', 'low').
+ * </pre>
*
* @return string Notification text on success.
* @throws IMP_Compose_Exception
*/
- public function saveDraft($headers, $message, $html)
+ public function saveDraft($headers, $message, array $opts = array())
{
- $body = $this->_saveDraftMsg($headers, $message, $html);
+ $body = $this->_saveDraftMsg($headers, $message, $opts);
return $this->_saveDraftServer($body);
}
/**
* Prepare the draft message.
*
- * @param array $headers List of message headers.
- * @param mixed $message Either the message text (string) or a
- * Horde_Mime_Part object that contains the
- * text to send.
- * @param boolean $html Whether this is an HTML message.
+ * @param array $headers List of message headers.
+ * @param mixed $message Either the message text (string) or a
+ * Horde_Mime_Part object that contains the text
+ * to send.
+ * @param array $opts An array of options w/the following keys:
+ * <pre>
+ * html - (boolean) Is this an HTML message?
+ * priority - (string) The message priority ('high', 'normal', 'low').
+ * </pre>
*
* @return string The body text.
* @throws IMP_Compose_Exception
*/
- protected function _saveDraftMsg($headers, $message, $html)
+ protected function _saveDraftMsg($headers, $message, $opts)
{
$has_session = (bool)$GLOBALS['registry']->getAuth();
/* Set up the base message now. */
$mime = $this->_createMimeMessage(array(null), $message, array(
- 'html' => $html,
+ 'html' => !empty($opts['html']),
'noattach' => !$has_session,
'nofinal' => true
));
}
/* Initalize a header object for the draft. */
- $draft_headers = $this->_prepareHeaders($headers);
+ $draft_headers = $this->_prepareHeaders($headers, $opts);
/* Add information necessary to log replies/forwards when finally
* sent. */
* 'identity' - (integer) The identity used to create the message.
* 'mode' - (string) 'html' or 'text'.
* 'msg' - (string) The message text.
+ * 'priority' - (string) The message priority.
* </pre>
* @throws IMP_Compose_Exception
*/
} catch (Exception $e) {}
}
+ $imp_ui_hdrs = new IMP_Ui_Headers();
+ $priority = $imp_ui_hdrs->getPriority($headers);
+
$this->_metadata['draft_uid_resume'] = $indices;
$this->changed = 'changed';
'header' => $header,
'identity' => $identity_id,
'mode' => $mode,
- 'msg' => $message
+ 'msg' => $message,
+ 'priority' => $priority
);
}
}
/* Initalize a header object for the outgoing message. */
- $headers = $this->_prepareHeaders($header);
+ $headers = $this->_prepareHeaders($header, $opts);
/* Add a Received header for the hop from browser to server. */
$headers->addReceivedHeader(array(
$headers->addHeader('Reply-to', $header['replyto']);
}
- /* Add priority header, if requested. */
- if (!empty($opts['priority'])) {
- switch ($opts['priority']) {
- case 'high':
- $headers->addHeader('Importance', 'High');
- $headers->addHeader('X-Priority', '1 (Highest)');
- break;
-
- case 'low':
- $headers->addHeader('Importance', 'Low');
- $headers->addHeader('X-Priority', '5 (Lowest)');
- break;
- }
- }
-
/* Add Return Receipt Headers. */
$mdn = null;
if (!empty($opts['readreceipt']) &&
*
* @param array $headers Array with 'from', 'to', 'cc', 'bcc', and
* 'subject' values.
+ * @param array $opts An array of options w/the following keys:
+ * <pre>
+ * priority - (string) The message priority ('high', 'normal', 'low').
+ * </pre>
*
- * @return Horde_Mime_Headers Headers object with the Date, From, To, Cc,
- * Bcc, Subject, Message-ID, References, and
- * In-Reply-To headers set.
+ * @return Horde_Mime_Headers Headers object with the appropriate headers
+ * set.
*/
- protected function _prepareHeaders($headers)
+ protected function _prepareHeaders($headers, array $opts = array())
{
$ob = new Horde_Mime_Headers();
}
}
+ /* Add priority header, if requested. */
+ if (!empty($opts['priority'])) {
+ switch ($opts['priority']) {
+ case 'high':
+ $ob->addHeader('Importance', 'High');
+ $ob->addHeader('X-Priority', '1 (Highest)');
+ break;
+
+ case 'low':
+ $ob->addHeader('Importance', 'Low');
+ $ob->addHeader('X-Priority', '5 (Lowest)');
+ break;
+ }
+ }
+
return $ob;
}
}
try {
- $body = $this->_saveDraftMsg($headers, $vars->message, $vars->rtemode);
+ $body = $this->_saveDraftMsg($headers, $vars->message, array(
+ 'html' => $vars->rtemode,
+ 'priority' => $vars->priority
+ ));
} catch (IMP_Compose_Exception $e) {
return;
}