);
// Display attachment information in mailbox list.
-// Disabled by default, and not shown to user, because this display requires
-// substantial overhead to parse the message structures of all message in
-// the mailbox list at view time.
+// Disabled by default since display requires a bit of extra overhead to
+// obtain the MIME Content-Type of the base portion of the message.
$_prefs['atc_flag'] = array(
'value' => 0,
- // Locked by default
- 'locked' => true,
+ 'advanced' => true,
'type' => 'checkbox',
'desc' => _("Display attachment information about a message in the mailbox listing?")
);
*
* @param array $options Additional options:
* <pre>
- * 'atc' - (Horde_Mime_Part) Attachment info. A Horde_Mime_Part object
- * representing the message structure.
- * DEFAULT: not parsed
* 'div' - (boolean) If true, return a DIV tag containing the code
* necessary to display the icon.
* DEFAULT: false
* 'flags' - (array) [REQUIRED] IMAP flag info. A lowercase list of flags
* returned by the IMAP server.
+ * 'headers' - (Horde_Mime_Headers) Determines attachment and priority
+ * information from a headers object.
* 'personal' - (mixed) Personal message info. Either an array of to
* addresses as returned by
* Horde_Mime_Address::getAddressesFromObject(), or the
* identity that matched the address list.
- * 'priority' - (Horde_Mime_Headers) Determines priority information from
- * a headers object.
* </pre>
*
* @return array A list of flags with the following keys:
}
}
- if (!empty($options['priority'])) {
+ if (!empty($options['headers'])) {
$imp_hdr_ui = new IMP_Ui_Headers();
- switch ($imp_hdr_ui->getPriority($options['priority'])) {
+ switch ($imp_hdr_ui->getPriority($options['headers'])) {
case 'high':
$process['highpri'] = $f['highpri'];
break;
$process['lowpri'] = $f['lowpri'];
break;
}
- }
- if (!empty($options['atc'])) {
- $imp_mbox_ui = new IMP_Ui_Mailbox();
- if ($type = $imp_mbox_ui->getAttachmentType($options['atc']->getType())) {
- $process[$type] = $f[$type];
+ if ($ctype = $options['headers']->getValue('content-type', Horde_Mime_Headers::VALUE_BASE)) {
+ $imp_mbox_ui = new IMP_Ui_Mailbox();
+ if ($type = $imp_mbox_ui->getAttachmentType($ctype)) {
+ $process[$type] = $f[$type];
+ }
}
}
* @param array $msgnum An array of message sequence numbers.
* @param array $options Additional options:
* <pre>
- * 'headers' - (boolean) Return info on the non-envelope headers
- * 'Importance', 'List-Post', and 'X-Priority'.
- * DEFAULT: false (only envelope headers returned)
- * 'preview' - (mixed) Include preview information? If empty, add no
- * preview information. If 1, uses value from prefs.
- * If 2, forces addition of preview info.
- * DEFAULT: No preview information.
- * 'structure' - (boolean) Get structure information from server.
- * Contained in the 'structure' entry.
- * DEFAULT: false
+ * headers - (boolean) Return info on the non-envelope headers
+ * 'Importance', 'List-Post', and 'X-Priority'.
+ * DEFAULT: false (only envelope headers returned)
+ * preview - (mixed) Include preview information? If empty, add no
+ * preview information. If 1, uses value from prefs.
+ * If 2, forces addition of preview info.
+ * DEFAULT: No preview information.
+ * type - (boolean) Return info on the MIME Content-Type of the base
+ * message part ('Content-Type' header).
+ * DEFAULT: false
* </pre>
*
* @return array An array with the following keys:
* server. See Horde_Imap_Client::fetch() for format.
* flags - (array) The list of IMAP flags returned from the server.
* See Horde_Imap_Client::fetch() for the format.
- * headers - (array) Any headers requested in $options['headers'].
- * Horde_Mime_Headers objects are returned. See
- * Horde_Imap_Client::fetch() for the format.
+ * headers - (array) Horde_Mime_Headers objects containing header data
+ * if either $options['headers'] or $options['type'] are
+ * true. See Horde_Imap_Client::fetch() for the format.
* mailbox - (string) The mailbox containing the message.
* preview - (string) If requested in $options['preview'], the preview
* text.
* previewcut - (boolean) Has the preview text been cut?
* size - (integer) The size of the message in bytes.
- * structure - (array) The structure of the message. Only set if
- * $options['structure'] is true. See
- * Horde_Imap_Client::fetch() for format.
* uid - (string) The unique ID of the message.
* uids - (IMP_Indices) An indices object.
* </pre>
{
$this->_buildMailbox();
- $overview = $to_process = $uids = array();
+ $headers = $overview = $to_process = $uids = array();
/* Build the list of mailboxes and messages. */
foreach ($msgnum as $i) {
);
if (!empty($options['headers'])) {
- $fetch_criteria[Horde_Imap_Client::FETCH_HEADERS] = array(array('cache' => true, 'headers' => array('importance', 'list-post', 'x-priority'), 'label' => 'imp', 'parse' => true, 'peek' => true));
+ $headers = array_merge($headers, array(
+ 'importance',
+ 'list-post',
+ 'x-priority'
+ ));
}
- if (!empty($options['structure'])) {
- $fetch_criteria[Horde_Imap_Client::FETCH_STRUCTURE] = array('parse' => true);
+ if (!empty($options['type'])) {
+ $headers[] = 'content-type';
+ }
+
+ if (!empty($headers)) {
+ $fetch_criteria[Horde_Imap_Client::FETCH_HEADERS] = array(array(
+ 'cache' => true,
+ 'headers' => $headers,
+ 'label' => 'imp',
+ 'parse' => true,
+ 'peek' => true
+ ));
}
$imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
*/
public function getPriority($header)
{
- if (preg_match('/\s*(\d+)\s*/', $header->getValue('x-priority'), $matches)) {
+ if (($xpriority = $header->getValue('x-priority')) &&
+ (preg_match('/\s*(\d+)\s*/', $xpriority, $matches))) {
if (in_array($matches[1], array(1, 2))) {
return 'high';
} elseif (in_array($matches[1], array(4, 5))) {
return 'low';
}
- } elseif (preg_match('/:\s*(\w+)\s*/', $header->getValue('importance'), $matches)) {
+ } elseif (($importance = $header->getValue('importance')) &&
+ preg_match('/:\s*(\w+)\s*/', $importance, $matches)) {
if (strcasecmp($matches[1], 'high') === 0) {
return 'high';
} elseif (strcasecmp($matches[1], 'low') === 0) {
}
/* Get mailbox information. */
- $overview = $imp_mailbox->getMailboxArray($msglist, array('headers' => true, 'structure' => $GLOBALS['prefs']->getValue('atc_flag')));
+ $overview = $imp_mailbox->getMailboxArray($msglist, array(
+ 'headers' => true,
+ 'type' => $GLOBALS['prefs']->getValue('atc_flag')
+ ));
$charset = 'UTF-8';
$imp_ui = new IMP_Ui_Mailbox($folder);
$no_flags_hook = false;
}
$flag_parse = $GLOBALS['injector']->getInstance('IMP_Imap_Flags')->parse(array(
- 'atc' => isset($ob['structure']) ? $ob['structure'] : null,
'flags' => $ob['flags'],
- 'personal' => Horde_Mime_Address::getAddressesFromObject($ob['envelope']['to'], array('charset' => $charset)),
- 'priority' => $ob['headers']
+ 'headers' => $ob['headers'],
+ 'personal' => Horde_Mime_Address::getAddressesFromObject($ob['envelope']['to'], array('charset' => $charset))
));
if (!empty($flag_parse)) {
$pageOb = $imp_mailbox->buildMailboxPage($vars->page, $start);
$show_preview = $prefs->getValue('preview_enabled');
-$mbox_info = $imp_mailbox->getMailboxArray(range($pageOb['begin'], $pageOb['end']), array('preview' => $show_preview, 'headers' => true, 'structure' => $prefs->getValue('atc_flag')));
+$mbox_info = $imp_mailbox->getMailboxArray(range($pageOb['begin'], $pageOb['end']), array(
+ 'headers' => true,
+ 'preview' => $show_preview,
+ 'type' => $prefs->getValue('atc_flag')
+));
/* Determine sorting preferences. */
$sortpref = IMP::getSort(IMP::$mailbox);
} catch (Horde_Exception_HookNotSet $e) {}
$flag_parse = $imp_flags->parse(array(
- 'atc' => isset($ob['structure']) ? $ob['structure'] : null,
'div' => true,
'flags' => $ob['flags'],
- 'personal' => Horde_Mime_Address::getAddressesFromObject($ob['envelope']['to'], array('charset' => 'UTF-8')),
- 'priority' => $ob['headers']
+ 'headers' => $ob['headers'],
+ 'personal' => Horde_Mime_Address::getAddressesFromObject($ob['envelope']['to'], array('charset' => 'UTF-8'))
));
$subject_flags = array();