fix for problem with moving messages from folders that begin with "c", thanks Venge...
[squirrelmail.git] / plugins / delete_move_next / setup.php
index c8470e4143758d1719732651f7ef645c39884348..4cb6172ccf7703ff0fa3adebc357b6bfb112e4f2 100644 (file)
@@ -26,6 +26,22 @@ function squirrelmail_plugin_init_delete_move_next() {
 }
 
 
+/* fixes the sort_array for the prev_del/next_del links when 
+ * using server side sorting or thread sorting 
+ */
+
+function fix_sort_array () {
+    global $username, $data_dir, $allow_server_sort, $allow_thread_sort,
+    $mailbox, $imapConnection, $sort;
+    if ($allow_server_sort == true) {
+        $server_sort_array = sqimap_get_sort_order($imapConnection, $sort);
+    }
+    $thread_sort_messages = getPref($username, $data_dir, "thread_$mailbox");
+    if ($allow_thread_sort == true && $thread_sort_messages == 1) {
+        $server_sort_array = get_thread_sort($imapConnection);
+    }
+}
+
 /*
  * Warning: this function relies on the internal representation of
  * of the message cache for the current mailbox. As such, it is fragile
@@ -34,6 +50,7 @@ function squirrelmail_plugin_init_delete_move_next() {
  * perhaps even as inline code to sqimap_mailbox_expunge(). In the 
  * meantime, you have been warned. [alane@geeksrus.net 2001/05/06]
  */
+
 function delete_move_del_arr_elem($arr, $index) {
     $tmp = array();
     $lim = count($arr);
@@ -91,8 +108,10 @@ function delete_move_next_action() {
 
     if ($delete_id) {
         delete_move_next_delete();
+        fix_sort_array();
     } elseif ($move_id) {
         delete_move_next_move();
+        fix_sort_array();
     }
 
 }
@@ -123,7 +142,6 @@ function delete_move_next_read($currloc) {
            $imapConnection, $auto_expunge, $move_to_trash;
 
     if (!(($where && $what) || ($currentArrayIndex == -1))) {
-    
         $next = findNextMessage();
         $prev = findPreviousMessage();
         $prev_if_del = $prev;
@@ -214,7 +232,7 @@ function delete_move_next_moveNextForm($next) {
          "<td bgcolor=\"$color[9]\" width=\"100%\" align=\"center\">".
            '<form action="read_body.php" method="post"><small>'.
             "<input type=\"hidden\" name=\"passed_id\" value=\"$next\">".
-            "<input type=\"hidden\" name=\"mailbox\" value=\"$urlMailbox\">".
+            "<input type=\"hidden\" name=\"mailbox\" value=\"".urldecode($urlMailbox)."\">".
             "<input type=\"hidden\" name=\"sort\" value=\"$sort\">".
             "<input type=\"hidden\" name=\"startMessage\" value=\"$startMessage\">".
             "<input type=\"hidden\" name=\"show_more\" value=\"0\">".
@@ -239,7 +257,7 @@ function delete_move_next_moveRightMainForm() {
     echo '<tr>' .      
             "<td bgcolor=\"$color[9]\" width=\"100%\" align=\"center\">".
             '<form action="right_main.php" method="post"><small>' .
-            "<input type=\"hidden\" name=\"mailbox\" value=\"$urlMailbox\">".
+            "<input type=\"hidden\" name=\"mailbox\" value=\"".urldecode($urlMailbox)."\">".
             "<input type=\"hidden\" name=\"sort\" value=\"$sort\">".
             "<input type=\"hidden\" name=\"startMessage\" value=\"$startMessage\">".
             "<input type=\"hidden\" name=\"move_id\" value=\"$passed_id\">".
@@ -284,31 +302,31 @@ function delete_move_next_display_inside() {
         $delete_move_next_b, $delete_move_next_formATbottom;
     
     echo "<tr><td align=right valign=top>\n".
-         _("delete_move_next:") . "</td>\n".
+         _("Delete/Move/Next Buttons:") . "</td>\n".
          "<td><input type=checkbox name=delete_move_next_ti";
          
     if ($delete_move_next_t == 'on') {
         echo " checked";
     }
-    echo '> <- ' . _("display at top").
+    echo '> ' . _("Display at top").
          " <input type=checkbox name=delete_move_next_formATtopi";
          
     if ($delete_move_next_formATtop == 'on') {
         echo ' checked';
     }
-    echo '> <- ' . _("with move option") . '<br>';    
+    echo '> ' . _("with move option") . '<br>';    
     
     echo '<input type=checkbox name=delete_move_next_bi';
     if($delete_move_next_b != 'off') {
         echo ' checked';
     }
-    echo '> <- ' . _("display at bottom") .
+    echo '> ' . _("Display at bottom") .
          '<input type=checkbox name=delete_move_next_formATbottomi';
          
     if ($delete_move_next_formATbottom != 'off') {
         echo ' checked';
     }
-    echo '> <- ' . _("with move option") . '<br>'.
+    echo '> ' . _("with move option") . '<br>'.
          "</td></tr>\n";
 }