fixed a bug in deleting messages where no messages were selected. was putting the
authornehresma <nehresma@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 4 Dec 1999 19:24:02 +0000 (19:24 +0000)
committernehresma <nehresma@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 4 Dec 1999 19:24:02 +0000 (19:24 +0000)
server into an infinite loop.  also started message moving - but is not completely
working yet so don't try it!  :)

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@56 7612ce4b-ef26-0410-bec9-ea0150e637f0

src/move_messages.php

index 154c6610a0141c580a238c0d7f6b6abaafc8f1cc..80e48ac7974bfe10d9a914d0b54e3b1b0034d267 100644 (file)
       // Marks the selected messages ad 'Deleted'
       $j = 0;
       $i = 0;
-      while ($j < count($msg)) {
+      
+      // If they have selected nothing msg is size one still, but will be an infinite
+      //    loop because we never increment j.  so check to see if msg[0] is set or not to fix this.
+      while (($j < count($msg)) && ($msg[0])) {
          if ($msg[$i]) {
             /** check if they would like to move it to the trash folder or not */
             if ($move_to_trash == true) {
       displayPageHeader($mailbox);
       messages_deleted_message($mailbox, $sort, $startMessage);
    } else {
-      if ($auto_expunge == true)
-         expungeBox($imapConnection, $mailbox, $numMessages);
-      displayPageHeader($mailbox);
+      $j = 0;
+      $i = 0;
+      
+      // If they have selected nothing msg is size one still, but will be an infinite
+      //    loop because we never increment j.  so check to see if msg[0] is set or not to fix this.
+      while (($j < count($msg)) && ($msg[0])) {
+         if ($msg[$i]) {
+            $success = copyMessages($imapConnection, $msg[$i], $msg[$i], $trash_folder);
+            if ($success == true) {
+               setMessageFlag($imapConnection, $msg[$i], $msg[$i], "Deleted");
+               displayPageHeader($mailbox);
+            }
+            if ($auto_expunge == true)
+               expungeBox($imapConnection, $mailbox, $numMessages);
+            $j++;
+         }
+         $i++;
+      }
    }
 
    // Log out this session