/
LogList.php
58 lines (50 loc) · 1.4 KB
/
LogList.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace Concrete\Core\Logging;
use Concrete\Core\Legacy\DatabaseItemList;
use Database;
class LogList extends DatabaseItemList
{
protected $autoSortColumns = array('logID', 'level');
protected $sortBy = 'logID';
protected $sortByDirection = 'desc';
public function __construct()
{
$this->setQuery("select Logs.logID from Logs");
}
public function get($itemsToGet = 100, $offset = 0)
{
$r = parent::get($itemsToGet, intval($offset));
$entries = array();
foreach ($r as $row) {
$e = LogEntry::getByID($row['logID']);
if (is_object($e)) {
$entries[] = $e;
}
}
return $entries;
}
public function filterByKeywords($keywords)
{
$db = Database::get();
$this->filter(false, "message like " . $db->qstr('%' . $keywords . '%'));
}
public function filterByChannel($channel)
{
$this->filter('channel', $channel);
}
public function filterByLevels($levels)
{
$db = Database::get();
if (is_array($levels)) {
$lth = '(';
for ($i = 0; $i < count($levels); ++$i) {
if ($i > 0) {
$lth .= ',';
}
$lth .= $db->quote($levels[$i]);
}
$lth .= ')';
$this->filter(false, "(level in {$lth})");
}
}
}