Code

Split gofaxBlocklists into management and generic class
[gosa.git] / include / class_log.inc
index 462be2892e3b53566e64def61b51400c6afe14ca..daad88908e19a8211f9338350e61f0021f146f40 100644 (file)
@@ -43,7 +43,7 @@ class log {
 
     \sa log()
    */
-  function log($action,$objecttype,$object,$changes_array = array(),$result = TRUE)
+  function log($action,$objecttype,$object,$changes_array = array(),$result = "")
   {
     if(!is_array($changes_array)){
       trigger_error("log(string,string,string,array(),bool). Forth parameter must be an array.");
@@ -55,7 +55,7 @@ class log {
       $entry['user']= "unkown";
     }else{
 
-      $this->config = $_SESSION['config'];
+      $this->config = &$_SESSION['config'];
       $ui           = get_userinfo(); 
       $entry['user']= @$ui->dn;
     }
@@ -98,7 +98,13 @@ class log {
           $this->log_into_syslog($entry);
         }
         if(isset($this->config->current['LOGGING']) && preg_match("/(^|,)mysql(,|$)/i",$this->config->current['LOGGING'])){
-          $this->log_into_db($entry);
+          $res = $this->log_into_db($entry);
+
+          if(!$res){
+            global $config;
+            $config->current['LOGGING'] = preg_replace("/(^|,)mysql(,|$)/",",",$config->current['LOGGING']);
+            msg_dialog::display(_("Logging to MySQL disabled"),_("The logging to a MySQL database is now disabled for this session of GOsa, due to communication errors with the specified logging database."), INFO_DIALOG);
+          }
         }
       }
     }
@@ -108,9 +114,6 @@ class log {
   function check($entry = array())
   {
     $msgs = array();
-  #  if(!isset($entry['user']) || empty($entry['user'])){
-  #    $msgs[] = "Currently active user is empty.";
-  #  }
 
     if(!isset($entry['action']) || !in_array($entry['action'],array("modify","create","remove","copy","snapshot","view","security","debug"))){
       $msgs[] = "Invalid option specified '".$entry['action']."'";
@@ -147,10 +150,12 @@ class log {
       $con = @mysql_pconnect($server_name,$server['USER'],$server['PWD']);
       if(!$con){
         print_red(sprintf(_("Could not connect to logging server %s."),$server_name));
+        return(FALSE);
       }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)));
+          return(FALSE);
         }else{
 
           /* Create mysql syntax */
@@ -169,13 +174,14 @@ class log {
               ";
           $res = mysql_query($query,$con);
           if(!$res){
-            print_red(sprintf(_("Could not query database %s on server %s. Server ssys :%s"),$server['DB'],$server['SERVER'],mysql_error($con)));
-            
+            print_red(sprintf(_("Could not query database %s on server %s. Server says :%s"),$server['DB'],$server['SERVER'],mysql_error($con)));
+            return(FALSE);
           } 
         }
         mysql_close($con);
       }
     }
+    return(TRUE);
   }
 }