Code

Fixed logging, removed group by clause.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 27 Nov 2007 11:50:27 +0000 (11:50 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 27 Nov 2007 11:50:27 +0000 (11:50 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7907 594d385d-05f5-0310-b6e9-bd551577e9d8

contrib/mysql/logging/logging.sql
plugins/addons/logview/class_gosa_logview.inc
plugins/addons/logview/gosa_log_contents.tpl

index 856758e9f2b4b2c859e76f843b8f32fec84fdf40..e61472d8b186ade3a870235447d4f2ed69305fc1 100644 (file)
@@ -11,7 +11,7 @@ CREATE TABLE `gosa_log` (
   `changes` blob NOT NULL,
   `result` varchar(255) NOT NULL,
   PRIMARY KEY  (`id`)
-  KEY `action` (`action`),
   KEY `timestamp` (`timestamp`)
+  KEY `action` (`action`),
 ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
 
index a48d5ffe356486b5bb93b04861b879c45a721754..b6f182a8044fc4d263a8e7605343fb5d1b37086c 100644 (file)
@@ -207,14 +207,7 @@ class gosa_logview extends plugin
         new log("debug","logview","",array(),@mysql_error());
       } else {
 
-        
-
-        $start = $date_select_[$this->time];
-        
-        $sql_regex =trim(preg_replace("/\*/","%",$this->regex));
-        $sql_regex = "%".trim($sql_regex,"%")."%";
-
-        /* Order setting */
+        /* Prepare order setting */
         if ($this->sort_direction == "down"){
           $desc= "DESC";
           $sort_sign = "<img src='images/sort_down.png' alt='\/' class='center' title='down' border=0>";
@@ -222,44 +215,51 @@ class gosa_logview extends plugin
           $desc= "";
           $sort_sign = "<img src='images/sort_up.png' alt='/\' class='center' title='up' border=0>";
         }
-        $end= date ("YmdHis",time());
-        $query_base= "  FROM 
-          gosa_log 
-          WHERE
-          timestamp <= $end AND timestamp >= $start 
-          AND  
-          result like '".$sql_regex."' OR user like '".$sql_regex."' ";
 
+        /* Get start time */
+        $start = $date_select_[$this->time];
+        
+        /* Prepare search filter */
+        $sql_regex =trim(preg_replace("/\*/","%",$this->regex));
+        $sql_regex = "%".trim($sql_regex,"%")."%";
 
+        /* Create search filter */
+        $query_base= "FROM  gosa_log WHERE timestamp >= $start ";
+  
+        /* Append action filter */
         if($this->action != "!ALL"){
-          $query_base .="
-            AND
-            action like '".$this->action."'
-            ";
-        } 
+          $query_base .=" AND action like '".$this->action."' ";
+        }
+
+        /* Append search filter */
+        if($sql_regex != "%%"){
+          $query_base .=" AND ( result like '".$sql_regex."' OR user like '".$sql_regex."') ";
+        }
 
         /* Get number of entries */
-        $query= "SELECT COUNT(*)".$query_base.";";
+        $query= "SELECT COUNT(`user`) ".$query_base.";";
         $result = mysql_query($query);
         if(!$result){
           new log("debug","logview","",array(),@mysql_error());
         }
         $line= mysql_fetch_array($result, MYSQL_ASSOC);
-        $count= $line['COUNT(*)'];
+        $count= $line['COUNT(`user`)'];
         if ($count > 25){
           $smarty->assign("range_selector", range_selector($count, $this->start, $this->range,"EntriesPerPage"));
         } else {
           $smarty->assign("range_selector", "");
         }
 
-        /* Query results */
-        $query= "SELECT count(`action`) as 'repeated',`user`,`result`,`timestamp`,`action`,`action`,`objecttype`,`object`".$query_base." GROUP BY `action`,`result`,`timestamp` ORDER BY ".$this->fields[$this->sort]." $desc LIMIT ".$this->start.",".$this->range.";";
+        /* Query results that will be displayed */
+        $query= "SELECT * ".$query_base." ORDER BY ".$this->fields[$this->sort]." ".$desc." LIMIT  ".$this->start.",".$this->range.";";
         @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__, $query, "Database query");
         $result = @mysql_query($query);
-
         if(!$result){
           new log("debug","logview","",array(),@mysql_error());
         }
+
+        echo "<pre>".$query."</pre>";
+
         /* Display results */
         $mod= 0;
 
@@ -289,11 +289,11 @@ class gosa_logview extends plugin
           $res.="   <td title='".$line['objecttype']."'>".$line['objecttype']."</td>"; 
           $res.="   <td title='".$line['object']."'>".preg_replace("/,/",", ",$object)."</td>"; 
           $res.="   <td>".$line['result']."</td>";
-          if($line['repeated'] == 1){
-            $res.="   <td>-</td>";
-          }else{
-            $res.="   <td>".($line['repeated']-1)."</td>";
-          }
+#         if($line['repeated'] == 1){
+#           $res.="   <td>-</td>";
+#         }else{
+#           $res.="   <td>".($line['repeated']-1)."</td>";
+#         }
           $res.=" </tr>\n";
         }
         mysql_close($link);
index f10d978063a60728cd936006ca938220e1814793..5d71d8103d84cea736e181ea7fdd92d17ef2adcb 100644 (file)
@@ -85,7 +85,6 @@
    <td><a href="main.php{$plug}&amp;sort=3&amp;direction={$direction}">{t}Object type{/t} {$mode3}</a></td>
    <td><a href="main.php{$plug}&amp;sort=4&amp;direction={$direction}">{t}Object{/t} {$mode4}</a></td>
    <td><a href="main.php{$plug}&amp;sort=5&amp;direction={$direction}">{t}Message{/t} {$mode5}</a></td>
-   <td><a href="main.php{$plug}&amp;sort=6&amp;direction={$direction}">{t}Repeated{/t} {$mode6}</a></td>
   </tr>
   {$search_result}
  </table>