Moving "doc/db-backend.txt" to the administrator's manual (again).
[squirrelmail.git] / functions / imap_messages.php
index d99bcebd7aa22e34f8e8331181b7713d30142fb2..9afef47d2b8ecd473f9a7e5773849ca911543db8 100755 (executable)
@@ -6,7 +6,7 @@
  * This implements functions that manipulate messages
  * NOTE: Quite a few functions in this file are obsolete
  *
- * @copyright © 1999-2006 The SquirrelMail Project Team
+ * @copyright © 1999-2007 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package squirrelmail
@@ -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
- * @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), 3 = hide (return error string) (OPTIONAL; default don't hide)
+ * @return mixed  Message object or FALSE/error string if error occurred and $hide is set to 2/3
  */
-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();
@@ -926,11 +927,19 @@ function sqimap_get_message($imap_stream, $id, $mailbox) {
             }
         }
     } else {
+
+        if ($hide == 1) exit;
+        if ($hide == 2) return FALSE;
+
         /* the message was not found, maybe the mailbox was modified? */
         global $sort, $startMessage, $color;
 
-        $errmessage = _("The server couldn't find the message you requested.") .
-            '<p>'._("Most probably your message list was out of date and the message has been moved away or deleted (perhaps by another program accessing the same mailbox).");
+        $errmessage = _("The server couldn't find the message you requested.");
+
+        if ($hide == 3) return $errmessage;
+
+        $errmessage .= '<p>'._("Most probably your message list was out of date and the message has been moved away or deleted (perhaps by another program accessing the same mailbox).");
+
         /* this will include a link back to the message list */
         error_message($errmessage, $mailbox, $sort, (int) $startMessage, $color);
         exit;