From 705c67593307c3edd1ba9739b251a5402ae6d24a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 3 Oct 2010 21:43:03 +0000 Subject: [PATCH] New: add constante MAIN_CORE_ERROR if "$dolibarr_main_prod" is defined, better error message with an ajax dialog --- htdocs/langs/en_US/main.lang | 2 ++ htdocs/langs/fr_FR/main.lang | 2 ++ htdocs/lib/ajax.lib.php | 35 +++++++++++++++++++++++++++++++++-- htdocs/lib/functions.lib.php | 9 ++++++--- htdocs/main.inc.php | 23 ++++++++++++++++++++--- 5 files changed, 63 insertions(+), 8 deletions(-) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 95e2c73ef40..3857d4d40bf 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -551,6 +551,8 @@ Merge=Merge PrintContentArea=Show page to print main content area NoMenu=No sub-menu WarningYouAreInMaintenanceMode=Warning, you are in a maintenance mode, so only login %s is allowed to use application at the moment. +CoreErrorTitle=System error +CoreErrorMessage=Sorry, an error occurred. Check the logs or contact your system administrator. CreditCard=Credit card FieldsWithAreMandatory=Fields with %s are mandatory FieldsWithIsForPublic=Fields with %s are shown on public list of members. If you don't want this, check the "public" box. diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index 7083011b870..e726d604df3 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -550,6 +550,8 @@ Merge=Fusion PrintContentArea=Afficher page d'impression de la zone centrale NoMenu=Aucun sous-menu WarningYouAreInMaintenanceMode=Attention, vous êtes en mode maintenance, aussi seul le login %s est autorisé à utiliser l'application en ce moment. +CoreErrorTitle=Erreur système +CoreErrorMessage=Désolé, une erreur s'est produite. Vérifier les logs ou contacter l'administrateur du système. CreditCard=Carte de crédit FieldsWithAreMandatory=Les champs marqués par un %s sont obligatoires FieldsWithIsForPublic=Les champs marqués par %s seront affichés sur la liste publique des membres. Si vous ne le souhaitez pas, décochez la case "public". diff --git a/htdocs/lib/ajax.lib.php b/htdocs/lib/ajax.lib.php index 60cb3e734c4..d680747f911 100644 --- a/htdocs/lib/ajax.lib.php +++ b/htdocs/lib/ajax.lib.php @@ -1,6 +1,6 @@ - * Copyright (C) 2007 Regis Houssin +/* Copyright (C) 2007-2010 Laurent Destailleur + * Copyright (C) 2007-2010 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -135,4 +135,35 @@ function ajax_autocompleter2($selected='', $htmlname, $url, $option='') return $script; } +/** + * Show an ajax dialog + */ +function ajax_dialog($title,$message,$w=350,$h=150) +{ + global $langs; + + $msg.= '
'; + $msg.= $message; + $msg.= '
'."\n"; + $msg.= ''; + + $msg.= "\n"; + + return $msg; +} + ?> \ No newline at end of file diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index daa87800824..7bea9085f9a 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -1880,6 +1880,8 @@ function dolibarr_print_error($db='',$error='') function dol_print_error($db='',$error='') { global $conf,$langs,$argv; + global $dolibarr_main_prod; + $out = ''; $syslog = ''; @@ -1967,7 +1969,8 @@ function dol_print_error($db='',$error='') $syslog.=", msg=".$msg; } } - if ($_SERVER['DOCUMENT_ROOT'] && function_exists('xdebug_call_file')) + + if (empty($dolibarr_main_prod) && $_SERVER['DOCUMENT_ROOT'] && function_exists('xdebug_call_file')) { xdebug_print_function_stack(); $out.='XDebug informations:'."
\n"; @@ -1977,9 +1980,9 @@ function dol_print_error($db='',$error='') $out.="
\n"; } - global $dolibarr_main_prod; if (empty($dolibarr_main_prod)) print $out; - else print 'Sorry, an error occured but the parameter $dolibarr_main_prod is defined in conf file so no message is reported to your browser. Please read the log file for error message.'; + else define("MAIN_CORE_ERROR", 1); + //else print 'Sorry, an error occured but the parameter $dolibarr_main_prod is defined in conf file so no message is reported to your browser. Please read the log file for error message.'; dol_syslog("Error ".$syslog, LOG_ERR); } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 04adf1c684d..0ac5e4d3875 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -732,8 +732,6 @@ else $heightforframes=48; - - // Functions @@ -1329,7 +1327,26 @@ if (! function_exists("llxFooter")) { function llxFooter($foot='') { - global $conf, $dolibarr_auto_user, $micro_start_time; + global $conf, $langs, $dolibarr_auto_user, $micro_start_time; + + // Core error message + if (defined("MAIN_CORE_ERROR") && constant("MAIN_CORE_ERROR") == 1) + { + // Ajax version + if ($conf->use_javascript_ajax) + { + $title = img_warning().' '.$langs->trans('CoreErrorTitle'); + print ajax_dialog($title, $langs->trans('CoreErrorMessage')); + } + // html version + else + { + $msg = img_warning().' '.$langs->trans('CoreErrorMessage'); + print '
'.$msg.'
'; + } + + define("MAIN_CORE_ERROR",0); + } print "\n\n".' '."\n";