No need for move and copy to be constants
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 18 Dec 2008 23:34:02 +0000 (16:34 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 18 Dec 2008 23:34:02 +0000 (16:34 -0700)
imp/ajax.php
imp/lib/Message.php
imp/lib/Spam.php
imp/mailbox.php
imp/message.php

index a1ef86e..7c55892 100644 (file)
@@ -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') {
index 606b3d3..edda67c 100644 (file)
  */
 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);
         }
 
index f3c23a8..1541fac 100644 (file)
@@ -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 {
index d21214e..4410fee 100644 (file)
@@ -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;
 
index d5e9dec..fb475a4 100644 (file)
@@ -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';