From: Michael M Slusarz Date: Wed, 18 Aug 2010 07:45:31 +0000 (-0600) Subject: Implement Countable interface for IMP_Indices:: X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=a5fc25ac47ede9d08e683a5cd6112f5e00925e03;p=horde.git Implement Countable interface for IMP_Indices:: --- diff --git a/imp/lib/Ajax/Application.php b/imp/lib/Ajax/Application.php index 4a2e23113..bcb44ff7a 100644 --- a/imp/lib/Ajax/Application.php +++ b/imp/lib/Ajax/Application.php @@ -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; } diff --git a/imp/lib/Compose.php b/imp/lib/Compose.php index 493912079..fa5ce5aa1 100644 --- a/imp/lib/Compose.php +++ b/imp/lib/Compose.php @@ -1712,7 +1712,7 @@ class IMP_Compose */ public function attachIMAPMessage($indices) { - if (!$indices->count()) { + if (!count($indices)) { return false; } diff --git a/imp/lib/Filter.php b/imp/lib/Filter.php index 018cef81b..ff111c1d1 100644 --- a/imp/lib/Filter.php +++ b/imp/lib/Filter.php @@ -106,7 +106,7 @@ class IMP_Filter */ protected function _processBWlist($indices, $descrip, $reg1, $reg2, $link) { - if (!$indices->count()) { + if (!count($indices)) { return false; } diff --git a/imp/lib/Indices.php b/imp/lib/Indices.php index 04c7ca8c1..208af0829 100644 --- a/imp/lib/Indices.php +++ b/imp/lib/Indices.php @@ -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. diff --git a/imp/lib/LoginTasks/Task/PurgeSentmail.php b/imp/lib/LoginTasks/Task/PurgeSentmail.php index e24334667..2fe6d6b57 100644 --- a/imp/lib/LoginTasks/Task/PurgeSentmail.php +++ b/imp/lib/LoginTasks/Task/PurgeSentmail.php @@ -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 { diff --git a/imp/lib/LoginTasks/Task/PurgeTrash.php b/imp/lib/LoginTasks/Task/PurgeTrash.php index 1ad6ba763..d72ac1688 100644 --- a/imp/lib/LoginTasks/Task/PurgeTrash.php +++ b/imp/lib/LoginTasks/Task/PurgeTrash.php @@ -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; } diff --git a/imp/lib/Mailbox.php b/imp/lib/Mailbox.php index f560c7cc5..ce7acd3b6 100644 --- a/imp/lib/Mailbox.php +++ b/imp/lib/Mailbox.php @@ -751,7 +751,7 @@ class IMP_Mailbox return; } - if (!$indices->count()) { + if (!count($indices)) { return; } diff --git a/imp/lib/Message.php b/imp/lib/Message.php index 98f57830f..63fb71d04 100644 --- a/imp/lib/Message.php +++ b/imp/lib/Message.php @@ -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; } diff --git a/imp/lib/Mime/Viewer/Partial.php b/imp/lib/Mime/Viewer/Partial.php index 08e02d1b2..883c59c21 100644 --- a/imp/lib/Mime/Viewer/Partial.php +++ b/imp/lib/Mime/Viewer/Partial.php @@ -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")), diff --git a/imp/lib/Spam.php b/imp/lib/Spam.php index bb0c904d8..e72416e12 100644 --- a/imp/lib/Spam.php +++ b/imp/lib/Spam.php @@ -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; } diff --git a/imp/mailbox.php b/imp/mailbox.php index 3de12f514..0ed048aec 100644 --- a/imp/mailbox.php +++ b/imp/mailbox.php @@ -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']); } diff --git a/imp/message.php b/imp/message.php index 9fa8b46cc..94374b331 100644 --- a/imp/message.php +++ b/imp/message.php @@ -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']); diff --git a/imp/rss.php b/imp/rss.php index 9de575ad0..2240181f4 100644 --- a/imp/rss.php +++ b/imp/rss.php @@ -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'))); diff --git a/imp/thread.php b/imp/thread.php index 78f50a895..ce37deab8 100644 --- a/imp/thread.php +++ b/imp/thread.php @@ -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; } }