From ec73f243f05cbe95afa128848eef6845887dc8e9 Mon Sep 17 00:00:00 2001 From: alex-brainstorm Date: Sun, 9 Nov 2003 17:50:54 +0000 Subject: [PATCH] Add an optional link parameter to sqimap_error_box(), allow self error handling even when connection is dropped, and remove the notices that happen in that case. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@6131 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/imap_general.php | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/functions/imap_general.php b/functions/imap_general.php index 5e755b5d..d02e35a8 100755 --- a/functions/imap_general.php +++ b/functions/imap_general.php @@ -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 .= "
\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': -- 2.25.1