From 180045ab5d9532009e99620fe8f82a64d3a37ae9 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 14 Jan 2015 21:36:15 -0700 Subject: [PATCH] Add addChangedFlag() This should be run by display code (not library code), and only by code that uses it (this is not used on message page). --- imp/lib/Ajax/Queue.php | 2 ++ imp/lib/Contents/Message.php | 27 +++++++++++++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/imp/lib/Ajax/Queue.php b/imp/lib/Ajax/Queue.php index 90505b71ce1..287d5eb0e5b 100644 --- a/imp/lib/Ajax/Queue.php +++ b/imp/lib/Ajax/Queue.php @@ -456,6 +456,8 @@ public function message(IMP_Indices $indices, array $opts = array()) $show_msg = new IMP_Contents_Message($indices, !empty($opts['peek'])); $msg = (object)$show_msg->showMessage(); + $show_msg->addChangedFlag(); + /* Need to grab cached inline scripts. */ Horde::startBuffer(); $page_output->outputInlineScript(true); diff --git a/imp/lib/Contents/Message.php b/imp/lib/Contents/Message.php index 85633a50bc4..dbc6f416a55 100644 --- a/imp/lib/Contents/Message.php +++ b/imp/lib/Contents/Message.php @@ -178,8 +178,6 @@ public function showMessage() $part_info = $this->part_info; $show_parts = $prefs->getValue('parts_display'); - list($mbox,) = $this->_indices->getSingle(); - /* Do MDN processing now. */ switch ($registry->getView()) { case $registry::VIEW_DYNAMIC: @@ -262,15 +260,32 @@ public function showMessage() ) )->setRaw(true); + return $result; + } + + /** + * Add changed flag information to the AJAX queue output, if necessary. + */ + public function addChangedFlag() + { + global $injector; + /* Add changed flag information. */ + list($mbox,) = $this->_indices->getSingle(); if (!$this->_peek && $mbox->is_imap) { - $status = $mbox->imp_imap->status($mbox, Horde_Imap_Client::STATUS_PERMFLAGS); + $status = $mbox->imp_imap->status( + $mbox, + Horde_Imap_Client::STATUS_PERMFLAGS + ); + if (in_array(Horde_Imap_Client::FLAG_SEEN, $status['permflags'])) { - $ajax_queue->flag(array(Horde_Imap_Client::FLAG_SEEN), true, $this->_indices); + $injector->getInstance('IMP_Ajax_Queue')->flag( + array(Horde_Imap_Client::FLAG_SEEN), + true, + $this->_indices + ); } } - - return $result; } /**