[prev in list] [next in list] [prev in thread] [next in thread] 

List:       squirrelmail-cvs
Subject:    [SM-CVS] CVS: squirrelmail/src move_messages.php,1.99,1.100
From:       "Seth E. Randall" <indiri69 () users ! sourceforge ! net>
Date:       2004-04-28 0:40:16
Message-ID: E1BId7Y-0004gj-I5 () sc8-pr-cvs1 ! sourceforge ! net
[Download RAW message or body]

Update of /cvsroot/squirrelmail/squirrelmail/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17551

Modified Files:
	move_messages.php 
Log Message:
Cleaned up some redundant code, now we only change startMessage when we've
actually moved or deleted messages.  Also fixed a problem where marking all the
messages read on the last page of the message list would kick you back one
page.  I'll look at making the same change in stable.


Index: move_messages.php
===================================================================
RCS file: /cvsroot/squirrelmail/squirrelmail/src/move_messages.php,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -w -r1.99 -r1.100
--- move_messages.php	12 Apr 2004 06:53:26 -0000	1.99
+++ move_messages.php	28 Apr 2004 00:40:14 -0000	1.100
@@ -91,8 +91,6 @@
     return $composesession;
 }
 
-
-
 /* get globals */
 sqgetGlobalVar('key',       $key,           SQ_COOKIE);
 sqgetGlobalVar('username',  $username,      SQ_SESSION);
@@ -140,10 +138,10 @@
     sqsession_register($lastTargetMailbox, 'lastTargetMailbox');
 }
 $exception = false;
+$change    = false;
 
 do_hook('move_before_move');
 
-
 /*
     Move msg list sorting up here, as it is used several times,
     makes it more efficient to do it in one place for the code
@@ -155,28 +153,22 @@
         $id[] = $uid;
     }
 }
+$num_ids = count($id);
 
 // expunge-on-demand if user isn't using move_to_trash or auto_expunge
 if(isset($expungeButton)) {
-    $cnt = sqimap_mailbox_expunge($imapConnection, $mailbox, true);
-    if (($startMessage+$cnt-1) >= $mbx_response['EXISTS']) {
-        if ($startMessage > $show_num) {
-            $location = set_url_var($location,'startMessage',$startMessage-$show_num,false);
-        } else {
-            $location = set_url_var($location,'startMessage',1,false);
-        }
-    }
+    $num_ids = sqimap_mailbox_expunge($imapConnection, $mailbox, true);
+    $change = true;
 } elseif(isset($undeleteButton)) {
     // undelete messages if user isn't using move_to_trash or auto_expunge
     // Removes \Deleted flag from selected messages
-    if (count($id)) {
+    if ($num_ids) {
         sqimap_toggle_flag($imapConnection, $id, '\\Deleted',false,true);
     } else {
         $exception = true;
     }
 } elseif (!isset($moveButton)) {
-    if (count($id)) {
-        $cnt = count($id);
+    if ($num_ids) {
         if (!isset($attache)) {
             if (isset($markRead)) {
                 sqimap_toggle_flag($imapConnection, $id, '\\Seen',true,true);
@@ -186,16 +178,16 @@
                 sqimap_toggle_flag($imapConnection, $id, '\\Flagged', true, true);
             } else if (isset($markUnflagged)) {
                 sqimap_toggle_flag($imapConnection, $id, '\\Flagged', false, true);
-            } else  {
+            } else  { // Delete messages
                 if (!boolean_hook_function('move_messages_button_action', NULL, 1)) {
                     sqimap_msgs_list_delete($imapConnection, $mailbox, $id,$bypass_trash);
                     if ($auto_expunge) {
-                        $cnt = sqimap_mailbox_expunge($imapConnection, $mailbox, true);
-                    }
+                        $num_ids = sqimap_mailbox_expunge($imapConnection, $mailbox, true);
                 }
+                    $change = true;
             }
         }
-        if (isset($attache)) {
+        } else {
             $composesession = attachSelectedMessages($id, $imapConnection);
             $location = set_url_var($location, 'session', $composesession, false);
             if ($compose_new_win) {
@@ -204,44 +196,34 @@
                 $location = str_replace('search.php','compose.php',$location);
                 $location = str_replace('right_main.php','compose.php',$location);
             }
-        } else {
-            if (($startMessage+$cnt-1) >= $mbx_response['EXISTS']) {
-                if ($startMessage > $show_num) {
-                    $location = set_url_var($location,'startMessage',$startMessage-$show_num, false);
-                } else {
-                    $location = set_url_var($location,'startMessage',1, false);
-                }
-            }
         }
     } else {
         $exception = true;
     }
 } else {    // Move messages
-
-    $num_ids = count($id);
     if ( $num_ids > 0 ) {
-        if ( $is_dmn && count($id) == 1 ) {
+        if ( $is_dmn && $num_ids == 1 ) {
             sqimap_msgs_list_move($imapConnection,$id[0],$targetMailbox);
-            $cnt = sqimap_mailbox_expunge_dmn($id[0]);
+            $num_ids = sqimap_mailbox_expunge_dmn($id[0]);
         } else {
             sqimap_msgs_list_move($imapConnection,$id,$targetMailbox);
             if ($auto_expunge) {
-                $cnt = sqimap_mailbox_expunge($imapConnection, $mailbox, true);
+                $num_ids = sqimap_mailbox_expunge($imapConnection, $mailbox, true);
+            }
+        }
+        $change = true;
             } else {
-                $cnt = 0;
+        $exception = true;
             }
         }
-
-        if (($startMessage+$cnt-1) >= $mbx_response['EXISTS']) {
+if($change) { // Change the startMessage number if the mailbox was changed
+    if (($startMessage+$num_ids-1) >= $mbx_response['EXISTS']) {
             if ($startMessage > $show_num) {
                 $location = set_url_var($location,'startMessage',$startMessage-$show_num, false);
             } else {
                 $location = set_url_var($location,'startMessage',1, false);
             }
         }
-    } else {
-        $exception = true;
-    }
 }
 // Log out this session
 sqimap_logout($imapConnection);



-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. 
Take an Oracle 10g class now, and we'll give you the exam FREE. 
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
--
squirrelmail-cvs mailing list
List Address: squirrelmail-cvs@lists.sourceforge.net
List Info: https://lists.sourceforge.net/lists/listinfo/squirrelmail-cvs
http://squirrelmail.org/cvs
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic