diff --git a/imp/lib/Ajax/Application/ShowMessage.php b/imp/lib/Ajax/Application/ShowMessage.php index a7e3e4eb1c0..4b3ef71afe1 100644 --- a/imp/lib/Ajax/Application/ShowMessage.php +++ b/imp/lib/Ajax/Application/ShowMessage.php @@ -22,6 +22,13 @@ */ class IMP_Ajax_Application_ShowMessage { + /** + * Contents object. + * + * @var IMP_Contents + */ + public $contents; + /** * Default list of part info elements to display. * @@ -31,13 +38,6 @@ class IMP_Ajax_Application_ShowMessage 'icon', 'description', 'size', 'download' ); - /** - * Contents object. - * - * @var IMP_Contents - */ - protected $_contents; - /** * Envelope object. * @@ -98,12 +98,11 @@ public function __construct(IMP_Indices $indices, $peek = false) throw new Exception(); } - $imp_contents = $injector->getInstance('IMP_Factory_Contents')->create($indices); + $this->contents = $injector->getInstance('IMP_Factory_Contents')->create($indices); } catch (Exception $e) { throw new IMP_Exception(_("Requested message not found.")); } - $this->_contents = $imp_contents; $this->_envelope = $ob->getEnvelope(); $this->_indices = $indices; $this->_peek = $peek; @@ -129,7 +128,6 @@ public function __construct(IMP_Indices $indices, $peek = false) * - from: (array) The From addresses. * - headers: (array; FULL): An array of user-defined headers. * - js: (array) Javascript code to run on display. - * - list_info: (array; FULL) List information. * - localdate: (string) The date formatted to the user's timezone. * - md: (array) Metadata. * - msgtext: (string) The text of the message. @@ -267,8 +265,8 @@ public function showMessage($args) ? _("Parts") : sprintf(ngettext("%d Attachment", "%d Attachments", count($inlineout['atc_parts'])), count($inlineout['atc_parts'])); if (count($inlineout['atc_parts']) > 1) { - $result['atc']['download'] = strval($this->_contents->urlView( - $this->_contents->getMIMEMessage(), + $result['atc']['download'] = strval($this->contents->urlView( + $this->contents->getMIMEMessage(), 'download_all' )->setRaw(true)); } @@ -291,7 +289,7 @@ public function showMessage($args) $part_info[] = 'description_raw'; $part_info[] = 'download_url'; - $summary = $this->_contents->getSummary($id, $contents_mask); + $summary = $this->contents->getSummary($id, $contents_mask); $tmp = array(); foreach ($part_info as $val) { if (isset($summary[$val])) { @@ -327,11 +325,6 @@ public function showMessage($args) } $result['save_as'] = strval($result['save_as']->setRaw(true)); - } else { - $list_info = $imp_ui->getListInformation($this->_headers); - if (!empty($list_info['exists'])) { - $result['list_info'] = $list_info; - } } /* Add changed flag information. */ @@ -414,7 +407,7 @@ public function getInlineOutput($mimeid = null) $part_info_display[] = 'print'; $inline_ob = new IMP_Contents_InlineOutput(); - return $inline_ob->getInlineOutput($this->_contents, array( + return $inline_ob->getInlineOutput($this->contents, array( 'mask' => $contents_mask, 'mimeid' => $mimeid, 'part_info_display' => $part_info_display @@ -479,8 +472,8 @@ protected function _loadHeaders() { if (!isset($this->_headers)) { $this->_headers = $this->_peek - ? $this->_contents->getHeader() - : $this->_contents->getHeaderAndMarkAsSeen(); + ? $this->contents->getHeader() + : $this->contents->getHeaderAndMarkAsSeen(); } } diff --git a/imp/lib/Compose.php b/imp/lib/Compose.php index 1f56de6767e..77a194a82d0 100644 --- a/imp/lib/Compose.php +++ b/imp/lib/Compose.php @@ -1933,7 +1933,7 @@ public function replyMessage($type, $contents, array $opts = array()) /* We might need $list_info in the reply_all section. */ $list_info = in_array($type, array(self::REPLY_AUTO, self::REPLY_LIST)) - ? $injector->getInstance('IMP_Message_Ui')->getListInformation($h) + ? $contents->getListInformation() : null; if (!is_null($list_info) && !empty($list_info['reply_list'])) { diff --git a/imp/lib/Contents.php b/imp/lib/Contents.php index a686e70e19a..95158c6aa37 100644 --- a/imp/lib/Contents.php +++ b/imp/lib/Contents.php @@ -1379,4 +1379,45 @@ public function getViewCache() return $this->_viewcache; } + /** + * Returns mailing list information for the message. + * + * @return array An array with 2 elements: + *
+     *   - exists: (boolean) True if this is a mailing list message.
+     *   - reply_list: (string) If non-null, the e-mail address to use to post
+     *                 to the list.
+     * 
+ */ + public function getListInformation() + { + global $injector; + + $headers = $this->getHeader(); + $lh = $injector->getInstance('Horde_ListHeaders'); + $ret = array( + 'exists' => false, + 'reply_list' => null + ); + + if ($lh->listHeadersExist($headers)) { + $ret['exists'] = true; + + /* See if the List-Post header provides an e-mail address for the + * list. */ + if ($val = $headers['List-Post']) { + foreach ($lh->parse('list-post', $val->value) as $val2) { + if ($val2 instanceof Horde_ListHeaders_NoPost) { + break; + } elseif (stripos($val2->url, 'mailto:') === 0) { + $ret['reply_list'] = substr($val2->url, 7); + break; + } + } + } + } + + return $ret; + } + } diff --git a/imp/lib/Dynamic/Message.php b/imp/lib/Dynamic/Message.php index b17a5255ae0..32f3fb0d95b 100644 --- a/imp/lib/Dynamic/Message.php +++ b/imp/lib/Dynamic/Message.php @@ -87,7 +87,9 @@ protected function _init() $js_vars['ImpMessage.' . $val] = $msg_res[$val]; } } - if (!empty($msg_res['list_info']['exists'])) { + + $list_info = $show_msg->contents->getListInformation(); + if (!empty($list_info['exists'])) { $js_vars['ImpMessage.reply_list'] = true; $this->view->listinfo = Horde::popupJs( IMP_Basic_Listinfo::url(array( diff --git a/imp/lib/Message/Ui.php b/imp/lib/Message/Ui.php index d9f5df73cf3..a9d1e676863 100644 --- a/imp/lib/Message/Ui.php +++ b/imp/lib/Message/Ui.php @@ -39,36 +39,4 @@ public function basicHeaders() ); } - /** - * Returns e-mail information for a mailing list. - * - * @param Horde_Mime_Headers $headers A Horde_Mime_Headers object. - * - * @return array An array with 2 elements: 'exists' and 'reply_list'. - */ - public function getListInformation($headers) - { - $lh = $GLOBALS['injector']->getInstance('Horde_ListHeaders'); - $ret = array('exists' => false, 'reply_list' => null); - - if ($lh->listHeadersExist($headers)) { - $ret['exists'] = true; - - /* See if the List-Post header provides an e-mail address for the - * list. */ - if ($val = $headers['List-Post']) { - foreach ($lh->parse('list-post', $val->value) as $val2) { - if ($val2 instanceof Horde_ListHeaders_NoPost) { - break; - } elseif (stripos($val2->url, 'mailto:') === 0) { - $ret['reply_list'] = substr($val2->url, 7); - break; - } - } - } - } - - return $ret; - } - } diff --git a/imp/lib/Mime/Viewer/Plain.php b/imp/lib/Mime/Viewer/Plain.php index 90e477c9936..df35b651d74 100644 --- a/imp/lib/Mime/Viewer/Plain.php +++ b/imp/lib/Mime/Viewer/Plain.php @@ -60,7 +60,9 @@ protected function _impRender($inline) { global $injector, $prefs, $registry; - $cache = $this->getConfigParam('imp_contents')->getViewCache(); + $contents = $this->getConfigParam('imp_contents'); + + $cache = $contents->getViewCache(); $mime_id = $this->_mimepart->getMimeId(); if (isset($cache->plain[$mime_id])) { @@ -120,8 +122,7 @@ protected function _impRender($inline) (($show == 'thread') && ($injector->getInstance('Horde_Variables')->page == 'thread'))); if (!$hideBlocks && in_array($show, array('list', 'listthread'))) { - $header = $this->getConfigParam('imp_contents')->getHeader(); - $list_info = $injector->getInstance('IMP_Message_Ui')->getListInformation($header); + $list_info = $contents->getListInformation(); $hideBlocks = $list_info['exists']; } }