Allow silent failure for sqimap_get_message()
authorpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 11 Nov 2006 10:34:22 +0000 (10:34 +0000)
committerpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 11 Nov 2006 10:34:22 +0000 (10:34 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@11954 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/imap_messages.php

index d99bcebd7aa22e34f8e8331181b7713d30142fb2..42ecaa1ef28903070763cccf4aff54e22725f48a 100755 (executable)
@@ -912,9 +912,10 @@ function sqimap_parse_address($read, &$i) {
  * @param  resource $imap_stream imap connection
  * @param  integer  $id uid of the message
  * @param  string   $mailbox used for error handling, can be removed because we should return an error code and generate the message elsewhere
  * @param  resource $imap_stream imap connection
  * @param  integer  $id uid of the message
  * @param  string   $mailbox used for error handling, can be removed because we should return an error code and generate the message elsewhere
- * @return Message  Message object
+ * @param  int      $hide Indicates whether or not to hide any errors: 0 = don't hide, 1 = hide (just exit), 2 = hide (return FALSE) (OPTIONAL; default don't hide)
+ * @return mixed  Message object or FALSE if error occurred and $hide is set to 2
  */
  */
-function sqimap_get_message($imap_stream, $id, $mailbox) {
+function sqimap_get_message($imap_stream, $id, $mailbox, $hide=0) {
     // typecast to int to prohibit 1:* msgs sets
     $id = (int) $id;
     $flags = array();
     // typecast to int to prohibit 1:* msgs sets
     $id = (int) $id;
     $flags = array();
@@ -926,6 +927,10 @@ function sqimap_get_message($imap_stream, $id, $mailbox) {
             }
         }
     } else {
             }
         }
     } else {
+
+        if ($hide == 1) exit;
+        if ($hide == 2) return FALSE;
+
         /* the message was not found, maybe the mailbox was modified? */
         global $sort, $startMessage, $color;
 
         /* the message was not found, maybe the mailbox was modified? */
         global $sort, $startMessage, $color;