From: Michael M Slusarz Date: Wed, 10 Dec 2008 07:51:51 +0000 (-0700) Subject: Fix hooks/config options to work with new code. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=d7f793427c092e67d8e8461caf2f4cd368c9f4bd;p=horde.git Fix hooks/config options to work with new code. --- diff --git a/imp/config/conf.xml b/imp/config/conf.xml index dcd878922..9158a4e47 100644 --- a/imp/config/conf.xml +++ b/imp/config/conf.xml @@ -441,91 +441,95 @@ - - Mailbox Settings - 10 - 20 + + + Mailbox Settings + 10 + 20 + Custom Hooks - - false - false - false - false - false - + + + false + false + false + false + false + - + - JavaScript Settings - - false - + JavaScript Settings + + false + - ViewPort Settings - - 5 - 35 - 12 - true - + ViewPort Settings + + 5 + 35 + 12 + true + - Search Settings - - false - + Search Settings + + false + - - Menu Settings - - - - - + + Menu Settings + + + + + + diff --git a/imp/config/hooks.php.dist b/imp/config/hooks.php.dist index 62198d9a5..708e1b398 100644 --- a/imp/config/hooks.php.dist +++ b/imp/config/hooks.php.dist @@ -40,67 +40,15 @@ // } // } -// This is an example for a post-sending hook that automatically prints all -// messages that have been sent successfully. +// This is an example for a post-sending hook that performs an action after +// a message has been sent successfully. +// $message = Base Horde_Mime_part object. +// $headers = Horde_Mime_Headers object. // if (!function_exists('_imp_hook_postsent')) { // function _imp_hook_postsent($message, $headers) // { -// require_once IMP_BASE . '/lib/MIME/Contents.php'; -// require_once IMP_BASE . '/lib/UI/Message.php'; -// -// IMP::$printMode = true; -// $contents = new IMP_Contents($message); -// $contents->showSummaryLinks(false); -// $contents->buildMessage(); -// $attachments = $contents->getAttachments(); -// $msgText = $contents->getMessage(); -// -// // @todo this is no longer good code. -// $imp_ui = new IMP_UI_Message(); -// $basic_headers = $imp_ui->basicHeaders(); -// $headers->setValueByFunction('date', array('nl2br', array($headers, 'addLocalTime'), 'htmlspecialchars')); -// if (($subject = $headers->getValue('subject'))) { -// $subject = IMP::filterText($subject); -// require_once 'Horde/Text.php'; -// $headers->setValue('subject', Text::htmlSpaces($subject)); -// } else { -// $headers->addHeader('Subject', _("[No Subject]")); -// } -// $headers->buildAddressLinks('from', null, true, false); -// foreach (array('to', 'cc', 'bcc') as $val) { -// $headers->buildAddressLinks($val, null, true, false); -// } -// if ($reply_to = $headers->buildAddressLinks('reply-to', null, false, false)) { -// if (!($from = $headers->getValue('from')) || ($from != $reply_to)) { -// $headers->setValue('Reply-to', $reply_to); -// } else { -// $headers->removeHeader('reply-to'); -// } -// } -// $hdrs = array(); -// foreach ($basic_headers as $head => $str) { -// if ($val = $headers->getValue($head)) { -// $hdrs[] = array('name' => $str, 'val' => $val, 'i' => 0); -// } -// } -// if ($val = $headers->getValue('priority')) { -// $hdrs[] = array('name' => _("Priority"), 'val' => $val, 'i' => 0); -// } -// if (!empty($attachments)) { -// $hdrs[] = array('name' => _("Part(s)"), 'val' => '' . $attachments . '
', 'i' => 0); -// } -// -// require_once IMP_BASE . '/lib/Template.php'; -// $template = new IMP_Template(); -// $template->set('headers', $hdrs); -// $template->set('msgtext', $msgText); -// $printer_friendly = true; -// require IMP_TEMPLATES . '/common-header.inc'; -// echo $template->fetch(IMP_TEMPLATES . '/message/message.html'); -// require $GLOBALS['registry']->get('templates', 'horde') . '/javascript/print.js'; -// require $GLOBALS['registry']->get('templates', 'horde') . '/common-footer.inc'; -// exit; +// // Do entire action here -- no return value from this hook. // } // } @@ -127,18 +75,18 @@ // if (!function_exists('_imp_hook_trailer')) { // function _imp_hook_trailer($trailer) // { -// $vdomain = getenv('HTTP_HOST'); -// $vdomain = preg_replace('|^.*?\.|i', '', $vdomain); -// $vdomain = String::lower($vdomain); +// $vdomain = String::lower(preg_replace('|^.*?\.|i', '', getenv('HTTP_HOST'))); // $ldapServer = 'localhost'; // $ldapPort = '389'; // $searchBase = 'ispmanDomain=' . $vdomain . ",o=ispman"; // -// $ds = @ldap_connect($ldapServer, $ldapPort); -// $searchResult = @ldap_search($ds, $searchBase, 'uid=' . $vdomain); -// $information = @ldap_get_entries($ds, $searchResult); +// $old_error = error_reporting(0); +// $ds = ldap_connect($ldapServer, $ldapPort); +// $searchResult = ldap_search($ds, $searchBase, 'uid=' . $vdomain); +// $information = ldap_get_entries($ds, $searchResult); // $trailer= $information[0]['ispmandomainsignature'][0]; // ldap_close($ds); +// error_reporting($old_error); // // return $trailer; // } @@ -159,9 +107,7 @@ // if (!function_exists('_imp_hook_vinfo')) { // function _imp_hook_vinfo($type = 'username', $data = null) // { -// $vdomain = getenv('HTTP_HOST'); -// $vdomain = preg_replace('|^mail\.|i', '', $vdomain); -// $vdomain = String::lower($vdomain); +// $vdomain = String::lower(preg_replace('|^mail\.|i', '', getenv('HTTP_HOST'))); // // switch ($type) { // case 'username': @@ -190,6 +136,7 @@ // // for preferences? // $cmd = '/usr/local/bin/spamc'; // $username = Auth::getAuth(); +// // // If you use the _sam_hook_username() hook, uncomment the next line // //$username = _sam_hook_username($username); // $username = escapeshellarg($username); @@ -206,6 +153,7 @@ // // Read the new message from the temporary file // $message = file_get_contents($file); // unlink($file); +// // return $message; // } // } @@ -231,45 +179,90 @@ // information in the message listing screen for a mailbox. This example hook // will add a icon if the message contains attachments and will change the // 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). +// $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: +// +// For IMP: +// 'class' - (array) CSS classnames that will be added to the row. +// 'flagbits' - (integer) Flag mask which will be OR'd with the current flags +// set for the row. The flag constants used in IMP can be +// found at the top of lib/IMP.php. +// 'status' - (string) HTML code to add to the status column for the row. +// +// For DIMP: +// 'atc' - (string) Attachment type (either 'signed', 'encrypted', or +// 'attachment'). +// 'class' - (array) CSS classnames that will be added to the row. // if (!function_exists('_imp_hook_msglist_format')) { -// function _imp_hook_msglist_format($mailbox, $uid) +// function _imp_hook_msglist_format($uids, $mbox, $mode) // { -// // Required return (array): -// // 'class' - An array of CSS classnames that will be added to -// // the row. -// // 'flagbits' - An integer value which will be OR'd with the -// // current flags set for the row. The IMAP flag -// // constants used in IMP can be found at the top -// // of lib/IMP.php. -// // 'status' - HTML code to add to the status column for the row. -// $ret = array('class' => array(), 'flagbits' => 0, 'status' => ''); -// -// require_once IMP_BASE . '/lib/IMAP/MessageCache.php'; -// $cache = &IMP_MessageCache::singleton(); -// $cache_entry = $cache->retrieve($mailbox, array($uid), 8 | 32); -// $ob = reset($cache_entry); -// -// // Add attachment information -// $imp_ui = new IMP_UI_Mailbox($mailbox); -// if (($attachment = $imp_ui->getAttachmentType($MIMETYPE))) { -// $alt_list = IMP_UI_Mailbox::getAttachmentAltList(); -// $alt_text = (isset($list[$attachment])) ? $list[$attachment] : $list['attachment']; -// $ret['status'] = Horde::img($attachment . '.png', $alt_text, array('title' => $alt_text)); -// } +// $ret = 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; +// } // -// // Add xpriority information -// switch ($ob->header->getXpriority()) { -// case 'high': -// $ret['flagbits'] = IMP_FLAGGED; -// $ret['status'] .= Horde::img('mail_priority_high.png', _("High Priority"), array('title' => _("High Priority"))); -// $ret['class'][] = 'important'; -// break; -// -// case 'low': -// $ret['status'] .= Horde::img('mail_priority_low.png', _("Low Priority"), array('title' => _("Low Priority"))); -// $ret['class'][] = 'unimportant'; -// break; +// $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; +// } +// } +// +// // 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'; +// break; +// +// case 'low': +// if ($mode == 'imp') { +// $ptr['status'] .= Horde::img('mail_priority_low.png', _("Low Priority"), array('title' => _("Low Priority"))); +// } +// $ptr['class'][] = 'unimportant'; +// break; +// } +// } // } // // return $ret; @@ -287,19 +280,17 @@ // if (!function_exists('_imp_hook_mbox_redirect')) { // function _imp_hook_mbox_redirect($mailbox) // { -// require_once 'Horde/Kolab.php'; -// -// if (strpos($mailbox, "INBOX/Calendar") !== false -// || preg_match("!^user/[^/]+/Calendar!", $mailbox)) { +// if ((strpos($mailbox, "INBOX/Calendar") !== false) || +// preg_match("!^user/[^/]+/Calendar!", $mailbox)) { // return $GLOBALS['registry']->get('webroot', 'kronolith'); -// } elseif (strpos($mailbox, "INBOX/Tasks") !== false -// || preg_match("!^user/[^/]+/Tasks!", $mailbox)) { +// } elseif ((strpos($mailbox, "INBOX/Tasks") !== false) || +// preg_match("!^user/[^/]+/Tasks!", $mailbox)) { // return $GLOBALS['registry']->get('webroot', 'nag'); -// } elseif (strpos($mailbox, "INBOX/Notes") !== false -// || preg_match("!^user/[^/]+/Notes!", $mailbox)) { +// } elseif ((strpos($mailbox, "INBOX/Notes") !== false) || +// preg_match("!^user/[^/]+/Notes!", $mailbox)) { // return $GLOBALS['registry']->get('webroot', 'mnemo'); -// } elseif (strpos($mailbox, "INBOX/Contacts") !== false -// || preg_match("!^user/[^/]+/Contacts!", $mailbox)) { +// } elseif ((strpos($mailbox, "INBOX/Contacts") !== false) || +// preg_match("!^user/[^/]+/Contacts!", $mailbox)) { // return $GLOBALS['registry']->get('webroot', 'turba'); // } // @@ -314,8 +305,6 @@ // trash folders.) // If a mailbox name doesn't appear in the below list, the default mailbox // icon is displayed. -// Note that in IMP 4.2.x, the expected return value from this hook has -// changed. See the below examples for more information. // if (!function_exists('_imp_hook_mbox_icons')) { // function _imp_hook_mbox_icons() @@ -334,62 +323,38 @@ // // foreach ($mailboxes as $box) { // $box = preg_replace("/^{[^}]+}/", "", $box); -// if (strpos($box, "INBOX/Calendar") !== false -// || preg_match("!^user/[^/]+/Calendar!", $box)) { -// $newmailboxes[$box] = Horde::img( -// $GLOBALS['registry']->get('icon', 'kronolith'), -// _("Calendar"), -// 'width="16" height="16" style="vertical-align:middle"', -// '' -// ); +// 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') -// // 'alt' => _("Calendar") -// // ); -// } elseif (strpos($box, "INBOX/Tasks") !== false -// || preg_match("!^user/[^/]+/Tasks!", $box)) { -// $newmailboxes[$box] = Horde::img( -// $GLOBALS['registry']->get('icon', 'nag'), -// _("Tasks"), -// 'width="16" height="16" style="vertical-align:middle"', -// '' +// $newmailboxes[$box] = array( +// 'icon' => 'kronolith.png', +// 'icondir' => $GLOBALS['registry']->getImageDir('kronolith') +// 'alt' => _("Calendar") // ); +// } 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') -// // 'alt' => _("Tasks") -// // ); -// } elseif (strpos($box, "INBOX/Notes") !== false -// || preg_match("!^user/[^/]+/Notes!", $box)) { -// $newmailboxes[$box] = Horde::img( -// $GLOBALS['registry']->get('icon', 'mnemo'), -// _("Notes"), -// 'width="16" height="16" style="vertical-align:middle"', -// '' +// $newmailboxes[$box] = array( +// 'icon' => 'nag.png', +// 'icondir' => $GLOBALS['registry']->getImageDir('nag') +// 'alt' => _("Tasks") // ); +// } 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') -// // 'alt' => _("Notes") -// // ); -// } elseif (strpos($box, "INBOX/Contacts") !== false -// || preg_match("!^user/[^/]+/Contacts!", $box)) { -// $newmailboxes[$box] = Horde::img( -// $GLOBALS['registry']->get('icon', 'turba'), -// _("Contacts"), -// 'width="16" height="16" style="vertical-align:middle"', -// '' +// $newmailboxes[$box] = array( +// 'icon' => 'mnemo.png', +// 'icondir' => $GLOBALS['registry']->getImageDir('mnemo') +// 'alt' => _("Notes") // ); +// } 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') -// // 'alt' => _("Contacts") -// // ); +// $newmailboxes[$box] = array( +// 'icon' => 'turba.png', +// 'icondir' => $GLOBALS['registry']->getImageDir('turba') +// 'alt' => _("Contacts") +// ); // } // } // @@ -436,6 +401,7 @@ // Default Kolab hooks: if (!empty($GLOBALS['conf']['kolab']['enabled'])) { require_once 'Horde/Kolab.php'; + if (!function_exists('_imp_hook_mbox_redirect')) { function _imp_hook_mbox_redirect($mailbox) { @@ -556,52 +522,54 @@ if (!function_exists('_imp_hook_quota')) { } - -// This is an example hook function for the DIMP mailbox view. This function -// is called for every message and allows additional information to be added -// to the array that is passed to the mailbox display template - +// This is an example hook function for the dynamic (dimp) mailbox view. This +// function is allows additional information to be added to the array that is +// is passed to the mailbox display template - // dimp/templates/javascript/mailbox.js. The current entry array is passed // in, the value returned should be the altered array to use in the // template. If you are going to add new columns, you also have to update // dimp/templates/index/index.inc to contain the new field in the header and // dimp/themes/screen.css to specify the column width. -// if (!function_exists('_dimp_hook_mailboxarray')) { -// function _dimp_hook_mailboxarray($msg, $ob) { -// $msg['foo'] = true; +// if (!function_exists('_imp_hook_dimp_mailboxarray')) { +// function _imp_hook_dimp_mailboxarray($msgs) { +// foreach (array_keys($msgs) as $key) { +// $msgs[$key]['foo'] = true; +// } +// // return $msg; // } // } -// This is an example hook function for the DIMP message view. This function -// allows additional information to be added to the array that is passed to -// the message text display template - dimp/templates/chunks/message.html. -// The current entry array is passed in (see the showMessage() function in -// dimp/lib/Views/ShowMessage.php for the format). The value returned should -// be the altered array to use in the template. See the showMessage() function -// in dimp/lib/Views/ShowMessage for the base values contained in the original -// passed-in array. - -// if (!function_exists('_dimp_hook_messageview')) { -// function _dimp_hook_messageview($msg) { +// This is an example hook function for the dynamic (dimp) message view. This +// function allows additional information to be added to the array that is +// passed to the message text display template - +// dimp/templates/chunks/message.html. The current entry array is passed in +// (see the showMessage() function in lib/Views/ShowMessage.php for the +// format). The value returned should be the altered array to use in the +// template. + +// if (!function_exists('_imp_hook_dimp_messageview')) { +// function _imp_hook_dimp_messageview($msg) { // // Ex.: Add a new foo variable // $msg['foo'] = '
BAR
'; // return $msg; // } // } -// This is an example hook function for the DIMP preview view. This function -// allows additional information to be added to the preview view and its -// corresponding template - dimp/templates/index/index.inc. The current entry -// array is passed in (see the showMessage() function in -// dimp/lib/Views/ShowMessage.php for the format). Since the preview pane is + +// This is an example hook function for the dynamic (dimp) preview view. This +// function allows additional information to be added to the preview view and +// its corresponding template - dimp/templates/index/index.inc. The current +// entry array is passed in (see the showMessage() function in +// lib/Views/ShowMessage.php for the format). Since the preview pane is // dynamically updated via javascript, all updates other than the base // entries must be provided in javascript code to be run at update time. The // expected return is a 2 element array - the first element is the original // array with any changes made to the initial data. The second element is an // array of javascript commands, one command per array value. -// if (!function_exists('_dimp_hook_previewview')) { -// function _dimp_hook_previewview($msg) { +// if (!function_exists('_imp_hook_dimp_previewview')) { +// function _imp_hook_dimp_previewview($msg) { // // Ex.: Alter the subject // $msg['subject'] .= 'test'; // @@ -618,56 +586,17 @@ if (!function_exists('_imp_hook_quota')) { // This is an example hook function for the address formatting in email // message headers. The argument passed to the function is an object with the // following possible properties: -// 'address' - Full address -// 'display' - Display address -// 'host' - Host name -// 'inner' - Trimmed, bare address -// 'personal' - Personal string +// 'address' - Full address +// 'display' - Display address +// 'host' - Host name +// 'inner' - Trimmed, bare address +// 'personal' - Personal string // The return value is the raw string to display for that address. This value // must be properly escaped (i.e. htmlspecialchars() used on the portions of // the string where appropriate). -// if (!function_exists('_dimp_hook_addressformatting')) { +// if (!function_exists('_imp_hook_dimp_addressformatting')) { // function _dimp_hook_addressformatting($ob) { -// return empty($ob->personal) ? $ob->address : $ob->personal; -// } -// } - -// This is an example hook function for displaying additional message -// information in the message listing screen for a mailbox. This example hook -// will add a icon if the message contains attachments and will change the -// display of the message entry based on the X-Priority header. - -// if (!function_exists('_dimp_hook_msglist_format')) { -// function _dimp_hook_msglist_format($mailbox, $uid) -// { -// // Required return (array): -// // 'atc' - Attachment type (either 'signed', 'encrypted', or -// // 'attachment'). -// // 'class' - An array of CSS classnames that will be added to -// // the row. -// $ret = array('atc' => '', 'class' => array()); -// -// require_once IMP_BASE . '/lib/IMAP/MessageCache.php'; -// $cache = &IMP_MessageCache::singleton(); -// $cache_entry = $cache->retrieve($mailbox, array($uid), 8 | 32); -// $ob = reset($cache_entry); -// -// // Add attachment information -// $imp_ui = new IMP_UI_Mailbox($mailbox); -// $ret['atc'] = $imp_ui->getAttachmentType($MIMETYPE); -// -// // Add xpriority information -// switch ($ob->header->getXpriority()) { -// case 'high': -// $ret['class'][] = 'important'; -// break; -// -// case 'low': -// $ret['class'][] = 'unimportant'; -// break; -// } -// -// return $ret; +// return empty($ob['personal']) ? $ob['address'] : $ob['personal']; // } // } diff --git a/imp/docs/UPGRADING b/imp/docs/UPGRADING index d8d9ee9d6..d5c24c95c 100644 --- a/imp/docs/UPGRADING +++ b/imp/docs/UPGRADING @@ -27,6 +27,7 @@ supported. * imp_hook_vinfo has changed * alternative_display, attachment_display pref is gone. * imp_hook_spam_bounce -> imp_hook_spam_email +* imp_hook_msglist_format input has changed. Upgrading IMP From 4.1.x To 4.2.x diff --git a/imp/lib/Compose.php b/imp/lib/Compose.php index 6f44368d3..7c772602c 100644 --- a/imp/lib/Compose.php +++ b/imp/lib/Compose.php @@ -595,7 +595,7 @@ class IMP_Compose /* Call post-sent hook. */ if (!empty($conf['hooks']['postsent'])) { - Horde::callHook('_imp_hook_postsent', array($save_msg['msg'], $msg_headers), 'imp', null); + Horde::callHook('_imp_hook_postsent', array($save_msg['msg'], $headers), 'imp', null); } return $sent_saved; diff --git a/imp/lib/DIMP.php b/imp/lib/DIMP.php index a4232a25c..e41e34e0f 100644 --- a/imp/lib/DIMP.php +++ b/imp/lib/DIMP.php @@ -163,7 +163,7 @@ class DIMP 'ham_reporting' => (int) !empty($conf['notspam']['reporting']), 'ham_spamfolder' => (int) !empty($conf['notspam']['spamfolder']), 'refresh_time' => (int) $prefs->getValue('refresh_time'), - 'search_all' => (int) !empty($conf['search']['search_all']), + 'search_all' => (int) !empty($conf['dimp']['search']['search_all']), 'fixed_folders' => empty($conf['server']['fixed_folders']) ? array() @@ -175,14 +175,14 @@ class DIMP 'is_ie6' => ($browser->isBrowser('msie') && ($browser->getMajor() < 7)), - 'buffer_pages' => intval($conf['viewport']['buffer_pages']), - 'limit_factor' => intval($conf['viewport']['limit_factor']), - 'viewport_wait' => intval($conf['viewport']['viewport_wait']), + 'buffer_pages' => intval($conf['dimp']['viewport']['buffer_pages']), + 'limit_factor' => intval($conf['dimp']['viewport']['limit_factor']), + 'viewport_wait' => intval($conf['dimp']['viewport']['viewport_wait']), 'login_view' => $prefs->getValue('login_view'), - 'background_inbox' => !empty($conf['viewport']['background_inbox']), + 'background_inbox' => !empty($conf['dimp']['viewport']['background_inbox']), // Turn debugging on? - 'debug' => !empty($conf['js']['debug']), + 'debug' => !empty($conf['dimp']['js']['debug']), ); /* Gettext strings used in core javascript files. */ @@ -490,8 +490,8 @@ class DIMP */ public function menuList() { - if (isset($GLOBALS['conf']['menu']['apps'])) { - $apps = $GLOBALS['conf']['menu']['apps']; + if (isset($GLOBALS['conf']['dimp']['menu']['apps'])) { + $apps = $GLOBALS['conf']['dimp']['menu']['apps']; if (is_array($apps) && count($apps)) { return $apps; } diff --git a/imp/lib/IMAP/Tree.php b/imp/lib/IMAP/Tree.php index fb0a66110..725973d57 100644 --- a/imp/lib/IMAP/Tree.php +++ b/imp/lib/IMAP/Tree.php @@ -1584,8 +1584,7 @@ class IMP_IMAP_Tree } if (!isset($mbox_icons)) { - $mbox_icons = Horde::callHook('_imp_hook_mbox_icons', array(), - 'imp', false); + $mbox_icons = Horde::callHook('_imp_hook_mbox_icons', array(), 'imp', false); if (!$mbox_icons) { return false; } diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index 2cd4be110..9cc555d1b 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -1628,7 +1628,7 @@ class IMP if ($app == 'dimp') { // Load custom stylesheets. - if (!empty($conf['css_files'])) { + if (!empty($conf['dimp']['css_files'])) { foreach ($conf['css_files'] as $css_file) { $css[] = array('u' => $themesuri . '/' . $css_file, 'f' => $themesfs . '/' . $css_file); diff --git a/imp/lib/Mailbox.php b/imp/lib/Mailbox.php index 656d21c98..aa4979ad6 100644 --- a/imp/lib/Mailbox.php +++ b/imp/lib/Mailbox.php @@ -130,7 +130,8 @@ class IMP_Mailbox * @return array An array with the following keys: *
      * 'overview' - (array) The overview information.
-     * 'uids' - (array) The array of UIDs.
+     * 'uids' - (array) The array of UIDs. It is in the same format as used
+     *          for IMP::parseIndicesList().
      * 
*/ public function getMailboxArray($msgnum, $preview = false, @@ -138,7 +139,7 @@ class IMP_Mailbox { $this->_buildMailbox(); - $mboxes = $overview = $uids = array(); + $overview = $to_process = $uids = array(); /* Build the list of mailboxes and messages. */ foreach ($msgnum as $i) { @@ -147,11 +148,11 @@ class IMP_Mailbox example, there may be gaps here. */ if (isset($this->_sorted[$i - 1])) { $mboxname = ($this->_searchmbox) ? $this->_sortedInfo[$i - 1]['m'] : $this->_mailbox; - if (!isset($mboxes[$mboxname])) { - $mboxes[$mboxname] = array(); + if (!isset($to_process[$mboxname])) { + $to_process[$mboxname] = array(); } - // $mboxes - KEY: UID, VALUE: sequence number - $mboxes[$mboxname][$this->_sorted[$i - 1]] = $i; + // $uids - KEY: UID, VALUE: sequence number + $to_process[$mboxname][$this->_sorted[$i - 1]] = $i; } } @@ -170,7 +171,7 @@ class IMP_Mailbox $cacheob = $preview ? $GLOBALS['imp_imap']->ob->getCacheOb() : null; /* Retrieve information from each mailbox. */ - foreach ($mboxes as $mbox => $ids) { + foreach ($to_process as $mbox => $ids) { try { $fetch_res = $GLOBALS['imp_imap']->ob->fetch($mbox, $fetch_criteria, array('ids' => array_keys($ids))); @@ -214,7 +215,7 @@ class IMP_Mailbox $overview[$ids[$k]] = $v; } - $uids = array_merge($uids, array_keys($fetch_res)); + $uids[$mbox] = array_keys($fetch_res); if (!is_null($cacheob) && !empty($tostore)) { $cacheob->set($mbox, $tostore); diff --git a/imp/lib/UI/Message.php b/imp/lib/UI/Message.php index 1f18c7bfc..697c08cff 100644 --- a/imp/lib/UI/Message.php +++ b/imp/lib/UI/Message.php @@ -223,14 +223,13 @@ class IMP_UI_Message /** * Determines the X-Priority of the message based on the headers. * - * @param Horde_Mime_Headers $headers Horde_Mime_Headers object. + * @param string $header The X-Priority header. * * @return string 'high', 'low', or 'normal'. */ - public function getXpriority($headers) + public function getXpriority($header) { - if (($priority = $headers->getValue('x-priority')) && - preg_match('/\s*(\d+)\s*/', $priority, $matches)) { + if ($header && preg_match('/\s*(\d+)\s*/', $header, $matches)) { if (in_array($matches[1], array(1, 2))) { return 'high'; } elseif (in_array($matches[1], array(4, 5))) { diff --git a/imp/lib/Views/ListMessages.php b/imp/lib/Views/ListMessages.php index b53da3263..30c3f0d84 100644 --- a/imp/lib/Views/ListMessages.php +++ b/imp/lib/Views/ListMessages.php @@ -297,26 +297,8 @@ class IMP_Views_ListMessages } } - $attachment = ''; - if (!empty($GLOBALS['conf']['hooks']['msglist_format'])) { - $ob_f = Horde::callHook('_dimp_hook_msglist_format', array($ob['mailbox'], $ob['uid']), 'dimp'); - if (is_a($ob_f, 'PEAR_Error')) { - Horde::logMessage($ob_f, __FILE__, __LINE__, PEAR_LOG_ERR); - } else { - $attachment = empty($ob_f['atc']) ? '' : $ob_f['atc']; - if (!empty($ob_f['class'])) { - $bg = array_merge($bg, $ob_f['class']); - } - } - } - $msg['bg'] = $bg; - /* Format attachment information. */ - if (!empty($attachment)) { - $msg['atc'] = $attachment; - } - /* Format size information. */ $msg['size'] = htmlspecialchars($imp_ui->getSize($ob['size']), ENT_QUOTES, $charset); @@ -330,15 +312,6 @@ class IMP_Views_ListMessages /* Format the Subject: Header. */ $msg['subject'] = $imp_ui->getSubject($ob['envelope']['subject']); - if (!empty($GLOBALS['conf']['hooks']['mailboxarray'])) { - $result = Horde::callHook('_dimp_hook_mailboxarray', array($msg, $ob), 'dimp'); - if (is_a($result, 'PEAR_Error')) { - Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR); - } else { - $msg = $result; - } - } - /* Check to see if this is a list message. Namely, we want to * check for 'List-Post' information because that is the header * that gives the e-mail address to reply to, which is all we @@ -356,6 +329,30 @@ class IMP_Views_ListMessages } } + /* 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($val['atc'])) { + $ptr['atc'] = $val['atc']; + } + + if (!empty($val['class'])) { + $ptr['bg'] = array_merge($ptr['bg'], $val['class']); + } + } + } + } + + /* Allow user to alter template array. */ + if (!empty($GLOBALS['conf']['dimp']['hooks']['mailboxarray'])) { + $msgs = Horde::callHook('_imp_hook_dimp_mailboxarray', array($msgs), 'imp'); + } + return $msgs; } } diff --git a/imp/lib/Views/ShowMessage.php b/imp/lib/Views/ShowMessage.php index b50b963af..983a1ccd3 100644 --- a/imp/lib/Views/ShowMessage.php +++ b/imp/lib/Views/ShowMessage.php @@ -27,7 +27,7 @@ class IMP_Views_ShowMessage } $addr_array = array(); - $call_hook = !empty($GLOBALS['conf']['hooks']['addressformatting']); + $call_hook = !empty($GLOBALS['conf']['dimp']['hooks']['addressformatting']); foreach (Horde_Mime_Address::getAddressesFromObject($addrlist) as $ob) { if (empty($ob['address']) || empty($ob['inner'])) { @@ -37,12 +37,7 @@ class IMP_Views_ShowMessage /* If this is an incomplete e-mail address, don't link to * anything. */ if ($call_hook) { - $result = Horde::callHook('_dimp_hook_addressformatting', array($ob), 'imp'); - if (is_a($result, 'PEAR_Error')) { - Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR); - } else { - $addr_array[] = array('raw' => $result); - } + $addr_array[] = array('raw' => Horde::callHook('_imp_hook_dimp_addressformatting', array($ob), 'imp')); } else { $tmp = array(); foreach (array('address', 'display', 'inner', 'personal') as $val) { @@ -241,7 +236,7 @@ class IMP_Views_ShowMessage } /* Get X-Priority. */ - $result['priority'] = $imp_ui->getXpriority($mime_headers); + $result['priority'] = $imp_ui->getXpriority($mime_headers->getValue('x-priority')); // Create message text and attachment list. $parts_list = $imp_contents->getContentTypeMap(); @@ -345,22 +340,14 @@ class IMP_Views_ShowMessage $result['atc_list'] = '' . $tmp . '
'; } - // TODO: Hooks - if ($preview && !empty($GLOBALS['conf']['hooks']['previewview'])) { - $res = Horde::callHook('_dimp_hook_previewview', array($result), 'dimp'); - if (is_a($res, 'PEAR_Error')) { - Horde::logMessage($res, __FILE__, __LINE__, PEAR_LOG_ERR); - } else { + if ($preview && !empty($GLOBALS['conf']['dimp']['hooks']['previewview'])) { + $res = Horde::callHook('_imp_hook_dimp_previewview', array($result), 'imp'); + if (!empty($res)) { $result = $res[0]; $result['js'] = $res[1]; } - } elseif (!$preview && !empty($GLOBALS['conf']['hooks']['messageview'])) { - $res = Horde::callHook('_dimp_hook_messageview', array($result), 'dimp'); - if (is_a($res, 'PEAR_Error')) { - Horde::logMessage($res, __FILE__, __LINE__, PEAR_LOG_ERR); - } else { - $result = $res; - } + } elseif (!$preview && !empty($GLOBALS['conf']['dimp']['hooks']['messageview'])) { + $result = Horde::callHook('_imp_hook_dimp_messageview', array($result), 'imp'); } /* Retrieve any history information for this message. */ diff --git a/imp/mailbox-mimp.php b/imp/mailbox-mimp.php index 7f8bd26bf..5d1ff2579 100644 --- a/imp/mailbox-mimp.php +++ b/imp/mailbox-mimp.php @@ -104,8 +104,8 @@ while (list(,$ob) = each($mbox_info['overview'])) { /* Format the from header. */ $getfrom = $imp_ui->getFrom($ob['envelope'], false); $msg['from'] = $getfrom['from']; - if (String::length($msg['from']) > $conf['mimp']['max_from_chars']) { - $msg['from'] = String::substr($msg['from'], 0, $conf['mimp']['max_from_chars']) . '...'; + if (String::length($msg['from']) > $conf['mimp']['mailbox']['max_from_chars']) { + $msg['from'] = String::substr($msg['from'], 0, $conf['mimp']['mailbox']['max_from_chars']) . '...'; } $msg['subject'] = $imp_ui->getSubject($ob['envelope']['subject']); @@ -114,8 +114,8 @@ while (list(,$ob) = each($mbox_info['overview'])) { $msg['subject'] = '>> ' . ltrim($msg['subject']); } - if (String::length($msg['subject']) > $conf['mimp']['max_subj_chars']) { - $msg['subject'] = String::substr($msg['subject'], 0, $conf['mimp']['max_subj_chars']) . '...'; + if (String::length($msg['subject']) > $conf['mimp']['mailbox']['max_subj_chars']) { + $msg['subject'] = String::substr($msg['subject'], 0, $conf['mimp']['mailbox']['max_subj_chars']) . '...'; } /* Generate the target link. */ diff --git a/imp/mailbox.php b/imp/mailbox.php index 0a79f927a..024279ffa 100644 --- a/imp/mailbox.php +++ b/imp/mailbox.php @@ -568,7 +568,7 @@ $messages = $threadlevel = array(); /* Get thread object, if necessary. */ if ($sortpref['by'] == Horde_Imap_Client::SORT_THREAD) { $imp_thread = new IMP_IMAP_Thread($imp_mailbox->getThreadOb()); - $threadtree = $imp_thread->getThreadImageTree($mbox_info['uids'], $sortpref['dir']); + $threadtree = $imp_thread->getThreadImageTree(reset($mbox_info['uids']), $sortpref['dir']); } /* Don't show header row if this is a search mailbox or if no messages in the @@ -682,7 +682,7 @@ $imp_ui = new IMP_UI_Mailbox($imp_mbox['mailbox']); require_once 'Horde/Text.php'; $ids = $msgs = array(); $search_template = null; -while (list(,$ob) = each($mbox_info['overview'])) { +while (list($seq, $ob) = each($mbox_info['overview'])) { if ($search_mbox) { if (empty($lastMbox) || ($ob['mailbox'] != $lastMbox)) { if (!empty($lastMbox)) { @@ -691,7 +691,7 @@ while (list(,$ob) = each($mbox_info['overview'])) { } $folder_link = Horde::url(Util::addParameter('mailbox.php', 'mailbox', $ob['mailbox'])); $folder_link = Horde::link($folder_link, sprintf(_("View messages in %s"), IMP::displayFolder($ob['mailbox'])), 'smallheader') . IMP::displayFolder($ob['mailbox']) . ''; - if ($search_template === null) { + if (is_null($search_template)) { $search_template = new IMP_Template(); } $search_template->set('lastMbox', $lastMbox); @@ -712,6 +712,7 @@ while (list(,$ob) = each($mbox_info['overview'])) { 'bg' => '', 'color' => '', 'date' => htmlspecialchars($imp_ui->getDate($ob['envelope']['date'])), + 'number' => $seq, 'preview' => '', 'size' => htmlspecialchars($imp_ui->getSize($ob['size'])), 'status' => '', @@ -765,19 +766,6 @@ while (list(,$ob) = each($mbox_info['overview'])) { } } - if (!empty($conf['hooks']['msglist_format'])) { - $ob_f = Horde::callHook('_imp_hook_msglist_format', array($ob['mailbox'], $ob['uid']), 'imp'); - if (!empty($ob_f['class'])) { - $bg = array_merge($bg, $ob_f['class']); - } - if (!empty($ob_f['flagbits'])) { - $flagbits |= $ob_f['flagbits']; - } - if (!empty($ob_f['status'])) { - $msg['status'] .= $ob_f['status']; - } - } - $ids[$msg['id']] = $flagbits; $msg['bg'] = implode(' ', $bg); @@ -812,9 +800,6 @@ while (list(,$ob) = each($mbox_info['overview'])) { $msg['preview'] = $ptext; } - /* Set the message number. */ - $msg['number'] = $ob['seq']; - /* Format the From: Header. */ $getfrom = $imp_ui->getFrom($ob['envelope']); $msg['from'] = htmlspecialchars($getfrom['from']); @@ -847,7 +832,30 @@ while (list(,$ob) = each($mbox_info['overview'])) { } } - $msgs[] = $msg; + $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']; + } + } + } } _outputSummaries($msgs); diff --git a/imp/message-mimp.php b/imp/message-mimp.php index f27d0ae46..8f02bf587 100644 --- a/imp/message-mimp.php +++ b/imp/message-mimp.php @@ -168,11 +168,12 @@ $display_headers['subject'] = $subject; $list_info = $imp_ui->getListInformation($mime_headers); /* See if the 'X-Priority' header has been set. */ -switch ($imp_ui->getXpriority($mime_headers)) { +$xpriority = $mime_headers->getValue('x-priority'); +switch ($imp_ui->getXpriority($xpriority)) { case 'high': case 'low': $basic_headers['priority'] = _("Priority"); - $display_headers['priority'] = $mime_headers->getValue('x-priority'); + $display_headers['priority'] = $xpriority; break; } diff --git a/imp/message.php b/imp/message.php index 800c052d6..668611e73 100644 --- a/imp/message.php +++ b/imp/message.php @@ -315,15 +315,16 @@ if (($subject = $mime_headers->getValue('subject'))) { } /* See if the 'X-Priority' header has been set. */ -switch ($imp_ui->getXpriority($mime_headers)) { +$xpriority = $mime_headers->getValue('x-priority'); +switch ($imp_ui->getXpriority($xpriority)) { case 'high': $basic_headers['priority'] = _("Priority"); - $display_headers['priority'] = Horde::img('mail_priority_high.png', _("High Priority")) . ' ' . $mime_headers->getValue('x-priority'); + $display_headers['priority'] = Horde::img('mail_priority_high.png', _("High Priority")) . ' ' . $xpriority; break; case 'low': $basic_headers['priority'] = _("Priority"); - $display_headers['priority'] = Horde::img('mail_priority_low.png', _("Low Priority")) . ' ' . $mime_headers->getValue('x-priority'); + $display_headers['priority'] = Horde::img('mail_priority_low.png', _("Low Priority")) . ' ' . $xpriority; break; } diff --git a/imp/templates/index/index.inc b/imp/templates/index/index.inc index a7680d90d..54d5a395c 100644 --- a/imp/templates/index/index.inc +++ b/imp/templates/index/index.inc @@ -221,7 +221,7 @@ function _simpleButton($id, $text, $image, $imagedir = null)
x - +