From c1c83a020df92ae83a518417772934795200529a Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Thu, 18 Dec 2008 16:34:02 -0700 Subject: [PATCH] No need for move and copy to be constants --- imp/ajax.php | 2 +- imp/lib/Message.php | 27 +++++++++++---------------- imp/lib/Spam.php | 2 +- imp/mailbox.php | 3 +-- imp/message.php | 4 +--- 5 files changed, 15 insertions(+), 23 deletions(-) diff --git a/imp/ajax.php b/imp/ajax.php index a1ef86e79..7c558922b 100644 --- a/imp/ajax.php +++ b/imp/ajax.php @@ -347,7 +347,7 @@ case 'CopyMessage': $imp_message = &IMP_Message::singleton(); - $result = $imp_message->copy($to, ($action == 'MoveMessage') ? IMP_MESSAGE::MOVE : IMP_MESSAGE::COPY, $indices); + $result = $imp_message->copy($to, ($action == 'MoveMessage') ? 'move' : 'copy', $indices); if ($result) { if ($action == 'MoveMessage') { diff --git a/imp/lib/Message.php b/imp/lib/Message.php index 606b3d358..edda67c60 100644 --- a/imp/lib/Message.php +++ b/imp/lib/Message.php @@ -18,10 +18,6 @@ */ class IMP_Message { - /* Constants used in copy(). */ - const MOVE = 1; - const COPY = 2; - /** * Using POP to access mailboxes? * @@ -67,8 +63,7 @@ class IMP_Message * * @param string $targetMbox The mailbox to move/copy messages to * (UTF7-IMAP). - * @param integer $action Either IMP_Message::MOVE or - * IMP_Message::COPY. + * @param string $action Either 'copy' or 'move'. * @param mixed $indices See IMP::parseIndicesList(). * @param boolean $new Whether the target mailbox has to be created. * @@ -78,7 +73,7 @@ class IMP_Message { global $conf, $imp_imap, $notification, $prefs; - if (($action == self::MOVE) && $imp_imap->isReadOnly($targetMbox)) { + if (($action == 'move') && $imp_imap->isReadOnly($targetMbox)) { return false; } @@ -111,18 +106,18 @@ class IMP_Message $return_value = true; switch ($action) { - case self::MOVE: + case 'move': $imap_move = true; $message = _("There was an error moving messages from \"%s\" to \"%s\". This is what the server said"); break; - case self::COPY: + case 'copy': $message = _("There was an error copying messages from \"%s\" to \"%s\". This is what the server said"); break; } foreach ($msgList as $mbox => $msgIndices) { - if (($action == self::MOVE) && $imp_imap->isReadOnly($mbox)) { + if (($action == 'move') && $imp_imap->isReadOnly($mbox)) { $notification->push(sprintf($message, IMP::displayFolder($mbox), IMP::displayFolder($targetMbox)) . ': ' . _("The target directory is read-only."), 'horde.error'); $return_value = false; continue; @@ -286,11 +281,11 @@ class IMP_Message * Copies or moves a list of messages to a tasklist or notepad. * Handles use of the IMP::SEARCH_MBOX mailbox and the Trash folder. * - * @param string $list The list in which the task or note will be - * created. - * @param integer $action Either IMP_Message::MOVE or IMP_Message::COPY. - * @param mixed $indices See IMP::parseIndicesList(). - * @param string $type The object type to create, defaults to task. + * @param string $list The list in which the task or note will be + * created. + * @param string $action Either 'copy' or 'move'. + * @param mixed $indices See IMP::parseIndicesList(). + * @param string $type The object type to create, defaults to task. * * @return boolean True if successful, false if not. */ @@ -413,7 +408,7 @@ class IMP_Message } /* Delete the original messages if this is a "move" operation. */ - if ($action == self::MOVE) { + if ($action == 'move') { $this->delete($indices); } diff --git a/imp/lib/Spam.php b/imp/lib/Spam.php index f3c23a8af..1541facd3 100644 --- a/imp/lib/Spam.php +++ b/imp/lib/Spam.php @@ -179,7 +179,7 @@ class IMP_Spam case 2: $targetMbox = ($action == 'spam') ? IMP::folderPref($GLOBALS['prefs']->getValue('spam_folder'), true) : 'INBOX'; if ($targetMbox) { - if ($imp_message->copy($targetMbox, IMP_Message::MOVE, $indices, true) === false) { + if ($imp_message->copy($targetMbox, 'move', $indices, true) === false) { $delete_spam = 0; } } else { diff --git a/imp/mailbox.php b/imp/mailbox.php index d21214e0e..4410fee39 100644 --- a/imp/mailbox.php +++ b/imp/mailbox.php @@ -163,14 +163,13 @@ case 'move_messages': case 'copy_messages': if (!empty($indices) && !empty($targetMbox)) { $imp_message = &IMP_Message::singleton(); - $action = ($actionID == 'move_messages') ? IMP_Message::MOVE : IMP_Message::COPY; if (!empty($newMbox) && ($newMbox == 1)) { $targetMbox = IMP::folderPref($targetMbox, true); $newMbox = true; } else { $newMbox = false; } - $imp_message->copy($targetMbox, $action, $indices, $newMbox); + $imp_message->copy($targetMbox, ($actionID == 'move_messages') ? 'move' : 'copy', $indices, $newMbox); } break; diff --git a/imp/message.php b/imp/message.php index d5e9dec04..fb475a4af 100644 --- a/imp/message.php +++ b/imp/message.php @@ -115,15 +115,13 @@ case 'copy_message': if (($targetMbox = Util::getFormData('targetMbox')) !== null) { $imp_message = &IMP_Message::singleton(); - $action = ($actionID == 'move_message') ? IMP_Message::MOVE : IMP_Message::COPY; - if (Util::getFormData('newMbox', 0) == 1) { $targetMbox = IMP::folderPref($targetMbox, true); $newMbox = true; } else { $newMbox = false; } - $imp_message->copy($targetMbox, $action, $indices_array, $newMbox); + $imp_message->copy($targetMbox, ($actionID == 'move_message') ? 'move' : 'copy', $indices_array, $newMbox); if ($prefs->getValue('mailbox_return')) { _returnToMailbox($imp_mailbox->getMessageIndex()); require IMP_BASE . '/mailbox.php'; -- 2.11.0