From: hickert Date: Tue, 27 Nov 2007 11:50:27 +0000 (+0000) Subject: Fixed logging, removed group by clause. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=73ab72c2fc39ecc0f63343327023dcd0ff6036cc;p=gosa.git Fixed logging, removed group by clause. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7907 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/contrib/mysql/logging/logging.sql b/contrib/mysql/logging/logging.sql index 856758e9f..e61472d8b 100644 --- a/contrib/mysql/logging/logging.sql +++ b/contrib/mysql/logging/logging.sql @@ -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 ; diff --git a/plugins/addons/logview/class_gosa_logview.inc b/plugins/addons/logview/class_gosa_logview.inc index a48d5ffe3..b6f182a80 100644 --- a/plugins/addons/logview/class_gosa_logview.inc +++ b/plugins/addons/logview/class_gosa_logview.inc @@ -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 = "\/"; @@ -222,44 +215,51 @@ class gosa_logview extends plugin $desc= ""; $sort_sign = "/\"; } - $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 "
".$query."
"; + /* Display results */ $mod= 0; @@ -289,11 +289,11 @@ class gosa_logview extends plugin $res.=" ".$line['objecttype'].""; $res.=" ".preg_replace("/,/",", ",$object).""; $res.=" ".$line['result'].""; - if($line['repeated'] == 1){ - $res.=" -"; - }else{ - $res.=" ".($line['repeated']-1).""; - } +# if($line['repeated'] == 1){ +# $res.=" -"; +# }else{ +# $res.=" ".($line['repeated']-1).""; +# } $res.=" \n"; } mysql_close($link); diff --git a/plugins/addons/logview/gosa_log_contents.tpl b/plugins/addons/logview/gosa_log_contents.tpl index f10d97806..5d71d8103 100644 --- a/plugins/addons/logview/gosa_log_contents.tpl +++ b/plugins/addons/logview/gosa_log_contents.tpl @@ -85,7 +85,6 @@ {t}Object type{/t} {$mode3} {t}Object{/t} {$mode4} {t}Message{/t} {$mode5} - {t}Repeated{/t} {$mode6} {$search_result}