@@ -13,10 +13,10 @@ |
||
13 | 13 | */ |
14 | 14 | interface IAntiSpoofProvider |
15 | 15 | { |
16 | - /** |
|
17 | - * @param string $username |
|
18 | - * |
|
19 | - * @return array |
|
20 | - */ |
|
21 | - public function getSpoofs($username); |
|
16 | + /** |
|
17 | + * @param string $username |
|
18 | + * |
|
19 | + * @return array |
|
20 | + */ |
|
21 | + public function getSpoofs($username); |
|
22 | 22 | } |
@@ -15,72 +15,72 @@ |
||
15 | 15 | |
16 | 16 | class ConsoleStart extends ApplicationBase |
17 | 17 | { |
18 | - /** |
|
19 | - * @var ConsoleTaskBase |
|
20 | - */ |
|
21 | - private $consoleTask; |
|
18 | + /** |
|
19 | + * @var ConsoleTaskBase |
|
20 | + */ |
|
21 | + private $consoleTask; |
|
22 | 22 | |
23 | - /** |
|
24 | - * ConsoleStart constructor. |
|
25 | - * |
|
26 | - * @param SiteConfiguration $configuration |
|
27 | - * @param ConsoleTaskBase $consoleTask |
|
28 | - */ |
|
29 | - public function __construct(SiteConfiguration $configuration, ConsoleTaskBase $consoleTask) |
|
30 | - { |
|
31 | - parent::__construct($configuration); |
|
32 | - $this->consoleTask = $consoleTask; |
|
33 | - } |
|
23 | + /** |
|
24 | + * ConsoleStart constructor. |
|
25 | + * |
|
26 | + * @param SiteConfiguration $configuration |
|
27 | + * @param ConsoleTaskBase $consoleTask |
|
28 | + */ |
|
29 | + public function __construct(SiteConfiguration $configuration, ConsoleTaskBase $consoleTask) |
|
30 | + { |
|
31 | + parent::__construct($configuration); |
|
32 | + $this->consoleTask = $consoleTask; |
|
33 | + } |
|
34 | 34 | |
35 | - protected function setupEnvironment() |
|
36 | - { |
|
37 | - // initialise super-global providers |
|
38 | - WebRequest::setGlobalStateProvider(new FakeGlobalStateProvider()); |
|
35 | + protected function setupEnvironment() |
|
36 | + { |
|
37 | + // initialise super-global providers |
|
38 | + WebRequest::setGlobalStateProvider(new FakeGlobalStateProvider()); |
|
39 | 39 | |
40 | - if (WebRequest::method() !== null) { |
|
41 | - throw new EnvironmentException('This is a console task, which cannot be executed via the web.'); |
|
42 | - } |
|
40 | + if (WebRequest::method() !== null) { |
|
41 | + throw new EnvironmentException('This is a console task, which cannot be executed via the web.'); |
|
42 | + } |
|
43 | 43 | |
44 | - return parent::setupEnvironment(); |
|
45 | - } |
|
44 | + return parent::setupEnvironment(); |
|
45 | + } |
|
46 | 46 | |
47 | - protected function cleanupEnvironment() |
|
48 | - { |
|
49 | - } |
|
47 | + protected function cleanupEnvironment() |
|
48 | + { |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * Main application logic |
|
53 | - */ |
|
54 | - protected function main() |
|
55 | - { |
|
56 | - $database = PdoDatabase::getDatabaseConnection('acc'); |
|
51 | + /** |
|
52 | + * Main application logic |
|
53 | + */ |
|
54 | + protected function main() |
|
55 | + { |
|
56 | + $database = PdoDatabase::getDatabaseConnection('acc'); |
|
57 | 57 | |
58 | - if ($this->getConfiguration()->getIrcNotificationsEnabled()) { |
|
59 | - $notificationsDatabase = PdoDatabase::getDatabaseConnection('notifications'); |
|
60 | - } |
|
61 | - else { |
|
62 | - // pass through null |
|
63 | - $notificationsDatabase = null; |
|
64 | - } |
|
58 | + if ($this->getConfiguration()->getIrcNotificationsEnabled()) { |
|
59 | + $notificationsDatabase = PdoDatabase::getDatabaseConnection('notifications'); |
|
60 | + } |
|
61 | + else { |
|
62 | + // pass through null |
|
63 | + $notificationsDatabase = null; |
|
64 | + } |
|
65 | 65 | |
66 | - $this->setupHelpers($this->consoleTask, $this->getConfiguration(), $database, $notificationsDatabase); |
|
66 | + $this->setupHelpers($this->consoleTask, $this->getConfiguration(), $database, $notificationsDatabase); |
|
67 | 67 | |
68 | - // initialise a database transaction |
|
69 | - if (!$database->beginTransaction()) { |
|
70 | - throw new Exception('Failed to start transaction on primary database.'); |
|
71 | - } |
|
68 | + // initialise a database transaction |
|
69 | + if (!$database->beginTransaction()) { |
|
70 | + throw new Exception('Failed to start transaction on primary database.'); |
|
71 | + } |
|
72 | 72 | |
73 | - try { |
|
74 | - // run the task |
|
75 | - $this->consoleTask->execute(); |
|
73 | + try { |
|
74 | + // run the task |
|
75 | + $this->consoleTask->execute(); |
|
76 | 76 | |
77 | - $database->commit(); |
|
78 | - } |
|
79 | - finally { |
|
80 | - // Catch any hanging on transactions |
|
81 | - if ($database->hasActiveTransaction()) { |
|
82 | - $database->rollBack(); |
|
83 | - } |
|
84 | - } |
|
85 | - } |
|
77 | + $database->commit(); |
|
78 | + } |
|
79 | + finally { |
|
80 | + // Catch any hanging on transactions |
|
81 | + if ($database->hasActiveTransaction()) { |
|
82 | + $database->rollBack(); |
|
83 | + } |
|
84 | + } |
|
85 | + } |
|
86 | 86 | } |
87 | 87 | \ No newline at end of file |
@@ -13,21 +13,21 @@ |
||
13 | 13 | */ |
14 | 14 | class Environment |
15 | 15 | { |
16 | - /** |
|
17 | - * @var string Cached copy of the tool version |
|
18 | - */ |
|
19 | - private static $toolVersion = null; |
|
16 | + /** |
|
17 | + * @var string Cached copy of the tool version |
|
18 | + */ |
|
19 | + private static $toolVersion = null; |
|
20 | 20 | |
21 | - /** |
|
22 | - * Gets the tool version, using cached data if available. |
|
23 | - * @return string |
|
24 | - */ |
|
25 | - public static function getToolVersion() |
|
26 | - { |
|
27 | - if (self::$toolVersion === null) { |
|
28 | - self::$toolVersion = exec("git describe --always --dirty"); |
|
29 | - } |
|
21 | + /** |
|
22 | + * Gets the tool version, using cached data if available. |
|
23 | + * @return string |
|
24 | + */ |
|
25 | + public static function getToolVersion() |
|
26 | + { |
|
27 | + if (self::$toolVersion === null) { |
|
28 | + self::$toolVersion = exec("git describe --always --dirty"); |
|
29 | + } |
|
30 | 30 | |
31 | - return self::$toolVersion; |
|
32 | - } |
|
31 | + return self::$toolVersion; |
|
32 | + } |
|
33 | 33 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | ******************************************************************************/ |
8 | 8 | |
9 | 9 | if (isset($_SERVER['REQUEST_METHOD'])) { |
10 | - die(); |
|
10 | + die(); |
|
11 | 11 | } //Web clients die. |
12 | 12 | |
13 | 13 | // Get all the classes. |
@@ -19,12 +19,12 @@ discard block |
||
19 | 19 | |
20 | 20 | $arg = $argv['1']; |
21 | 21 | if ($arg == "--monthly") { |
22 | - echo "running monthly backups.\n"; |
|
23 | - $dateModifier = date("FY"); |
|
24 | - $cmdLine = "$BUtar $BUmonthdir/mBackup-$dateModifier.tar $BUdir/*.sql.gz; rm $BUdir/*.sql.gz"; |
|
25 | - echo "running command $cmdLine\n"; |
|
26 | - shell_exec($cmdLine); |
|
27 | - die("done."); |
|
22 | + echo "running monthly backups.\n"; |
|
23 | + $dateModifier = date("FY"); |
|
24 | + $cmdLine = "$BUtar $BUmonthdir/mBackup-$dateModifier.tar $BUdir/*.sql.gz; rm $BUdir/*.sql.gz"; |
|
25 | + echo "running command $cmdLine\n"; |
|
26 | + shell_exec($cmdLine); |
|
27 | + die("done."); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | echo "running nightly backups\n"; |
@@ -16,68 +16,68 @@ |
||
16 | 16 | */ |
17 | 17 | function smarty_modifier_relativedate($input) |
18 | 18 | { |
19 | - $now = new DateTime(); |
|
19 | + $now = new DateTime(); |
|
20 | 20 | |
21 | - if (gettype($input) === 'object' |
|
22 | - && (get_class($input) === DateTime::class || get_class($input) === DateTimeImmutable::class) |
|
23 | - ) { |
|
24 | - $then = $input; |
|
25 | - } |
|
26 | - else { |
|
27 | - $then = new DateTime($input); |
|
28 | - } |
|
21 | + if (gettype($input) === 'object' |
|
22 | + && (get_class($input) === DateTime::class || get_class($input) === DateTimeImmutable::class) |
|
23 | + ) { |
|
24 | + $then = $input; |
|
25 | + } |
|
26 | + else { |
|
27 | + $then = new DateTime($input); |
|
28 | + } |
|
29 | 29 | |
30 | - $secs = $now->getTimestamp() - $then->getTimestamp(); |
|
30 | + $secs = $now->getTimestamp() - $then->getTimestamp(); |
|
31 | 31 | |
32 | - $second = 1; |
|
33 | - $minute = 60 * $second; |
|
34 | - $minuteCut = 60 * $second; |
|
35 | - $hour = 60 * $minute; |
|
36 | - $hourCut = 90 * $minute; |
|
37 | - $day = 24 * $hour; |
|
38 | - $dayCut = 48 * $hour; |
|
39 | - $week = 7 * $day; |
|
40 | - $weekCut = 14 * $day; |
|
41 | - $month = 30 * $day; |
|
42 | - $monthCut = 60 * $day; |
|
43 | - $year = 365 * $day; |
|
44 | - $yearCut = $year * 2; |
|
32 | + $second = 1; |
|
33 | + $minute = 60 * $second; |
|
34 | + $minuteCut = 60 * $second; |
|
35 | + $hour = 60 * $minute; |
|
36 | + $hourCut = 90 * $minute; |
|
37 | + $day = 24 * $hour; |
|
38 | + $dayCut = 48 * $hour; |
|
39 | + $week = 7 * $day; |
|
40 | + $weekCut = 14 * $day; |
|
41 | + $month = 30 * $day; |
|
42 | + $monthCut = 60 * $day; |
|
43 | + $year = 365 * $day; |
|
44 | + $yearCut = $year * 2; |
|
45 | 45 | |
46 | - $pluralise = true; |
|
46 | + $pluralise = true; |
|
47 | 47 | |
48 | - if ($secs <= 10) { |
|
49 | - $output = "just now"; |
|
50 | - $pluralise = false; |
|
51 | - } |
|
52 | - elseif ($secs > 10 && $secs < $minuteCut) { |
|
53 | - $output = round($secs / $second) . " second"; |
|
54 | - } |
|
55 | - elseif ($secs >= $minuteCut && $secs < $hourCut) { |
|
56 | - $output = round($secs / $minute) . " minute"; |
|
57 | - } |
|
58 | - elseif ($secs >= $hourCut && $secs < $dayCut) { |
|
59 | - $output = round($secs / $hour) . " hour"; |
|
60 | - } |
|
61 | - elseif ($secs >= $dayCut && $secs < $weekCut) { |
|
62 | - $output = round($secs / $day) . " day"; |
|
63 | - } |
|
64 | - elseif ($secs >= $weekCut && $secs < $monthCut) { |
|
65 | - $output = round($secs / $week) . " week"; |
|
66 | - } |
|
67 | - elseif ($secs >= $monthCut && $secs < $yearCut) { |
|
68 | - $output = round($secs / $month) . " month"; |
|
69 | - } |
|
70 | - elseif ($secs >= $yearCut && $secs < $year * 10) { |
|
71 | - $output = round($secs / $year) . " year"; |
|
72 | - } |
|
73 | - else { |
|
74 | - $output = "a long time ago"; |
|
75 | - $pluralise = false; |
|
76 | - } |
|
48 | + if ($secs <= 10) { |
|
49 | + $output = "just now"; |
|
50 | + $pluralise = false; |
|
51 | + } |
|
52 | + elseif ($secs > 10 && $secs < $minuteCut) { |
|
53 | + $output = round($secs / $second) . " second"; |
|
54 | + } |
|
55 | + elseif ($secs >= $minuteCut && $secs < $hourCut) { |
|
56 | + $output = round($secs / $minute) . " minute"; |
|
57 | + } |
|
58 | + elseif ($secs >= $hourCut && $secs < $dayCut) { |
|
59 | + $output = round($secs / $hour) . " hour"; |
|
60 | + } |
|
61 | + elseif ($secs >= $dayCut && $secs < $weekCut) { |
|
62 | + $output = round($secs / $day) . " day"; |
|
63 | + } |
|
64 | + elseif ($secs >= $weekCut && $secs < $monthCut) { |
|
65 | + $output = round($secs / $week) . " week"; |
|
66 | + } |
|
67 | + elseif ($secs >= $monthCut && $secs < $yearCut) { |
|
68 | + $output = round($secs / $month) . " month"; |
|
69 | + } |
|
70 | + elseif ($secs >= $yearCut && $secs < $year * 10) { |
|
71 | + $output = round($secs / $year) . " year"; |
|
72 | + } |
|
73 | + else { |
|
74 | + $output = "a long time ago"; |
|
75 | + $pluralise = false; |
|
76 | + } |
|
77 | 77 | |
78 | - if ($pluralise) { |
|
79 | - $output = (substr($output, 0, 2) <> "1 ") ? $output . "s ago" : $output . " ago"; |
|
80 | - } |
|
78 | + if ($pluralise) { |
|
79 | + $output = (substr($output, 0, 2) <> "1 ") ? $output . "s ago" : $output . " ago"; |
|
80 | + } |
|
81 | 81 | |
82 | - return $output; |
|
82 | + return $output; |
|
83 | 83 | } |
84 | 84 | \ No newline at end of file |
@@ -16,16 +16,16 @@ |
||
16 | 16 | */ |
17 | 17 | function smarty_modifier_date($input) |
18 | 18 | { |
19 | - if (gettype($input) === 'object' |
|
20 | - && (get_class($input) === DateTime::class || get_class($input) === DateTimeImmutable::class) |
|
21 | - ) { |
|
22 | - /** @var $date DateTime|DateTimeImmutable */ |
|
23 | - $date = $input; |
|
24 | - $dateString = $date->format('Y-m-d H:i:s'); |
|
19 | + if (gettype($input) === 'object' |
|
20 | + && (get_class($input) === DateTime::class || get_class($input) === DateTimeImmutable::class) |
|
21 | + ) { |
|
22 | + /** @var $date DateTime|DateTimeImmutable */ |
|
23 | + $date = $input; |
|
24 | + $dateString = $date->format('Y-m-d H:i:s'); |
|
25 | 25 | |
26 | - return $dateString; |
|
27 | - } |
|
28 | - else { |
|
29 | - return $input; |
|
30 | - } |
|
26 | + return $dateString; |
|
27 | + } |
|
28 | + else { |
|
29 | + return $input; |
|
30 | + } |
|
31 | 31 | } |
32 | 32 | \ No newline at end of file |
@@ -17,87 +17,87 @@ |
||
17 | 17 | |
18 | 18 | class PageExpandedRequestList extends InternalPageBase |
19 | 19 | { |
20 | - /** |
|
21 | - * Sets up the security for this page. If certain actions have different permissions, this should be reflected in |
|
22 | - * the return value from this function. |
|
23 | - * |
|
24 | - * If this page even supports actions, you will need to check the route |
|
25 | - * |
|
26 | - * @return SecurityConfiguration |
|
27 | - * @category Security-Critical |
|
28 | - */ |
|
29 | - protected function getSecurityConfiguration() |
|
30 | - { |
|
31 | - return $this->getSecurityManager()->configure()->asInternalPage(); |
|
32 | - } |
|
33 | - |
|
34 | - /** |
|
35 | - * Main function for this page, when no specific actions are called. |
|
36 | - * @return void |
|
37 | - * @todo This is very similar to the PageMain code, we could probably generalise this somehow |
|
38 | - */ |
|
39 | - protected function main() |
|
40 | - { |
|
41 | - $config = $this->getSiteConfiguration(); |
|
42 | - |
|
43 | - $requestedStatus = WebRequest::getString('status'); |
|
44 | - $requestStates = $config->getRequestStates(); |
|
45 | - |
|
46 | - if ($requestedStatus !== null && isset($requestStates[$requestedStatus])) { |
|
47 | - |
|
48 | - $this->assignCSRFToken(); |
|
49 | - |
|
50 | - $database = $this->getDatabase(); |
|
51 | - |
|
52 | - if ($config->getEmailConfirmationEnabled()) { |
|
53 | - $query = "SELECT * FROM request WHERE status = :type AND emailconfirm = 'Confirmed';"; |
|
54 | - $totalQuery = "SELECT COUNT(id) FROM request WHERE status = :type AND emailconfirm = 'Confirmed';"; |
|
55 | - } |
|
56 | - else { |
|
57 | - $query = "SELECT * FROM request WHERE status = :type;"; |
|
58 | - $totalQuery = "SELECT COUNT(id) FROM request WHERE status = :type;"; |
|
59 | - } |
|
60 | - |
|
61 | - $statement = $database->prepare($query); |
|
62 | - |
|
63 | - $totalRequestsStatement = $database->prepare($totalQuery); |
|
64 | - |
|
65 | - $this->assign('defaultRequestState', $config->getDefaultRequestStateKey()); |
|
66 | - |
|
67 | - $type = $requestedStatus; |
|
68 | - |
|
69 | - $statement->bindValue(":type", $type); |
|
70 | - $statement->execute(); |
|
71 | - |
|
72 | - $requests = $statement->fetchAll(PDO::FETCH_CLASS, Request::class); |
|
73 | - |
|
74 | - /** @var Request $req */ |
|
75 | - foreach ($requests as $req) { |
|
76 | - $req->setDatabase($database); |
|
77 | - } |
|
78 | - |
|
79 | - $this->assign('requests', $requests); |
|
80 | - $this->assign('header', $type); |
|
81 | - |
|
82 | - $totalRequestsStatement->bindValue(':type', $type); |
|
83 | - $totalRequestsStatement->execute(); |
|
84 | - $totalRequests = $totalRequestsStatement->fetchColumn(); |
|
85 | - $totalRequestsStatement->closeCursor(); |
|
86 | - $this->assign('totalRequests', $totalRequests); |
|
87 | - |
|
88 | - $userIds = array_map( |
|
89 | - function(Request $entry) { |
|
90 | - return $entry->getReserved(); |
|
91 | - }, |
|
92 | - $requests |
|
93 | - ); |
|
94 | - |
|
95 | - $userList = User::getUsernames($userIds, $this->getDatabase()); |
|
96 | - $this->assign('userlist', $userList); |
|
97 | - |
|
98 | - $this->assign('requestLimitShowOnly', $config->getMiserModeLimit()); |
|
99 | - |
|
100 | - $this->setTemplate('mainpage/expandedrequestlist.tpl'); |
|
101 | - } |
|
102 | - } |
|
20 | + /** |
|
21 | + * Sets up the security for this page. If certain actions have different permissions, this should be reflected in |
|
22 | + * the return value from this function. |
|
23 | + * |
|
24 | + * If this page even supports actions, you will need to check the route |
|
25 | + * |
|
26 | + * @return SecurityConfiguration |
|
27 | + * @category Security-Critical |
|
28 | + */ |
|
29 | + protected function getSecurityConfiguration() |
|
30 | + { |
|
31 | + return $this->getSecurityManager()->configure()->asInternalPage(); |
|
32 | + } |
|
33 | + |
|
34 | + /** |
|
35 | + * Main function for this page, when no specific actions are called. |
|
36 | + * @return void |
|
37 | + * @todo This is very similar to the PageMain code, we could probably generalise this somehow |
|
38 | + */ |
|
39 | + protected function main() |
|
40 | + { |
|
41 | + $config = $this->getSiteConfiguration(); |
|
42 | + |
|
43 | + $requestedStatus = WebRequest::getString('status'); |
|
44 | + $requestStates = $config->getRequestStates(); |
|
45 | + |
|
46 | + if ($requestedStatus !== null && isset($requestStates[$requestedStatus])) { |
|
47 | + |
|
48 | + $this->assignCSRFToken(); |
|
49 | + |
|
50 | + $database = $this->getDatabase(); |
|
51 | + |
|
52 | + if ($config->getEmailConfirmationEnabled()) { |
|
53 | + $query = "SELECT * FROM request WHERE status = :type AND emailconfirm = 'Confirmed';"; |
|
54 | + $totalQuery = "SELECT COUNT(id) FROM request WHERE status = :type AND emailconfirm = 'Confirmed';"; |
|
55 | + } |
|
56 | + else { |
|
57 | + $query = "SELECT * FROM request WHERE status = :type;"; |
|
58 | + $totalQuery = "SELECT COUNT(id) FROM request WHERE status = :type;"; |
|
59 | + } |
|
60 | + |
|
61 | + $statement = $database->prepare($query); |
|
62 | + |
|
63 | + $totalRequestsStatement = $database->prepare($totalQuery); |
|
64 | + |
|
65 | + $this->assign('defaultRequestState', $config->getDefaultRequestStateKey()); |
|
66 | + |
|
67 | + $type = $requestedStatus; |
|
68 | + |
|
69 | + $statement->bindValue(":type", $type); |
|
70 | + $statement->execute(); |
|
71 | + |
|
72 | + $requests = $statement->fetchAll(PDO::FETCH_CLASS, Request::class); |
|
73 | + |
|
74 | + /** @var Request $req */ |
|
75 | + foreach ($requests as $req) { |
|
76 | + $req->setDatabase($database); |
|
77 | + } |
|
78 | + |
|
79 | + $this->assign('requests', $requests); |
|
80 | + $this->assign('header', $type); |
|
81 | + |
|
82 | + $totalRequestsStatement->bindValue(':type', $type); |
|
83 | + $totalRequestsStatement->execute(); |
|
84 | + $totalRequests = $totalRequestsStatement->fetchColumn(); |
|
85 | + $totalRequestsStatement->closeCursor(); |
|
86 | + $this->assign('totalRequests', $totalRequests); |
|
87 | + |
|
88 | + $userIds = array_map( |
|
89 | + function(Request $entry) { |
|
90 | + return $entry->getReserved(); |
|
91 | + }, |
|
92 | + $requests |
|
93 | + ); |
|
94 | + |
|
95 | + $userList = User::getUsernames($userIds, $this->getDatabase()); |
|
96 | + $this->assign('userlist', $userList); |
|
97 | + |
|
98 | + $this->assign('requestLimitShowOnly', $config->getMiserModeLimit()); |
|
99 | + |
|
100 | + $this->setTemplate('mainpage/expandedrequestlist.tpl'); |
|
101 | + } |
|
102 | + } |
|
103 | 103 | } |
@@ -14,117 +14,117 @@ |
||
14 | 14 | |
15 | 15 | class RequestSearchHelper extends SearchHelperBase |
16 | 16 | { |
17 | - /** |
|
18 | - * RequestSearchHelper constructor. |
|
19 | - * |
|
20 | - * @param PdoDatabase $database |
|
21 | - */ |
|
22 | - protected function __construct(PdoDatabase $database) |
|
23 | - { |
|
24 | - parent::__construct($database, 'request', Request::class); |
|
25 | - } |
|
26 | - |
|
27 | - /** |
|
28 | - * Initiates a search for requests |
|
29 | - * |
|
30 | - * @param PdoDatabase $database |
|
31 | - * |
|
32 | - * @return RequestSearchHelper |
|
33 | - */ |
|
34 | - public static function get(PdoDatabase $database) |
|
35 | - { |
|
36 | - $helper = new RequestSearchHelper($database); |
|
37 | - |
|
38 | - return $helper; |
|
39 | - } |
|
40 | - |
|
41 | - /** |
|
42 | - * Filters the results by IP address |
|
43 | - * |
|
44 | - * @param string $ipAddress |
|
45 | - * |
|
46 | - * @return $this |
|
47 | - */ |
|
48 | - public function byIp($ipAddress) |
|
49 | - { |
|
50 | - $this->whereClause .= ' AND (ip LIKE ? OR forwardedip LIKE ?)'; |
|
51 | - $this->parameterList[] = $ipAddress; |
|
52 | - $this->parameterList[] = '%' . trim($ipAddress, '%') . '%'; |
|
53 | - |
|
54 | - return $this; |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * Filters the results by email address |
|
59 | - * |
|
60 | - * @param string $emailAddress |
|
61 | - * |
|
62 | - * @return $this |
|
63 | - */ |
|
64 | - public function byEmailAddress($emailAddress) |
|
65 | - { |
|
66 | - $this->whereClause .= ' AND email LIKE ?'; |
|
67 | - $this->parameterList[] = $emailAddress; |
|
68 | - |
|
69 | - return $this; |
|
70 | - } |
|
71 | - |
|
72 | - /** |
|
73 | - * Filters the results by name |
|
74 | - * |
|
75 | - * @param string $name |
|
76 | - * |
|
77 | - * @return $this |
|
78 | - */ |
|
79 | - public function byName($name) |
|
80 | - { |
|
81 | - $this->whereClause .= ' AND name LIKE ?'; |
|
82 | - $this->parameterList[] = $name; |
|
83 | - |
|
84 | - return $this; |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * Excludes a request from the results |
|
89 | - * |
|
90 | - * @param int $requestId |
|
91 | - * |
|
92 | - * @return $this |
|
93 | - */ |
|
94 | - public function excludingRequest($requestId) |
|
95 | - { |
|
96 | - $this->whereClause .= ' AND id <> ?'; |
|
97 | - $this->parameterList[] = $requestId; |
|
98 | - |
|
99 | - return $this; |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * Filters the results to only those with a confirmed email address |
|
104 | - * |
|
105 | - * @return $this |
|
106 | - */ |
|
107 | - public function withConfirmedEmail() |
|
108 | - { |
|
109 | - $this->whereClause .= ' AND emailconfirm = ?'; |
|
110 | - $this->parameterList[] = 'Confirmed'; |
|
111 | - |
|
112 | - return $this; |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * Filters the results to exclude purged data |
|
117 | - * |
|
118 | - * @param SiteConfiguration $configuration |
|
119 | - * |
|
120 | - * @return $this |
|
121 | - */ |
|
122 | - public function excludingPurgedData(SiteConfiguration $configuration) |
|
123 | - { |
|
124 | - $this->whereClause .= ' AND ip <> ? AND email <> ?'; |
|
125 | - $this->parameterList[] = $configuration->getDataClearIp(); |
|
126 | - $this->parameterList[] = $configuration->getDataClearEmail(); |
|
127 | - |
|
128 | - return $this; |
|
129 | - } |
|
17 | + /** |
|
18 | + * RequestSearchHelper constructor. |
|
19 | + * |
|
20 | + * @param PdoDatabase $database |
|
21 | + */ |
|
22 | + protected function __construct(PdoDatabase $database) |
|
23 | + { |
|
24 | + parent::__construct($database, 'request', Request::class); |
|
25 | + } |
|
26 | + |
|
27 | + /** |
|
28 | + * Initiates a search for requests |
|
29 | + * |
|
30 | + * @param PdoDatabase $database |
|
31 | + * |
|
32 | + * @return RequestSearchHelper |
|
33 | + */ |
|
34 | + public static function get(PdoDatabase $database) |
|
35 | + { |
|
36 | + $helper = new RequestSearchHelper($database); |
|
37 | + |
|
38 | + return $helper; |
|
39 | + } |
|
40 | + |
|
41 | + /** |
|
42 | + * Filters the results by IP address |
|
43 | + * |
|
44 | + * @param string $ipAddress |
|
45 | + * |
|
46 | + * @return $this |
|
47 | + */ |
|
48 | + public function byIp($ipAddress) |
|
49 | + { |
|
50 | + $this->whereClause .= ' AND (ip LIKE ? OR forwardedip LIKE ?)'; |
|
51 | + $this->parameterList[] = $ipAddress; |
|
52 | + $this->parameterList[] = '%' . trim($ipAddress, '%') . '%'; |
|
53 | + |
|
54 | + return $this; |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * Filters the results by email address |
|
59 | + * |
|
60 | + * @param string $emailAddress |
|
61 | + * |
|
62 | + * @return $this |
|
63 | + */ |
|
64 | + public function byEmailAddress($emailAddress) |
|
65 | + { |
|
66 | + $this->whereClause .= ' AND email LIKE ?'; |
|
67 | + $this->parameterList[] = $emailAddress; |
|
68 | + |
|
69 | + return $this; |
|
70 | + } |
|
71 | + |
|
72 | + /** |
|
73 | + * Filters the results by name |
|
74 | + * |
|
75 | + * @param string $name |
|
76 | + * |
|
77 | + * @return $this |
|
78 | + */ |
|
79 | + public function byName($name) |
|
80 | + { |
|
81 | + $this->whereClause .= ' AND name LIKE ?'; |
|
82 | + $this->parameterList[] = $name; |
|
83 | + |
|
84 | + return $this; |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * Excludes a request from the results |
|
89 | + * |
|
90 | + * @param int $requestId |
|
91 | + * |
|
92 | + * @return $this |
|
93 | + */ |
|
94 | + public function excludingRequest($requestId) |
|
95 | + { |
|
96 | + $this->whereClause .= ' AND id <> ?'; |
|
97 | + $this->parameterList[] = $requestId; |
|
98 | + |
|
99 | + return $this; |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * Filters the results to only those with a confirmed email address |
|
104 | + * |
|
105 | + * @return $this |
|
106 | + */ |
|
107 | + public function withConfirmedEmail() |
|
108 | + { |
|
109 | + $this->whereClause .= ' AND emailconfirm = ?'; |
|
110 | + $this->parameterList[] = 'Confirmed'; |
|
111 | + |
|
112 | + return $this; |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * Filters the results to exclude purged data |
|
117 | + * |
|
118 | + * @param SiteConfiguration $configuration |
|
119 | + * |
|
120 | + * @return $this |
|
121 | + */ |
|
122 | + public function excludingPurgedData(SiteConfiguration $configuration) |
|
123 | + { |
|
124 | + $this->whereClause .= ' AND ip <> ? AND email <> ?'; |
|
125 | + $this->parameterList[] = $configuration->getDataClearIp(); |
|
126 | + $this->parameterList[] = $configuration->getDataClearEmail(); |
|
127 | + |
|
128 | + return $this; |
|
129 | + } |
|
130 | 130 | } |
131 | 131 | \ No newline at end of file |
@@ -13,87 +13,87 @@ |
||
13 | 13 | |
14 | 14 | class LogSearchHelper extends SearchHelperBase |
15 | 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 | - } |
|
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 | 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); |
|
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 | 36 | |
37 | - return $helper; |
|
38 | - } |
|
37 | + return $helper; |
|
38 | + } |
|
39 | 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; |
|
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 | 51 | |
52 | - return $this; |
|
53 | - } |
|
52 | + return $this; |
|
53 | + } |
|
54 | 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; |
|
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 | 66 | |
67 | - return $this; |
|
68 | - } |
|
67 | + return $this; |
|
68 | + } |
|
69 | 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; |
|
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 | 81 | |
82 | - return $this; |
|
83 | - } |
|
82 | + return $this; |
|
83 | + } |
|
84 | 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; |
|
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 | 96 | |
97 | - return $this; |
|
98 | - } |
|
97 | + return $this; |
|
98 | + } |
|
99 | 99 | } |
100 | 100 | \ No newline at end of file |