From: hickert Date: Mon, 6 Mar 2006 09:16:22 +0000 (+0000) Subject: Updated print_red error output, every message is now displayed only once. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=d893b43bda171766b7dc1dfa40b7d88b0fcf7ab3;p=gosa.git Updated print_red error output, every message is now displayed only once. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2812 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/html/main.php b/html/main.php index a2b8d72ee..8471e3eea 100644 --- a/html/main.php +++ b/html/main.php @@ -54,6 +54,8 @@ if (!isset($_SESSION['config'])){ /* Reset errors */ $_SESSION['errors']= ""; +$_SESSION['errorsAlreadyPosted']= array(); +$_SESSION['LastError'] =""; /* Check for uniqe ip address */ $ui= $_SESSION["ui"]; @@ -335,7 +337,13 @@ if (is_file("$plugin_dir/main.inc")){ } /* Close div/tables */ + +/* Print_out last ErrorMessage repeated string. + */ +print_red(NULL); + $smarty->assign("contents", $display); + if (isset($_SESSION['errors'])){ $smarty->assign("errors", $_SESSION['errors']); } diff --git a/include/functions.inc b/include/functions.inc index a7695a017..3aaf3bfee 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -975,20 +975,56 @@ function print_red() $string= preg_replace ("/%s/", $array[$i], $string, 1); } + if((!isset($_SESSION['errorsAlreadyPosted'])) || !is_array($_SESSION['errorsAlreadyPosted'])){ + $_SESSION['errorsAlreadyPosted'] = array(); + } + /* If DEBUGLEVEL is set, we're in web mode, use textual output in the other case... */ + if (isset($_SESSION['DEBUGLEVEL'])){ - $_SESSION['errors'].= "
". - "
\"\"". - "$string". - "\"\"src=\"".get_template_path('images/warning.png').
\n"; + + if($_SESSION['LastError'] == $string){ + + if((!isset($_SESSION['errorsAlreadyPosted'][$string]))){ + $_SESSION['errorsAlreadyPosted'][$string] = 1; + } + $_SESSION['errorsAlreadyPosted'][$string] ++; + + }else{ + if((!empty($_SESSION['LastError'])) && ($_SESSION['errorsAlreadyPosted'][$_SESSION['LastError']]>1)){ + $_SESSION['errors'].= "
". + "
\"\"". + "".sprintf(_("Last message repeated %s times."),$_SESSION['errorsAlreadyPosted'][$_SESSION['LastError']])."". + "\"\"src=\"".get_template_path('images/warning.png').
\n"; + } + + if($string != NULL){ + $_SESSION['errors'].= "
". + "
\"\"". + "$string". + "\"\"src=\"".get_template_path('images/warning.png').
\n"; + }else{ + return; + } + $_SESSION['errorsAlreadyPosted'] = array(); + $_SESSION['errorsAlreadyPosted'][$string] = 1; + + } + } else { echo "Error: $string\n"; } + $_SESSION['LastError'] = $string; + }