/
EntryList.php
69 lines (59 loc) · 1.61 KB
/
EntryList.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
59
60
61
62
63
64
65
66
67
68
69
<?php
namespace Concrete\Core\User\Point;
use Concrete\Core\Legacy\DatabaseItemList;
use Loader;
use Concrete\Core\User\Point\Entry as UserPointEntry;
class EntryList extends DatabaseItemList
{
protected $autoSortColumns = array('uName', 'upaName', 'upPoints', 'timestamp');
public function __construct()
{
$this->setBaseQuery();
}
protected function setBaseQuery()
{
$this->setQuery('SELECT UserPointHistory.upID
FROM UserPointHistory
LEFT JOIN UserPointActions ON UserPointActions.upaID = UserPointHistory.upaID
LEFT JOIN Groups ON UserPointActions.gBadgeID = Groups.gID
LEFT JOIN Users ON UserPointHistory.upuID = Users.uID
');
}
/**
* @param int $gID
*/
public function filterByGroupID($gID)
{
$this->filter('UserPointActions.gBadgeID', $gID);
}
/**
* @param string $uName
*/
public function filterByUserName($uName)
{
$this->filter('Users.uName', $uName);
}
public function filterByUserPointActionName($upaName)
{
$db = Loader::db();
$this->filter(false, "UserPointActions.upaName LIKE ".$db->quote('%'.$upaName.'%'));
}
/**
* @param int $uID
*/
public function filterByUserID($uID)
{
$this->filter('UserPointHistory.upuID', (int) $uID);
}
public function get($items = 0, $offset = 0)
{
$resp = parent::get($items, $offset);
$entries = array();
foreach ($resp as $r) {
$up = new UserPointEntry();
$up->load($r['upID']);
$entries[] = $up;
}
return $entries;
}
}