Code

Updated print_red error output, every message is now displayed only once.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 6 Mar 2006 09:16:22 +0000 (09:16 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 6 Mar 2006 09:16:22 +0000 (09:16 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2812 594d385d-05f5-0310-b6e9-bd551577e9d8

html/main.php
include/functions.inc

index a2b8d72eee59d9bb9a7607a4ba8f95729761ae37..8471e3eea3751e21ed743551bfa80a99d85ef8f4 100644 (file)
@@ -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']);
 }
index a7695a01744376076f803b212f935a993e50b49e..3aaf3bfee7e64e70ee98e37e06f9a9bcd1230cb1 100644 (file)
@@ -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'].= "<div align=\"left\" style=\"border-width:5px;".
-      "border-style:solid;border-color:red; background-color:black;".
-      "margin-bottom:10px; padding:8px;\"><table style='width:100%' summary=''><tr><td><img alt=\"\" src=\"".
-      get_template_path('images/warning.png')."\"></td>".
-      "<td width=\"100%\" style=\"text-align:center\"><font color=\"#FFFFFF\">".
-      "<b style='font-size:16px;'>$string</b></font></td><td>".
-      "<img alt=\"\"src=\"".get_template_path('images/warning.png').
-      "\"></td></tr></table></div>\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'].= "<div align=\"left\" style=\"border-width:5px;".
+          "border-style:solid;border-color:red; background-color:black;".
+          "margin-bottom:10px; padding:8px;\"><table style='width:100%' summary=''><tr><td><img alt=\"\" src=\"".
+          get_template_path('images/warning.png')."\"></td>".
+          "<td width=\"100%\" style=\"text-align:center\"><font color=\"#FFFFFF\">".
+          "<b style='font-size:16px;'>".sprintf(_("Last message repeated %s times."),$_SESSION['errorsAlreadyPosted'][$_SESSION['LastError']])."</b></font></td><td>".
+          "<img alt=\"\"src=\"".get_template_path('images/warning.png').
+          "\"></td></tr></table></div>\n";
+      }
+
+      if($string != NULL){
+      $_SESSION['errors'].= "<div align=\"left\" style=\"border-width:5px;".
+        "border-style:solid;border-color:red; background-color:black;".
+        "margin-bottom:10px; padding:8px;\"><table style='width:100%' summary=''><tr><td><img alt=\"\" src=\"".
+        get_template_path('images/warning.png')."\"></td>".
+        "<td width=\"100%\" style=\"text-align:center\"><font color=\"#FFFFFF\">".
+        "<b style='font-size:16px;'>$string</b></font></td><td>".
+        "<img alt=\"\"src=\"".get_template_path('images/warning.png').
+        "\"></td></tr></table></div>\n";
+      }else{
+        return;
+      }
+      $_SESSION['errorsAlreadyPosted'] = array();
+      $_SESSION['errorsAlreadyPosted'][$string] = 1;
+      
+    }
+
   } else {
     echo "Error: $string\n";
   }
+  $_SESSION['LastError'] = $string; 
+
 }