|
1
|
|
|
<?php |
|
2
|
|
|
/****************************************************************************** |
|
3
|
|
|
* Wikipedia Account Creation Assistance tool * |
|
4
|
|
|
* * |
|
5
|
|
|
* All code in this file is released into the public domain by the ACC * |
|
6
|
|
|
* Development Team. Please see team.json for a list of contributors. * |
|
7
|
|
|
******************************************************************************/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Waca\Helpers\SearchHelpers; |
|
10
|
|
|
|
|
11
|
|
|
use Waca\DataObjects\Log; |
|
12
|
|
|
use Waca\PdoDatabase; |
|
13
|
|
|
|
|
14
|
|
|
class LogSearchHelper extends SearchHelperBase |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* LogSearchHelper constructor. |
|
18
|
|
|
* |
|
19
|
|
|
* @param PdoDatabase $database |
|
20
|
|
|
*/ |
|
21
|
|
|
protected function __construct(PdoDatabase $database) |
|
22
|
|
|
{ |
|
23
|
|
|
parent::__construct($database, 'log', Log::class, 'timestamp DESC'); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Initiates a search for requests |
|
28
|
|
|
* |
|
29
|
|
|
* @param PdoDatabase $database |
|
30
|
|
|
* |
|
31
|
|
|
* @return LogSearchHelper |
|
32
|
|
|
*/ |
|
33
|
|
|
public static function get(PdoDatabase $database) |
|
34
|
|
|
{ |
|
35
|
|
|
$helper = new LogSearchHelper($database); |
|
36
|
|
|
|
|
37
|
|
|
return $helper; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Filters the results by user |
|
42
|
|
|
* |
|
43
|
|
|
* @param int $userId |
|
44
|
|
|
* |
|
45
|
|
|
* @return $this |
|
46
|
|
|
*/ |
|
47
|
|
|
public function byUser($userId) |
|
48
|
|
|
{ |
|
49
|
|
|
$this->whereClause .= ' AND user = ?'; |
|
50
|
|
|
$this->parameterList[] = $userId; |
|
51
|
|
|
|
|
52
|
|
|
return $this; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Filters the results by log action |
|
57
|
|
|
* |
|
58
|
|
|
* @param string $action |
|
59
|
|
|
* |
|
60
|
|
|
* @return $this |
|
61
|
|
|
*/ |
|
62
|
|
|
public function byAction($action) |
|
63
|
|
|
{ |
|
64
|
|
|
$this->whereClause .= ' AND action = ?'; |
|
65
|
|
|
$this->parameterList[] = $action; |
|
66
|
|
|
|
|
67
|
|
|
return $this; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Filters the results by object type |
|
72
|
|
|
* |
|
73
|
|
|
* @param string $objectType |
|
74
|
|
|
* |
|
75
|
|
|
* @return $this |
|
76
|
|
|
*/ |
|
77
|
|
|
public function byObjectType($objectType) |
|
78
|
|
|
{ |
|
79
|
|
|
$this->whereClause .= ' AND objecttype = ?'; |
|
80
|
|
|
$this->parameterList[] = $objectType; |
|
81
|
|
|
|
|
82
|
|
|
return $this; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Filters the results by object type |
|
87
|
|
|
* |
|
88
|
|
|
* @param integer $objectId |
|
89
|
|
|
* |
|
90
|
|
|
* @return $this |
|
91
|
|
|
*/ |
|
92
|
|
|
public function byObjectId($objectId) |
|
93
|
|
|
{ |
|
94
|
|
|
$this->whereClause .= ' AND objectid = ?'; |
|
95
|
|
|
$this->parameterList[] = $objectId; |
|
96
|
|
|
|
|
97
|
|
|
return $this; |
|
98
|
|
|
} |
|
99
|
|
|
} |