From 6d31e3a336f60a88ffef070c60df49591f02c18c Mon Sep 17 00:00:00 2001 From: stekkel Date: Wed, 8 Feb 2006 07:59:19 +0000 Subject: [PATCH] made the code work for triggering imap related errors. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@10658 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- class/error.class.php | 29 +++++++++++++++++------------ include/errors.php | 22 ++++++++++++++++++++-- 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/class/error.class.php b/class/error.class.php index cef939bd..7eba7966 100644 --- a/class/error.class.php +++ b/class/error.class.php @@ -205,7 +205,7 @@ function SquirrelMailErrorhandler($iErrNo, $sErrStr, $sErrFile, $iErrLine, $aCon /** * Triggers an imap error. Utility function for sqm_trigger_error() - * @param integer $iErrNo error number defined in errors.php + * @param string $sErrNo error string defined in errors.php * @param string $sRequest imap request string * @param string $sResponse tagged imap response * @param string $sMessage tagged imap response message @@ -214,37 +214,42 @@ function SquirrelMailErrorhandler($iErrNo, $sErrStr, $sErrFile, $iErrLine, $aCon * @author Marc Groot Koerkamp * @since 1.5.1 */ -function sqm_trigger_imap_error($iErrNo,$sRequest,$sResponse, $sMessage, $aExtra=array()) { +function sqm_trigger_imap_error($sErrNo,$sRequest,$sResponse, $sMessage, $aExtra=array()) { $aError = array( 'REQUEST' => $sRequest, 'RESPONSE' => $sResponse, 'MESSAGE' => $sMessage); $aError = array_merge($aExtra,$aError); - sqm_trigger_error($iErrNo,$aError); + sqm_trigger_error($sErrNo,$aError); } /** * Trigger an error. - * @param integer $iErrNo error number defined in errors.php + * @param string $sErrNo error string defined in errors.php * @param array $aExtra optional associative array with extra error info * @return void * @author Marc Groot Koerkamp * @since 1.5.1 */ -function sqm_trigger_error($iErrNo,$aExtra=array()) { - // Include the error definition file. - include_once(SM_PATH.'include/errors.php'); +function sqm_trigger_error($sErrNo,$aExtra=array()) { + static $aErrors; + if (!isset($aErrors)) { + // Include the error definition file. + include_once(SM_PATH.'include/errors.php'); + } + $iPhpErr = E_USER_NOTICE; - if (is_array($aErrors) && isset($aErrors[$iErrNo]['level'])) { + if (is_array($aErrors) && isset($aErrors[$sErrNo]['level'])) { if (is_array($aExtra) && count($aExtra)) { - $aErrors[$iErrNo]['extra'] = $aExtra; + $aErrors[$sErrNo]['extra'] = $aExtra; } // because trigger_error can only handle a string argument for the error description // we serialize the result. - $sErrString = serialize($aErrors[$iErrNo]); - $iPhpErr = $aErrors[$iErrNo]['level']; + $sErrString = serialize($aErrors[$sErrNo]); + $iPhpErr = $aErrors[$sErrNo]['level']; } else { - $sErrString = "Error number <$iErrNo> does not exist, fix the code or update the errors.php file"; + sm_print_r($aErrors); + $sErrString = "Error <$sErrNo> does not exist, fix the code or update the errors.php file"; $iPhpErr = E_USER_ERROR; } trigger_error($sErrString, $iPhpErr); diff --git a/include/errors.php b/include/errors.php index 2fd46a84..972d40d9 100644 --- a/include/errors.php +++ b/include/errors.php @@ -20,13 +20,15 @@ define('SQM_ERROR_DB',16); define('SQM_ERROR_PLUGIN',32); // define('SQM_ERROR_X',64); future error category + + $aErrors['SQM_IMAP_NO_THREAD'] = array( 'level' => E_USER_ERROR, 'category' => SQM_ERROR_IMAP, 'message' => _("Thread sorting is not supported by your IMAP server.") . "\n" . _("Please contact your system administrator and report this error."), 'link' => '', - 'tip' => _("Run \"configure\", choose option 4 (General options) and set option 10 (Allow server thread sort to false).") + 'tip' => _("Run \"configure\", choose option 4 (General options) and set option 10 (Disable server thread sort) to true).") ); $aErrors['SQM_IMAP_NO_SORT'] = array( @@ -35,9 +37,25 @@ $aErrors['SQM_IMAP_NO_SORT'] = array( 'message' => _( "Server-side sorting is not supported by your IMAP server.") . "\n" . _("Please contact your system administrator and report this error."), 'link' => '', - 'tip' => _("Run \"configure\", choose option 4 (General options) and set option 11 (Allow server-side sorting to false).") + 'tip' => _("Run \"configure\", choose option 4 (General options) and set option 11 (Disable server-side sorting) to true.") ); +$aErrors['SQM_IMAP_BADCHARSET'] = array( + 'level' => E_USER_NOTICE, + 'category' => SQM_ERROR_IMAP, + 'message' => _( "Your used charset is not supported by your IMAP server.") . "\n" . + _("Please contact your system administrator and report this error."), + 'link' => '', + 'tip' => _("Run \"configure\", choose option 4 (General options) and set option 12 (Allow server charset search) to false) or choose option 10 (Language settings) and set option 2 (Default charset) to a charset supported by your IMAP server.") +); + +$aErrors['SQM_IMAP_ERROR'] = array( + 'level' => E_USER_ERROR, + 'category' => SQM_ERROR_IMAP, + 'message' => _( "Your IMAP server returned an error.") . "\n" . + _("Please contact your system administrator and report this error."), + 'link' => '' +); //$aError['SQM_FS'] // Filesystem related errors ?> \ No newline at end of file -- 2.25.1