Code

Udpated message handling
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 15 Oct 2007 07:38:22 +0000 (07:38 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 15 Oct 2007 07:38:22 +0000 (07:38 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7543 594d385d-05f5-0310-b6e9-bd551577e9d8

include/class_log.inc
include/class_msg_dialog.inc
include/functions.inc

index af687c39e605b2c64bcdc03cd0d0f0bc9ed97470..d9c3565f0df6f1c8a21b4823a4ccfbe2351f4a27 100644 (file)
@@ -150,7 +150,7 @@ class log {
       }else{
         $db = mysql_select_db($server['DB'],$con);
         if(!$db){
-          @print_red(sprintf(_("Could not select database %s on server %s. Server says :%s"),$server['DB'],$server['SERVER'],mysql_error($con)));
+          print_red(sprintf(_("Could not select database %s on server %s. Server says :%s"),$server['DB'],$server['SERVER'],mysql_error($con)));
         }else{
 
           /* Create mysql syntax */
index 8d6d633347b7cea789f70a363d993329ca047acc..505d47fc7b412bb77c4a673042f69f364a7e6e75 100644 (file)
@@ -21,20 +21,32 @@ class msg_dialog
                        $i_type = INFO_DIALOG;
                }
 
-               $this->i_ID      = preg_replace("/[^0-9]*/","",microtime()); 
-               $this->s_Title   = $s_title;
-               $this->s_Message = $s_message;
-               $this->i_Type    = $i_type;
-               $this->a_Trace   = debug_backtrace();
-               if(!isset($_SESSION['msg_dialogs'])){
-                       $_SESSION['msg_dialogs'] = array();
+               if((!isset($_SESSION['errorsAlreadyPosted'])) || !is_array($_SESSION['errorsAlreadyPosted'])){
+                       $_SESSION['errorsAlreadyPosted'] = array();
                }
-               if($this->i_Type == FATAL_ERROR_DIALOG){
-               restore_error_handler();
-               error_reporting(E_ALL);
-                       echo $this->execute();
-               }else{
-                       $_SESSION['msg_dialogs'][] = $this;
+
+               if(!isset($_SESSION['errorsAlreadyPosted'][$s_title.$s_message])){
+                       $_SESSION['errorsAlreadyPosted'][$s_title.$s_message] = 0;
+               }
+               $_SESSION['errorsAlreadyPosted'][$s_title.$s_message]++;
+
+               if($_SESSION['errorsAlreadyPosted'][$s_title.$s_message] <=1  ){
+
+                       $this->i_ID      = preg_replace("/[^0-9]*/","",microtime()); 
+                       $this->s_Title   = $s_title;
+                       $this->s_Message = $s_message;
+                       $this->i_Type    = $i_type;
+                       $this->a_Trace   = debug_backtrace();
+                       if(!isset($_SESSION['msg_dialogs'])){
+                               $_SESSION['msg_dialogs'] = array();
+                       }
+                       if($this->i_Type == FATAL_ERROR_DIALOG){
+                               restore_error_handler();
+                               error_reporting(E_ALL);
+                               echo $this->execute();
+                       }else{
+                               $_SESSION['msg_dialogs'][] = $this;
+                       }
                }
        }
 
index 600e91034776e7bea97da3693b33db955c742e4a..b244a0896791d5875904669353d0283659c546bb 100644 (file)
@@ -1011,114 +1011,28 @@ 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'])){
-
-    if($_SESSION['LastError'] == $string){
-    
-      if((!isset($_SESSION['errorsAlreadyPosted'][$string]))){
-        $_SESSION['errorsAlreadyPosted'][$string] = 1;
-      }
-      $_SESSION['errorsAlreadyPosted'][$string]++;
-
-    }else{
-      if($string !== NULL){
-        if (preg_match("/"._("LDAP error:")."/", $string)){
-          $addmsg= _("Problems with the LDAP server mean that you probably lost the last changes. Please check your LDAP setup for possible errors and try again.");
-          $img= "images/error.png";
-        } else {
-          if (!preg_match('/[.!?]$/', $string)){
-            $string.= ".";
-          }
-          $string= preg_replace('/<br>/', ' ', $string);
-          $img= "images/warning.png";
-          $addmsg= _("Please check your input and fix the error. Press 'OK' to close this message box.");
-        }
-     
-        msg_dialog::display($addmsg, $string,ERROR_DIALOG);
-        return;
-/*
-        if(isset($_SESSION['errors']) && strlen($_SESSION['errors'])==0) {
-
-          if(preg_match("/MSIE/", $_SERVER['HTTP_USER_AGENT'])){
-
-            $_SESSION['errors'].= "
-              <iframe id='e_layer3' 
-                style=\"  position:absolute;
-                          width:100%;
-                          height:100%;
-                          top:0px;
-                          left:0px;
-                          border:none;  
-                          border-style:none; 
-                          border-width:0pt;
-                          display:block;
-                          allowtransparency='true';
-                          background-color: #FFFFFF;
-                          filter:chroma(color=#FFFFFF);
-                          z-index:0; \">
-              </iframe>
-              <div  id='e_layer2'
-                style=\"
-                  position: absolute;
-                  left: 0px;
-                  top: 0px;
-                  right:0px;
-                  bottom:0px;
-                  z-index:0;
-                  width:100%;
-                  height:100%;
-                  filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src='images/opacity_black.png'); \">
-              </div>";
-              $hide = "hide(\"e_layer\");hide(\"e_layer2\");hide(\"e_layer3\");";
-          }else{
-
-            $_SESSION['errors'].= "
-              <div  id='e_layer2'
-                style=\"
-                  position: absolute;
-                  left: 0px;
-                  top: 0px;
-                  right:0px;
-                  bottom:0px;
-                  z-index:0;
-                  background-image: url(images/opacity_black.png);\">
-               </div>";
-              $hide = "hide(\"e_layer\");hide(\"e_layer2\");";
-          }
-
-        $_SESSION['errors'].= "
-         <div style='left:20%;right:20%;top:30%;".
-         "background-color:white;padding:5px;border:5px solid red;z-index:150;".
-         "position:absolute' id='e_layer'><table style='width:100%' summary='' border=0>".
-         "<tr><td style='vertical-align:top;padding:10px'><img alt='' src='".
-         get_template_path($img)."'></td>".
-         "<td style='width:100%'><h1>"._("An error occurred while processing your request").
-         "</h1><b>$string</b><br><br>$addmsg</td></tr><tr><td colspan='2' align='center'><br><button ".
-         (($_SESSION['js']==FALSE)?"type='submit'":"type='button' name='error_accept'").
-         " style='width:80px' onClick='".$hide."'>".
-         _("OK")."</button></td></tr></table></div>";
-
+    if($string !== NULL){
+      if (preg_match("/"._("LDAP error:")."/", $string)){
+        $addmsg= _("Problems with the LDAP server mean that you probably lost the last changes. Please check your LDAP setup for possible errors and try again.");
+      } else {
+        if (!preg_match('/[.!?]$/', $string)){
+          $string.= ".";
         }
-        */
-      }else{
-        return;
+        $string= preg_replace('/<br>/', ' ', $string);
+        $addmsg= _("Please check your input and fix the error. Press 'OK' to close this message box.");
       }
-      $_SESSION['errorsAlreadyPosted'][$string] = 1;
-
+      msg_dialog::display($addmsg, $string,ERROR_DIALOG);
+      return;
+    }else{
+      return;
     }
 
   } else {
     echo "Error: $string\n";
   }
-  $_SESSION['LastError'] = $string; 
 }