summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7c5ebee)
raw | patch | inline | side by side (parent: 7c5ebee)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 4 Mar 2008 14:40:05 +0000 (14:40 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 4 Mar 2008 14:40:05 +0000 (14:40 +0000) |
-A message will be shown now, if the database isn't up to date
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9324 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9324 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-plugins/log/addons/logview/class_gosa_logview.inc | patch | blob | history |
diff --git a/gosa-plugins/log/addons/logview/class_gosa_logview.inc b/gosa-plugins/log/addons/logview/class_gosa_logview.inc
index 2e98fcad9f2ff619f9ff049509de012b4c174570..856af273e80cd62f93a32758d4f6b249abd30db2 100644 (file)
return ($smarty->fetch (get_template_path('gosa_log_contents.tpl', TRUE)));
}
+ /* 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>";
+ } else {
+ $desc= "";
+ $sort_sign = "<img src='images/sort_up.png' alt='/\' class='center' title='up' border=0>";
+ }
/****
* Query stuff
} else {
if (! @mysql_select_db($cfg['DB'])){
- msg_dialog::display(_("Error"), sprintf(_("Cannot select %s database!"), "GOsa LOG"), ERROR_DIALOG);
+ msg_dialog::display(_("Error"), sprintf(_("Cannot select %s database!"), "GOsa LOG"), ERROR_DIALOG);
new log("debug","logview","",array(),@mysql_error());
} else {
- /* 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>";
- } else {
- $desc= "";
- $sort_sign = "<img src='images/sort_up.png' alt='/\' class='center' title='up' border=0>";
+ /* Check for required tables
+ */
+ $query = "SHOW TABLES;";
+ $res = @mysql_query($query,$con);
+ $tables = array();
+ while($attrs = @mysql_fetch_row($res)){
+ $tables[] = $attrs[0];
}
+ $error = FALSE;
+ foreach(array("gosa_log","gosa_locations") as $required){
+ if(!in_array($required,$tables)){
+ msg_dialog::display(_("Error"),
+ sprintf(_("Missing logging table (%s.%s) update your GOsa logging database schema."),
+ $cfg['DB'],$required), ERROR_DIALOG);
+ $error = TRUE;
+ }
+ }
+ if(!$error){
- /* Get start time */
- $start = $date_select_[$this->time];
-
- /* Prepare search filter */
- $sql_regex =trim(preg_replace("/\*/","%",$this->regex));
- $sql_regex = "%".trim($sql_regex,"%")."%";
+ /* Get start time */
+ $start = $date_select_[$this->time];
- /* 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."' ";
- }
+ /* Prepare search filter */
+ $sql_regex =trim(preg_replace("/\*/","%",$this->regex));
+ $sql_regex = "%".trim($sql_regex,"%")."%";
- /* Append search filter */
- if($sql_regex != "%%"){
- $query_base .=" AND ( result like '".$sql_regex."' OR user like '".$sql_regex."') ";
- }
+ /* Create search filter */
+ $query_base= "FROM gosa_log WHERE timestamp >= $start ";
- /* Appen location */
- $query_base .= " AND location_id='".$this->location_id."' ";
+ /* Append action filter */
+ if($this->action != "!ALL"){
+ $query_base .=" AND action like '".$this->action."' ";
+ }
- /* Get number of entries */
- $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(`user`)'];
- if ($count > 25){
- $smarty->assign("range_selector", range_selector($count, $this->start, $this->range,"EntriesPerPage"));
- } else {
- $smarty->assign("range_selector", "");
- }
+ /* Append search filter */
+ if($sql_regex != "%%"){
+ $query_base .=" AND ( result like '".$sql_regex."' OR user like '".$sql_regex."') ";
+ }
- /* 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());
- msg_dialog::display(_("Error"), sprintf(_("Cannot query %s database!"), "GOsa LOG"), ERROR_DIALOG);
- }else{
+ /* Appen location */
+ $query_base .= " AND location_id='".$this->location_id."' ";
+
+ /* Get number of entries */
+ $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(`user`)'];
+ if ($count > 25){
+ $smarty->assign("range_selector", range_selector($count, $this->start, $this->range,"EntriesPerPage"));
+ } else {
+ $smarty->assign("range_selector", "");
+ }
+
+ /* 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());
+ }
/* Display results */
$mod= 0;