From 0b323e03586865781592a52370148f23636239b9 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 26 Jan 2010 13:38:25 -0700 Subject: [PATCH] Remove Imp_Imap_Tree::getElementInfo(). It no longer provides any added value to a Horde_Imap_Client_Base::status() call. --- imp/folders.php | 8 +++++++- imp/lib/Ajax/Application.php | 19 ++++++++++++++----- imp/lib/Imap/Tree.php | 38 +++++++++----------------------------- imp/lib/Views/ListMessages.php | 10 +++++----- 4 files changed, 35 insertions(+), 40 deletions(-) diff --git a/imp/folders.php b/imp/folders.php index 0e1e0e131..7c23800f0 100644 --- a/imp/folders.php +++ b/imp/folders.php @@ -253,7 +253,13 @@ case 'folders_empty_mailbox_confirm': $notification->push(sprintf(_("The folder \"%s\" may not be deleted."), IMP::displayFolder($val)), 'horde.error'); continue; } - $elt_info = $imaptree->getElementInfo($val); + + try { + $elt_info = $imp_imap->ob()->status($val, Horde_Imap_Client::STATUS_MESSAGES); + } catch (Horde_Imap_Client_Exception $e) { + $elt_info = null; + } + $data = array( 'class' => (++$rowct % 2) ? 'item0' : 'item1', 'name' => htmlspecialchars(IMP::displayFolder($val)), diff --git a/imp/lib/Ajax/Application.php b/imp/lib/Ajax/Application.php index 187f05cf5..f42759257 100644 --- a/imp/lib/Ajax/Application.php +++ b/imp/lib/Ajax/Application.php @@ -403,9 +403,11 @@ class IMP_Ajax_Application extends Horde_Ajax_Application_Base if ($vars->add) { $imptree->addPollList($vars->view); - if ($info = $imptree->getElementInfo($vars->view)) { - $result->poll = array($vars->view => intval($info['unseen'])); - } + try { + if ($info = $GLOBALS['imp_imap']->ob()->status($vars->view, Horde_Imap_Client::STATUS_UNSEEN)) { + $result->poll = array($vars->view => intval($info['unseen'])); + } + } catch (Horde_Imap_Client_Exception $e) {} $GLOBALS['notification']->push(sprintf(_("\"%s\" mailbox now polled for new mail."), $display_folder), 'horde.success'); } else { $imptree->removePollList($vars->view); @@ -1507,8 +1509,15 @@ class IMP_Ajax_Application extends Horde_Ajax_Application_Base return array(); } - $info = $imptree->getElementInfo($mbox); - return array($mbox => isset($info['unseen']) ? intval($info['unseen']) : 0); + try { + $count = ($info = $GLOBALS['imp_imap']->ob()->status($mbox, Horde_Imap_Client::STATUS_UNSEEN)) + ? intval($info['unseen']) + : 0; + } catch (Horde_Imap_Client_Exception $e) { + $count = 0; + } + + return array($mbox => $count); } /** diff --git a/imp/lib/Imap/Tree.php b/imp/lib/Imap/Tree.php index 9562b1a4d..58a5ee446 100644 --- a/imp/lib/Imap/Tree.php +++ b/imp/lib/Imap/Tree.php @@ -1398,27 +1398,6 @@ class IMP_Imap_Tree } /** - * Get information about new/unseen/total messages for the given element. - * - * @param string $name The element name (UTF7-IMAP). - * - * @return array Array with the following fields: - *
-     * 'messages' - (integer) Number of total messages.
-     * 'recent' - (integer) Number of new messages.
-     * 'unseen' - (integer) Number of unseen messages.
-     * 
- */ - public function getElementInfo($name) - { - try { - return $GLOBALS['imp_imap']->ob()->status($name, Horde_Imap_Client::STATUS_MESSAGES | Horde_Imap_Client::STATUS_RECENT | Horde_Imap_Client::STATUS_UNSEEN); - } catch (Horde_Imap_Client_Exception $e) { - return array(); - } - } - - /** * Sorts a list of mailboxes. * * @param array &$mbox The list of mailboxes to sort. @@ -1933,15 +1912,16 @@ class IMP_Imap_Tree if ($this->isPolled($mailbox)) { /* If we need message information for this folder, update * it now. */ - $msgs_info = $this->getElementInfo($mailbox['v']); - if (!empty($msgs_info)) { - $row['polled'] = true; - if (!empty($msgs_info['recent'])) { - $row['recent'] = $msgs_info['recent']; + try { + if ($msgs_info = $GLOBALS['imp_imap']->ob()->status($mailbox['v'], Horde_Imap_Client::STATUS_RECENT | Horde_Imap_Client::STATUS_UNSEEN | Horde_Imap_Client::STATUS_MESSAGES)) { + $row['polled'] = true; + if (!empty($msgs_info['recent'])) { + $row['recent'] = $msgs_info['recent']; + } + $row['msgs'] = $msgs_info['messages']; + $row['unseen'] = $msgs_info['unseen']; } - $row['msgs'] = $msgs_info['messages']; - $row['unseen'] = $msgs_info['unseen']; - } + } catch (Horde_Imap_Client_Exception $e) {} } switch ($mailbox['v']) { diff --git a/imp/lib/Views/ListMessages.php b/imp/lib/Views/ListMessages.php index 7ed6b9397..38943c807 100644 --- a/imp/lib/Views/ListMessages.php +++ b/imp/lib/Views/ListMessages.php @@ -275,11 +275,11 @@ class IMP_Views_ListMessages /* Get unseen/thread information. */ if (!$is_search) { - $imptree = IMP_Imap_Tree::singleton(); - $info = $imptree->getElementInfo($mbox); - if (!empty($info)) { - $md->unseen = intval($info['unseen']); - } + try { + if ($info = $GLOBALS['imp_imap']->ob()->status($mbox, Horde_Imap_Client::STATUS_UNSEEN)) { + $md->unseen = intval($info['unseen']); + } + } catch (Horde_Imap_Client_Exception $e) {} if ($sortpref['by'] == Horde_Imap_Client::SORT_THREAD) { $threadob = $imp_mailbox->getThreadOb(); -- 2.11.0