@@ -26,455 +26,455 @@ |
||
26 | 26 | */ |
27 | 27 | class IrcNotificationHelper |
28 | 28 | { |
29 | - /** @var PdoDatabase $notificationsDatabase */ |
|
30 | - private $notificationsDatabase; |
|
31 | - /** @var PdoDatabase $primaryDatabase */ |
|
32 | - private $primaryDatabase; |
|
33 | - /** @var bool $notificationsEnabled */ |
|
34 | - private $notificationsEnabled; |
|
35 | - /** @var int $notificationType */ |
|
36 | - private $notificationType; |
|
37 | - /** @var User $currentUser */ |
|
38 | - private $currentUser; |
|
39 | - /** @var string $instanceName */ |
|
40 | - private $instanceName; |
|
41 | - /** @var string */ |
|
42 | - private $baseUrl; |
|
43 | - /** @var array */ |
|
44 | - private $requestStates; |
|
45 | - |
|
46 | - /** |
|
47 | - * IrcNotificationHelper constructor. |
|
48 | - * |
|
49 | - * @param SiteConfiguration $siteConfiguration |
|
50 | - * @param PdoDatabase $primaryDatabase |
|
51 | - * @param PdoDatabase $notificationsDatabase |
|
52 | - */ |
|
53 | - public function __construct( |
|
54 | - SiteConfiguration $siteConfiguration, |
|
55 | - PdoDatabase $primaryDatabase, |
|
56 | - PdoDatabase $notificationsDatabase = null |
|
57 | - ) { |
|
58 | - $this->primaryDatabase = $primaryDatabase; |
|
59 | - |
|
60 | - if ($this->notificationsDatabase !== null) { |
|
61 | - $this->notificationsDatabase = $notificationsDatabase; |
|
62 | - $this->notificationsEnabled = $siteConfiguration->getIrcNotificationsEnabled(); |
|
63 | - } |
|
64 | - else { |
|
65 | - $this->notificationsEnabled = false; |
|
66 | - } |
|
67 | - |
|
68 | - $this->notificationType = $siteConfiguration->getIrcNotificationType(); |
|
69 | - $this->instanceName = $siteConfiguration->getIrcNotificationsInstance(); |
|
70 | - $this->baseUrl = $siteConfiguration->getBaseUrl(); |
|
71 | - $this->requestStates = $siteConfiguration->getRequestStates(); |
|
72 | - |
|
73 | - $this->currentUser = User::getCurrent($primaryDatabase); |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * Send a notification |
|
78 | - * |
|
79 | - * @param string $message The text to send |
|
80 | - */ |
|
81 | - protected function send($message) |
|
82 | - { |
|
83 | - $instanceName = $this->instanceName; |
|
84 | - |
|
85 | - if (!$this->notificationsEnabled) { |
|
86 | - return; |
|
87 | - } |
|
88 | - |
|
89 | - $blacklist = array("DCC", "CCTP", "PRIVMSG"); |
|
90 | - $message = str_replace($blacklist, "(IRC Blacklist)", $message); // Lets stop DCC etc |
|
91 | - |
|
92 | - $msg = IrcColourCode::RESET . IrcColourCode::BOLD . "[$instanceName]" . IrcColourCode::RESET . ": $message"; |
|
93 | - |
|
94 | - try { |
|
95 | - $notification = new Notification(); |
|
96 | - $notification->setDatabase($this->notificationsDatabase); |
|
97 | - $notification->setType($this->notificationType); |
|
98 | - $notification->setText($msg); |
|
99 | - |
|
100 | - $notification->save(); |
|
101 | - } |
|
102 | - catch (Exception $ex) { |
|
103 | - // OK, so we failed to send the notification - that db might be down? |
|
104 | - // This is non-critical, so silently fail. |
|
105 | - |
|
106 | - // Disable notifications for remainder of request. |
|
107 | - $this->notificationsEnabled = false; |
|
108 | - } |
|
109 | - } |
|
110 | - |
|
111 | - #region user management |
|
112 | - |
|
113 | - /** |
|
114 | - * send a new user notification |
|
115 | - * |
|
116 | - * @param User $user |
|
117 | - */ |
|
118 | - public function userNew(User $user) |
|
119 | - { |
|
120 | - $this->send("New user: {$user->getUsername()}"); |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * send an approved notification |
|
125 | - * |
|
126 | - * @param User $user |
|
127 | - */ |
|
128 | - public function userApproved(User $user) |
|
129 | - { |
|
130 | - $this->send("{$user->getUsername()} approved by " . $this->currentUser->getUsername()); |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * send a promoted notification |
|
135 | - * |
|
136 | - * @param User $user |
|
137 | - */ |
|
138 | - public function userPromoted(User $user) |
|
139 | - { |
|
140 | - $this->send("{$user->getUsername()} promoted to tool admin by " . $this->currentUser->getUsername()); |
|
141 | - } |
|
142 | - |
|
143 | - /** |
|
144 | - * send a declined notification |
|
145 | - * |
|
146 | - * @param User $user |
|
147 | - * @param string $reason the reason the user was declined |
|
148 | - */ |
|
149 | - public function userDeclined(User $user, $reason) |
|
150 | - { |
|
151 | - $this->send("{$user->getUsername()} declined by " . $this->currentUser->getUsername() . " ($reason)"); |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * send a demotion notification |
|
156 | - * |
|
157 | - * @param User $user |
|
158 | - * @param string $reason the reason the user was demoted |
|
159 | - */ |
|
160 | - public function userDemoted(User $user, $reason) |
|
161 | - { |
|
162 | - $this->send("{$user->getUsername()} demoted by " . $this->currentUser->getUsername() . " ($reason)"); |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * send a suspended notification |
|
167 | - * |
|
168 | - * @param User $user |
|
169 | - * @param string $reason The reason the user has been suspended |
|
170 | - */ |
|
171 | - public function userSuspended(User $user, $reason) |
|
172 | - { |
|
173 | - $this->send("{$user->getUsername()} suspended by " . $this->currentUser->getUsername() . " ($reason)"); |
|
174 | - } |
|
175 | - |
|
176 | - /** |
|
177 | - * Send a preference change notification |
|
178 | - * |
|
179 | - * @param User $user |
|
180 | - */ |
|
181 | - public function userPrefChange(User $user) |
|
182 | - { |
|
183 | - $this->send("{$user->getUsername()}'s preferences were changed by " . $this->currentUser->getUsername()); |
|
184 | - } |
|
185 | - |
|
186 | - /** |
|
187 | - * Send a user renamed notification |
|
188 | - * |
|
189 | - * @param User $user |
|
190 | - * @param string $old |
|
191 | - */ |
|
192 | - public function userRenamed(User $user, $old) |
|
193 | - { |
|
194 | - $this->send($this->currentUser->getUsername() . " renamed $old to {$user->getUsername()}"); |
|
195 | - } |
|
196 | - |
|
197 | - /** |
|
198 | - * @param User $user |
|
199 | - * @param string $reason |
|
200 | - */ |
|
201 | - public function userRolesEdited(User $user, $reason) |
|
202 | - { |
|
203 | - $currentUser = $this->currentUser->getUsername(); |
|
204 | - $this->send("Active roles for {$user->getUsername()} changed by " . $currentUser . " ($reason)"); |
|
205 | - } |
|
206 | - |
|
207 | - #endregion |
|
208 | - |
|
209 | - #region Site Notice |
|
210 | - |
|
211 | - /** |
|
212 | - * Summary of siteNoticeEdited |
|
213 | - */ |
|
214 | - public function siteNoticeEdited() |
|
215 | - { |
|
216 | - $this->send("Site notice edited by " . $this->currentUser->getUsername()); |
|
217 | - } |
|
218 | - #endregion |
|
219 | - |
|
220 | - #region Welcome Templates |
|
221 | - /** |
|
222 | - * Summary of welcomeTemplateCreated |
|
223 | - * |
|
224 | - * @param WelcomeTemplate $template |
|
225 | - */ |
|
226 | - public function welcomeTemplateCreated(WelcomeTemplate $template) |
|
227 | - { |
|
228 | - $this->send("Welcome template {$template->getId()} created by " . $this->currentUser->getUsername()); |
|
229 | - } |
|
230 | - |
|
231 | - /** |
|
232 | - * Summary of welcomeTemplateDeleted |
|
233 | - * |
|
234 | - * @param int $templateid |
|
235 | - */ |
|
236 | - public function welcomeTemplateDeleted($templateid) |
|
237 | - { |
|
238 | - $this->send("Welcome template {$templateid} deleted by " . $this->currentUser->getUsername()); |
|
239 | - } |
|
240 | - |
|
241 | - /** |
|
242 | - * Summary of welcomeTemplateEdited |
|
243 | - * |
|
244 | - * @param WelcomeTemplate $template |
|
245 | - */ |
|
246 | - public function welcomeTemplateEdited(WelcomeTemplate $template) |
|
247 | - { |
|
248 | - $this->send("Welcome template {$template->getId()} edited by " . $this->currentUser->getUsername()); |
|
249 | - } |
|
250 | - |
|
251 | - #endregion |
|
252 | - |
|
253 | - #region bans |
|
254 | - /** |
|
255 | - * Summary of banned |
|
256 | - * |
|
257 | - * @param Ban $ban |
|
258 | - */ |
|
259 | - public function banned(Ban $ban) |
|
260 | - { |
|
261 | - if ($ban->getDuration() == -1) { |
|
262 | - $duration = "indefinitely"; |
|
263 | - } |
|
264 | - else { |
|
265 | - $duration = "until " . date("F j, Y, g:i a", $ban->getDuration()); |
|
266 | - } |
|
267 | - |
|
268 | - $username = $this->currentUser->getUsername(); |
|
269 | - |
|
270 | - $this->send("{$ban->getTarget()} banned by {$username} for '{$ban->getReason()}' {$duration}"); |
|
271 | - } |
|
272 | - |
|
273 | - /** |
|
274 | - * Summary of unbanned |
|
275 | - * |
|
276 | - * @param Ban $ban |
|
277 | - * @param string $unbanreason |
|
278 | - */ |
|
279 | - public function unbanned(Ban $ban, $unbanreason) |
|
280 | - { |
|
281 | - $this->send($ban->getTarget() . " unbanned by " . $this->currentUser |
|
282 | - ->getUsername() . " (" . $unbanreason . ")"); |
|
283 | - } |
|
284 | - |
|
285 | - #endregion |
|
286 | - |
|
287 | - #region request management |
|
288 | - |
|
289 | - /** |
|
290 | - * Summary of requestReceived |
|
291 | - * |
|
292 | - * @param Request $request |
|
293 | - */ |
|
294 | - public function requestReceived(Request $request) |
|
295 | - { |
|
296 | - $this->send( |
|
297 | - IrcColourCode::DARK_GREY . "[[" |
|
298 | - . IrcColourCode::DARK_GREEN . "acc:" |
|
299 | - . IrcColourCode::ORANGE . $request->getId() |
|
300 | - . IrcColourCode::DARK_GREY . "]]" |
|
301 | - . IrcColourCode::RED . " N " |
|
302 | - . IrcColourCode::DARK_BLUE . $this->baseUrl . "/internal.php/viewRequest?id={$request->getId()} " |
|
303 | - . IrcColourCode::DARK_RED . "* " |
|
304 | - . IrcColourCode::DARK_GREEN . $request->getName() |
|
305 | - . IrcColourCode::DARK_RED . " * " |
|
306 | - . IrcColourCode::RESET |
|
307 | - ); |
|
308 | - } |
|
309 | - |
|
310 | - /** |
|
311 | - * Summary of requestDeferred |
|
312 | - * |
|
313 | - * @param Request $request |
|
314 | - */ |
|
315 | - public function requestDeferred(Request $request) |
|
316 | - { |
|
317 | - $availableRequestStates = $this->requestStates; |
|
318 | - |
|
319 | - $deferTo = $availableRequestStates[$request->getStatus()]['deferto']; |
|
320 | - $username = $this->currentUser->getUsername(); |
|
321 | - |
|
322 | - $this->send("Request {$request->getId()} ({$request->getName()}) deferred to {$deferTo} by {$username}"); |
|
323 | - } |
|
324 | - |
|
325 | - /** |
|
326 | - * |
|
327 | - * Summary of requestDeferredWithMail |
|
328 | - * |
|
329 | - * @param Request $request |
|
330 | - */ |
|
331 | - public function requestDeferredWithMail(Request $request) |
|
332 | - { |
|
333 | - $availableRequestStates = $this->requestStates; |
|
334 | - |
|
335 | - $deferTo = $availableRequestStates[$request->getStatus()]['deferto']; |
|
336 | - $username = $this->currentUser->getUsername(); |
|
337 | - $id = $request->getId(); |
|
338 | - $name = $request->getName(); |
|
339 | - |
|
340 | - $this->send("Request {$id} ({$name}) deferred to {$deferTo} with an email by {$username}"); |
|
341 | - } |
|
342 | - |
|
343 | - /** |
|
344 | - * Summary of requestClosed |
|
345 | - * |
|
346 | - * @param Request $request |
|
347 | - * @param string $closetype |
|
348 | - */ |
|
349 | - public function requestClosed(Request $request, $closetype) |
|
350 | - { |
|
351 | - $username = $this->currentUser->getUsername(); |
|
352 | - |
|
353 | - $this->send("Request {$request->getId()} ({$request->getName()}) closed ($closetype) by {$username}"); |
|
354 | - } |
|
355 | - |
|
356 | - /** |
|
357 | - * Summary of sentMail |
|
358 | - * |
|
359 | - * @param Request $request |
|
360 | - */ |
|
361 | - public function sentMail(Request $request) |
|
362 | - { |
|
363 | - $this->send($this->currentUser->getUsername() |
|
364 | - . " sent an email related to Request {$request->getId()} ({$request->getName()})"); |
|
365 | - } |
|
366 | - |
|
367 | - #endregion |
|
368 | - |
|
369 | - #region reservations |
|
370 | - |
|
371 | - /** |
|
372 | - * Summary of requestReserved |
|
373 | - * |
|
374 | - * @param Request $request |
|
375 | - */ |
|
376 | - public function requestReserved(Request $request) |
|
377 | - { |
|
378 | - $username = $this->currentUser->getUsername(); |
|
379 | - |
|
380 | - $this->send("Request {$request->getId()} ({$request->getName()}) reserved by {$username}"); |
|
381 | - } |
|
382 | - |
|
383 | - /** |
|
384 | - * Summary of requestReserveBroken |
|
385 | - * |
|
386 | - * @param Request $request |
|
387 | - */ |
|
388 | - public function requestReserveBroken(Request $request) |
|
389 | - { |
|
390 | - $username = $this->currentUser->getUsername(); |
|
391 | - |
|
392 | - $this->send("Reservation on request {$request->getId()} ({$request->getName()}) broken by {$username}"); |
|
393 | - } |
|
394 | - |
|
395 | - /** |
|
396 | - * Summary of requestUnreserved |
|
397 | - * |
|
398 | - * @param Request $request |
|
399 | - */ |
|
400 | - public function requestUnreserved(Request $request) |
|
401 | - { |
|
402 | - $this->send("Request {$request->getId()} ({$request->getName()}) is no longer being handled."); |
|
403 | - } |
|
404 | - |
|
405 | - /** |
|
406 | - * Summary of requestReservationSent |
|
407 | - * |
|
408 | - * @param Request $request |
|
409 | - * @param User $target |
|
410 | - */ |
|
411 | - public function requestReservationSent(Request $request, User $target) |
|
412 | - { |
|
413 | - $username = $this->currentUser->getUsername(); |
|
414 | - |
|
415 | - $this->send( |
|
416 | - "Reservation of request {$request->getId()} ({$request->getName()}) sent to {$target->getUsername()} by " |
|
417 | - . $username); |
|
418 | - } |
|
419 | - |
|
420 | - #endregion |
|
421 | - |
|
422 | - #region comments |
|
423 | - |
|
424 | - /** |
|
425 | - * Summary of commentCreated |
|
426 | - * |
|
427 | - * @param Comment $comment |
|
428 | - * @param Request $request |
|
429 | - */ |
|
430 | - public function commentCreated(Comment $comment, Request $request) |
|
431 | - { |
|
432 | - $username = $this->currentUser->getUsername(); |
|
433 | - $visibility = ($comment->getVisibility() == "admin" ? "private " : ""); |
|
434 | - |
|
435 | - $this->send("{$username} posted a {$visibility}comment on request {$request->getId()} ({$request->getName()})"); |
|
436 | - } |
|
437 | - |
|
438 | - /** |
|
439 | - * Summary of commentEdited |
|
440 | - * |
|
441 | - * @param Comment $comment |
|
442 | - * @param Request $request |
|
443 | - */ |
|
444 | - public function commentEdited(Comment $comment, Request $request) |
|
445 | - { |
|
446 | - $username = $this->currentUser->getUsername(); |
|
447 | - |
|
448 | - $this->send(<<<TAG |
|
29 | + /** @var PdoDatabase $notificationsDatabase */ |
|
30 | + private $notificationsDatabase; |
|
31 | + /** @var PdoDatabase $primaryDatabase */ |
|
32 | + private $primaryDatabase; |
|
33 | + /** @var bool $notificationsEnabled */ |
|
34 | + private $notificationsEnabled; |
|
35 | + /** @var int $notificationType */ |
|
36 | + private $notificationType; |
|
37 | + /** @var User $currentUser */ |
|
38 | + private $currentUser; |
|
39 | + /** @var string $instanceName */ |
|
40 | + private $instanceName; |
|
41 | + /** @var string */ |
|
42 | + private $baseUrl; |
|
43 | + /** @var array */ |
|
44 | + private $requestStates; |
|
45 | + |
|
46 | + /** |
|
47 | + * IrcNotificationHelper constructor. |
|
48 | + * |
|
49 | + * @param SiteConfiguration $siteConfiguration |
|
50 | + * @param PdoDatabase $primaryDatabase |
|
51 | + * @param PdoDatabase $notificationsDatabase |
|
52 | + */ |
|
53 | + public function __construct( |
|
54 | + SiteConfiguration $siteConfiguration, |
|
55 | + PdoDatabase $primaryDatabase, |
|
56 | + PdoDatabase $notificationsDatabase = null |
|
57 | + ) { |
|
58 | + $this->primaryDatabase = $primaryDatabase; |
|
59 | + |
|
60 | + if ($this->notificationsDatabase !== null) { |
|
61 | + $this->notificationsDatabase = $notificationsDatabase; |
|
62 | + $this->notificationsEnabled = $siteConfiguration->getIrcNotificationsEnabled(); |
|
63 | + } |
|
64 | + else { |
|
65 | + $this->notificationsEnabled = false; |
|
66 | + } |
|
67 | + |
|
68 | + $this->notificationType = $siteConfiguration->getIrcNotificationType(); |
|
69 | + $this->instanceName = $siteConfiguration->getIrcNotificationsInstance(); |
|
70 | + $this->baseUrl = $siteConfiguration->getBaseUrl(); |
|
71 | + $this->requestStates = $siteConfiguration->getRequestStates(); |
|
72 | + |
|
73 | + $this->currentUser = User::getCurrent($primaryDatabase); |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * Send a notification |
|
78 | + * |
|
79 | + * @param string $message The text to send |
|
80 | + */ |
|
81 | + protected function send($message) |
|
82 | + { |
|
83 | + $instanceName = $this->instanceName; |
|
84 | + |
|
85 | + if (!$this->notificationsEnabled) { |
|
86 | + return; |
|
87 | + } |
|
88 | + |
|
89 | + $blacklist = array("DCC", "CCTP", "PRIVMSG"); |
|
90 | + $message = str_replace($blacklist, "(IRC Blacklist)", $message); // Lets stop DCC etc |
|
91 | + |
|
92 | + $msg = IrcColourCode::RESET . IrcColourCode::BOLD . "[$instanceName]" . IrcColourCode::RESET . ": $message"; |
|
93 | + |
|
94 | + try { |
|
95 | + $notification = new Notification(); |
|
96 | + $notification->setDatabase($this->notificationsDatabase); |
|
97 | + $notification->setType($this->notificationType); |
|
98 | + $notification->setText($msg); |
|
99 | + |
|
100 | + $notification->save(); |
|
101 | + } |
|
102 | + catch (Exception $ex) { |
|
103 | + // OK, so we failed to send the notification - that db might be down? |
|
104 | + // This is non-critical, so silently fail. |
|
105 | + |
|
106 | + // Disable notifications for remainder of request. |
|
107 | + $this->notificationsEnabled = false; |
|
108 | + } |
|
109 | + } |
|
110 | + |
|
111 | + #region user management |
|
112 | + |
|
113 | + /** |
|
114 | + * send a new user notification |
|
115 | + * |
|
116 | + * @param User $user |
|
117 | + */ |
|
118 | + public function userNew(User $user) |
|
119 | + { |
|
120 | + $this->send("New user: {$user->getUsername()}"); |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * send an approved notification |
|
125 | + * |
|
126 | + * @param User $user |
|
127 | + */ |
|
128 | + public function userApproved(User $user) |
|
129 | + { |
|
130 | + $this->send("{$user->getUsername()} approved by " . $this->currentUser->getUsername()); |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * send a promoted notification |
|
135 | + * |
|
136 | + * @param User $user |
|
137 | + */ |
|
138 | + public function userPromoted(User $user) |
|
139 | + { |
|
140 | + $this->send("{$user->getUsername()} promoted to tool admin by " . $this->currentUser->getUsername()); |
|
141 | + } |
|
142 | + |
|
143 | + /** |
|
144 | + * send a declined notification |
|
145 | + * |
|
146 | + * @param User $user |
|
147 | + * @param string $reason the reason the user was declined |
|
148 | + */ |
|
149 | + public function userDeclined(User $user, $reason) |
|
150 | + { |
|
151 | + $this->send("{$user->getUsername()} declined by " . $this->currentUser->getUsername() . " ($reason)"); |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * send a demotion notification |
|
156 | + * |
|
157 | + * @param User $user |
|
158 | + * @param string $reason the reason the user was demoted |
|
159 | + */ |
|
160 | + public function userDemoted(User $user, $reason) |
|
161 | + { |
|
162 | + $this->send("{$user->getUsername()} demoted by " . $this->currentUser->getUsername() . " ($reason)"); |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * send a suspended notification |
|
167 | + * |
|
168 | + * @param User $user |
|
169 | + * @param string $reason The reason the user has been suspended |
|
170 | + */ |
|
171 | + public function userSuspended(User $user, $reason) |
|
172 | + { |
|
173 | + $this->send("{$user->getUsername()} suspended by " . $this->currentUser->getUsername() . " ($reason)"); |
|
174 | + } |
|
175 | + |
|
176 | + /** |
|
177 | + * Send a preference change notification |
|
178 | + * |
|
179 | + * @param User $user |
|
180 | + */ |
|
181 | + public function userPrefChange(User $user) |
|
182 | + { |
|
183 | + $this->send("{$user->getUsername()}'s preferences were changed by " . $this->currentUser->getUsername()); |
|
184 | + } |
|
185 | + |
|
186 | + /** |
|
187 | + * Send a user renamed notification |
|
188 | + * |
|
189 | + * @param User $user |
|
190 | + * @param string $old |
|
191 | + */ |
|
192 | + public function userRenamed(User $user, $old) |
|
193 | + { |
|
194 | + $this->send($this->currentUser->getUsername() . " renamed $old to {$user->getUsername()}"); |
|
195 | + } |
|
196 | + |
|
197 | + /** |
|
198 | + * @param User $user |
|
199 | + * @param string $reason |
|
200 | + */ |
|
201 | + public function userRolesEdited(User $user, $reason) |
|
202 | + { |
|
203 | + $currentUser = $this->currentUser->getUsername(); |
|
204 | + $this->send("Active roles for {$user->getUsername()} changed by " . $currentUser . " ($reason)"); |
|
205 | + } |
|
206 | + |
|
207 | + #endregion |
|
208 | + |
|
209 | + #region Site Notice |
|
210 | + |
|
211 | + /** |
|
212 | + * Summary of siteNoticeEdited |
|
213 | + */ |
|
214 | + public function siteNoticeEdited() |
|
215 | + { |
|
216 | + $this->send("Site notice edited by " . $this->currentUser->getUsername()); |
|
217 | + } |
|
218 | + #endregion |
|
219 | + |
|
220 | + #region Welcome Templates |
|
221 | + /** |
|
222 | + * Summary of welcomeTemplateCreated |
|
223 | + * |
|
224 | + * @param WelcomeTemplate $template |
|
225 | + */ |
|
226 | + public function welcomeTemplateCreated(WelcomeTemplate $template) |
|
227 | + { |
|
228 | + $this->send("Welcome template {$template->getId()} created by " . $this->currentUser->getUsername()); |
|
229 | + } |
|
230 | + |
|
231 | + /** |
|
232 | + * Summary of welcomeTemplateDeleted |
|
233 | + * |
|
234 | + * @param int $templateid |
|
235 | + */ |
|
236 | + public function welcomeTemplateDeleted($templateid) |
|
237 | + { |
|
238 | + $this->send("Welcome template {$templateid} deleted by " . $this->currentUser->getUsername()); |
|
239 | + } |
|
240 | + |
|
241 | + /** |
|
242 | + * Summary of welcomeTemplateEdited |
|
243 | + * |
|
244 | + * @param WelcomeTemplate $template |
|
245 | + */ |
|
246 | + public function welcomeTemplateEdited(WelcomeTemplate $template) |
|
247 | + { |
|
248 | + $this->send("Welcome template {$template->getId()} edited by " . $this->currentUser->getUsername()); |
|
249 | + } |
|
250 | + |
|
251 | + #endregion |
|
252 | + |
|
253 | + #region bans |
|
254 | + /** |
|
255 | + * Summary of banned |
|
256 | + * |
|
257 | + * @param Ban $ban |
|
258 | + */ |
|
259 | + public function banned(Ban $ban) |
|
260 | + { |
|
261 | + if ($ban->getDuration() == -1) { |
|
262 | + $duration = "indefinitely"; |
|
263 | + } |
|
264 | + else { |
|
265 | + $duration = "until " . date("F j, Y, g:i a", $ban->getDuration()); |
|
266 | + } |
|
267 | + |
|
268 | + $username = $this->currentUser->getUsername(); |
|
269 | + |
|
270 | + $this->send("{$ban->getTarget()} banned by {$username} for '{$ban->getReason()}' {$duration}"); |
|
271 | + } |
|
272 | + |
|
273 | + /** |
|
274 | + * Summary of unbanned |
|
275 | + * |
|
276 | + * @param Ban $ban |
|
277 | + * @param string $unbanreason |
|
278 | + */ |
|
279 | + public function unbanned(Ban $ban, $unbanreason) |
|
280 | + { |
|
281 | + $this->send($ban->getTarget() . " unbanned by " . $this->currentUser |
|
282 | + ->getUsername() . " (" . $unbanreason . ")"); |
|
283 | + } |
|
284 | + |
|
285 | + #endregion |
|
286 | + |
|
287 | + #region request management |
|
288 | + |
|
289 | + /** |
|
290 | + * Summary of requestReceived |
|
291 | + * |
|
292 | + * @param Request $request |
|
293 | + */ |
|
294 | + public function requestReceived(Request $request) |
|
295 | + { |
|
296 | + $this->send( |
|
297 | + IrcColourCode::DARK_GREY . "[[" |
|
298 | + . IrcColourCode::DARK_GREEN . "acc:" |
|
299 | + . IrcColourCode::ORANGE . $request->getId() |
|
300 | + . IrcColourCode::DARK_GREY . "]]" |
|
301 | + . IrcColourCode::RED . " N " |
|
302 | + . IrcColourCode::DARK_BLUE . $this->baseUrl . "/internal.php/viewRequest?id={$request->getId()} " |
|
303 | + . IrcColourCode::DARK_RED . "* " |
|
304 | + . IrcColourCode::DARK_GREEN . $request->getName() |
|
305 | + . IrcColourCode::DARK_RED . " * " |
|
306 | + . IrcColourCode::RESET |
|
307 | + ); |
|
308 | + } |
|
309 | + |
|
310 | + /** |
|
311 | + * Summary of requestDeferred |
|
312 | + * |
|
313 | + * @param Request $request |
|
314 | + */ |
|
315 | + public function requestDeferred(Request $request) |
|
316 | + { |
|
317 | + $availableRequestStates = $this->requestStates; |
|
318 | + |
|
319 | + $deferTo = $availableRequestStates[$request->getStatus()]['deferto']; |
|
320 | + $username = $this->currentUser->getUsername(); |
|
321 | + |
|
322 | + $this->send("Request {$request->getId()} ({$request->getName()}) deferred to {$deferTo} by {$username}"); |
|
323 | + } |
|
324 | + |
|
325 | + /** |
|
326 | + * |
|
327 | + * Summary of requestDeferredWithMail |
|
328 | + * |
|
329 | + * @param Request $request |
|
330 | + */ |
|
331 | + public function requestDeferredWithMail(Request $request) |
|
332 | + { |
|
333 | + $availableRequestStates = $this->requestStates; |
|
334 | + |
|
335 | + $deferTo = $availableRequestStates[$request->getStatus()]['deferto']; |
|
336 | + $username = $this->currentUser->getUsername(); |
|
337 | + $id = $request->getId(); |
|
338 | + $name = $request->getName(); |
|
339 | + |
|
340 | + $this->send("Request {$id} ({$name}) deferred to {$deferTo} with an email by {$username}"); |
|
341 | + } |
|
342 | + |
|
343 | + /** |
|
344 | + * Summary of requestClosed |
|
345 | + * |
|
346 | + * @param Request $request |
|
347 | + * @param string $closetype |
|
348 | + */ |
|
349 | + public function requestClosed(Request $request, $closetype) |
|
350 | + { |
|
351 | + $username = $this->currentUser->getUsername(); |
|
352 | + |
|
353 | + $this->send("Request {$request->getId()} ({$request->getName()}) closed ($closetype) by {$username}"); |
|
354 | + } |
|
355 | + |
|
356 | + /** |
|
357 | + * Summary of sentMail |
|
358 | + * |
|
359 | + * @param Request $request |
|
360 | + */ |
|
361 | + public function sentMail(Request $request) |
|
362 | + { |
|
363 | + $this->send($this->currentUser->getUsername() |
|
364 | + . " sent an email related to Request {$request->getId()} ({$request->getName()})"); |
|
365 | + } |
|
366 | + |
|
367 | + #endregion |
|
368 | + |
|
369 | + #region reservations |
|
370 | + |
|
371 | + /** |
|
372 | + * Summary of requestReserved |
|
373 | + * |
|
374 | + * @param Request $request |
|
375 | + */ |
|
376 | + public function requestReserved(Request $request) |
|
377 | + { |
|
378 | + $username = $this->currentUser->getUsername(); |
|
379 | + |
|
380 | + $this->send("Request {$request->getId()} ({$request->getName()}) reserved by {$username}"); |
|
381 | + } |
|
382 | + |
|
383 | + /** |
|
384 | + * Summary of requestReserveBroken |
|
385 | + * |
|
386 | + * @param Request $request |
|
387 | + */ |
|
388 | + public function requestReserveBroken(Request $request) |
|
389 | + { |
|
390 | + $username = $this->currentUser->getUsername(); |
|
391 | + |
|
392 | + $this->send("Reservation on request {$request->getId()} ({$request->getName()}) broken by {$username}"); |
|
393 | + } |
|
394 | + |
|
395 | + /** |
|
396 | + * Summary of requestUnreserved |
|
397 | + * |
|
398 | + * @param Request $request |
|
399 | + */ |
|
400 | + public function requestUnreserved(Request $request) |
|
401 | + { |
|
402 | + $this->send("Request {$request->getId()} ({$request->getName()}) is no longer being handled."); |
|
403 | + } |
|
404 | + |
|
405 | + /** |
|
406 | + * Summary of requestReservationSent |
|
407 | + * |
|
408 | + * @param Request $request |
|
409 | + * @param User $target |
|
410 | + */ |
|
411 | + public function requestReservationSent(Request $request, User $target) |
|
412 | + { |
|
413 | + $username = $this->currentUser->getUsername(); |
|
414 | + |
|
415 | + $this->send( |
|
416 | + "Reservation of request {$request->getId()} ({$request->getName()}) sent to {$target->getUsername()} by " |
|
417 | + . $username); |
|
418 | + } |
|
419 | + |
|
420 | + #endregion |
|
421 | + |
|
422 | + #region comments |
|
423 | + |
|
424 | + /** |
|
425 | + * Summary of commentCreated |
|
426 | + * |
|
427 | + * @param Comment $comment |
|
428 | + * @param Request $request |
|
429 | + */ |
|
430 | + public function commentCreated(Comment $comment, Request $request) |
|
431 | + { |
|
432 | + $username = $this->currentUser->getUsername(); |
|
433 | + $visibility = ($comment->getVisibility() == "admin" ? "private " : ""); |
|
434 | + |
|
435 | + $this->send("{$username} posted a {$visibility}comment on request {$request->getId()} ({$request->getName()})"); |
|
436 | + } |
|
437 | + |
|
438 | + /** |
|
439 | + * Summary of commentEdited |
|
440 | + * |
|
441 | + * @param Comment $comment |
|
442 | + * @param Request $request |
|
443 | + */ |
|
444 | + public function commentEdited(Comment $comment, Request $request) |
|
445 | + { |
|
446 | + $username = $this->currentUser->getUsername(); |
|
447 | + |
|
448 | + $this->send(<<<TAG |
|
449 | 449 | Comment {$comment->getId()} on request {$request->getId()} ({$request->getName()}) edited by {$username} |
450 | 450 | TAG |
451 | - ); |
|
452 | - } |
|
453 | - |
|
454 | - #endregion |
|
455 | - |
|
456 | - #region email management (close reasons) |
|
457 | - |
|
458 | - /** |
|
459 | - * Summary of emailCreated |
|
460 | - * |
|
461 | - * @param EmailTemplate $template |
|
462 | - */ |
|
463 | - public function emailCreated(EmailTemplate $template) |
|
464 | - { |
|
465 | - $username = $this->currentUser->getUsername(); |
|
466 | - $this->send("Email {$template->getId()} ({$template->getName()}) created by " . $username); |
|
467 | - } |
|
468 | - |
|
469 | - /** |
|
470 | - * Summary of emailEdited |
|
471 | - * |
|
472 | - * @param EmailTemplate $template |
|
473 | - */ |
|
474 | - public function emailEdited(EmailTemplate $template) |
|
475 | - { |
|
476 | - $username = $this->currentUser->getUsername(); |
|
477 | - $this->send("Email {$template->getId()} ({$template->getName()}) edited by " . $username); |
|
478 | - } |
|
479 | - #endregion |
|
451 | + ); |
|
452 | + } |
|
453 | + |
|
454 | + #endregion |
|
455 | + |
|
456 | + #region email management (close reasons) |
|
457 | + |
|
458 | + /** |
|
459 | + * Summary of emailCreated |
|
460 | + * |
|
461 | + * @param EmailTemplate $template |
|
462 | + */ |
|
463 | + public function emailCreated(EmailTemplate $template) |
|
464 | + { |
|
465 | + $username = $this->currentUser->getUsername(); |
|
466 | + $this->send("Email {$template->getId()} ({$template->getName()}) created by " . $username); |
|
467 | + } |
|
468 | + |
|
469 | + /** |
|
470 | + * Summary of emailEdited |
|
471 | + * |
|
472 | + * @param EmailTemplate $template |
|
473 | + */ |
|
474 | + public function emailEdited(EmailTemplate $template) |
|
475 | + { |
|
476 | + $username = $this->currentUser->getUsername(); |
|
477 | + $this->send("Email {$template->getId()} ({$template->getName()}) edited by " . $username); |
|
478 | + } |
|
479 | + #endregion |
|
480 | 480 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $blacklist = array("DCC", "CCTP", "PRIVMSG"); |
90 | 90 | $message = str_replace($blacklist, "(IRC Blacklist)", $message); // Lets stop DCC etc |
91 | 91 | |
92 | - $msg = IrcColourCode::RESET . IrcColourCode::BOLD . "[$instanceName]" . IrcColourCode::RESET . ": $message"; |
|
92 | + $msg = IrcColourCode::RESET.IrcColourCode::BOLD."[$instanceName]".IrcColourCode::RESET.": $message"; |
|
93 | 93 | |
94 | 94 | try { |
95 | 95 | $notification = new Notification(); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function userApproved(User $user) |
129 | 129 | { |
130 | - $this->send("{$user->getUsername()} approved by " . $this->currentUser->getUsername()); |
|
130 | + $this->send("{$user->getUsername()} approved by ".$this->currentUser->getUsername()); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public function userPromoted(User $user) |
139 | 139 | { |
140 | - $this->send("{$user->getUsername()} promoted to tool admin by " . $this->currentUser->getUsername()); |
|
140 | + $this->send("{$user->getUsername()} promoted to tool admin by ".$this->currentUser->getUsername()); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | */ |
149 | 149 | public function userDeclined(User $user, $reason) |
150 | 150 | { |
151 | - $this->send("{$user->getUsername()} declined by " . $this->currentUser->getUsername() . " ($reason)"); |
|
151 | + $this->send("{$user->getUsername()} declined by ".$this->currentUser->getUsername()." ($reason)"); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public function userDemoted(User $user, $reason) |
161 | 161 | { |
162 | - $this->send("{$user->getUsername()} demoted by " . $this->currentUser->getUsername() . " ($reason)"); |
|
162 | + $this->send("{$user->getUsername()} demoted by ".$this->currentUser->getUsername()." ($reason)"); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public function userSuspended(User $user, $reason) |
172 | 172 | { |
173 | - $this->send("{$user->getUsername()} suspended by " . $this->currentUser->getUsername() . " ($reason)"); |
|
173 | + $this->send("{$user->getUsername()} suspended by ".$this->currentUser->getUsername()." ($reason)"); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | */ |
181 | 181 | public function userPrefChange(User $user) |
182 | 182 | { |
183 | - $this->send("{$user->getUsername()}'s preferences were changed by " . $this->currentUser->getUsername()); |
|
183 | + $this->send("{$user->getUsername()}'s preferences were changed by ".$this->currentUser->getUsername()); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function userRenamed(User $user, $old) |
193 | 193 | { |
194 | - $this->send($this->currentUser->getUsername() . " renamed $old to {$user->getUsername()}"); |
|
194 | + $this->send($this->currentUser->getUsername()." renamed $old to {$user->getUsername()}"); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | public function userRolesEdited(User $user, $reason) |
202 | 202 | { |
203 | 203 | $currentUser = $this->currentUser->getUsername(); |
204 | - $this->send("Active roles for {$user->getUsername()} changed by " . $currentUser . " ($reason)"); |
|
204 | + $this->send("Active roles for {$user->getUsername()} changed by ".$currentUser." ($reason)"); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | #endregion |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | */ |
214 | 214 | public function siteNoticeEdited() |
215 | 215 | { |
216 | - $this->send("Site notice edited by " . $this->currentUser->getUsername()); |
|
216 | + $this->send("Site notice edited by ".$this->currentUser->getUsername()); |
|
217 | 217 | } |
218 | 218 | #endregion |
219 | 219 | |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | */ |
226 | 226 | public function welcomeTemplateCreated(WelcomeTemplate $template) |
227 | 227 | { |
228 | - $this->send("Welcome template {$template->getId()} created by " . $this->currentUser->getUsername()); |
|
228 | + $this->send("Welcome template {$template->getId()} created by ".$this->currentUser->getUsername()); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | */ |
236 | 236 | public function welcomeTemplateDeleted($templateid) |
237 | 237 | { |
238 | - $this->send("Welcome template {$templateid} deleted by " . $this->currentUser->getUsername()); |
|
238 | + $this->send("Welcome template {$templateid} deleted by ".$this->currentUser->getUsername()); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | /** |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | */ |
246 | 246 | public function welcomeTemplateEdited(WelcomeTemplate $template) |
247 | 247 | { |
248 | - $this->send("Welcome template {$template->getId()} edited by " . $this->currentUser->getUsername()); |
|
248 | + $this->send("Welcome template {$template->getId()} edited by ".$this->currentUser->getUsername()); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | #endregion |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | $duration = "indefinitely"; |
263 | 263 | } |
264 | 264 | else { |
265 | - $duration = "until " . date("F j, Y, g:i a", $ban->getDuration()); |
|
265 | + $duration = "until ".date("F j, Y, g:i a", $ban->getDuration()); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | $username = $this->currentUser->getUsername(); |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | */ |
279 | 279 | public function unbanned(Ban $ban, $unbanreason) |
280 | 280 | { |
281 | - $this->send($ban->getTarget() . " unbanned by " . $this->currentUser |
|
282 | - ->getUsername() . " (" . $unbanreason . ")"); |
|
281 | + $this->send($ban->getTarget()." unbanned by ".$this->currentUser |
|
282 | + ->getUsername()." (".$unbanreason.")"); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | #endregion |
@@ -294,15 +294,15 @@ discard block |
||
294 | 294 | public function requestReceived(Request $request) |
295 | 295 | { |
296 | 296 | $this->send( |
297 | - IrcColourCode::DARK_GREY . "[[" |
|
298 | - . IrcColourCode::DARK_GREEN . "acc:" |
|
299 | - . IrcColourCode::ORANGE . $request->getId() |
|
300 | - . IrcColourCode::DARK_GREY . "]]" |
|
301 | - . IrcColourCode::RED . " N " |
|
302 | - . IrcColourCode::DARK_BLUE . $this->baseUrl . "/internal.php/viewRequest?id={$request->getId()} " |
|
303 | - . IrcColourCode::DARK_RED . "* " |
|
304 | - . IrcColourCode::DARK_GREEN . $request->getName() |
|
305 | - . IrcColourCode::DARK_RED . " * " |
|
297 | + IrcColourCode::DARK_GREY."[[" |
|
298 | + . IrcColourCode::DARK_GREEN."acc:" |
|
299 | + . IrcColourCode::ORANGE.$request->getId() |
|
300 | + . IrcColourCode::DARK_GREY."]]" |
|
301 | + . IrcColourCode::RED." N " |
|
302 | + . IrcColourCode::DARK_BLUE.$this->baseUrl."/internal.php/viewRequest?id={$request->getId()} " |
|
303 | + . IrcColourCode::DARK_RED."* " |
|
304 | + . IrcColourCode::DARK_GREEN.$request->getName() |
|
305 | + . IrcColourCode::DARK_RED." * " |
|
306 | 306 | . IrcColourCode::RESET |
307 | 307 | ); |
308 | 308 | } |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | public function emailCreated(EmailTemplate $template) |
464 | 464 | { |
465 | 465 | $username = $this->currentUser->getUsername(); |
466 | - $this->send("Email {$template->getId()} ({$template->getName()}) created by " . $username); |
|
466 | + $this->send("Email {$template->getId()} ({$template->getName()}) created by ".$username); |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | /** |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | public function emailEdited(EmailTemplate $template) |
475 | 475 | { |
476 | 476 | $username = $this->currentUser->getUsername(); |
477 | - $this->send("Email {$template->getId()} ({$template->getName()}) edited by " . $username); |
|
477 | + $this->send("Email {$template->getId()} ({$template->getName()}) edited by ".$username); |
|
478 | 478 | } |
479 | 479 | #endregion |
480 | 480 | } |
@@ -21,13 +21,13 @@ discard block |
||
21 | 21 | |
22 | 22 | class StatsUsers extends InternalPageBase |
23 | 23 | { |
24 | - public function main() |
|
25 | - { |
|
26 | - $this->setHtmlTitle('Users :: Statistics'); |
|
24 | + public function main() |
|
25 | + { |
|
26 | + $this->setHtmlTitle('Users :: Statistics'); |
|
27 | 27 | |
28 | - $database = $this->getDatabase(); |
|
28 | + $database = $this->getDatabase(); |
|
29 | 29 | |
30 | - $query = <<<SQL |
|
30 | + $query = <<<SQL |
|
31 | 31 | select |
32 | 32 | u.id |
33 | 33 | , u.username |
@@ -43,36 +43,36 @@ discard block |
||
43 | 43 | where u.status = 'Active' |
44 | 44 | SQL; |
45 | 45 | |
46 | - $users = $database->query($query)->fetchAll(PDO::FETCH_ASSOC); |
|
47 | - $this->assign('users', $users); |
|
46 | + $users = $database->query($query)->fetchAll(PDO::FETCH_ASSOC); |
|
47 | + $this->assign('users', $users); |
|
48 | 48 | |
49 | - $this->assign('statsPageTitle', 'Account Creation Tool users'); |
|
50 | - $this->setTemplate("statistics/users.tpl"); |
|
51 | - } |
|
49 | + $this->assign('statsPageTitle', 'Account Creation Tool users'); |
|
50 | + $this->setTemplate("statistics/users.tpl"); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Entry point for the detail action. |
|
55 | - * |
|
56 | - * @throws ApplicationLogicException |
|
57 | - */ |
|
58 | - protected function detail() |
|
59 | - { |
|
60 | - $userId = WebRequest::getInt('user'); |
|
61 | - if ($userId === null) { |
|
62 | - throw new ApplicationLogicException("User not found"); |
|
63 | - } |
|
53 | + /** |
|
54 | + * Entry point for the detail action. |
|
55 | + * |
|
56 | + * @throws ApplicationLogicException |
|
57 | + */ |
|
58 | + protected function detail() |
|
59 | + { |
|
60 | + $userId = WebRequest::getInt('user'); |
|
61 | + if ($userId === null) { |
|
62 | + throw new ApplicationLogicException("User not found"); |
|
63 | + } |
|
64 | 64 | |
65 | - $database = $this->getDatabase(); |
|
65 | + $database = $this->getDatabase(); |
|
66 | 66 | |
67 | - $user = User::getById($userId, $database); |
|
68 | - if ($user == false) { |
|
69 | - throw new ApplicationLogicException('User not found'); |
|
70 | - } |
|
67 | + $user = User::getById($userId, $database); |
|
68 | + if ($user == false) { |
|
69 | + throw new ApplicationLogicException('User not found'); |
|
70 | + } |
|
71 | 71 | |
72 | - $safeUsername = htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8'); |
|
73 | - $this->setHtmlTitle($safeUsername . ' :: Users :: Statistics'); |
|
72 | + $safeUsername = htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8'); |
|
73 | + $this->setHtmlTitle($safeUsername . ' :: Users :: Statistics'); |
|
74 | 74 | |
75 | - $activitySummary = $database->prepare(<<<SQL |
|
75 | + $activitySummary = $database->prepare(<<<SQL |
|
76 | 76 | SELECT COALESCE(closes.mail_desc, log.action) AS action, COUNT(*) AS count |
77 | 77 | FROM log |
78 | 78 | INNER JOIN user ON log.user = user.id |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | WHERE user.username = :username |
81 | 81 | GROUP BY action; |
82 | 82 | SQL |
83 | - ); |
|
84 | - $activitySummary->execute(array(":username" => $user->getUsername())); |
|
85 | - $activitySummaryData = $activitySummary->fetchAll(PDO::FETCH_ASSOC); |
|
83 | + ); |
|
84 | + $activitySummary->execute(array(":username" => $user->getUsername())); |
|
85 | + $activitySummaryData = $activitySummary->fetchAll(PDO::FETCH_ASSOC); |
|
86 | 86 | |
87 | - $this->assign("user", $user); |
|
88 | - $this->assign("activity", $activitySummaryData); |
|
87 | + $this->assign("user", $user); |
|
88 | + $this->assign("activity", $activitySummaryData); |
|
89 | 89 | |
90 | - $usersCreatedQuery = $database->prepare(<<<SQL |
|
90 | + $usersCreatedQuery = $database->prepare(<<<SQL |
|
91 | 91 | SELECT log.timestamp time, request.name name, request.id id |
92 | 92 | FROM log |
93 | 93 | INNER JOIN request ON (request.id = log.objectid AND log.objecttype = 'Request') |
@@ -98,12 +98,12 @@ discard block |
||
98 | 98 | AND (emailtemplate.oncreated = '1' OR log.action = 'Closed custom-y') |
99 | 99 | ORDER BY log.timestamp; |
100 | 100 | SQL |
101 | - ); |
|
102 | - $usersCreatedQuery->execute(array(":username" => $user->getUsername())); |
|
103 | - $usersCreated = $usersCreatedQuery->fetchAll(PDO::FETCH_ASSOC); |
|
104 | - $this->assign("created", $usersCreated); |
|
101 | + ); |
|
102 | + $usersCreatedQuery->execute(array(":username" => $user->getUsername())); |
|
103 | + $usersCreated = $usersCreatedQuery->fetchAll(PDO::FETCH_ASSOC); |
|
104 | + $this->assign("created", $usersCreated); |
|
105 | 105 | |
106 | - $usersNotCreatedQuery = $database->prepare(<<<SQL |
|
106 | + $usersNotCreatedQuery = $database->prepare(<<<SQL |
|
107 | 107 | SELECT log.timestamp time, request.name name, request.id id |
108 | 108 | FROM log |
109 | 109 | JOIN request ON request.id = log.objectid AND log.objecttype = 'Request' |
@@ -114,37 +114,37 @@ discard block |
||
114 | 114 | AND (emailtemplate.oncreated = '0' OR log.action = 'Closed custom-n' OR log.action = 'Closed 0') |
115 | 115 | ORDER BY log.timestamp; |
116 | 116 | SQL |
117 | - ); |
|
118 | - $usersNotCreatedQuery->execute(array(":username" => $user->getUsername())); |
|
119 | - $usersNotCreated = $usersNotCreatedQuery->fetchAll(PDO::FETCH_ASSOC); |
|
120 | - $this->assign("notcreated", $usersNotCreated); |
|
121 | - |
|
122 | - /** @var Log[] $logs */ |
|
123 | - $logs = LogSearchHelper::get($database) |
|
124 | - ->byObjectType('User') |
|
125 | - ->byObjectId($user->getId()) |
|
126 | - ->getRecordCount($logCount) |
|
127 | - ->fetch(); |
|
128 | - |
|
129 | - if ($logCount === 0) { |
|
130 | - $this->assign('accountlog', array()); |
|
131 | - } |
|
132 | - else { |
|
133 | - list($users, $logData) = LogHelper::prepareLogsForTemplate($logs, $database, $this->getSiteConfiguration()); |
|
134 | - |
|
135 | - $this->assign("accountlog", $logData); |
|
136 | - $this->assign("users", $users); |
|
137 | - } |
|
138 | - |
|
139 | - $currentUser = User::getCurrent($database); |
|
140 | - $this->assign('canApprove', $this->barrierTest('approve', $currentUser, PageUserManagement::class)); |
|
141 | - $this->assign('canDecline', $this->barrierTest('decline', $currentUser, PageUserManagement::class)); |
|
142 | - $this->assign('canRename', $this->barrierTest('rename', $currentUser, PageUserManagement::class)); |
|
143 | - $this->assign('canEditUser', $this->barrierTest('editUser', $currentUser, PageUserManagement::class)); |
|
144 | - $this->assign('canSuspend', $this->barrierTest('suspend', $currentUser, PageUserManagement::class)); |
|
145 | - $this->assign('canEditRoles', $this->barrierTest('editRoles', $currentUser, PageUserManagement::class)); |
|
146 | - |
|
147 | - $this->assign('statsPageTitle', 'Account Creation Tool users'); |
|
148 | - $this->setTemplate("statistics/userdetail.tpl"); |
|
149 | - } |
|
117 | + ); |
|
118 | + $usersNotCreatedQuery->execute(array(":username" => $user->getUsername())); |
|
119 | + $usersNotCreated = $usersNotCreatedQuery->fetchAll(PDO::FETCH_ASSOC); |
|
120 | + $this->assign("notcreated", $usersNotCreated); |
|
121 | + |
|
122 | + /** @var Log[] $logs */ |
|
123 | + $logs = LogSearchHelper::get($database) |
|
124 | + ->byObjectType('User') |
|
125 | + ->byObjectId($user->getId()) |
|
126 | + ->getRecordCount($logCount) |
|
127 | + ->fetch(); |
|
128 | + |
|
129 | + if ($logCount === 0) { |
|
130 | + $this->assign('accountlog', array()); |
|
131 | + } |
|
132 | + else { |
|
133 | + list($users, $logData) = LogHelper::prepareLogsForTemplate($logs, $database, $this->getSiteConfiguration()); |
|
134 | + |
|
135 | + $this->assign("accountlog", $logData); |
|
136 | + $this->assign("users", $users); |
|
137 | + } |
|
138 | + |
|
139 | + $currentUser = User::getCurrent($database); |
|
140 | + $this->assign('canApprove', $this->barrierTest('approve', $currentUser, PageUserManagement::class)); |
|
141 | + $this->assign('canDecline', $this->barrierTest('decline', $currentUser, PageUserManagement::class)); |
|
142 | + $this->assign('canRename', $this->barrierTest('rename', $currentUser, PageUserManagement::class)); |
|
143 | + $this->assign('canEditUser', $this->barrierTest('editUser', $currentUser, PageUserManagement::class)); |
|
144 | + $this->assign('canSuspend', $this->barrierTest('suspend', $currentUser, PageUserManagement::class)); |
|
145 | + $this->assign('canEditRoles', $this->barrierTest('editRoles', $currentUser, PageUserManagement::class)); |
|
146 | + |
|
147 | + $this->assign('statsPageTitle', 'Account Creation Tool users'); |
|
148 | + $this->setTemplate("statistics/userdetail.tpl"); |
|
149 | + } |
|
150 | 150 | } |
@@ -13,12 +13,12 @@ discard block |
||
13 | 13 | |
14 | 14 | class StatsTopCreators extends InternalPageBase |
15 | 15 | { |
16 | - public function main() |
|
17 | - { |
|
18 | - $this->setHtmlTitle('Top Creators :: Statistics'); |
|
16 | + public function main() |
|
17 | + { |
|
18 | + $this->setHtmlTitle('Top Creators :: Statistics'); |
|
19 | 19 | |
20 | - // Retrieve all-time stats |
|
21 | - $queryAllTime = <<<SQL |
|
20 | + // Retrieve all-time stats |
|
21 | + $queryAllTime = <<<SQL |
|
22 | 22 | SELECT |
23 | 23 | /* StatsTopCreators::execute()/queryAllTime */ |
24 | 24 | COUNT(*) count, |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | ORDER BY COUNT(*) DESC; |
36 | 36 | SQL; |
37 | 37 | |
38 | - // Retrieve all-time stats for active users only |
|
39 | - $queryAllTimeActive = <<<SQL |
|
38 | + // Retrieve all-time stats for active users only |
|
39 | + $queryAllTimeActive = <<<SQL |
|
40 | 40 | SELECT |
41 | 41 | /* StatsTopCreators::execute()/queryAllTimeActive */ |
42 | 42 | COUNT(*) count, |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | ORDER BY COUNT(*) DESC; |
54 | 54 | SQL; |
55 | 55 | |
56 | - // Retrieve today's stats (so far) |
|
57 | - $queryToday = <<<SQL |
|
56 | + // Retrieve today's stats (so far) |
|
57 | + $queryToday = <<<SQL |
|
58 | 58 | SELECT |
59 | 59 | /* StatsTopCreators::execute()/top5out */ |
60 | 60 | COUNT(*) count, |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | ORDER BY COUNT(*) DESC; |
71 | 71 | SQL; |
72 | 72 | |
73 | - // Retrieve Yesterday's stats |
|
74 | - $queryYesterday = <<<SQL |
|
73 | + // Retrieve Yesterday's stats |
|
74 | + $queryYesterday = <<<SQL |
|
75 | 75 | SELECT |
76 | 76 | /* StatsTopCreators::execute()/top5yout */ |
77 | 77 | COUNT(*) count, |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | ORDER BY COUNT(*) DESC; |
88 | 88 | SQL; |
89 | 89 | |
90 | - // Retrieve last 7 days |
|
91 | - $queryLast7Days = <<<SQL |
|
90 | + // Retrieve last 7 days |
|
91 | + $queryLast7Days = <<<SQL |
|
92 | 92 | SELECT |
93 | 93 | /* StatsTopCreators::execute()/top5wout */ |
94 | 94 | COUNT(*) count, |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | ORDER BY COUNT(*) DESC; |
105 | 105 | SQL; |
106 | 106 | |
107 | - // Retrieve last month's stats |
|
108 | - $queryLast28Days = <<<SQL |
|
107 | + // Retrieve last month's stats |
|
108 | + $queryLast28Days = <<<SQL |
|
109 | 109 | SELECT |
110 | 110 | /* StatsTopCreators::execute()/top5mout */ |
111 | 111 | COUNT(*) count, |
@@ -121,24 +121,24 @@ discard block |
||
121 | 121 | ORDER BY COUNT(*) DESC; |
122 | 122 | SQL; |
123 | 123 | |
124 | - // Put it all together |
|
125 | - $queries = array( |
|
126 | - 'queryAllTime' => $queryAllTime, |
|
127 | - 'queryAllTimeActive' => $queryAllTimeActive, |
|
128 | - 'queryToday' => $queryToday, |
|
129 | - 'queryYesterday' => $queryYesterday, |
|
130 | - 'queryLast7Days' => $queryLast7Days, |
|
131 | - 'queryLast28Days' => $queryLast28Days, |
|
132 | - ); |
|
124 | + // Put it all together |
|
125 | + $queries = array( |
|
126 | + 'queryAllTime' => $queryAllTime, |
|
127 | + 'queryAllTimeActive' => $queryAllTimeActive, |
|
128 | + 'queryToday' => $queryToday, |
|
129 | + 'queryYesterday' => $queryYesterday, |
|
130 | + 'queryLast7Days' => $queryLast7Days, |
|
131 | + 'queryLast28Days' => $queryLast28Days, |
|
132 | + ); |
|
133 | 133 | |
134 | - $database = $this->getDatabase(); |
|
135 | - foreach ($queries as $name => $sql) { |
|
136 | - $statement = $database->query($sql); |
|
137 | - $data = $statement->fetchAll(PDO::FETCH_ASSOC); |
|
138 | - $this->assign($name, $data); |
|
139 | - } |
|
134 | + $database = $this->getDatabase(); |
|
135 | + foreach ($queries as $name => $sql) { |
|
136 | + $statement = $database->query($sql); |
|
137 | + $data = $statement->fetchAll(PDO::FETCH_ASSOC); |
|
138 | + $this->assign($name, $data); |
|
139 | + } |
|
140 | 140 | |
141 | - $this->assign('statsPageTitle', 'Top Account Creators'); |
|
142 | - $this->setTemplate('statistics/top-creators.tpl'); |
|
143 | - } |
|
141 | + $this->assign('statsPageTitle', 'Top Account Creators'); |
|
142 | + $this->setTemplate('statistics/top-creators.tpl'); |
|
143 | + } |
|
144 | 144 | } |
@@ -17,31 +17,31 @@ |
||
17 | 17 | |
18 | 18 | class StatsInactiveUsers extends InternalPageBase |
19 | 19 | { |
20 | - public function main() |
|
21 | - { |
|
22 | - $this->setHtmlTitle('Inactive Users :: Statistics'); |
|
23 | - |
|
24 | - $date = new DateTime(); |
|
25 | - $date->modify("-45 days"); |
|
26 | - |
|
27 | - $inactiveUsers = UserSearchHelper::get($this->getDatabase()) |
|
28 | - ->byStatus('Active') |
|
29 | - ->lastActiveBefore($date) |
|
30 | - ->getRoleMap($roleMap) |
|
31 | - ->fetch(); |
|
32 | - |
|
33 | - $this->assign('inactiveUsers', $inactiveUsers); |
|
34 | - $this->assign('roles', $roleMap); |
|
35 | - $this->assign('canSuspend', |
|
36 | - $this->barrierTest('suspend', User::getCurrent($this->getDatabase()), PageUserManagement::class)); |
|
37 | - |
|
38 | - $immuneUsers = $this->getDatabase() |
|
39 | - ->query("SELECT user FROM userrole WHERE role IN ('toolRoot', 'checkuser') GROUP BY user;") |
|
40 | - ->fetchAll(PDO::FETCH_COLUMN); |
|
20 | + public function main() |
|
21 | + { |
|
22 | + $this->setHtmlTitle('Inactive Users :: Statistics'); |
|
23 | + |
|
24 | + $date = new DateTime(); |
|
25 | + $date->modify("-45 days"); |
|
26 | + |
|
27 | + $inactiveUsers = UserSearchHelper::get($this->getDatabase()) |
|
28 | + ->byStatus('Active') |
|
29 | + ->lastActiveBefore($date) |
|
30 | + ->getRoleMap($roleMap) |
|
31 | + ->fetch(); |
|
32 | + |
|
33 | + $this->assign('inactiveUsers', $inactiveUsers); |
|
34 | + $this->assign('roles', $roleMap); |
|
35 | + $this->assign('canSuspend', |
|
36 | + $this->barrierTest('suspend', User::getCurrent($this->getDatabase()), PageUserManagement::class)); |
|
37 | + |
|
38 | + $immuneUsers = $this->getDatabase() |
|
39 | + ->query("SELECT user FROM userrole WHERE role IN ('toolRoot', 'checkuser') GROUP BY user;") |
|
40 | + ->fetchAll(PDO::FETCH_COLUMN); |
|
41 | 41 | |
42 | - $this->assign('immune', array_fill_keys($immuneUsers, true)); |
|
42 | + $this->assign('immune', array_fill_keys($immuneUsers, true)); |
|
43 | 43 | |
44 | - $this->setTemplate('statistics/inactive-users.tpl'); |
|
45 | - $this->assign('statsPageTitle', 'Inactive tool users'); |
|
46 | - } |
|
44 | + $this->setTemplate('statistics/inactive-users.tpl'); |
|
45 | + $this->assign('statsPageTitle', 'Inactive tool users'); |
|
46 | + } |
|
47 | 47 | } |
@@ -13,11 +13,11 @@ discard block |
||
13 | 13 | |
14 | 14 | class StatsMonthlyStats extends InternalPageBase |
15 | 15 | { |
16 | - public function main() |
|
17 | - { |
|
18 | - $this->setHtmlTitle('Monthly Stats :: Statistics'); |
|
16 | + public function main() |
|
17 | + { |
|
18 | + $this->setHtmlTitle('Monthly Stats :: Statistics'); |
|
19 | 19 | |
20 | - $query = <<<SQL |
|
20 | + $query = <<<SQL |
|
21 | 21 | SELECT |
22 | 22 | COUNT(DISTINCT id) AS closed, |
23 | 23 | YEAR(timestamp) AS year, |
@@ -28,12 +28,12 @@ discard block |
||
28 | 28 | ORDER BY YEAR(timestamp) , MONTH(timestamp) ASC; |
29 | 29 | SQL; |
30 | 30 | |
31 | - $database = $this->getDatabase(); |
|
32 | - $statement = $database->query($query); |
|
33 | - $data = $statement->fetchAll(PDO::FETCH_ASSOC); |
|
31 | + $database = $this->getDatabase(); |
|
32 | + $statement = $database->query($query); |
|
33 | + $data = $statement->fetchAll(PDO::FETCH_ASSOC); |
|
34 | 34 | |
35 | - $this->assign('dataTable', $data); |
|
36 | - $this->assign('statsPageTitle', 'Monthly Statistics'); |
|
37 | - $this->setTemplate('statistics/monthly-stats.tpl'); |
|
38 | - } |
|
35 | + $this->assign('dataTable', $data); |
|
36 | + $this->assign('statsPageTitle', 'Monthly Statistics'); |
|
37 | + $this->setTemplate('statistics/monthly-stats.tpl'); |
|
38 | + } |
|
39 | 39 | } |
@@ -13,11 +13,11 @@ discard block |
||
13 | 13 | |
14 | 14 | class StatsFastCloses extends InternalPageBase |
15 | 15 | { |
16 | - public function main() |
|
17 | - { |
|
18 | - $this->setHtmlTitle('Fast Closes :: Statistics'); |
|
16 | + public function main() |
|
17 | + { |
|
18 | + $this->setHtmlTitle('Fast Closes :: Statistics'); |
|
19 | 19 | |
20 | - $query = <<<SQL |
|
20 | + $query = <<<SQL |
|
21 | 21 | SELECT |
22 | 22 | log_closed.objectid AS request, |
23 | 23 | user.username AS user, |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | ORDER BY TIMEDIFF(log_closed.timestamp, log_reserved.timestamp) ASC |
43 | 43 | ; |
44 | 44 | SQL; |
45 | - $database = $this->getDatabase(); |
|
46 | - $statement = $database->query($query); |
|
47 | - $data = $statement->fetchAll(PDO::FETCH_ASSOC); |
|
48 | - $this->assign('dataTable', $data); |
|
49 | - $this->assign('statsPageTitle', 'Requests closed less than 30 seconds after reservation in the past 3 months'); |
|
50 | - $this->setTemplate('statistics/fast-closes.tpl'); |
|
51 | - } |
|
45 | + $database = $this->getDatabase(); |
|
46 | + $statement = $database->query($query); |
|
47 | + $data = $statement->fetchAll(PDO::FETCH_ASSOC); |
|
48 | + $this->assign('dataTable', $data); |
|
49 | + $this->assign('statsPageTitle', 'Requests closed less than 30 seconds after reservation in the past 3 months'); |
|
50 | + $this->setTemplate('statistics/fast-closes.tpl'); |
|
51 | + } |
|
52 | 52 | } |
@@ -12,99 +12,99 @@ |
||
12 | 12 | |
13 | 13 | class StatsMain extends InternalPageBase |
14 | 14 | { |
15 | - public function main() |
|
16 | - { |
|
17 | - $this->setHtmlTitle('Statistics'); |
|
18 | - |
|
19 | - $this->assign('statsPageTitle', 'Account Creation Statistics'); |
|
20 | - |
|
21 | - $statsPages = array( |
|
22 | - 'fastCloses' => 'Requests closed less than 30 seconds after reservation in the past 3 months', |
|
23 | - 'inactiveUsers' => 'Inactive tool users', |
|
24 | - 'monthlyStats' => 'Monthly Statistics', |
|
25 | - 'reservedRequests' => 'All currently reserved requests', |
|
26 | - 'templateStats' => 'Template Stats', |
|
27 | - 'topCreators' => 'Top Account Creators', |
|
28 | - 'users' => 'Account Creation Tool users', |
|
29 | - ); |
|
30 | - |
|
31 | - $this->generateSmallStatsTable(); |
|
32 | - |
|
33 | - $this->assign('statsPages', $statsPages); |
|
34 | - |
|
35 | - $graphList = array('day', '2day', '4day', 'week', '2week', 'month', '3month'); |
|
36 | - $this->assign('graphList', $graphList); |
|
37 | - |
|
38 | - $this->setTemplate('statistics/main.tpl'); |
|
39 | - } |
|
40 | - |
|
41 | - /** |
|
42 | - * Gets the relevant statistics from the database for the small statistics table |
|
43 | - */ |
|
44 | - private function generateSmallStatsTable() |
|
45 | - { |
|
46 | - $database = $this->getDatabase(); |
|
47 | - $requestsQuery = <<<'SQL' |
|
15 | + public function main() |
|
16 | + { |
|
17 | + $this->setHtmlTitle('Statistics'); |
|
18 | + |
|
19 | + $this->assign('statsPageTitle', 'Account Creation Statistics'); |
|
20 | + |
|
21 | + $statsPages = array( |
|
22 | + 'fastCloses' => 'Requests closed less than 30 seconds after reservation in the past 3 months', |
|
23 | + 'inactiveUsers' => 'Inactive tool users', |
|
24 | + 'monthlyStats' => 'Monthly Statistics', |
|
25 | + 'reservedRequests' => 'All currently reserved requests', |
|
26 | + 'templateStats' => 'Template Stats', |
|
27 | + 'topCreators' => 'Top Account Creators', |
|
28 | + 'users' => 'Account Creation Tool users', |
|
29 | + ); |
|
30 | + |
|
31 | + $this->generateSmallStatsTable(); |
|
32 | + |
|
33 | + $this->assign('statsPages', $statsPages); |
|
34 | + |
|
35 | + $graphList = array('day', '2day', '4day', 'week', '2week', 'month', '3month'); |
|
36 | + $this->assign('graphList', $graphList); |
|
37 | + |
|
38 | + $this->setTemplate('statistics/main.tpl'); |
|
39 | + } |
|
40 | + |
|
41 | + /** |
|
42 | + * Gets the relevant statistics from the database for the small statistics table |
|
43 | + */ |
|
44 | + private function generateSmallStatsTable() |
|
45 | + { |
|
46 | + $database = $this->getDatabase(); |
|
47 | + $requestsQuery = <<<'SQL' |
|
48 | 48 | SELECT COUNT(*) FROM request WHERE status = :status AND emailconfirm = 'Confirmed'; |
49 | 49 | SQL; |
50 | - $requestsStatement = $database->prepare($requestsQuery); |
|
50 | + $requestsStatement = $database->prepare($requestsQuery); |
|
51 | 51 | |
52 | - $requestStates = $this->getSiteConfiguration()->getRequestStates(); |
|
52 | + $requestStates = $this->getSiteConfiguration()->getRequestStates(); |
|
53 | 53 | |
54 | - $requestStateData = array(); |
|
54 | + $requestStateData = array(); |
|
55 | 55 | |
56 | - foreach ($requestStates as $statusName => $data) { |
|
57 | - $requestsStatement->execute(array(':status' => $statusName)); |
|
58 | - $requestCount = $requestsStatement->fetchColumn(); |
|
59 | - $requestsStatement->closeCursor(); |
|
60 | - $headerText = $data['header']; |
|
61 | - $requestStateData[$headerText] = $requestCount; |
|
62 | - } |
|
56 | + foreach ($requestStates as $statusName => $data) { |
|
57 | + $requestsStatement->execute(array(':status' => $statusName)); |
|
58 | + $requestCount = $requestsStatement->fetchColumn(); |
|
59 | + $requestsStatement->closeCursor(); |
|
60 | + $headerText = $data['header']; |
|
61 | + $requestStateData[$headerText] = $requestCount; |
|
62 | + } |
|
63 | 63 | |
64 | - $this->assign('requestCountData', $requestStateData); |
|
64 | + $this->assign('requestCountData', $requestStateData); |
|
65 | 65 | |
66 | - // Unconfirmed requests |
|
67 | - $unconfirmedStatement = $database->query(<<<SQL |
|
66 | + // Unconfirmed requests |
|
67 | + $unconfirmedStatement = $database->query(<<<SQL |
|
68 | 68 | SELECT COUNT(*) FROM request WHERE emailconfirm != 'Confirmed' AND emailconfirm != ''; |
69 | 69 | SQL |
70 | - ); |
|
71 | - $unconfirmed = $unconfirmedStatement->fetchColumn(); |
|
72 | - $unconfirmedStatement->closeCursor(); |
|
73 | - $this->assign('statsUnconfirmed', $unconfirmed); |
|
74 | - |
|
75 | - $userStatusStatement = $database->prepare('SELECT COUNT(*) FROM user WHERE status = :status;'); |
|
76 | - |
|
77 | - // Admin users |
|
78 | - $userStatusStatement->execute(array(':status' => 'Admin')); |
|
79 | - $adminUsers = $userStatusStatement->fetchColumn(); |
|
80 | - $userStatusStatement->closeCursor(); |
|
81 | - $this->assign('statsAdminUsers', $adminUsers); |
|
82 | - |
|
83 | - // Users |
|
84 | - $userStatusStatement->execute(array(':status' => 'User')); |
|
85 | - $users = $userStatusStatement->fetchColumn(); |
|
86 | - $userStatusStatement->closeCursor(); |
|
87 | - $this->assign('statsUsers', $users); |
|
88 | - |
|
89 | - // Suspended users |
|
90 | - $userStatusStatement->execute(array(':status' => 'Suspended')); |
|
91 | - $suspendedUsers = $userStatusStatement->fetchColumn(); |
|
92 | - $userStatusStatement->closeCursor(); |
|
93 | - $this->assign('statsSuspendedUsers', $suspendedUsers); |
|
94 | - |
|
95 | - // New users |
|
96 | - $userStatusStatement->execute(array(':status' => 'New')); |
|
97 | - $newUsers = $userStatusStatement->fetchColumn(); |
|
98 | - $userStatusStatement->closeCursor(); |
|
99 | - $this->assign('statsNewUsers', $newUsers); |
|
100 | - |
|
101 | - // Most comments on a request |
|
102 | - $mostCommentsStatement = $database->query(<<<SQL |
|
70 | + ); |
|
71 | + $unconfirmed = $unconfirmedStatement->fetchColumn(); |
|
72 | + $unconfirmedStatement->closeCursor(); |
|
73 | + $this->assign('statsUnconfirmed', $unconfirmed); |
|
74 | + |
|
75 | + $userStatusStatement = $database->prepare('SELECT COUNT(*) FROM user WHERE status = :status;'); |
|
76 | + |
|
77 | + // Admin users |
|
78 | + $userStatusStatement->execute(array(':status' => 'Admin')); |
|
79 | + $adminUsers = $userStatusStatement->fetchColumn(); |
|
80 | + $userStatusStatement->closeCursor(); |
|
81 | + $this->assign('statsAdminUsers', $adminUsers); |
|
82 | + |
|
83 | + // Users |
|
84 | + $userStatusStatement->execute(array(':status' => 'User')); |
|
85 | + $users = $userStatusStatement->fetchColumn(); |
|
86 | + $userStatusStatement->closeCursor(); |
|
87 | + $this->assign('statsUsers', $users); |
|
88 | + |
|
89 | + // Suspended users |
|
90 | + $userStatusStatement->execute(array(':status' => 'Suspended')); |
|
91 | + $suspendedUsers = $userStatusStatement->fetchColumn(); |
|
92 | + $userStatusStatement->closeCursor(); |
|
93 | + $this->assign('statsSuspendedUsers', $suspendedUsers); |
|
94 | + |
|
95 | + // New users |
|
96 | + $userStatusStatement->execute(array(':status' => 'New')); |
|
97 | + $newUsers = $userStatusStatement->fetchColumn(); |
|
98 | + $userStatusStatement->closeCursor(); |
|
99 | + $this->assign('statsNewUsers', $newUsers); |
|
100 | + |
|
101 | + // Most comments on a request |
|
102 | + $mostCommentsStatement = $database->query(<<<SQL |
|
103 | 103 | SELECT request FROM comment GROUP BY request ORDER BY COUNT(*) DESC LIMIT 1; |
104 | 104 | SQL |
105 | - ); |
|
106 | - $mostComments = $mostCommentsStatement->fetchColumn(); |
|
107 | - $mostCommentsStatement->closeCursor(); |
|
108 | - $this->assign('mostComments', $mostComments); |
|
109 | - } |
|
105 | + ); |
|
106 | + $mostComments = $mostCommentsStatement->fetchColumn(); |
|
107 | + $mostCommentsStatement->closeCursor(); |
|
108 | + $this->assign('mostComments', $mostComments); |
|
109 | + } |
|
110 | 110 | } |
@@ -13,11 +13,11 @@ discard block |
||
13 | 13 | |
14 | 14 | class StatsTemplateStats extends InternalPageBase |
15 | 15 | { |
16 | - public function main() |
|
17 | - { |
|
18 | - $this->setHtmlTitle('Template Stats :: Statistics'); |
|
16 | + public function main() |
|
17 | + { |
|
18 | + $this->setHtmlTitle('Template Stats :: Statistics'); |
|
19 | 19 | |
20 | - $query = <<<SQL |
|
20 | + $query = <<<SQL |
|
21 | 21 | SELECT |
22 | 22 | t.id AS templateid, |
23 | 23 | t.usercode AS usercode, |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | GROUP BY welcome_template |
46 | 46 | ) u2 ON u2.allid = t.id; |
47 | 47 | SQL; |
48 | - $database = $this->getDatabase(); |
|
49 | - $statement = $database->query($query); |
|
50 | - $data = $statement->fetchAll(PDO::FETCH_ASSOC); |
|
51 | - $this->assign('dataTable', $data); |
|
52 | - $this->assign('statsPageTitle', 'Template Stats'); |
|
53 | - $this->setTemplate('statistics/welcome-template-usage.tpl'); |
|
54 | - } |
|
48 | + $database = $this->getDatabase(); |
|
49 | + $statement = $database->query($query); |
|
50 | + $data = $statement->fetchAll(PDO::FETCH_ASSOC); |
|
51 | + $this->assign('dataTable', $data); |
|
52 | + $this->assign('statsPageTitle', 'Template Stats'); |
|
53 | + $this->setTemplate('statistics/welcome-template-usage.tpl'); |
|
54 | + } |
|
55 | 55 | } |
@@ -13,11 +13,11 @@ discard block |
||
13 | 13 | |
14 | 14 | class StatsReservedRequests extends InternalPageBase |
15 | 15 | { |
16 | - public function main() |
|
17 | - { |
|
18 | - $this->setHtmlTitle('Reserved Requests :: Statistics'); |
|
16 | + public function main() |
|
17 | + { |
|
18 | + $this->setHtmlTitle('Reserved Requests :: Statistics'); |
|
19 | 19 | |
20 | - $query = <<<sql |
|
20 | + $query = <<<sql |
|
21 | 21 | SELECT |
22 | 22 | p.id AS requestid, |
23 | 23 | p.name AS name, |
@@ -29,11 +29,11 @@ discard block |
||
29 | 29 | WHERE reserved != 0; |
30 | 30 | sql; |
31 | 31 | |
32 | - $database = $this->getDatabase(); |
|
33 | - $statement = $database->query($query); |
|
34 | - $data = $statement->fetchAll(PDO::FETCH_ASSOC); |
|
35 | - $this->assign('dataTable', $data); |
|
36 | - $this->assign('statsPageTitle', 'All currently reserved requests'); |
|
37 | - $this->setTemplate('statistics/reserved-requests.tpl'); |
|
38 | - } |
|
32 | + $database = $this->getDatabase(); |
|
33 | + $statement = $database->query($query); |
|
34 | + $data = $statement->fetchAll(PDO::FETCH_ASSOC); |
|
35 | + $this->assign('dataTable', $data); |
|
36 | + $this->assign('statsPageTitle', 'All currently reserved requests'); |
|
37 | + $this->setTemplate('statistics/reserved-requests.tpl'); |
|
38 | + } |
|
39 | 39 | } |