Code

Updated logging
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 23 May 2007 06:18:38 +0000 (06:18 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 23 May 2007 06:18:38 +0000 (06:18 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6438 594d385d-05f5-0310-b6e9-bd551577e9d8

include/class_acl.inc
include/class_log.inc
include/class_plugin.inc
include/php_setup.inc
include/sieve/class_sieveManagement.inc

index 99adff3fc05ddffe0743a1e93b897eebe06de24d..23db48299827c7fe3728761250d65be0ab92fc14 100644 (file)
@@ -1032,7 +1032,9 @@ class acl extends plugin
     $this->cleanup();
     $ldap->modify ($this->attrs);
 
-    @log::log("modify","acls/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    if(count($this->attrs)){
+      @log::log("modify","acls/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    }
 
     show_ldap_error($ldap->get_error(), sprintf(_("Saving ACLs with dn '%s' failed."),$this->dn));
 
index 3b8a56c1aac24837cccb12a355c0b8126338769d..e41beba15e73fdb40f13d53a28ff3cda420d3641 100644 (file)
@@ -59,28 +59,38 @@ class log {
     /* Create data object */
     $entry = array(); 
     $entry['timestamp'] = time();
-    $entry['user']      = $ui->dn;
+    $entry['user']      = @$ui->dn;
     $entry['action']    = $action;
     $entry['objecttype']= $objecttype;
     $entry['object']    = $object;
     $entry['changes']   = $changes;
     $entry['result']    = $result;
+
+    if(!isset($this->config->current['LOGGING']) && empty($entry['user'])){
+      $entry['user']  = "unknown";
+    }
  
     /* Check if all given values are valid */
     $msgs = @log::check($entry);
     if(count($msgs)){
       foreach($msgs as $msg){
         trigger_error("Logging failed, reason was: ".$msg);
-        print_red("Logging failed, reason was: ".$msg);
+        print_red("Logging failed, reason was: ".$msg); 
       }
+      
     }else{
 
-      /* Start logging for configured methods */
-      if(isset($this->config->current['LOGGING']) && preg_match("/(^|,)syslog(,|$)/i",$this->config->current['LOGGING'])){
+      if(!isset($this->config->current['LOGGING'])){
         @log::log_into_syslog($entry);
-      }
-      if(isset($this->config->current['LOGGING']) && preg_match("/(^|,)mysql(,|$)/i",$this->config->current['LOGGING'])){
-        @log::log_into_db($entry);
+      }else{
+
+        /* Start logging for configured methods */
+        if(isset($this->config->current['LOGGING']) && preg_match("/(^|,)syslog(,|$)/i",$this->config->current['LOGGING'])){
+          @log::log_into_syslog($entry);
+        }
+        if(isset($this->config->current['LOGGING']) && preg_match("/(^|,)mysql(,|$)/i",$this->config->current['LOGGING'])){
+          @log::log_into_db($entry);
+        }
       }
     }
   }
@@ -89,11 +99,11 @@ class log {
   function check($entry = array())
   {
     $msgs = array();
-    if(!isset($entry['user']) || empty($entry['user'])){
-      $msgs[] = "Currently active user is empty.";
-    }
+  #  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"))){
+    if(!isset($entry['action']) || !in_array($entry['action'],array("modify","create","remove","copy","snapshot","view","security"))){
       $msgs[] = "Invalid option specified '".$entry['action']."'";
     }
 
index 6cbec1b4eddc6cf2a5559cf6b04e21b406a3c27c..3714609db1da2e2993ddf747795a4180bc39806d 100644 (file)
@@ -222,7 +222,7 @@ class plugin
    */
   function execute()
   {
-    gosa_log("ACL ".get_class($this)." - ".$this->acl_category." - ".$this->acl_base);
+    @log::log("view","acl/".get_class($this),$this->dn,array(),"ACL ".get_class($this)." - ".$this->acl_category." - ".$this->acl_base);
 
     /* This one is empty currently. Fabian - please fill in the docu code */
     $_SESSION['current_class_for_help'] = get_class($this);
@@ -1527,7 +1527,7 @@ class plugin
     /* Update userinfo if necessary */
     if($_SESSION['ui']->dn == $old_dn){
       $_SESSION['ui']->dn = $new_dn;
-      gosa_log(_("Updated current user dn from '".$old_dn."' to '".$new_dn."'"));
+      @log::log("view","acl/".get_class($this),$this->dn,array(),"Updated current user dn from '".$old_dn."' to '".$new_dn."'");
     }
 
     /* Object was moved, ensure that all acls will be moved too */
index e83379c9826cdd039a758e2d177d6658e75e8a22..7d6c73870158054dabcaa2c8772ccc467ccb341d 100644 (file)
@@ -57,7 +57,7 @@ function gosaRaiseError($errno, $errstr, $errfile, $errline)
     if((isset($config->data['MAIN']['DISPLAYERRORS']))&&(!preg_match("/^true$/i",$config->data['MAIN']['DISPLAYERRORS']))){
 
       /* Write to syslog */
-      gosa_log ("PHP error: $errstr ($errfile, line $errline)");
+      @log::log("view","error","",array(),"PHP error: $errstr ($errfile, line $errline)");
       return;
     }
   }
index ef45e77329ada9fa29c630a298ee5fa11a9eeaff..33c730945c693f604b812a5428435461f326e40c 100644 (file)
@@ -1039,7 +1039,8 @@ class sieveManagement extends plugin
       if($script['EDITED']){
         $data = $this->scripts[$key]['SCRIPT'];
         if(!$this->sieve_handle->sieve_sendscript($script['NAME'], addcslashes ($data,"\\"))){
-          gosa_log("Failed to save sieve script named '".$script['NAME']."': ".to_string($this->sieve_handle->error_raw));
+          @log::log("modify","users/mailAccount".get_class($this),$script['NAME'],"Failed to save sieve script named '".$script['NAME']."': ".to_string($this->sieve_handle->error_raw));
+
           $everything_went_fine = FALSE;
           print_red(to_string($this->sieve_handle->error_raw));
           $this->scripts[$key]['MSG'] = "<font color='red'>".