better sorting

git-svn-id: file:///home/shish/svn/shimmie2/trunk@472 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
shish 2007-08-24 13:41:43 +00:00
parent 2240262205
commit e98e4e31d5
2 changed files with 23 additions and 5 deletions

View file

@ -33,11 +33,17 @@ class EventLog extends Extension {
if(isset($_GET['sort']) && in_array($_GET['sort'], array("name", "date", "ip", "event"))) {
$sort = $_GET['sort'];
}
$order = "DESC";
if(isset($_GET['order']) && in_array($_GET['order'], array("ASC", "DESC"))) {
$order = $_GET['order'];
}
$events = $database->db->GetAll("
SELECT event_log.*,users.name FROM event_log
JOIN users ON event_log.owner_id = users.id
WHERE date > date_sub(now(), interval 1 day)
ORDER BY $sort DESC
ORDER BY $sort $order
");
$this->theme->display_page($event->page, $events);
}

View file

@ -23,13 +23,25 @@ class EventLogTheme extends Themelet {
</style>
<table border='1' class='event_log_table'>
<tr>
<th><a href='".make_link("event_log", "sort=name")."'>User</a></th>
<th style='width: 10em;'><a href='".make_link("event_log", "sort=ip")."'>IP</a></th>
<th>User
<a href='".make_link("event_log", "sort=name&order=ASC")."'>+</a>
<a href='".make_link("event_log", "sort=name&order=DESC")."'>-</a>
</th>
<th style='width: 10em;'>IP
<a href='".make_link("event_log", "sort=ip&order=ASC")."'>+</a>
<a href='".make_link("event_log", "sort=ip&order=DESC")."'>-</a>
</th>
<th rowspan='2' class='entry'>Entry</th>
</tr>
<tr>
<th style='width: 10em;'><a href='".make_link("event_log", "sort=date")."'>Date</a></th>
<th><a href='".make_link("event_log", "sort=event")."'>Event</a></th>
<th style='width: 10em;'>Date
<a href='".make_link("event_log", "sort=date&order=ASC")."'>+</a>
<a href='".make_link("event_log", "sort=date&order=DESC")."'>-</a>
</th>
<th>Event
<a href='".make_link("event_log", "sort=event&order=ASC")."'>+</a>
<a href='".make_link("event_log", "sort=event&order=DESC")."'>-</a>
</th>
</tr>
";
foreach($events as $event) {