Code

Added user to search statement.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 27 Nov 2007 10:30:15 +0000 (10:30 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 27 Nov 2007 10:30:15 +0000 (10:30 +0000)
rearranged SQL statement. Should be much faster now.
 - Slow string operations were done, before fast integer operations.

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7904 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/addons/logview/class_gosa_logview.inc

index a3cb6ede6886cb37e31cd739d681e5a640c673c3..a48d5ffe356486b5bb93b04861b879c45a721754 100644 (file)
@@ -210,6 +210,9 @@ class gosa_logview extends plugin
         
 
         $start = $date_select_[$this->time];
+        
+        $sql_regex =trim(preg_replace("/\*/","%",$this->regex));
+        $sql_regex = "%".trim($sql_regex,"%")."%";
 
         /* Order setting */
         if ($this->sort_direction == "down"){
@@ -222,8 +225,10 @@ class gosa_logview extends plugin
         $end= date ("YmdHis",time());
         $query_base= "  FROM 
           gosa_log 
-          WHERE 
-          result like '".preg_replace("/\*/","%",$this->regex)."' ";
+          WHERE
+          timestamp <= $end AND timestamp >= $start 
+          AND  
+          result like '".$sql_regex."' OR user like '".$sql_regex."' ";
 
 
         if($this->action != "!ALL"){
@@ -233,10 +238,6 @@ class gosa_logview extends plugin
             ";
         } 
 
-        $query_base .="
-          AND  
-          timestamp <= $end AND timestamp >= $start";
-
         /* Get number of entries */
         $query= "SELECT COUNT(*)".$query_base.";";
         $result = mysql_query($query);