Remove Imp_Imap_Tree::getElementInfo().
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 26 Jan 2010 20:38:25 +0000 (13:38 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 26 Jan 2010 20:42:49 +0000 (13:42 -0700)
It no longer provides any added value to a
Horde_Imap_Client_Base::status() call.

imp/folders.php
imp/lib/Ajax/Application.php
imp/lib/Imap/Tree.php
imp/lib/Views/ListMessages.php

index 0e1e0e1..7c23800 100644 (file)
@@ -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)),
index 187f05c..f427592 100644 (file)
@@ -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);
     }
 
     /**
index 9562b1a..58a5ee4 100644 (file)
@@ -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:
-     * <pre>
-     * 'messages' - (integer) Number of total messages.
-     * 'recent' - (integer) Number of new messages.
-     * 'unseen' - (integer) Number of unseen messages.
-     * </pre>
-     */
-    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']) {
index 7ed6b93..38943c8 100644 (file)
@@ -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();