From: Michael M Slusarz Date: Mon, 1 Dec 2008 23:51:19 +0000 (-0700) Subject: Slowly working my way through DIMP fixes. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=b09b1fcbe15249b004fc9c8b58d7595d38dcac85;p=horde.git Slowly working my way through DIMP fixes. --- diff --git a/imp/config/hooks.php.dist b/imp/config/hooks.php.dist index c854c5a20..4629a8175 100644 --- a/imp/config/hooks.php.dist +++ b/imp/config/hooks.php.dist @@ -251,10 +251,11 @@ // $ob = reset($cache_entry); // // // Add attachment information -// require_once IMP_BASE . '/lib/UI/Mailbox.php'; -// $imp_ui = new IMP_UI_Mailbox(); +// $imp_ui = new IMP_UI_Mailbox($mailbox); // if (($attachment = $imp_ui->getAttachmentType($ob->structure))) { -// $ret['status'] = Horde::img($attachment . '.png', $imp_ui->getAttachmentAlt($attachment), array('title' => $imp_ui->getAttachmentAlt($attachment))); +// $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)); // } // // // Add xpriority information @@ -653,8 +654,7 @@ if (!function_exists('_imp_hook_quota')) { // $ob = reset($cache_entry); // // // Add attachment information -// require_once IMP_BASE . '/lib/UI/Mailbox.php'; -// $imp_ui = new IMP_UI_Mailbox(); +// $imp_ui = new IMP_UI_Mailbox($mailbox); // $ret['atc'] = $imp_ui->getAttachmentType($ob->structure); // // // Add xpriority information diff --git a/imp/config/portal.php.dist b/imp/config/portal.php.dist index 9a6535e14..e60c98dc7 100644 --- a/imp/config/portal.php.dist +++ b/imp/config/portal.php.dist @@ -1,19 +1,19 @@ The Horde_Block object to display + * KEY: Block label text + * VALUE: An array with the following entries: + * 'ob' => The Horde_Block object to display * - * These entries are optional and will only be used if you need - * to customize the portal output: - * 'class' => A CSS class to assign to the containing block. - * Defaults to "headerbox". - * 'domid' => A DOM ID to assign to the containing block - * 'tag' => A tag name to add to the template array. Allows - * the use of in custom template files. + * These entries are optional and will only be used if you need + * to customize the portal output: + * 'class' => A CSS class to assign to the containing block. + * Defaults to "headerbox". + * 'domid' => A DOM ID to assign to the containing block + * 'tag' => A tag name to add to the template array. Allows + * the use of in custom template files. */ $collection = new Horde_Block_Collection(); @@ -22,14 +22,14 @@ $dimp_block_list = array(); // Show a folder summary of the mailbox. All polled folders are displayed. require_once IMP_BASE . '/lib/Block/foldersummary.php'; $dimp_block_list[_("Folder Summary")] = array( - 'ob' => new Horde_Block_dimp_foldersummary(array()) + 'ob' => new Horde_Block_imp_foldersummary(array()) ); // Alternate DIMP block - shows details of 'msgs_shown' number of the most // recent unseen messages. //require_once IMP_BASE . '/lib/Block/newmail.php'; //$dimp_block_list[_("Newest Unseen Messages")] = array( -// 'ob' => new Horde_Block_dimp_newmail(array('msgs_shown' => 3)) +// 'ob' => new Horde_Block_imp_newmail(array('msgs_shown' => 3)) //); // Show a contact search box. diff --git a/imp/lib/Block/foldersummary.php b/imp/lib/Block/foldersummary.php index d66d30596..110ebde59 100644 --- a/imp/lib/Block/foldersummary.php +++ b/imp/lib/Block/foldersummary.php @@ -8,7 +8,7 @@ * @package Horde_Block */ -class Horde_Block_dimp_foldersummary extends Horde_Block +class Horde_Block_imp_foldersummary extends Horde_Block { var $_app = 'imp'; diff --git a/imp/lib/Block/newmail.php b/imp/lib/Block/newmail.php index 3badbad1f..8e45dd814 100644 --- a/imp/lib/Block/newmail.php +++ b/imp/lib/Block/newmail.php @@ -1,5 +1,6 @@ */ -class Horde_Block_dimp_newmail extends Horde_Block +class Horde_Block_imp_newmail extends Horde_Block { var $_app = 'imp'; function _content() { $GLOBALS['authentication'] = 'none'; - require_once $GLOBALS['registry']->get('fileroot', 'imp') . '/lib/base.php'; + require_once dirname(__FILE__) . '/../base.php'; if (!IMP::checkAuthentication(true)) { return ''; @@ -26,10 +27,9 @@ class Horde_Block_dimp_newmail extends Horde_Block IMP_Filter::filter('INBOX'); } - // @todo - $query = new IMAP_Search_Query(); - $query->seen(false); - $ids = $GLOBALS['imp_search']->runSearchQuery($query, IMP::serverString('INBOX'), SORTARRIVAL, 1); + $query = new Horde_Imap_Client_Search_Query(); + $query->flag('\\seen', false); + $ids = $GLOBALS['imp_search']->runSearchQuery($query, 'INBOX', Horde_Imap_Client::SORT_ARRIVAL, 1); $html = ''; if (empty($ids)) { @@ -38,30 +38,33 @@ class Horde_Block_dimp_newmail extends Horde_Block require_once 'Horde/Identity.php'; $charset = NLS::getCharset(); - $identity = &Identity::singleton(array('imp', 'imp')); - $imp_ui = new IMP_UI_Mailbox('INBOX', $charset, $identity); + $imp_ui = new IMP_UI_Mailbox('INBOX'); $shown = empty($this->_params['msgs_shown']) ? 3 : $this->_params['msgs_shown']; - // @todo - $msg_cache = &IMP_MessageCache::singleton(); - $overview = $msg_cache->retrieve('INBOX', array_slice($ids, 0, $shown), 1 | 128); - foreach ($overview as $ob) { - $date = $imp_ui->getDate((isset($ob->date)) ? $ob->date : null); - $from_res = $imp_ui->getFrom($ob); - $subject = (empty($ob->subject)) ? _("[No Subject]") : $imp_ui->getSubject($ob->subject); + try { + $fetch_ret = $GLOBALS['imp_imap']->ob->fetch('INBOX', array( + Horde_Imap_Client::FETCH_ENVELOPE => true + ), array('ids' => array_slice($ids, 0, $shown))); + reset($fetch_ret); + } catch (Horde_Imap_Client_Exception $e) { + $fetch_ret = array(); + } + + while (list($uid, $ob) = each($fetch_ret)) { + $date = $imp_ui->getDate($ob['envelope']['date']); + $from = $imp_ui->getFrom($ob, false); + $subject = $imp_ui->getSubject($ob['envelope']['subject']); - $html .= '' . ''; } $more_msgs = count($ids) - $shown; - if ($more_msgs) { - $text = sprintf(ngettext("%d more unseen message...", "%d more unseen messages...", $more_msgs), $more_msgs); - } else { - $text = _("Go to your Inbox..."); - } + $text = $more_msgs + ? sprintf(ngettext("%d more unseen message...", "%d more unseen messages...", $more_msgs), $more_msgs) + : _("Go to your Inbox..."); $html .= ''; } diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index 39c3bf283..4c7271625 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -1729,10 +1729,13 @@ class IMP $themes_uri = Horde::url($GLOBALS['registry']->get('themesuri', $app), false, -1); $css[] = array('u' => $themes_uri . '/screen.css', 'f' => $themes_fs . '/screen.css'); $css[] = array('u' => $themes_uri . '/screen-dimp.css', 'f' => $themes_fs . '/screen-dimp.css'); - if (!empty($theme) && - file_exists($themes_fs . '/' . $theme . '/screen-dimp.css')) { - $css[] = array('u' => $themes_uri . '/' . $theme . '/screen.css', 'f' => $themes_fs . '/' . $theme . '/screen.css'); - $css[] = array('u' => $themes_uri . '/' . $theme . '/screen-dimp.css', 'f' => $themes_fs . '/' . $theme . '/screen-dimp.css'); + if (!empty($theme)) { + if (file_exists($themes_fs . '/' . $theme . '/screen.css')) { + $css[] = array('u' => $themes_uri . '/' . $theme . '/screen.css', 'f' => $themes_fs . '/' . $theme . '/screen.css'); + } + if (file_exists($themes_fs . '/' . $theme . '/screen-dimp.css')) { + $css[] = array('u' => $themes_uri . '/' . $theme . '/screen-dimp.css', 'f' => $themes_fs . '/' . $theme . '/screen-dimp.css'); + } } if ($rtl) { diff --git a/imp/lib/UI/Mailbox.php b/imp/lib/UI/Mailbox.php index d4f48ca8c..b34b07131 100644 --- a/imp/lib/UI/Mailbox.php +++ b/imp/lib/UI/Mailbox.php @@ -1,6 +1,6 @@ * @package IMP */ -class IMP_UI_Mailbox { - - /** - */ - var $_charset; - - /** - */ - var $_identity; - +class IMP_UI_Mailbox +{ /** + * The current mailbox. + * + * @var string */ - var $_mailbox; + private $_mailbox; /** - * Cache array. + * Cached data. * * @var array */ - var $_c = array(); + private $_cache = array(); /** + * Constructor. + * + * @param string $mailbox The current mailbox. */ - function IMP_UI_Mailbox($mailbox = null, $charset = null, $identity = null) + function __construct($mailbox = null) { $this->_mailbox = $mailbox; - $this->_charset = $charset; - $this->_identity = $identity; } /** - * TODO + * Get From address information for display on mailbox page. + * + * @param array $ob An array of envelope information. + * @param boolean $full If true, returns 'fullfrom' information. + * + * @return array An array of information: + *
+     * 'error' - (boolean)
+     * 'from' - (string)
+     * 'fullfrom' - (string)
+     * 'to' - (boolean)
+     * 
*/ - function getFrom($ob, $need_full = true) + public function getFrom($ob, $full = true) { $ret = array('error' => false, 'to' => false); @@ -54,51 +61,57 @@ class IMP_UI_Mailbox { return $ret; } - if (!isset($this->_c['drafts_sm_folder'])) { - $this->_c['drafts_sm_folder'] = IMP::isSpecialFolder($this->_mailbox); + if (!isset($this->_cache['drafts_sm_folder'])) { + $this->_cache['drafts_sm_folder'] = IMP::isSpecialFolder($this->_mailbox); } $from = Horde_Mime_Address::getAddressesFromObject($ob['from']); - $from = array_shift($from); + $from = reset($from); if (empty($from)) { $ret['from'] = _("Invalid Address"); $ret['error'] = true; - } elseif ($this->_identity && - $this->_identity->hasAddress($from['inner'])) { - /* This message was sent by one of the user's identity addresses - - * show To information instead. */ - if (empty($ob['to'])) { - $ret['from'] = _("Undisclosed Recipients"); - $ret['error'] = true; - } else { - $to = Horde_Mime_Address::getAddressesFromObject($ob['to']); - $first_to = array_shift($to); - if (empty($first_to)) { + } else { + $identity = &Identity::singleton(array('imp', 'imp')); + if ($identity->hasAddress($from['inner'])) { + /* This message was sent by one of the user's identity + * addresses - show To: information instead. */ + if (empty($ob['to'])) { $ret['from'] = _("Undisclosed Recipients"); $ret['error'] = true; } else { - $ret['from'] = empty($first_to['personal']) ? $first_to['inner'] : $first_to['personal']; - if ($need_full) { - $ret['fullfrom'] = $first_to['display']; + $to = Horde_Mime_Address::getAddressesFromObject($ob['to']); + $first_to = reset($to); + if (empty($first_to)) { + $ret['from'] = _("Undisclosed Recipients"); + $ret['error'] = true; + } else { + $ret['from'] = empty($first_to['personal']) + ? $first_to['inner'] + : $first_to['personal']; + if ($full) { + $ret['fullfrom'] = $first_to['display']; + } } } - } - if (!$this->_c['drafts_sm_folder']) { - $ret['from'] = _("To") . ': ' . $ret['from']; - } - $ret['to'] = true; - } else { - $ret['from'] = empty($from['personal']) ? $from['inner'] : $from['personal']; - if ($this->_c['drafts_sm_folder']) { - $ret['from'] = _("From") . ': ' . $ret['from']; - } - if ($need_full) { - $ret['fullfrom'] = $from['display']; + if (!$this->_cache['drafts_sm_folder']) { + $ret['from'] = _("To") . ': ' . $ret['from']; + } + $ret['to'] = true; + } else { + $ret['from'] = empty($from['personal']) + ? $from['inner'] + : $from['personal']; + if ($this->_cache['drafts_sm_folder']) { + $ret['from'] = _("From") . ': ' . $ret['from']; + } + if ($full) { + $ret['fullfrom'] = $from['display']; + } } } - if ($need_full && !isset($ret['fullfrom'])) { + if ($full && !isset($ret['fullfrom'])) { $ret['fullfrom'] = $ret['from']; } @@ -106,27 +119,35 @@ class IMP_UI_Mailbox { } /** + * Get size display information. + * + * @param integer $size The size of the message, in bytes. + * + * @return string A formatted size string. */ - function getSize($size) + public function getSize($size) { - if ($size > 1024) { - if (!isset($this->_c['localeinfo'])) { - $this->_c['localeinfo'] = NLS::getLocaleInfo(); - } - $size = $size / 1024; - if ($size > 1024) { - return sprintf(_("%s MB"), number_format($size / 1024, 1, $this->_c['localeinfo']['decimal_point'], $this->_c['localeinfo']['thousands_sep'])); - } else { - return sprintf(_("%s KB"), number_format($size, 0, $this->_c['localeinfo']['decimal_point'], $this->_c['localeinfo']['thousands_sep'])); - } + if ($size < 1024) { + return $size; + } + + if (!isset($this->_cache['localeinfo'])) { + $this->_cache['localeinfo'] = NLS::getLocaleInfo(); } - return $size; + $size = $size / 1024; + + return ($size > 1024) + ? sprintf(_("%s MB"), number_format($size / 1024, 1, $this->_cache['localeinfo']['decimal_point'], $this->_cache['localeinfo']['thousands_sep'])) + : sprintf(_("%s KB"), number_format($size, 0, $this->_cache['localeinfo']['decimal_point'], $this->_cache['localeinfo']['thousands_sep'])); } /** + * The list of ALT text to use for mailbox display icons. + * + * @return array Type -> ALT text mappings. */ - function getAttachmentAltList() + public function getAttachmentAltList() { return array( 'signed' => _("Message is signed"), @@ -136,19 +157,15 @@ class IMP_UI_Mailbox { } /** + * Return the icon to use for a given attachment. + * + * @return string The mailbox display icon type. */ - function getAttachmentAlt($attachment) - { - $list = $this->getAttachmentAltList(); - return (isset($list[$attachment])) ? $list[$attachment] : $list['attachment']; - } - - /** - */ - function getAttachmentType($structure) + public function getAttachmentType($type) { - if ($structure->getPrimaryType() == 'multipart') { - switch ($structure->getSubType()) { + list($primary, $sub) = explode('/', $type, 2); + if ($primary == 'multipart') { + switch ($sub) { case 'signed': return 'signed'; @@ -163,7 +180,7 @@ class IMP_UI_Mailbox { default: return 'attachment'; } - } elseif ($structure->getType() == 'application/pkcs7-mime') { + } elseif ($type == 'application/pkcs7-mime') { return 'encrypted'; } @@ -173,35 +190,40 @@ class IMP_UI_Mailbox { /** * Formats the date header. * - * @param DateTime $date A DateTime object. + * @param integer $date The UNIX timestamp. * * @return string The formatted date header. */ - function getDate($date) + public function getDate($date) { - if (!isset($this->_c['today_start'])) { - $this->_c['today_start'] = strtotime('today'); - $this->_c['today_end'] = strtotime('today + 1 day'); + if (!isset($this->_cache['today_start'])) { + $this->_cache['today_start'] = strtotime('today'); + $this->_cache['today_end'] = strtotime('today + 1 day'); } $d = new DateTime($date); $udate = $d->format('U'); - if (($udate < $this->_c['today_start']) || - ($udate > $this->_c['today_end'])) { + if (($udate < $this->_cache['today_start']) || + ($udate > $this->_cache['today_end'])) { /* Not today, use the date. */ return strftime($GLOBALS['prefs']->getValue('date_format'), $udate); - } else { - /* Else, it's today, use the time. */ - return strftime($GLOBALS['prefs']->getValue('time_format'), $udate); } + + /* Else, it's today, use the time. */ + return strftime($GLOBALS['prefs']->getValue('time_format'), $udate); } /** + * Formats the subject header. + * + * @param string $subject The MIME encoded subject header. + * + * @return string The formatted subject header. */ - function getSubject($subject) + public function getSubject($subject) { - $subject = Horde_Mime::decode($subject, $this->_charset); + $subject = Horde_Mime::decode($subject); $subject = empty($subject) ? _("[No Subject]") : IMP::filterText(preg_replace("/\s+/", ' ', $subject)); diff --git a/imp/lib/UI/Message.php b/imp/lib/UI/Message.php index 6b60ab559..1f18c7bfc 100644 --- a/imp/lib/UI/Message.php +++ b/imp/lib/UI/Message.php @@ -1,6 +1,6 @@ gettext translation mapping. */ public function basicHeaders() { @@ -31,7 +34,7 @@ class IMP_UI_Message /** * Get the list of user-defined headers to display. * - * @return array TODO + * @return array The list of user-defined headers. */ public function getUserHeaders() { @@ -54,33 +57,37 @@ class IMP_UI_Message } /** + * TODO */ public function MDNCheck($headers, $confirmed = false) { if (!$GLOBALS['prefs']->getValue('disposition_send_mdn')) { - return; + return false; } /* Check to see if an MDN has been requested. */ $mdn = new Horde_Mime_Mdn($headers); - if ($mdn->getMDNReturnAddr()) { - $msg_id = $headers->getValue('message-id'); - - /* See if we have already processed this message. */ - if (!IMP_Maillog::sentMDN($msg_id, 'displayed')) { - /* See if we need to query the user. */ - if ($mdn->userConfirmationNeeded() && !$confirmed) { - return true; - } else { - /* Send out the MDN now. */ - $result = $mdn->generate(false, $confirmed, 'displayed'); - if (!is_a($result, 'PEAR_Error')) { - IMP_Maillog::log('mdn', $msg_id, 'displayed'); - } - if ($GLOBALS['conf']['sentmail']['driver'] != 'none') { - $sentmail = IMP_Sentmail::factory(); - $sentmail->log('mdn', '', $mdn->getMDNReturnAddr(), !is_a($result, 'PEAR_Error')); - } + $return_addr = $mdn->getMDNReturnAddr(); + if (!$return_addr) { + return false; + } + + $msg_id = $headers->getValue('message-id'); + + /* See if we have already processed this message. */ + if (!IMP_Maillog::sentMDN($msg_id, 'displayed')) { + /* See if we need to query the user. */ + if ($mdn->userConfirmationNeeded() && !$confirmed) { + return true; + } else { + /* Send out the MDN now. */ + $result = $mdn->generate(false, $confirmed, 'displayed'); + if (!is_a($result, 'PEAR_Error')) { + IMP_Maillog::log('mdn', $msg_id, 'displayed'); + } + if ($GLOBALS['conf']['sentmail']['driver'] != 'none') { + $sentmail = IMP_Sentmail::factory(); + $sentmail->log('mdn', '', $return_addr, !is_a($result, 'PEAR_Error')); } } } @@ -93,8 +100,9 @@ class IMP_UI_Message * * @param string $date The date string. * - * @return string The date string with the local time added on. The - * output has been run through htmlspecialchars(). + * @return string The date string with the local time added on. If not + * in MIMP mode, the output has been run through + * htmlspecialchars(). */ public function addLocalTime($date) { @@ -105,29 +113,29 @@ class IMP_UI_Message $ltime = strtotime($date); } - $date = htmlspecialchars($date); + if (($ltime === false) || ($ltime === -1)) { + return ($_SESSION['imp']['view'] == 'mimp') + ? $date + : htmlspecialchars($date); + } - if ($ltime !== false && $ltime !== -1) { - $date_str = strftime($GLOBALS['prefs']->getValue('date_format'), $ltime); - $time_str = strftime($GLOBALS['prefs']->getValue('time_format'), $ltime); - $tz = strftime('%Z'); - - if ((date('Y') != @date('Y', $ltime)) || - (date('M') != @date('M', $ltime)) || - (date('d') != @date('d', $ltime))) { - /* Not today, use the date. */ - $local_date = sprintf('[%s %s %s]', $date_str, $time_str, $tz); - } else { - /* Else, it's today, use the time only. */ - $local_date = sprintf('[%s %s]', $time_str, $tz); - } + $time_str = strftime($GLOBALS['prefs']->getValue('time_format'), $ltime); + $tz = strftime('%Z'); - $date .= ($_SESSION['imp']['view'] == 'mimp') - ? ' ' . $local_date - : ' ' . htmlspecialchars($local_date) . ''; + if ((date('Y') != @date('Y', $ltime)) || + (date('M') != @date('M', $ltime)) || + (date('d') != @date('d', $ltime))) { + /* Not today, use the date. */ + $date_str = strftime($GLOBALS['prefs']->getValue('date_format'), $ltime); + $local_date = sprintf('[%s %s %s]', $date_str, $time_str, $tz); + } else { + /* Else, it's today, use the time only. */ + $local_date = sprintf('[%s %s]', $time_str, $tz); } - return $date; + return ($_SESSION['imp']['view'] == 'mimp') + ? $date . ' ' . $local_date + : htmlspecialchars($date) . ' ' . htmlspecialchars($local_date) . ''; } /** @@ -295,28 +303,24 @@ class IMP_UI_Message if (isset($ob['groupname'])) { $group_array = array(); foreach ($ob['addresses'] as $ad) { - if (empty($ad->address) || empty($ad->inner)) { + if (empty($ad['address']) || empty($ad['inner'])) { continue; } $ret = $mimp_view - ? $ad->display - : htmlspecialchars($ad->display); - - /* If this is an incomplete e-mail address, don't link to - * anything. */ - if (stristr($ad->host, 'UNKNOWN') === false) { - if ($link) { - $ret = Horde::link(IMP::composeLink(array('to' => $ad->address)), sprintf(_("New Message to %s"), $ad->inner)) . htmlspecialchars($ad->display) . ''; - } - - /* Append the add address icon to every address if contact - * manager is available. */ - if ($add_link) { - $curr_link = Util::addParameter($add_link, array('name' => $ad->personal, 'address' => $ad->inner)); - $ret .= Horde::link($curr_link, sprintf(_("Add %s to my Address Book"), $ad->inner)) . - Horde::img('addressbook_add.png', sprintf(_("Add %s to my Address Book"), $ad->inner)) . ''; - } + ? $ad['display'] + : htmlspecialchars($ad['display']); + + if ($link) { + $ret = Horde::link(IMP::composeLink(array('to' => $ad['address'])), sprintf(_("New Message to %s"), $ad['inner'])) . htmlspecialchars($ad['display']) . ''; + } + + /* Append the add address icon to every address if contact + * manager is available. */ + if ($add_link) { + $curr_link = Util::addParameter($add_link, array('name' => $ad['personal'], 'address' => $ad['inner'])); + $ret .= Horde::link($curr_link, sprintf(_("Add %s to my Address Book"), $ad['inner'])) . + Horde::img('addressbook_add.png', sprintf(_("Add %s to my Address Book"), $ad['inner'])) . ''; } $group_array[] = $ret; diff --git a/imp/lib/Views/ListMessages.php b/imp/lib/Views/ListMessages.php index 627e8be6b..28515b898 100644 --- a/imp/lib/Views/ListMessages.php +++ b/imp/lib/Views/ListMessages.php @@ -256,10 +256,8 @@ class IMP_Views_ListMessages /* Get mailbox information. */ $overview = $imp_mailbox->getMailboxArray($msglist, false, array('list-post')); - $charset = NLS::getCharset(); - $identity = &Identity::singleton(array('imp', 'imp')); - $imp_ui = new IMP_UI_Mailbox($folder, $charset, $identity); + $imp_ui = new IMP_UI_Mailbox($folder); /* Display message information. */ reset($overview['overview']); diff --git a/imp/lib/Views/ShowMessage.php b/imp/lib/Views/ShowMessage.php index 902c8bdb4..9f4a06536 100644 --- a/imp/lib/Views/ShowMessage.php +++ b/imp/lib/Views/ShowMessage.php @@ -14,14 +14,13 @@ class IMP_Views_ShowMessage /** * Builds a list of addresses from header information. * - * @param IMP_Headers &$headers The headers object. - * @param array $addrlist The list of addresses from - * MIME::parseAddressList(). + * @param array $addrlist The list of addresses from + * Horde_Mime_Address::parseAddressList(). * * @return array Array with the following keys: address, display, inner, * personal, raw. */ - private function _buildAddressList(&$headers, $addrlist) + private function _buildAddressList($addrlist) { if (empty($addrlist) || !is_array($addrlist)) { return; @@ -31,32 +30,30 @@ class IMP_Views_ShowMessage $call_hook = !empty($GLOBALS['conf']['hooks']['addressformatting']); foreach (Horde_Mime_Address::getAddressesFromObject($addrlist) as $ob) { - if (empty($ob->address) || empty($ob->inner)) { + if (empty($ob['address']) || empty($ob['inner'])) { continue; } /* If this is an incomplete e-mail address, don't link to * anything. */ if ($call_hook) { - $result = Horde::callHook('_dimp_hook_addressformatting', array($ob), 'dimp'); + $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); } - } elseif (stristr($ob->host, 'UNKNOWN') !== false) { - $addr_array[] = array('raw' => htmlspecialchars($ob->address)); } else { $tmp = array(); foreach (array('address', 'display', 'inner', 'personal') as $val) { if ($val == 'display') { - $ob->display = htmlspecialchars($ob->display); - if ($ob->display == $ob->address) { + $ob['display'] = htmlspecialchars($ob['display']); + if ($ob['display'] == $ob['address']) { continue; } } - if (!empty($ob->$val)) { - $tmp[$val] = $ob->$val; + if (!empty($ob[$val])) { + $tmp[$val] = $ob[$val]; } } $addr_array[] = $tmp; @@ -147,6 +144,9 @@ class IMP_Views_ShowMessage return $result; } + $envelope = $fetch_ret[$index]['envelope']; + $mime_headers = reset($fetch_ret[$index]['headertext']); + /* Get the IMP_UI_Message:: object. */ $imp_ui = new IMP_UI_Message(); @@ -167,7 +167,7 @@ class IMP_Views_ShowMessage foreach (array('from', 'to', 'cc', 'bcc', 'reply-to') as $val) { if (isset($basic_headers[$val]) && (!$preview || !in_array($val, array('bcc', 'reply-to')))) { - $tmp = $this->_buildAddressList($imp_headers, $ob->addrlist[$val]); + $tmp = $this->_buildAddressList($envelope[$val]); if (!empty($tmp)) { $result[$val] = $tmp; } elseif ($val == 'to') { @@ -194,10 +194,10 @@ class IMP_Views_ShowMessage unset($result['reply-to']); } $headers[] = array('id' => String::ucfirst($head), 'name' => $str, 'value' => ''); - } elseif ($val = $imp_headers->getValue($head)) { + } elseif ($val = $mime_headers->getValue($head)) { if ($head == 'date') { /* Add local time to date header. */ - $val = nl2br($imp_headers->addLocalTime(htmlspecialchars($val))); + $val = nl2br($imp_ui->addLocalTime($envelope['date'])); if ($preview) { $result['fulldate'] = $val; } @@ -214,7 +214,7 @@ class IMP_Views_ShowMessage if (!$preview) { $user_hdrs = $imp_ui->getUserHeaders(); if (!empty($user_hdrs)) { - $full_h = $imp_headers->getAllHeaders(); + $full_h = $mime_headers->getAllHeaders(); foreach ($user_hdrs as $user_hdr) { foreach ($full_h as $head => $val) { if (stristr($head, $user_hdr) !== false) { @@ -227,7 +227,7 @@ class IMP_Views_ShowMessage } /* Process the subject. */ - if (($subject = $imp_headers->getValue('subject'))) { + if (($subject = $mime_headers->getValue('subject'))) { require_once 'Horde/Text.php'; $subject = Text::htmlSpaces(IMP::filterText($subject)); } else { @@ -235,13 +235,13 @@ class IMP_Views_ShowMessage } $result['subject'] = $subject; - /* Get X-Priority/ */ - $result['priority'] = $imp_headers->getXpriority(); + /* Get X-Priority. */ + $result['priority'] = $imp_ui->getXpriority($mime_headers); /* Add attachment info. */ $atc_display = $GLOBALS['prefs']->getValue('attachment_display'); $show_parts = (!empty($attachments) && (($atc_display == 'list') || ($atc_display == 'both'))); - $downloadall_link = $imp_contents->getDownloadAllLink(); +// $downloadall_link = $imp_contents->getDownloadAllLink(); if ($attachments && ($show_parts || $downloadall_link)) { $result['atc_label'] = sprintf(ngettext("%d Attachment", "%d Attachments", @@ -296,7 +296,7 @@ class IMP_Views_ShowMessage /* Retrieve any history information for this message. */ if (!empty($GLOBALS['conf']['maillog']['use_maillog'])) { if (!$preview) { - IMP_Maillog::displayLog($imp_headers->getValue('message-id')); + IMP_Maillog::displayLog($mime_headers->getValue('message-id')); } /* Do MDN processing now. */ diff --git a/imp/mailbox-mimp.php b/imp/mailbox-mimp.php index 02c736ccd..7f8bd26bf 100644 --- a/imp/mailbox-mimp.php +++ b/imp/mailbox-mimp.php @@ -78,13 +78,12 @@ if ($pageOb['msgcount']) { $unseen = $imp_mailbox->unseenMessages(true); } -$charset = NLS::getCharset(); $curr_time = time(); $curr_time -= $curr_time % 60; $msgs = array(); $sortpref = IMP::getSort($imp_mbox['mailbox']); -$imp_ui = new IMP_UI_Mailbox($imp_mbox['mailbox'], $charset, $identity); +$imp_ui = new IMP_UI_Mailbox($imp_mbox['mailbox']); /* Build the array of message information. */ $mbox_info = $imp_mailbox->getMailboxArray(range($pageOb['begin'], $pageOb['end'])); diff --git a/imp/mailbox.php b/imp/mailbox.php index 7dcdf535b..d1a099302 100644 --- a/imp/mailbox.php +++ b/imp/mailbox.php @@ -73,9 +73,6 @@ if (!is_array(($indices = Util::getFormData('indices')))) { /* Set the current time zone. */ NLS::setTimeZone(); -/* Cache the charset. */ -$charset = NLS::getCharset(); - /* Initialize the user's identities. */ require_once 'Horde/Identity.php'; $identity = &Identity::singleton(array('imp', 'imp')); @@ -678,8 +675,7 @@ if ($pageOb['msgcount']) { /* Cache some repetitively used variables. */ $fromlinkstyle = $prefs->getValue('from_link'); - -$imp_ui = new IMP_UI_Mailbox($imp_mbox['mailbox'], $charset, $identity); +$imp_ui = new IMP_UI_Mailbox($imp_mbox['mailbox']); /* Display message information. */ require_once 'Horde/Text.php'; diff --git a/imp/message.php b/imp/message.php index 234b74eb8..f92cfbe33 100644 --- a/imp/message.php +++ b/imp/message.php @@ -19,10 +19,10 @@ function _returnToMailbox($startIndex = null, $actID = null) $from_message_page = true; $start = null; - if ($startIndex !== null) { + if (!is_null($startIndex)) { $start = $startIndex; } - if ($actID !== null) { + if (!is_null($actID)) { $actionID = $actID; } } diff --git a/imp/templates/index/index.inc b/imp/templates/index/index.inc index f95e2bd46..c14cc667b 100644 --- a/imp/templates/index/index.inc +++ b/imp/templates/index/index.inc @@ -18,7 +18,7 @@ $attachment = Horde::img('attachment.png', '', array('class' => 'attachmentImage $thread_imgs = IMP_IMAP_Thread::getImageUrls(); // Attachment images -$imp_ui = new IMP_UI_Mailbox(); +$imp_ui = new IMP_UI_Mailbox('INBOX'); $atc_imgs = array(); foreach ($imp_ui->getAttachmentAltList() as $k => $v) { $atc_imgs[] = Horde::img($k . '.png', $v, array('id' => 'atc_img_' . $k));
' . - '' . htmlspecialchars($from_res['from'], ENT_QUOTES, $charset) . '
' . + $html .= '
' . + '' . htmlspecialchars($from['from'], ENT_QUOTES, $charset) . '
' . $subject . '
' . htmlspecialchars($date, ENT_QUOTES, $charset) . '
' . $text . '