Add an optional link parameter to sqimap_error_box(), allow self error handling even...
authoralex-brainstorm <alex-brainstorm@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 9 Nov 2003 17:50:54 +0000 (17:50 +0000)
committeralex-brainstorm <alex-brainstorm@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 9 Nov 2003 17:50:54 +0000 (17:50 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@6131 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/imap_general.php

index 5e755b5d2ada1399555777cfafab99d2f12da6d3..d02e35a84b5d5d1989087eee83756a5a2e5a9b32 100755 (executable)
@@ -73,10 +73,15 @@ function sqimap_run_command ($imap_stream, $query, $handle_errors, &$response,
    
         $read = sqimap_read_data ($imap_stream, $tag, $handle_errors, $response,
                                   $message, $query,$filter,$outputstream,$no_return);
+        if (empty($read)) {    //Imap server dropped its connection
+            $response = '';
+            $message = '';
+            return false;
+        }
         /* retrieve the response and the message */
         $response = $response[$tag];
         $message  = $message[$tag];
-        
+    
         if (!empty($read[$tag])) {
             return $read[$tag][0];
         } else {
@@ -280,11 +285,12 @@ function sqimap_read_data_list($imap_stream, $tag, $handle_errors,
  * Function to display an error related to an IMAP-query.
  * @param string title the caption of the error box
  * @param string query the query that went wrong
- * @param string message_title
- * @param string message the error message
+ * @param string message_title optional message title
+ * @param string message optional error message
+ * @param string $link an optional link to try again
  * @return void
  */
-function sqimap_error_box($title, $query = '', $message_title = '', $message = '')
+function sqimap_error_box($title, $query = '', $message_title = '', $message = '', $link = '')
 {
     global $color, $squirrelmail_language;
 
@@ -301,6 +307,8 @@ function sqimap_error_box($title, $query = '', $message_title = '', $message = '
     if ($message != '')
         $string .= htmlspecialchars($message);
     $string .= "</font><br>\n";
+    if ($link != '')
+        $string .= $link;
     error_box($string,$color);
 }
 
@@ -316,6 +324,7 @@ function sqimap_retrieve_imap_response($imap_stream, $tag, $handle_errors,
     $read = '';
     if (!is_array($message)) $message = array();
     if (!is_array($response)) $response = array();
+    $aResponse = '';
     $resultlist = array();
     $data = array();
     $read = sqimap_fgets($imap_stream);
@@ -470,8 +479,10 @@ function sqimap_retrieve_imap_response($imap_stream, $tag, $handle_errors,
     /* error processing in case $read is false */
     if ($read === false) {
         unset($data);
-        sqimap_error_box(_("ERROR : Connection dropped by imap-server."), $query);
-        exit;
+        if ($handle_errors) {
+            sqimap_error_box(_("ERROR : Connection dropped by imap-server."), $query);
+            exit;
+        }
     }
     
     /* Set $resultlist array */
@@ -485,7 +496,6 @@ function sqimap_retrieve_imap_response($imap_stream, $tag, $handle_errors,
     /* Return result or handle errors */
     if ($handle_errors == false) {
         return $aResponse;
-        return( $resultlist ); //?? Why this?
     }
     switch ($response[$tag]) {
     case 'OK':