paginated logs
This commit is contained in:
parent
5d0c9d3fa3
commit
6c85ed3ba0
2 changed files with 33 additions and 3 deletions
|
@ -46,6 +46,8 @@ class LogDatabase extends SimpleExtension {
|
|||
if($user->is_admin()) {
|
||||
$wheres = array();
|
||||
$args = array();
|
||||
$page_num = int_escape($event->get_arg(0));
|
||||
if($page_num <= 0) $page_num = 1;
|
||||
if(!empty($_GET["time"])) {
|
||||
$wheres[] = "date_sent LIKE ?";
|
||||
$args[] = $_GET["time"]."%";
|
||||
|
@ -76,13 +78,32 @@ class LogDatabase extends SimpleExtension {
|
|||
$wheres[] = "priority >= ?";
|
||||
$args[] = int_escape($_GET["priority"]);
|
||||
}
|
||||
else {
|
||||
$wheres[] = "priority >= ?";
|
||||
$args[] = 20;
|
||||
}
|
||||
$where = "";
|
||||
if(count($wheres) > 0) {
|
||||
$where = "WHERE ";
|
||||
$where .= join(" AND ", $wheres);
|
||||
}
|
||||
$events = $database->get_all("SELECT * FROM score_log $where ORDER BY id DESC LIMIT 50", $args);
|
||||
$this->theme->display_events($events);
|
||||
|
||||
$limit = 50;
|
||||
$offset = ($page_num-1) * $limit;
|
||||
$page_total = $database->cache->get("event_log_length");
|
||||
if(!$page_total) {
|
||||
$page_total = $database->db->GetOne("SELECT count(*) FROM score_log $where", $args);
|
||||
// don't cache a length of zero when the extension is first installed
|
||||
if($page_total > 10) {
|
||||
$database->cache->set("event_log_length", 600);
|
||||
}
|
||||
}
|
||||
|
||||
$args[] = $offset;
|
||||
$args[] = $limit;
|
||||
$events = $database->get_all("SELECT * FROM score_log $where ORDER BY id DESC LIMIT ?,?", $args);
|
||||
|
||||
$this->theme->display_events($events, $page_num, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,13 @@ class LogDatabaseTheme extends Themelet {
|
|||
if(isset($_GET[$var])) return html_escape($_GET[$var]);
|
||||
else return "";
|
||||
}
|
||||
public function display_events($events) {
|
||||
|
||||
protected function ueie($var) {
|
||||
if(isset($_GET[$var])) return $var."=".url_escape($_GET[$var]);
|
||||
else return "";
|
||||
}
|
||||
|
||||
public function display_events($events, $page_num, $page_total) {
|
||||
$table = "
|
||||
<style>
|
||||
.sizedinputs TD INPUT {
|
||||
|
@ -59,6 +65,9 @@ class LogDatabaseTheme extends Themelet {
|
|||
$page->set_heading("Event Log");
|
||||
$page->add_block(new NavBlock());
|
||||
$page->add_block(new Block("Events", $table));
|
||||
|
||||
$args = $this->ueie("time")."&".$this->ueie("module")."&".$this->ueie("user")."&".$this->ueie("priority");
|
||||
$this->display_paginator($page, "log/view", $args, $page_num, $page_total);
|
||||
}
|
||||
|
||||
protected function pri_to_col($pri) {
|
||||
|
|
Reference in a new issue