浏览代码

Update message copy and move functions to allow for custom handling / ignoring of the error messages.
This fixes a bug where users with exceeded quota's could not login when the filter plugin is actively filtering.

Currently user does not get an error if filtering failed (I am working on it) and it continues parsing the next filter even if fails (I have code for this, but don't think its necessary)

Jimmy Conner 20 年之前
父节点
当前提交
f5a3a72aca
共有 3 个文件被更改,包括 11 次插入7 次删除
  1. 2 0
      ChangeLog
  2. 8 6
      functions/imap_messages.php
  3. 1 1
      plugins/filters/filters.php

+ 2 - 0
ChangeLog

@@ -273,6 +273,8 @@ Version 1.5.1 -- CVS
   - Strip position:absolute style from HTML mails.
   - Strip position:absolute style from HTML mails.
   - Add ability to the Filters plugin to filter on Message Body, or both
   - Add ability to the Filters plugin to filter on Message Body, or both
     the Headers and the Message Body.
     the Headers and the Message Body.
+  - Update the message copy and move functions to allow for error handling.
+  - Fix the filter plugin from halting the login process when copying errors occur
   
   
 Version 1.5.0
 Version 1.5.0
 --------------------
 --------------------

+ 8 - 6
functions/imap_messages.php

@@ -20,11 +20,12 @@
  * @param int $imap_stream The resource ID for the IMAP socket
  * @param int $imap_stream The resource ID for the IMAP socket
  * @param string $id The list of messages to copy
  * @param string $id The list of messages to copy
  * @param string $mailbox The destination to copy to
  * @param string $mailbox The destination to copy to
- * @return bool
+ * @param bool $handle_errors Show error messages in case of a NO, BAD or BYE response
+ * @return bool If the copy completed without errors  
  */
  */
-function sqimap_msgs_list_copy($imap_stream, $id, $mailbox) {
+function sqimap_msgs_list_copy($imap_stream, $id, $mailbox, $handle_errors = true) {
     $msgs_id = sqimap_message_list_squisher($id);
     $msgs_id = sqimap_message_list_squisher($id);
-    $read = sqimap_run_command ($imap_stream, "COPY $msgs_id " . sqimap_encode_mailbox_name($mailbox), true, $response, $message, TRUE);
+    $read = sqimap_run_command ($imap_stream, "COPY $msgs_id " . sqimap_encode_mailbox_name($mailbox), $handle_errors, $response, $message, TRUE);
     if ($response == 'OK') {
     if ($response == 'OK') {
         return true;
         return true;
     } else {
     } else {
@@ -38,11 +39,12 @@ function sqimap_msgs_list_copy($imap_stream, $id, $mailbox) {
  * @param int $imap_stream The resource ID for the IMAP socket
  * @param int $imap_stream The resource ID for the IMAP socket
  * @param string $id The list of messages to move
  * @param string $id The list of messages to move
  * @param string $mailbox The destination to move to
  * @param string $mailbox The destination to move to
- * @return void
+ * @param bool $handle_errors Show error messages in case of a NO, BAD or BYE response
+ * @return bool If the move completed without errors
  */
  */
-function sqimap_msgs_list_move($imap_stream, $id, $mailbox) {
+function sqimap_msgs_list_move($imap_stream, $id, $mailbox, $handle_errors = true) {
     $msgs_id = sqimap_message_list_squisher($id);
     $msgs_id = sqimap_message_list_squisher($id);
-    if (sqimap_msgs_list_copy ($imap_stream, $id, $mailbox)) {
+    if (sqimap_msgs_list_copy ($imap_stream, $id, $mailbox, $handle_errors)) {
         return sqimap_toggle_flag($imap_stream, $id, '\\Deleted', true, true);
         return sqimap_toggle_flag($imap_stream, $id, '\\Deleted', true, true);
     } else {
     } else {
         return false;
         return false;

+ 1 - 1
plugins/filters/filters.php

@@ -323,7 +323,7 @@ function filter_search_and_delete($imap_stream, $where, $what, $where_to, $user_
         if ($response == 'OK' && count($ids)) {
         if ($response == 'OK' && count($ids)) {
             if (sqimap_mailbox_exists($imap_stream, $where_to)) {
             if (sqimap_mailbox_exists($imap_stream, $where_to)) {
                  $should_expunge = true;
                  $should_expunge = true;
-                 sqimap_msgs_list_move ($imap_stream, $ids, $where_to);
+                 sqimap_msgs_list_move ($imap_stream, $ids, $where_to, false);
             }
             }
         }
         }
     }
     }