// display of the message entry based on the X-Priority header.
//
// INPUT:
-// $uids - (array) A list of UIDs/mailboxes. Mailboxes are the keys; values
-// are the list of UIDs in the mailbox.
-// $mbox - (string) The current mailbox string (may be a search mailbox
-// string).
+// $mbox - (string) The mailbox.
+// $uids - (array) A list of UIDs.
// $mode - (string) Either 'imp' or 'dimp'.
//
// OUTPUT:
-// An array with Mailboxes as the keys, and an array of arrays as the value.
-// Each array consists of the UID (key) and the following array values:
+// An array of arrays, with UIDs as keys and the following array values:
//
// For IMP:
// 'class' - (array) CSS classnames that will be added to the row.
// 'class' - (array) CSS classnames that will be added to the row.
// if (!function_exists('_imp_hook_msglist_format')) {
-// function _imp_hook_msglist_format($uids, $mbox, $mode)
+// function _imp_hook_msglist_format($mbox, $uids, $mode)
// {
-// $ret = array();
+// try {
+// $imap_res = $GLOBALS['imp_imap']->ob->fetch($mbox, array(
+// Horde_Imap_Client::FETCH_HEADERS => array(array('headers' => array('x-priority'), 'label' => 'hdr_search', 'parse' => true, 'peek' => true)),
+// Horde_Imap_Client::FETCH_STRUCTURE => array('parse' => true)
+// ), array('ids' => array_values($uids)));
+// } catch (Horde_Imap_Client_Exception $e) {
+// return array();
+// }
//
// $alt_list = IMP_UI_Mailbox::getAttachmentAltList();
// $imp_ui = new IMP_UI_Mailbox($mbox);
-// $imp_msg_ui = new IMP_UI_Messsage();
-//
-// foreach ($uids as $mailbox => $uid_list) {
-// try {
-// $imap_res = $GLOBALS['imp_imap']->ob->fetch($mailbox, array(
-// Horde_Imap_Client::FETCH_HEADERS => array('headers' => array('x-priority'), 'label' => 'hdr_search', 'parse' => true, 'peek' => false),
-// Horde_Imap_Client::FETCH_STRUCTURE => array('parse' => true)
-// ), array('ids' => array_values($uid_list)));
-// } catch (Horde_Imap_Client_Exception $e) {
-// continue;
-// }
-//
-// $ret[$mailbox] = array();
-//
-// foreach ($uid_list as $uid) {
-// $ret[$mailbox][$uid] = array();
-// $ptr = &$ret[$mailbox][$uid];
-// $res_ptr = &$imap_res[$uid];
-//
-// // Add attachment information
-// if (($attachment = $imp_ui->getAttachmentType($res_ptr['structure']->getType()))) {
-// switch ($mode) {
-// case 'imp':
-// $alt_text = (isset($list[$attachment]))
-// ? $list[$attachment]
-// : $list['attachment'];
-// $ptr['status'] = Horde::img($attachment . '.png', $alt_text, array('title' => $alt_text));
-// break;
-//
-// case 'dimp':
-// $ptr['atc'] = $attachment;
-// break;
-// }
-// }
+// $imp_msg_ui = new IMP_UI_Message();
+// $ret = array();
//
-// // Add X-Priority information
-// switch ($imp_msg_ui->getXpriority($res_ptr['headers']['hdr_search']->getValue('x-priority'))) {
-// case 'high':
-// if ($mode == 'imp') {
-// $ptr['flagbits'] = IMP::FLAG_FLAGGED;
-// $ptr['status'] .= Horde::img('mail_priority_high.png', _("High Priority"), array('title' => _("High Priority")));
-// }
-// $ptr['class'][] = 'important';
+// foreach ($uids as $uid) {
+// $tmp = array();
+// $res_ptr = &$imap_res[$uid];
+//
+// // Add attachment information
+// if (($attachment = $imp_ui->getAttachmentType($res_ptr['structure']->getType()))) {
+// switch ($mode) {
+// case 'imp':
+// $alt_text = (isset($list[$attachment]))
+// ? $list[$attachment]
+// : $list['attachment'];
+// $tmp['status'] = Horde::img($attachment . '.png', $alt_text, array('title' => $alt_text));
// break;
//
-// case 'low':
-// if ($mode == 'imp') {
-// $ptr['status'] .= Horde::img('mail_priority_low.png', _("Low Priority"), array('title' => _("Low Priority")));
-// }
-// $ptr['class'][] = 'unimportant';
+// case 'dimp':
+// $tmp['atc'] = $attachment;
// break;
// }
// }
+//
+// // Add X-Priority information
+// switch ($imp_msg_ui->getXpriority($res_ptr['headers']['hdr_search']->getValue('x-priority'))) {
+// case 'high':
+// if ($mode == 'imp') {
+// $tmp['flagbits'] = IMP::FLAG_FLAGGED;
+// $tmp['status'] .= Horde::img('mail_priority_high.png', _("High Priority"), array('title' => _("High Priority")));
+// }
+// $tmp['class'][] = 'important';
+// break;
+//
+// case 'low':
+// if ($mode == 'imp') {
+// $tmp['status'] .= Horde::img('mail_priority_low.png', _("Low Priority"), array('title' => _("Low Priority")));
+// }
+// $tmp['class'][] = 'unimportant';
+// break;
+// }
+//
+// if (!empty($tmp)) {
+// $ret[$uid] = $tmp;
+// }
// }
//
// return $ret;
// $box = preg_replace("/^{[^}]+}/", "", $box);
// if ((strpos($box, "INBOX/Calendar") !== false) ||
// preg_match("!^user/[^/]+/Calendar!", $box)) {
-// // Use this example for IMP 4.2.x+.
// $newmailboxes[$box] = array(
// 'icon' => 'kronolith.png',
// 'icondir' => $GLOBALS['registry']->getImageDir('kronolith')
// );
// } elseif ((strpos($box, "INBOX/Tasks") !== false) ||
// preg_match("!^user/[^/]+/Tasks!", $box)) {
-// // Use this example for IMP 4.2.x+.
// $newmailboxes[$box] = array(
// 'icon' => 'nag.png',
// 'icondir' => $GLOBALS['registry']->getImageDir('nag')
// );
// } elseif ((strpos($box, "INBOX/Notes") !== false) ||
// preg_match("!^user/[^/]+/Notes!", $box)) {
-// // Use this example for IMP 4.2.x+.
// $newmailboxes[$box] = array(
// 'icon' => 'mnemo.png',
// 'icondir' => $GLOBALS['registry']->getImageDir('mnemo')
// );
// } elseif ((strpos($box, "INBOX/Contacts") !== false) ||
// preg_match("!^user/[^/]+/Contacts!", $box)) {
-// // Use this example for IMP 4.2.x+.
// $newmailboxes[$box] = array(
// 'icon' => 'turba.png',
// 'icondir' => $GLOBALS['registry']->getImageDir('turba')
*/
private function _getOverviewData($imp_mailbox, $folder, $msglist, $search)
{
- $msgs = array();
+ $lookup = $msgs = array();
if (empty($msglist)) {
return $msgs;
} else {
$msgs[$ob['uid']] = $msg;
}
+
+ if (!isset($lookup[$ob['mailbox']])) {
+ $lookup[$ob['mailbox']] = array();
+ }
+ $lookup[$ob['mailbox']][] = $ob['uid'];
}
/* Add user supplied information from hook. */
- if (!empty($GLOBALS['conf']['dimp']['hooks']['msglist_format'])) {
- $ob_f = Horde::callHook('_imp_hook_msglist_format', array($ob['mailbox'], $ob['uid']), 'dimp');
-
- foreach ($ob_f as $mbox => $uids) {
- foreach ($uids as $uid => $val) {
- $ptr =& $search ? ($uid . $mbox) : $uid;
+ if (!empty($GLOBALS['conf']['imp']['hooks']['msglist_format'])) {
+ foreach (array_keys($lookup) as $mbox) {
+ $ob_f = Horde::callHook('_imp_hook_msglist_format', array($mbox, $lookup[$mbox], 'dimp'), 'imp');
+
+ foreach ($ob_f as $uid => $val) {
+ if ($search) {
+ $ptr = &$msgs[$uid . $mbox];
+ } else {
+ $ptr = &$msgs[$uid];
+ }
if (!empty($val['atc'])) {
$ptr['atc'] = $val['atc'];
}
/* Allow user to alter template array. */
- if (!empty($GLOBALS['conf']['dimp']['hooks']['mailboxarray'])) {
+ if (!empty($GLOBALS['conf']['imp']['dimp']['hooks']['mailboxarray'])) {
$msgs = Horde::callHook('_imp_hook_dimp_mailboxarray', array($msgs), 'imp');
}
*
* @package IMP
* @author Chuck Hagenbuch <chuck@horde.org>
+ * @author Michael Slusarz <slusarz@horde.org>
*/
-function _outputSummaries($msgs)
+function _outputSummaries($msgs, $mbox, &$ids)
{
static $template;
+ if (!empty($GLOBALS['conf']['hooks']['msglist_format'])) {
+ $ob_f = Horde::callHook('_imp_hook_msglist_format', array($mbox, array_keys($msgs), 'imp'), 'imp');
+
+ foreach ($ob_f as $uid => $val) {
+ $ptr = &$msgs[$uid];
+
+ if (!empty($val['class'])) {
+ $ptr['bg'] = array_merge($ptr['bg'], $val['class']);
+ }
+
+ if (!empty($val['flagbits'])) {
+ $ids[$ptr['id']] |= $val['flagbits'];
+ }
+
+ if (!empty($val['status'])) {
+ $ptr['status'] .= $val['status'];
+ }
+ }
+ }
+
if (!isset($template)) {
$template = new IMP_Template();
$template->setOption('gettext', true);
if ($search_mbox) {
if (empty($lastMbox) || ($ob['mailbox'] != $lastMbox)) {
if (!empty($lastMbox)) {
- _outputSummaries($msgs);
+ _outputSummaries($msgs, $lastMbox, $ids);
$msgs = array();
}
$folder_link = Horde::url(Util::addParameter('mailbox.php', 'mailbox', $ob['mailbox']));
$mh_template->set('mh_count', $mh_count++);
echo $mh_template->fetch(IMP_TEMPLATES . '/mailbox/message_headers.html');
}
- $lastMbox = $ob['mailbox'];
}
+ $lastMbox = $ob['mailbox'];
+
/* Initialize the header fields. */
$msg = array(
'bg' => '',
}
}
- $msgs[$ob['uid'] . $ob['mailbox']] = $msg;
-}
-
-/* Add user supplied information from hook. */
-if (!empty($conf['hooks']['msglist_format'])) {
- $ob_f = Horde::callHook('_imp_hook_msglist_format', array($mbox_info['uids'], $imp_mbox['mailbox'], 'imp'), 'imp');
-
- foreach ($ob_f as $mbox => $uids) {
- foreach ($uids as $uid => $val) {
- $ptr = &$msgs[$uid . $mbox];
-
- if (!empty($val['class'])) {
- $ptr['bg'] = array_merge($ptr['bg'], $val['class']);
- }
-
- if (!empty($val['flagbits'])) {
- $ids[$ptr['id']] |= $val['flagbits'];
- }
-
- if (!empty($val['status'])) {
- $ptr['status'] .= $val['status'];
- }
- }
- }
+ $msgs[$ob['uid']] = $msg;
}
-_outputSummaries($msgs);
+_outputSummaries($msgs, $lastMbox, $ids);
/* Prepare the message footers template. */
$mf_template = new IMP_Template();