From: Michael M Slusarz Date: Thu, 19 Aug 2010 21:17:03 +0000 (-0600) Subject: Implement Countable for IMP_Mailbox::. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=25153d6653f2e669a837b28e53da031e56f5d1ee;p=horde.git Implement Countable for IMP_Mailbox::. Remove unused getMailboxName() function. --- diff --git a/imp/lib/Mailbox.php b/imp/lib/Mailbox.php index ce7acd3b6..885a20a03 100644 --- a/imp/lib/Mailbox.php +++ b/imp/lib/Mailbox.php @@ -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); + } + } diff --git a/imp/message-mimp.php b/imp/message-mimp.php index 9201e26b8..8f9e8b6f1 100644 --- a/imp/message-mimp.php +++ b/imp/message-mimp.php @@ -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); diff --git a/imp/message.php b/imp/message.php index 57079bdf5..eba265962 100644 --- a/imp/message.php +++ b/imp/message.php @@ -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 of %d)"), $msgindex, $imp_mailbox->getMessageCount())); +$t_template->set('msg_count', sprintf(_("(%d of %d)"), $msgindex, count($imp_mailbox))); $t_template->set('status', $status); $t_template->set('message_token', $message_token); diff --git a/imp/rss.php b/imp/rss.php index 2240181f4..c000758ad 100644 --- a/imp/rss.php +++ b/imp/rss.php @@ -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();