Implement Countable for IMP_Mailbox::.
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 19 Aug 2010 21:17:03 +0000 (15:17 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 20 Aug 2010 16:15:10 +0000 (10:15 -0600)
Remove unused getMailboxName() function.

imp/lib/Mailbox.php
imp/message-mimp.php
imp/message.php
imp/rss.php

index ce7acd3..885a20a 100644 (file)
@@ -13,7 +13,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Mailbox
+class IMP_Mailbox implements Countable
 {
     /**
      * The mailbox to work with.
@@ -115,16 +115,6 @@ class IMP_Mailbox
     }
 
     /**
-     * The mailbox this object works with.
-     *
-     * @return string  A mailbox name.
-     */
-    public function getMailboxName()
-    {
-        return $this->_mailbox;
-    }
-
-    /**
      * Build the array of message information.
      *
      * @param array $msgnum   An array of message sequence numbers.
@@ -383,7 +373,7 @@ class IMP_Mailbox
                 $this->_searchmbox &&
                 ($type == 'unseen') &&
                 $GLOBALS['injector']->getInstance('IMP_Search')->isVINBOXFolder($this->_mailbox)) {
-                return $this->getMessageCount();
+                return count($this);
             }
 
             return $count ? 0 : array();
@@ -429,17 +419,6 @@ class IMP_Mailbox
     }
 
     /**
-     * Returns the current message count of the mailbox.
-     *
-     * @return integer  The mailbox message count.
-     */
-    public function getMessageCount()
-    {
-        $this->_buildMailbox();
-        return count($this->_sorted);
-    }
-
-    /**
      * Checks to see if the current index is valid.
      * This function is only useful if an index was passed to the constructor.
      *
@@ -804,4 +783,17 @@ class IMP_Mailbox
         return time() . mt_rand();
     }
 
+    /* Countable methods. */
+
+    /**
+     * Returns the current message count of the mailbox.
+     *
+     * @return integer  The mailbox message count.
+     */
+    public function count()
+    {
+        $this->_buildMailbox();
+        return count($this->_sorted);
+    }
+
 }
index 9201e26..8f9e8b6 100644 (file)
@@ -128,7 +128,7 @@ try {
 
 /* Get the starting index for the current message and the message count. */
 $msgindex = $imp_mailbox->getMessageIndex();
-$msgcount = $imp_mailbox->getMessageCount();
+$msgcount = count($imp_mailbox);
 
 /* Generate the mailbox link. */
 $mailbox_link = IMP::generateIMPUrl('mailbox-mimp.php', IMP::$mailbox)->add('s', $msgindex);
index 57079bd..eba2659 100644 (file)
@@ -178,7 +178,7 @@ $message_token = Horde::getRequestToken('imp.message');
  * message array, so we will return to mailbox.php if that is the
  * case. */
 if (!$imp_mailbox->isValidIndex()) {
-    _returnToMailbox($imp_mailbox->getMessageCount());
+    _returnToMailbox(count($imp_mailbox));
     require IMP_BASE . '/mailbox.php';
     exit;
 }
@@ -414,7 +414,7 @@ $t_template->set('thismailbox', htmlspecialchars($mailbox_name));
 $t_template->set('start', htmlspecialchars($msgindex));
 $t_template->set('uid', htmlspecialchars($uid));
 $t_template->set('label', sprintf(_("%s: %s"), $header_label, $shortsub));
-$t_template->set('msg_count', sprintf(_("(%d&nbsp;of&nbsp;%d)"), $msgindex, $imp_mailbox->getMessageCount()));
+$t_template->set('msg_count', sprintf(_("(%d&nbsp;of&nbsp;%d)"), $msgindex, count($imp_mailbox)));
 $t_template->set('status', $status);
 $t_template->set('message_token', $message_token);
 
index 2240181..c000758 100644 (file)
@@ -50,9 +50,9 @@ $imp_mailbox = $injector->getInstance('IMP_Mailbox')->getOb($mailbox);
 $imp_search = $injector->getInstance('IMP_Search');
 
 /* Obtain some information describing the mailbox state. */
-$total_num = $imp_mailbox->getMessageCount();
+$total_num = count($imp_mailbox);
 $unseen_num = ($imp_search->isVINBOXFolder($mailbox))
-    ? $imp_mailbox->getMessageCount()
+    ? $total_num
     : $imp_mailbox->unseenMessages(Horde_Imap_Client::SORT_RESULTS_COUNT);
 
 $query = new Horde_Imap_Client_Search_Query();