Implement Countable interface for IMP_Indices::
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 18 Aug 2010 07:45:31 +0000 (01:45 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 18 Aug 2010 07:47:16 +0000 (01:47 -0600)
14 files changed:
imp/lib/Ajax/Application.php
imp/lib/Compose.php
imp/lib/Filter.php
imp/lib/Indices.php
imp/lib/LoginTasks/Task/PurgeSentmail.php
imp/lib/LoginTasks/Task/PurgeTrash.php
imp/lib/Mailbox.php
imp/lib/Message.php
imp/lib/Mime/Viewer/Partial.php
imp/lib/Spam.php
imp/mailbox.php
imp/message.php
imp/rss.php
imp/thread.php

index 4a2e231..bcb44ff 100644 (file)
@@ -568,7 +568,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
     public function moveMessages()
     {
         $indices = new IMP_Indices($this->_vars->uid);
-        if (!$this->_vars->mboxto || !$indices->count()) {
+        if (!$this->_vars->mboxto || !count($indices)) {
             return false;
         }
 
@@ -622,7 +622,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
     public function copyMessages()
     {
         $indices = new IMP_Indices($this->_vars->uid);
-        if (!$this->_vars->mboxto || !$indices->count()) {
+        if (!$this->_vars->mboxto || !count($indices)) {
             return false;
         }
 
@@ -657,7 +657,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
     public function flagMessages()
     {
         $indices = new IMP_Indices($this->_vars->uid);
-        if (!$this->_vars->flags || !$indices->count()) {
+        if (!$this->_vars->flags || !count($indices)) {
             return false;
         }
 
@@ -718,7 +718,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
     public function deleteMessages()
     {
         $indices = new IMP_Indices($this->_vars->uid);
-        if (!$indices->count()) {
+        if (!count($indices)) {
             return false;
         }
 
@@ -812,7 +812,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
     public function blacklist()
     {
         $indices = new IMP_Indices($this->_vars->uid);
-        if (!$indices->count()) {
+        if (!count($indices)) {
             return false;
         }
 
@@ -1253,7 +1253,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
 
         $expunged = $GLOBALS['injector']->getInstance('IMP_Message')->expungeMailbox(array($this->_vars->view => 1), array('list' => true));
 
-        if (!($expunge_count = $expunged->count())) {
+        if (!($expunge_count = count($expunged))) {
             return false;
         }
 
@@ -1326,7 +1326,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
     public function stripAttachment()
     {
         $indices = new IMP_Indices($this->_vars->uid);
-        if ($indices->count() != 1) {
+        if (count($indices) != 1) {
             return false;
         }
 
index 4939120..fa5ce5a 100644 (file)
@@ -1712,7 +1712,7 @@ class IMP_Compose
      */
     public function attachIMAPMessage($indices)
     {
-        if (!$indices->count()) {
+        if (!count($indices)) {
             return false;
         }
 
index 018cef8..ff111c1 100644 (file)
@@ -106,7 +106,7 @@ class IMP_Filter
      */
     protected function _processBWlist($indices, $descrip, $reg1, $reg2, $link)
     {
-        if (!$indices->count()) {
+        if (!count($indices)) {
             return false;
         }
 
index 04c7ca8..208af08 100644 (file)
@@ -13,7 +13,7 @@
  * @license  http://www.fsf.org/copyleft/gpl.html GPL
  * @package  IMP
  */
-class IMP_Indices implements Iterator
+class IMP_Indices implements Countable, Iterator
 {
     /**
      * The indices list.
index e243346..2fe6d6b 100644 (file)
@@ -61,7 +61,7 @@ class IMP_LoginTasks_Task_PurgeSentmail extends Horde_LoginTasks_Task
 
             /* Go through the message list and delete the messages. */
             if ($imp_message->delete($msg_ids, array('nuke' => true))) {
-                $msgcount = $msg_ids->count();
+                $msgcount = count($msg_ids);
                 if ($msgcount == 1) {
                     $GLOBALS['notification']->push(sprintf(_("Purging 1 message from sent-mail folder %s."), IMP::displayFolder($mbox)), 'horde.message');
                 } else {
index 1ad6ba7..d72ac16 100644 (file)
@@ -59,7 +59,7 @@ class IMP_LoginTasks_Task_PurgeTrash extends Horde_LoginTasks_Task
 
         /* Go through the message list and delete the messages. */
         if ($GLOBALS['injector']->getInstance('IMP_Message')->delete($msg_ids, array('nuke' => true))) {
-            $msgcount = $msg_ids->count();
+            $msgcount = count($msg_ids);
             $GLOBALS['notification']->push(sprintf(ngettext("Purging %d message from Trash folder.", "Purging %d messages from Trash folder.", $msgcount), $msgcount), 'horde.message');
             return true;
         }
index f560c7c..ce7acd3 100644 (file)
@@ -751,7 +751,7 @@ class IMP_Mailbox
             return;
         }
 
-        if (!$indices->count()) {
+        if (!count($indices)) {
             return;
         }
 
index 98f5783..63fb71d 100644 (file)
@@ -58,7 +58,7 @@ class IMP_Message
     {
         global $conf, $notification, $prefs;
 
-        if (!$indices->count()) {
+        if (!count($indices)) {
             return false;
         }
 
@@ -175,7 +175,7 @@ class IMP_Message
     {
         global $conf, $notification, $prefs;
 
-        if (!$indices->count()) {
+        if (!count($indices)) {
             return false;
         }
 
@@ -591,7 +591,7 @@ class IMP_Message
      */
     public function flag($flags, $indices, $action = true)
     {
-        if (!$indices->count()) {
+        if (!count($indices)) {
             return false;
         }
 
index 08e02d1..883c59c 100644 (file)
@@ -91,7 +91,7 @@ class IMP_Mime_Viewer_Partial extends Horde_Mime_Viewer_Base
 
         /* If not able to find the other parts of the message, prepare a
          * status message. */
-        $msg_count = $indices->count();
+        $msg_count = count($indices);
         if ($msg_count != $total) {
             self::$_statuscache[$this->_mimepart->getMimeId()] = array(
                 'icon' => Horde::img('alerts/error.png', _("Error")),
index bb0c904..e72416e 100644 (file)
@@ -37,7 +37,7 @@ class IMP_Spam
         /* Abort immediately if spam reporting has not been enabled, or if
          * there are no messages. */
         if (empty($GLOBALS['conf'][$action]['reporting']) ||
-            !$indices->count()) {
+            !count($indices)) {
             return 0;
         }
 
index 3de12f5..0ed048a 100644 (file)
@@ -121,7 +121,7 @@ case 'message_missing':
     break;
 
 case 'fwd_digest':
-    if ($indices->count()) {
+    if (count($indices)) {
         $options = array_merge(array(
             'actionID' => 'fwd_digest',
             'fwddigest' => strval($indices)
@@ -147,7 +147,7 @@ case 'undelete_messages':
 
 case 'move_messages':
 case 'copy_messages':
-    if (isset($vars->targetMbox) && $indices->count()) {
+    if (isset($vars->targetMbox) && count($indices)) {
         if (!empty($vars->newMbox) && ($vars->newMbox == 1)) {
             $targetMbox = IMP::folderPref($vars->targetMbox, true);
             $newMbox = true;
@@ -161,7 +161,7 @@ case 'copy_messages':
 
 case 'flag_messages':
     $flag = Horde_Util::getPost('flag');
-    if ($flag && $indices->count()) {
+    if ($flag && count($indices)) {
         $flag = $imp_flags->parseFormId($flag);
         $injector->getInstance('IMP_Message')->flag(array($flag['flag']), $indices, $flag['set']);
     }
index 9fa8b46..94374b3 100644 (file)
@@ -138,7 +138,7 @@ case 'notspam_report':
     break;
 
 case 'flag_message':
-    if (isset($vars->flag) && $indices->count()) {
+    if (isset($vars->flag) && count($indices)) {
         $peek = true;
         $flag = $imp_flags->parseFormId($vars->flag);
         $imp_message->flag(array($flag['flag']), $indices, $flag['set']);
index 9de575a..2240181 100644 (file)
@@ -61,7 +61,7 @@ if ($new_mail) {
 }
 $ids = $imp_search->runSearchQuery($query, $mailbox, Horde_Imap_Client::SORT_ARRIVAL, 1);
 
-if ($ids->count()) {
+if (count($ids)) {
     $imp_ui = new IMP_Ui_Mailbox(IMP::$mailbox);
 
     $overview = $imp_mailbox->getMailboxArray(array_slice(reset($ids->indices()), 0, 20), array('preview' => $prefs->getValue('preview_enabled')));
index 78f50a8..ce37dea 100644 (file)
@@ -39,7 +39,7 @@ if ($mode == 'thread') {
 } else {
     /* MSGVIEW MODE: Make sure we have a valid list of messages. */
     $imp_indices = new IMP_Indices($vars->msglist);
-    if (!$imp_indices->count()) {
+    if (!count($imp_indices)) {
         $error = true;
     }
 }