From d462004f8e4a8ae69cc7cf1daab258fcd26966f2 Mon Sep 17 00:00:00 2001 From: pdontthink Date: Sun, 22 May 2022 15:44:41 +0000 Subject: [PATCH] Fix bug where could not toggle flag (delete, etc) a single message git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@14950 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/imap_messages.php | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/functions/imap_messages.php b/functions/imap_messages.php index 93aaaa8c..f16abe85 100755 --- a/functions/imap_messages.php +++ b/functions/imap_messages.php @@ -17,7 +17,8 @@ /** * Copy a set of messages ($id) to another mailbox ($mailbox) * @param int $imap_stream The resource ID for the IMAP socket - * @param string $id The list of messages to copy + * @param mixed $id Normally an array which is a list with message UIDs to be copied + * or a string range such as "1:*" or a simple integer * @param string $mailbox The destination to copy to * @param bool $handle_errors Show error messages in case of a NO, BAD or BYE response * @return bool If the copy completed without errors @@ -59,7 +60,8 @@ function sqimap_msgs_list_move($imap_stream, $id, $mailbox, $handle_errors = tru * Deletes a message and move it to trash or expunge the mailbox * @param resource imap connection * @param string $mailbox mailbox, used for checking if it concerns the trash_folder - * @param array $id list with uid's + * @param mixed $id Normally an array which is a list with message UIDs to be deleted + * or a string range such as "1:*" or a simple integer * @param bool $bypass_trash (since 1.5.0) skip copy to trash * @return array $aMessageList array with messages containing the new flags and UID @see parseFetch * @since 1.4.0 @@ -83,7 +85,7 @@ function sqimap_msgs_list_delete($imap_stream, $mailbox, $id, $bypass_trash=fals * Set a flag on the provided uid list * @param resource imap connection * @param mixed $id Normally an array which is a list with message UIDs to be flagged - * or a string range such as "1:*" + * or a string range such as "1:*" or a simple integer * @param string $flag Flags to set/unset flags can be i.e.'\Seen', '\Answered', '\Seen \Answered' * @param bool $set add (true) or remove (false) the provided flag * @param bool $handle_errors Show error messages in case of a NO, BAD or BYE response @@ -93,11 +95,15 @@ function sqimap_toggle_flag($imap_stream, $id, $flag, $set, $handle_errors) { $msgs_id = sqimap_message_list_squisher($id); $set_string = ($set ? '+' : '-'); + /* + * We need to return the data in the same order as the caller supplied + * in $id, but IMAP servers are free to return responses in + * whatever order they wish... So we need to re-sort manually + */ $aMessageList = array(); - // TODO: There doesn't seem to be a reason to set up $aMessageList anyway because an empty array for each message doesn't add anything to the parseFetch() return value, so this code block could be simply deleted: - if (!is_string($id)) { - for ($i=0; $i