@@ -16,16 +16,16 @@ |
||
16 | 16 | |
17 | 17 | class BotCreationTask extends CreationTaskBase |
18 | 18 | { |
19 | - /** |
|
20 | - * @return IMediaWikiClient |
|
21 | - */ |
|
22 | - protected function getMediaWikiClient() |
|
23 | - { |
|
24 | - return new BotMediaWikiClient($this->getSiteConfiguration()); |
|
25 | - } |
|
19 | + /** |
|
20 | + * @return IMediaWikiClient |
|
21 | + */ |
|
22 | + protected function getMediaWikiClient() |
|
23 | + { |
|
24 | + return new BotMediaWikiClient($this->getSiteConfiguration()); |
|
25 | + } |
|
26 | 26 | |
27 | - protected function getCreationReason(Request $request, User $user) |
|
28 | - { |
|
29 | - return parent::getCreationReason($request, $user) . ', on behalf of [[User:' . $user->getOnWikiName() . ']]'; |
|
30 | - } |
|
27 | + protected function getCreationReason(Request $request, User $user) |
|
28 | + { |
|
29 | + return parent::getCreationReason($request, $user) . ', on behalf of [[User:' . $user->getOnWikiName() . ']]'; |
|
30 | + } |
|
31 | 31 | } |
32 | 32 | \ No newline at end of file |
@@ -26,6 +26,6 @@ |
||
26 | 26 | |
27 | 27 | protected function getCreationReason(Request $request, User $user) |
28 | 28 | { |
29 | - return parent::getCreationReason($request, $user) . ', on behalf of [[User:' . $user->getOnWikiName() . ']]'; |
|
29 | + return parent::getCreationReason($request, $user).', on behalf of [[User:'.$user->getOnWikiName().']]'; |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | \ No newline at end of file |
@@ -14,14 +14,14 @@ |
||
14 | 14 | |
15 | 15 | class UserCreationTask extends CreationTaskBase |
16 | 16 | { |
17 | - /** |
|
18 | - * @return IMediaWikiClient |
|
19 | - */ |
|
20 | - protected function getMediaWikiClient() |
|
21 | - { |
|
22 | - $oauth = new OAuthUserHelper($this->getTriggerUser(), $this->getDatabase(), $this->getOauthProtocolHelper(), |
|
23 | - $this->getSiteConfiguration()); |
|
17 | + /** |
|
18 | + * @return IMediaWikiClient |
|
19 | + */ |
|
20 | + protected function getMediaWikiClient() |
|
21 | + { |
|
22 | + $oauth = new OAuthUserHelper($this->getTriggerUser(), $this->getDatabase(), $this->getOauthProtocolHelper(), |
|
23 | + $this->getSiteConfiguration()); |
|
24 | 24 | |
25 | - return $oauth; |
|
26 | - } |
|
25 | + return $oauth; |
|
26 | + } |
|
27 | 27 | } |
28 | 28 | \ No newline at end of file |
@@ -20,73 +20,73 @@ |
||
20 | 20 | |
21 | 21 | class WelcomeUserTask extends BackgroundTaskBase |
22 | 22 | { |
23 | - public static function enqueue(User $triggerUser, Request $request, PdoDatabase $database) |
|
24 | - { |
|
25 | - $job = new JobQueue(); |
|
26 | - $job->setDatabase($database); |
|
27 | - $job->setTask(WelcomeUserTask::class); |
|
28 | - $job->setRequest($request->getId()); |
|
29 | - $job->setTriggerUserId($triggerUser->getId()); |
|
30 | - $job->save(); |
|
31 | - } |
|
32 | - |
|
33 | - public function execute() |
|
34 | - { |
|
35 | - $database = $this->getDatabase(); |
|
36 | - $request = $this->getRequest(); |
|
37 | - $user = $this->getTriggerUser(); |
|
38 | - |
|
39 | - if ($user->getWelcomeTemplate() === null) { |
|
40 | - $this->markFailed('Welcome template not specified'); |
|
41 | - |
|
42 | - return; |
|
43 | - } |
|
44 | - |
|
45 | - /** @var WelcomeTemplate $template */ |
|
46 | - $template = WelcomeTemplate::getById($user->getWelcomeTemplate(), $database); |
|
47 | - |
|
48 | - if ($template === false) { |
|
49 | - $this->markFailed('Welcome template missing'); |
|
50 | - |
|
51 | - return; |
|
52 | - } |
|
53 | - |
|
54 | - $oauth = new OAuthUserHelper($user, $database, $this->getOauthProtocolHelper(), |
|
55 | - $this->getSiteConfiguration()); |
|
56 | - $mediaWikiHelper = new MediaWikiHelper($oauth, $this->getSiteConfiguration()); |
|
57 | - |
|
58 | - if ($request->getStatus() !== RequestStatus::CLOSED) { |
|
59 | - $this->markFailed('Request is currently open'); |
|
60 | - |
|
61 | - return; |
|
62 | - } |
|
63 | - |
|
64 | - if (!$mediaWikiHelper->checkAccountExists($request->getName())){ |
|
65 | - $this->markFailed('Account does not exist!'); |
|
66 | - |
|
67 | - return; |
|
68 | - } |
|
69 | - |
|
70 | - $this->performWelcome($template, $request, $mediaWikiHelper); |
|
71 | - $this->markComplete(); |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * Performs the welcome |
|
76 | - * |
|
77 | - * @param WelcomeTemplate $template |
|
78 | - * @param Request $request |
|
79 | - * @param MediaWikiHelper $mediaWikiHelper |
|
80 | - */ |
|
81 | - private function performWelcome( |
|
82 | - WelcomeTemplate $template, |
|
83 | - Request $request, |
|
84 | - MediaWikiHelper $mediaWikiHelper |
|
85 | - ) { |
|
86 | - $templateText = $template->getBotCode(); |
|
87 | - $templateText = str_replace('$signature', '~~~~', $templateText); |
|
88 | - $templateText = str_replace('$username', $request->getName(), $templateText); |
|
89 | - |
|
90 | - $mediaWikiHelper->addTalkPageMessage($request->getName(), 'Welcome!', 'Welcoming user created through [[WP:ACC]]', $templateText); |
|
91 | - } |
|
23 | + public static function enqueue(User $triggerUser, Request $request, PdoDatabase $database) |
|
24 | + { |
|
25 | + $job = new JobQueue(); |
|
26 | + $job->setDatabase($database); |
|
27 | + $job->setTask(WelcomeUserTask::class); |
|
28 | + $job->setRequest($request->getId()); |
|
29 | + $job->setTriggerUserId($triggerUser->getId()); |
|
30 | + $job->save(); |
|
31 | + } |
|
32 | + |
|
33 | + public function execute() |
|
34 | + { |
|
35 | + $database = $this->getDatabase(); |
|
36 | + $request = $this->getRequest(); |
|
37 | + $user = $this->getTriggerUser(); |
|
38 | + |
|
39 | + if ($user->getWelcomeTemplate() === null) { |
|
40 | + $this->markFailed('Welcome template not specified'); |
|
41 | + |
|
42 | + return; |
|
43 | + } |
|
44 | + |
|
45 | + /** @var WelcomeTemplate $template */ |
|
46 | + $template = WelcomeTemplate::getById($user->getWelcomeTemplate(), $database); |
|
47 | + |
|
48 | + if ($template === false) { |
|
49 | + $this->markFailed('Welcome template missing'); |
|
50 | + |
|
51 | + return; |
|
52 | + } |
|
53 | + |
|
54 | + $oauth = new OAuthUserHelper($user, $database, $this->getOauthProtocolHelper(), |
|
55 | + $this->getSiteConfiguration()); |
|
56 | + $mediaWikiHelper = new MediaWikiHelper($oauth, $this->getSiteConfiguration()); |
|
57 | + |
|
58 | + if ($request->getStatus() !== RequestStatus::CLOSED) { |
|
59 | + $this->markFailed('Request is currently open'); |
|
60 | + |
|
61 | + return; |
|
62 | + } |
|
63 | + |
|
64 | + if (!$mediaWikiHelper->checkAccountExists($request->getName())){ |
|
65 | + $this->markFailed('Account does not exist!'); |
|
66 | + |
|
67 | + return; |
|
68 | + } |
|
69 | + |
|
70 | + $this->performWelcome($template, $request, $mediaWikiHelper); |
|
71 | + $this->markComplete(); |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * Performs the welcome |
|
76 | + * |
|
77 | + * @param WelcomeTemplate $template |
|
78 | + * @param Request $request |
|
79 | + * @param MediaWikiHelper $mediaWikiHelper |
|
80 | + */ |
|
81 | + private function performWelcome( |
|
82 | + WelcomeTemplate $template, |
|
83 | + Request $request, |
|
84 | + MediaWikiHelper $mediaWikiHelper |
|
85 | + ) { |
|
86 | + $templateText = $template->getBotCode(); |
|
87 | + $templateText = str_replace('$signature', '~~~~', $templateText); |
|
88 | + $templateText = str_replace('$username', $request->getName(), $templateText); |
|
89 | + |
|
90 | + $mediaWikiHelper->addTalkPageMessage($request->getName(), 'Welcome!', 'Welcoming user created through [[WP:ACC]]', $templateText); |
|
91 | + } |
|
92 | 92 | } |
93 | 93 | \ No newline at end of file |
@@ -61,7 +61,7 @@ |
||
61 | 61 | return; |
62 | 62 | } |
63 | 63 | |
64 | - if (!$mediaWikiHelper->checkAccountExists($request->getName())){ |
|
64 | + if (!$mediaWikiHelper->checkAccountExists($request->getName())) { |
|
65 | 65 | $this->markFailed('Account does not exist!'); |
66 | 66 | |
67 | 67 | return; |
@@ -61,7 +61,7 @@ |
||
61 | 61 | return; |
62 | 62 | } |
63 | 63 | |
64 | - if (!$mediaWikiHelper->checkAccountExists($request->getName())){ |
|
64 | + if (!$mediaWikiHelper->checkAccountExists($request->getName())) { |
|
65 | 65 | $this->markFailed('Account does not exist!'); |
66 | 66 | |
67 | 67 | return; |
@@ -20,123 +20,123 @@ |
||
20 | 20 | |
21 | 21 | abstract class CreationTaskBase extends BackgroundTaskBase |
22 | 22 | { |
23 | - /** @var Request */ |
|
24 | - private $request; |
|
25 | - /** |
|
26 | - * @var MediaWikiHelper |
|
27 | - * Don't use this directly. |
|
28 | - */ |
|
29 | - private $mwHelper = null; |
|
30 | - |
|
31 | - public function execute() |
|
32 | - { |
|
33 | - $this->request = $this->getRequest(); |
|
34 | - $user = $this->getTriggerUser(); |
|
35 | - |
|
36 | - if ($this->request->getStatus() !== RequestStatus::JOBQUEUE) { |
|
37 | - $this->markCancelled('Request is not deferred to the job queue'); |
|
38 | - |
|
39 | - return; |
|
40 | - } |
|
41 | - |
|
42 | - if ($this->request->getEmailSent() != 0) { |
|
43 | - $this->markFailed('Request has already been sent an email'); |
|
44 | - |
|
45 | - return; |
|
46 | - } |
|
47 | - |
|
48 | - if ($this->getEmailTemplate() === null) { |
|
49 | - $this->markFailed('No email template specified'); |
|
50 | - |
|
51 | - return; |
|
52 | - } |
|
53 | - |
|
54 | - try { |
|
55 | - $this->performCreation($user); |
|
56 | - |
|
57 | - $this->request->setStatus(RequestStatus::CLOSED); |
|
58 | - $this->request->setReserved(null); |
|
59 | - $this->request->save(); |
|
60 | - |
|
61 | - // Log the closure as the user |
|
62 | - Logger::closeRequest($this->getDatabase(), $this->request, $this->getEmailTemplate()->getId(), null, |
|
63 | - $this->getTriggerUser()); |
|
64 | - |
|
65 | - $requestEmailHelper = new RequestEmailHelper($this->getEmailHelper()); |
|
66 | - $requestEmailHelper->sendMail($this->request, $this->getEmailTemplate()->getText(), $this->getTriggerUser(), |
|
67 | - false); |
|
68 | - |
|
69 | - $this->getNotificationHelper()->requestClosed($this->request, $this->getEmailTemplate()->getName()); |
|
70 | - } |
|
71 | - catch (Exception $ex) { |
|
72 | - $this->markFailed($ex->getMessage()); |
|
73 | - |
|
74 | - return; |
|
75 | - } |
|
76 | - |
|
77 | - $this->markComplete(); |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * @return IMediaWikiClient |
|
82 | - */ |
|
83 | - protected abstract function getMediaWikiClient(); |
|
84 | - |
|
85 | - protected function getMediaWikiHelper(){ |
|
86 | - if($this->mwHelper === null) { |
|
87 | - $this->mwHelper = new MediaWikiHelper($this->getMediaWikiClient(), $this->getSiteConfiguration()); |
|
88 | - } |
|
89 | - |
|
90 | - return $this->mwHelper; |
|
91 | - } |
|
92 | - |
|
93 | - protected function getCreationReason(Request $request, User $user) |
|
94 | - { |
|
95 | - return 'Requested account at [[WP:ACC]], request #' . $request->getId(); |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * @param string $name |
|
100 | - * |
|
101 | - * @return bool |
|
102 | - */ |
|
103 | - protected function checkAccountExists($name) |
|
104 | - { |
|
105 | - return $this->getMediaWikiHelper()->checkAccountExists($name); |
|
106 | - } |
|
107 | - |
|
108 | - protected function markFailed($reason = null) |
|
109 | - { |
|
110 | - $this->request->setStatus(RequestStatus::HOSPITAL); |
|
111 | - $this->request->save(); |
|
112 | - |
|
113 | - Logger::hospitalised($this->getDatabase(), $this->request); |
|
114 | - |
|
115 | - parent::markFailed($reason); |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * @param $user |
|
120 | - * |
|
121 | - * @throws ApplicationLogicException |
|
122 | - */ |
|
123 | - protected function performCreation($user) |
|
124 | - { |
|
125 | - $mw = $this->getMediaWikiHelper(); |
|
126 | - |
|
127 | - $reason = $this->getCreationReason($this->request, $user); |
|
23 | + /** @var Request */ |
|
24 | + private $request; |
|
25 | + /** |
|
26 | + * @var MediaWikiHelper |
|
27 | + * Don't use this directly. |
|
28 | + */ |
|
29 | + private $mwHelper = null; |
|
30 | + |
|
31 | + public function execute() |
|
32 | + { |
|
33 | + $this->request = $this->getRequest(); |
|
34 | + $user = $this->getTriggerUser(); |
|
35 | + |
|
36 | + if ($this->request->getStatus() !== RequestStatus::JOBQUEUE) { |
|
37 | + $this->markCancelled('Request is not deferred to the job queue'); |
|
38 | + |
|
39 | + return; |
|
40 | + } |
|
41 | + |
|
42 | + if ($this->request->getEmailSent() != 0) { |
|
43 | + $this->markFailed('Request has already been sent an email'); |
|
44 | + |
|
45 | + return; |
|
46 | + } |
|
47 | + |
|
48 | + if ($this->getEmailTemplate() === null) { |
|
49 | + $this->markFailed('No email template specified'); |
|
50 | + |
|
51 | + return; |
|
52 | + } |
|
53 | + |
|
54 | + try { |
|
55 | + $this->performCreation($user); |
|
56 | + |
|
57 | + $this->request->setStatus(RequestStatus::CLOSED); |
|
58 | + $this->request->setReserved(null); |
|
59 | + $this->request->save(); |
|
60 | + |
|
61 | + // Log the closure as the user |
|
62 | + Logger::closeRequest($this->getDatabase(), $this->request, $this->getEmailTemplate()->getId(), null, |
|
63 | + $this->getTriggerUser()); |
|
64 | + |
|
65 | + $requestEmailHelper = new RequestEmailHelper($this->getEmailHelper()); |
|
66 | + $requestEmailHelper->sendMail($this->request, $this->getEmailTemplate()->getText(), $this->getTriggerUser(), |
|
67 | + false); |
|
68 | + |
|
69 | + $this->getNotificationHelper()->requestClosed($this->request, $this->getEmailTemplate()->getName()); |
|
70 | + } |
|
71 | + catch (Exception $ex) { |
|
72 | + $this->markFailed($ex->getMessage()); |
|
73 | + |
|
74 | + return; |
|
75 | + } |
|
76 | + |
|
77 | + $this->markComplete(); |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * @return IMediaWikiClient |
|
82 | + */ |
|
83 | + protected abstract function getMediaWikiClient(); |
|
84 | + |
|
85 | + protected function getMediaWikiHelper(){ |
|
86 | + if($this->mwHelper === null) { |
|
87 | + $this->mwHelper = new MediaWikiHelper($this->getMediaWikiClient(), $this->getSiteConfiguration()); |
|
88 | + } |
|
89 | + |
|
90 | + return $this->mwHelper; |
|
91 | + } |
|
92 | + |
|
93 | + protected function getCreationReason(Request $request, User $user) |
|
94 | + { |
|
95 | + return 'Requested account at [[WP:ACC]], request #' . $request->getId(); |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * @param string $name |
|
100 | + * |
|
101 | + * @return bool |
|
102 | + */ |
|
103 | + protected function checkAccountExists($name) |
|
104 | + { |
|
105 | + return $this->getMediaWikiHelper()->checkAccountExists($name); |
|
106 | + } |
|
107 | + |
|
108 | + protected function markFailed($reason = null) |
|
109 | + { |
|
110 | + $this->request->setStatus(RequestStatus::HOSPITAL); |
|
111 | + $this->request->save(); |
|
112 | + |
|
113 | + Logger::hospitalised($this->getDatabase(), $this->request); |
|
114 | + |
|
115 | + parent::markFailed($reason); |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * @param $user |
|
120 | + * |
|
121 | + * @throws ApplicationLogicException |
|
122 | + */ |
|
123 | + protected function performCreation($user) |
|
124 | + { |
|
125 | + $mw = $this->getMediaWikiHelper(); |
|
126 | + |
|
127 | + $reason = $this->getCreationReason($this->request, $user); |
|
128 | 128 | |
129 | - if ($this->checkAccountExists($this->request->getName())) { |
|
130 | - throw new ApplicationLogicException('Account already exists'); |
|
131 | - } |
|
129 | + if ($this->checkAccountExists($this->request->getName())) { |
|
130 | + throw new ApplicationLogicException('Account already exists'); |
|
131 | + } |
|
132 | 132 | |
133 | - $mw->createAccount($this->request->getName(), $this->request->getEmail(), $reason); |
|
133 | + $mw->createAccount($this->request->getName(), $this->request->getEmail(), $reason); |
|
134 | 134 | |
135 | - if (!$this->checkAccountExists($this->request->getName())) { |
|
136 | - throw new ApplicationLogicException('Account creation appeared to succeed but account does not exist.'); |
|
137 | - } |
|
135 | + if (!$this->checkAccountExists($this->request->getName())) { |
|
136 | + throw new ApplicationLogicException('Account creation appeared to succeed but account does not exist.'); |
|
137 | + } |
|
138 | 138 | |
139 | - $this->request->setStatus(RequestStatus::CLOSED); |
|
140 | - $this->request->save(); |
|
141 | - } |
|
139 | + $this->request->setStatus(RequestStatus::CLOSED); |
|
140 | + $this->request->save(); |
|
141 | + } |
|
142 | 142 | } |
143 | 143 | \ No newline at end of file |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | */ |
83 | 83 | protected abstract function getMediaWikiClient(); |
84 | 84 | |
85 | - protected function getMediaWikiHelper(){ |
|
86 | - if($this->mwHelper === null) { |
|
85 | + protected function getMediaWikiHelper() { |
|
86 | + if ($this->mwHelper === null) { |
|
87 | 87 | $this->mwHelper = new MediaWikiHelper($this->getMediaWikiClient(), $this->getSiteConfiguration()); |
88 | 88 | } |
89 | 89 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | protected function getCreationReason(Request $request, User $user) |
94 | 94 | { |
95 | - return 'Requested account at [[WP:ACC]], request #' . $request->getId(); |
|
95 | + return 'Requested account at [[WP:ACC]], request #'.$request->getId(); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -82,7 +82,8 @@ |
||
82 | 82 | */ |
83 | 83 | protected abstract function getMediaWikiClient(); |
84 | 84 | |
85 | - protected function getMediaWikiHelper(){ |
|
85 | + protected function getMediaWikiHelper() |
|
86 | + { |
|
86 | 87 | if($this->mwHelper === null) { |
87 | 88 | $this->mwHelper = new MediaWikiHelper($this->getMediaWikiClient(), $this->getSiteConfiguration()); |
88 | 89 | } |
@@ -177,7 +177,7 @@ |
||
177 | 177 | throw new ApplicationLogicException('Cannot locate request'); |
178 | 178 | } |
179 | 179 | |
180 | - if($this->job->getEmailTemplate() !== null){ |
|
180 | + if($this->job->getEmailTemplate() !== null) { |
|
181 | 181 | $this->emailTemplate = EmailTemplate::getById($this->job->getEmailTemplate(), $this->getDatabase()); |
182 | 182 | |
183 | 183 | if ($this->emailTemplate === false) { |
@@ -23,267 +23,267 @@ |
||
23 | 23 | |
24 | 24 | abstract class BackgroundTaskBase |
25 | 25 | { |
26 | - /** @var JobQueue */ |
|
27 | - private $job; |
|
28 | - /** @var PdoDatabase */ |
|
29 | - private $database; |
|
30 | - /** @var IOAuthProtocolHelper */ |
|
31 | - private $oauthProtocolHelper; |
|
32 | - /** @var SiteConfiguration */ |
|
33 | - private $siteConfiguration; |
|
34 | - /** @var IEmailHelper */ |
|
35 | - private $emailHelper; |
|
36 | - /** @var HttpHelper */ |
|
37 | - private $httpHelper; |
|
38 | - /** @var IrcNotificationHelper */ |
|
39 | - private $notificationHelper; |
|
40 | - /** @var User */ |
|
41 | - private $triggerUser; |
|
42 | - /** @var Request */ |
|
43 | - private $request; |
|
44 | - /** @var EmailTemplate */ |
|
45 | - private $emailTemplate = null; |
|
46 | - /** @var mixed */ |
|
47 | - private $parameters; |
|
48 | - |
|
49 | - /** |
|
50 | - * @return JobQueue |
|
51 | - */ |
|
52 | - public function getJob() |
|
53 | - { |
|
54 | - return $this->job; |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * @param JobQueue $job |
|
59 | - */ |
|
60 | - public function setJob(JobQueue $job) |
|
61 | - { |
|
62 | - $this->job = $job; |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * @return PdoDatabase |
|
67 | - */ |
|
68 | - public function getDatabase() |
|
69 | - { |
|
70 | - return $this->database; |
|
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * @param PdoDatabase $database |
|
75 | - */ |
|
76 | - public function setDatabase(PdoDatabase $database) |
|
77 | - { |
|
78 | - $this->database = $database; |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * @return IOAuthProtocolHelper |
|
83 | - */ |
|
84 | - public function getOauthProtocolHelper() |
|
85 | - { |
|
86 | - return $this->oauthProtocolHelper; |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * @param IOAuthProtocolHelper $oauthProtocolHelper |
|
91 | - */ |
|
92 | - public function setOauthProtocolHelper(IOAuthProtocolHelper $oauthProtocolHelper) |
|
93 | - { |
|
94 | - $this->oauthProtocolHelper = $oauthProtocolHelper; |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * @return SiteConfiguration |
|
99 | - */ |
|
100 | - public function getSiteConfiguration() |
|
101 | - { |
|
102 | - return $this->siteConfiguration; |
|
103 | - } |
|
104 | - |
|
105 | - /** |
|
106 | - * @param SiteConfiguration $siteConfiguration |
|
107 | - */ |
|
108 | - public function setSiteConfiguration(SiteConfiguration $siteConfiguration) |
|
109 | - { |
|
110 | - $this->siteConfiguration = $siteConfiguration; |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * @return HttpHelper |
|
115 | - */ |
|
116 | - public function getHttpHelper() |
|
117 | - { |
|
118 | - return $this->httpHelper; |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * @param HttpHelper $httpHelper |
|
123 | - */ |
|
124 | - public function setHttpHelper(HttpHelper $httpHelper) |
|
125 | - { |
|
126 | - $this->httpHelper = $httpHelper; |
|
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * @return IEmailHelper |
|
131 | - */ |
|
132 | - public function getEmailHelper() |
|
133 | - { |
|
134 | - return $this->emailHelper; |
|
135 | - } |
|
136 | - |
|
137 | - /** |
|
138 | - * @param IEmailHelper $emailHelper |
|
139 | - */ |
|
140 | - public function setEmailHelper(IEmailHelper $emailHelper) |
|
141 | - { |
|
142 | - $this->emailHelper = $emailHelper; |
|
143 | - } |
|
144 | - |
|
145 | - /** |
|
146 | - * @return IrcNotificationHelper |
|
147 | - */ |
|
148 | - public function getNotificationHelper() |
|
149 | - { |
|
150 | - return $this->notificationHelper; |
|
151 | - } |
|
152 | - |
|
153 | - /** |
|
154 | - * @param IrcNotificationHelper $notificationHelper |
|
155 | - */ |
|
156 | - public function setNotificationHelper($notificationHelper) |
|
157 | - { |
|
158 | - $this->notificationHelper = $notificationHelper; |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * @return void |
|
163 | - */ |
|
164 | - protected abstract function execute(); |
|
165 | - |
|
166 | - public function run() |
|
167 | - { |
|
168 | - $this->triggerUser = User::getById($this->job->getTriggerUserId(), $this->getDatabase()); |
|
169 | - |
|
170 | - if ($this->triggerUser === false) { |
|
171 | - throw new ApplicationLogicException('Cannot locate trigger user'); |
|
172 | - } |
|
173 | - |
|
174 | - $this->request = Request::getById($this->job->getRequest(), $this->getDatabase()); |
|
175 | - |
|
176 | - if ($this->request === false) { |
|
177 | - throw new ApplicationLogicException('Cannot locate request'); |
|
178 | - } |
|
179 | - |
|
180 | - if($this->job->getEmailTemplate() !== null){ |
|
181 | - $this->emailTemplate = EmailTemplate::getById($this->job->getEmailTemplate(), $this->getDatabase()); |
|
182 | - |
|
183 | - if ($this->emailTemplate === false) { |
|
184 | - throw new ApplicationLogicException('Cannot locate email template'); |
|
185 | - } |
|
186 | - } |
|
187 | - |
|
188 | - if($this->job->getParameters() !== null) { |
|
189 | - $this->parameters = json_decode($this->job->getParameters()); |
|
190 | - |
|
191 | - if (json_last_error() !== JSON_ERROR_NONE) { |
|
192 | - throw new ApplicationLogicException('JSON decode: ' . json_last_error_msg()); |
|
193 | - } |
|
194 | - } |
|
195 | - |
|
196 | - // Should we wait for a parent job? |
|
197 | - if($this->job->getParent() !== null) { |
|
198 | - /** @var JobQueue $parentJob */ |
|
199 | - $parentJob = JobQueue::getById($this->job->getParent(), $this->getDatabase()); |
|
200 | - |
|
201 | - if($parentJob === false) { |
|
202 | - $this->markFailed("Parent job could not be found"); |
|
203 | - return; |
|
204 | - } |
|
205 | - |
|
206 | - switch ($parentJob->getStatus()) { |
|
207 | - case JobQueue::STATUS_CANCELLED: |
|
208 | - case JobQueue::STATUS_FAILED: |
|
209 | - $this->markCancelled('Parent job failed/cancelled'); |
|
210 | - return; |
|
211 | - case JobQueue::STATUS_WAITING: |
|
212 | - case JobQueue::STATUS_READY: |
|
213 | - case JobQueue::STATUS_RUNNING: |
|
214 | - case JobQueue::STATUS_HELD: |
|
215 | - // Defer to next execution |
|
216 | - $this->job->setStatus(JobQueue::STATUS_READY); |
|
217 | - $this->job->save(); |
|
218 | - return; |
|
219 | - case JobQueue::STATUS_COMPLETE: |
|
220 | - // do nothing |
|
221 | - break; |
|
222 | - } |
|
223 | - } |
|
224 | - |
|
225 | - $this->execute(); |
|
226 | - } |
|
227 | - |
|
228 | - protected function markComplete() |
|
229 | - { |
|
230 | - $this->job->setStatus(JobQueue::STATUS_COMPLETE); |
|
231 | - $this->job->setError(null); |
|
232 | - $this->job->setAcknowledged(null); |
|
233 | - $this->job->save(); |
|
234 | - |
|
235 | - Logger::backgroundJobComplete($this->getDatabase(), $this->getJob()); |
|
236 | - } |
|
237 | - |
|
238 | - protected function markCancelled($reason = null) |
|
239 | - { |
|
240 | - $this->job->setStatus(JobQueue::STATUS_CANCELLED); |
|
241 | - $this->job->setError($reason); |
|
242 | - $this->job->setAcknowledged(null); |
|
243 | - $this->job->save(); |
|
244 | - |
|
245 | - Logger::backgroundJobIssue($this->getDatabase(), $this->getJob()); |
|
246 | - } |
|
247 | - |
|
248 | - protected function markFailed($reason = null) |
|
249 | - { |
|
250 | - $this->job->setStatus(JobQueue::STATUS_FAILED); |
|
251 | - $this->job->setError($reason); |
|
252 | - $this->job->setAcknowledged(0); |
|
253 | - $this->job->save(); |
|
254 | - |
|
255 | - Logger::backgroundJobIssue($this->getDatabase(), $this->getJob()); |
|
256 | - } |
|
257 | - |
|
258 | - /** |
|
259 | - * @return User |
|
260 | - */ |
|
261 | - public function getTriggerUser() |
|
262 | - { |
|
263 | - return $this->triggerUser; |
|
264 | - } |
|
265 | - |
|
266 | - /** |
|
267 | - * @return Request |
|
268 | - */ |
|
269 | - public function getRequest() |
|
270 | - { |
|
271 | - return $this->request; |
|
272 | - } |
|
273 | - |
|
274 | - /** |
|
275 | - * @return EmailTemplate |
|
276 | - */ |
|
277 | - public function getEmailTemplate() |
|
278 | - { |
|
279 | - return $this->emailTemplate; |
|
280 | - } |
|
281 | - |
|
282 | - /** |
|
283 | - * @return mixed |
|
284 | - */ |
|
285 | - public function getParameters() |
|
286 | - { |
|
287 | - return $this->parameters; |
|
288 | - } |
|
26 | + /** @var JobQueue */ |
|
27 | + private $job; |
|
28 | + /** @var PdoDatabase */ |
|
29 | + private $database; |
|
30 | + /** @var IOAuthProtocolHelper */ |
|
31 | + private $oauthProtocolHelper; |
|
32 | + /** @var SiteConfiguration */ |
|
33 | + private $siteConfiguration; |
|
34 | + /** @var IEmailHelper */ |
|
35 | + private $emailHelper; |
|
36 | + /** @var HttpHelper */ |
|
37 | + private $httpHelper; |
|
38 | + /** @var IrcNotificationHelper */ |
|
39 | + private $notificationHelper; |
|
40 | + /** @var User */ |
|
41 | + private $triggerUser; |
|
42 | + /** @var Request */ |
|
43 | + private $request; |
|
44 | + /** @var EmailTemplate */ |
|
45 | + private $emailTemplate = null; |
|
46 | + /** @var mixed */ |
|
47 | + private $parameters; |
|
48 | + |
|
49 | + /** |
|
50 | + * @return JobQueue |
|
51 | + */ |
|
52 | + public function getJob() |
|
53 | + { |
|
54 | + return $this->job; |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * @param JobQueue $job |
|
59 | + */ |
|
60 | + public function setJob(JobQueue $job) |
|
61 | + { |
|
62 | + $this->job = $job; |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * @return PdoDatabase |
|
67 | + */ |
|
68 | + public function getDatabase() |
|
69 | + { |
|
70 | + return $this->database; |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * @param PdoDatabase $database |
|
75 | + */ |
|
76 | + public function setDatabase(PdoDatabase $database) |
|
77 | + { |
|
78 | + $this->database = $database; |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * @return IOAuthProtocolHelper |
|
83 | + */ |
|
84 | + public function getOauthProtocolHelper() |
|
85 | + { |
|
86 | + return $this->oauthProtocolHelper; |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * @param IOAuthProtocolHelper $oauthProtocolHelper |
|
91 | + */ |
|
92 | + public function setOauthProtocolHelper(IOAuthProtocolHelper $oauthProtocolHelper) |
|
93 | + { |
|
94 | + $this->oauthProtocolHelper = $oauthProtocolHelper; |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * @return SiteConfiguration |
|
99 | + */ |
|
100 | + public function getSiteConfiguration() |
|
101 | + { |
|
102 | + return $this->siteConfiguration; |
|
103 | + } |
|
104 | + |
|
105 | + /** |
|
106 | + * @param SiteConfiguration $siteConfiguration |
|
107 | + */ |
|
108 | + public function setSiteConfiguration(SiteConfiguration $siteConfiguration) |
|
109 | + { |
|
110 | + $this->siteConfiguration = $siteConfiguration; |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * @return HttpHelper |
|
115 | + */ |
|
116 | + public function getHttpHelper() |
|
117 | + { |
|
118 | + return $this->httpHelper; |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * @param HttpHelper $httpHelper |
|
123 | + */ |
|
124 | + public function setHttpHelper(HttpHelper $httpHelper) |
|
125 | + { |
|
126 | + $this->httpHelper = $httpHelper; |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * @return IEmailHelper |
|
131 | + */ |
|
132 | + public function getEmailHelper() |
|
133 | + { |
|
134 | + return $this->emailHelper; |
|
135 | + } |
|
136 | + |
|
137 | + /** |
|
138 | + * @param IEmailHelper $emailHelper |
|
139 | + */ |
|
140 | + public function setEmailHelper(IEmailHelper $emailHelper) |
|
141 | + { |
|
142 | + $this->emailHelper = $emailHelper; |
|
143 | + } |
|
144 | + |
|
145 | + /** |
|
146 | + * @return IrcNotificationHelper |
|
147 | + */ |
|
148 | + public function getNotificationHelper() |
|
149 | + { |
|
150 | + return $this->notificationHelper; |
|
151 | + } |
|
152 | + |
|
153 | + /** |
|
154 | + * @param IrcNotificationHelper $notificationHelper |
|
155 | + */ |
|
156 | + public function setNotificationHelper($notificationHelper) |
|
157 | + { |
|
158 | + $this->notificationHelper = $notificationHelper; |
|
159 | + } |
|
160 | + |
|
161 | + /** |
|
162 | + * @return void |
|
163 | + */ |
|
164 | + protected abstract function execute(); |
|
165 | + |
|
166 | + public function run() |
|
167 | + { |
|
168 | + $this->triggerUser = User::getById($this->job->getTriggerUserId(), $this->getDatabase()); |
|
169 | + |
|
170 | + if ($this->triggerUser === false) { |
|
171 | + throw new ApplicationLogicException('Cannot locate trigger user'); |
|
172 | + } |
|
173 | + |
|
174 | + $this->request = Request::getById($this->job->getRequest(), $this->getDatabase()); |
|
175 | + |
|
176 | + if ($this->request === false) { |
|
177 | + throw new ApplicationLogicException('Cannot locate request'); |
|
178 | + } |
|
179 | + |
|
180 | + if($this->job->getEmailTemplate() !== null){ |
|
181 | + $this->emailTemplate = EmailTemplate::getById($this->job->getEmailTemplate(), $this->getDatabase()); |
|
182 | + |
|
183 | + if ($this->emailTemplate === false) { |
|
184 | + throw new ApplicationLogicException('Cannot locate email template'); |
|
185 | + } |
|
186 | + } |
|
187 | + |
|
188 | + if($this->job->getParameters() !== null) { |
|
189 | + $this->parameters = json_decode($this->job->getParameters()); |
|
190 | + |
|
191 | + if (json_last_error() !== JSON_ERROR_NONE) { |
|
192 | + throw new ApplicationLogicException('JSON decode: ' . json_last_error_msg()); |
|
193 | + } |
|
194 | + } |
|
195 | + |
|
196 | + // Should we wait for a parent job? |
|
197 | + if($this->job->getParent() !== null) { |
|
198 | + /** @var JobQueue $parentJob */ |
|
199 | + $parentJob = JobQueue::getById($this->job->getParent(), $this->getDatabase()); |
|
200 | + |
|
201 | + if($parentJob === false) { |
|
202 | + $this->markFailed("Parent job could not be found"); |
|
203 | + return; |
|
204 | + } |
|
205 | + |
|
206 | + switch ($parentJob->getStatus()) { |
|
207 | + case JobQueue::STATUS_CANCELLED: |
|
208 | + case JobQueue::STATUS_FAILED: |
|
209 | + $this->markCancelled('Parent job failed/cancelled'); |
|
210 | + return; |
|
211 | + case JobQueue::STATUS_WAITING: |
|
212 | + case JobQueue::STATUS_READY: |
|
213 | + case JobQueue::STATUS_RUNNING: |
|
214 | + case JobQueue::STATUS_HELD: |
|
215 | + // Defer to next execution |
|
216 | + $this->job->setStatus(JobQueue::STATUS_READY); |
|
217 | + $this->job->save(); |
|
218 | + return; |
|
219 | + case JobQueue::STATUS_COMPLETE: |
|
220 | + // do nothing |
|
221 | + break; |
|
222 | + } |
|
223 | + } |
|
224 | + |
|
225 | + $this->execute(); |
|
226 | + } |
|
227 | + |
|
228 | + protected function markComplete() |
|
229 | + { |
|
230 | + $this->job->setStatus(JobQueue::STATUS_COMPLETE); |
|
231 | + $this->job->setError(null); |
|
232 | + $this->job->setAcknowledged(null); |
|
233 | + $this->job->save(); |
|
234 | + |
|
235 | + Logger::backgroundJobComplete($this->getDatabase(), $this->getJob()); |
|
236 | + } |
|
237 | + |
|
238 | + protected function markCancelled($reason = null) |
|
239 | + { |
|
240 | + $this->job->setStatus(JobQueue::STATUS_CANCELLED); |
|
241 | + $this->job->setError($reason); |
|
242 | + $this->job->setAcknowledged(null); |
|
243 | + $this->job->save(); |
|
244 | + |
|
245 | + Logger::backgroundJobIssue($this->getDatabase(), $this->getJob()); |
|
246 | + } |
|
247 | + |
|
248 | + protected function markFailed($reason = null) |
|
249 | + { |
|
250 | + $this->job->setStatus(JobQueue::STATUS_FAILED); |
|
251 | + $this->job->setError($reason); |
|
252 | + $this->job->setAcknowledged(0); |
|
253 | + $this->job->save(); |
|
254 | + |
|
255 | + Logger::backgroundJobIssue($this->getDatabase(), $this->getJob()); |
|
256 | + } |
|
257 | + |
|
258 | + /** |
|
259 | + * @return User |
|
260 | + */ |
|
261 | + public function getTriggerUser() |
|
262 | + { |
|
263 | + return $this->triggerUser; |
|
264 | + } |
|
265 | + |
|
266 | + /** |
|
267 | + * @return Request |
|
268 | + */ |
|
269 | + public function getRequest() |
|
270 | + { |
|
271 | + return $this->request; |
|
272 | + } |
|
273 | + |
|
274 | + /** |
|
275 | + * @return EmailTemplate |
|
276 | + */ |
|
277 | + public function getEmailTemplate() |
|
278 | + { |
|
279 | + return $this->emailTemplate; |
|
280 | + } |
|
281 | + |
|
282 | + /** |
|
283 | + * @return mixed |
|
284 | + */ |
|
285 | + public function getParameters() |
|
286 | + { |
|
287 | + return $this->parameters; |
|
288 | + } |
|
289 | 289 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | throw new ApplicationLogicException('Cannot locate request'); |
178 | 178 | } |
179 | 179 | |
180 | - if($this->job->getEmailTemplate() !== null){ |
|
180 | + if ($this->job->getEmailTemplate() !== null) { |
|
181 | 181 | $this->emailTemplate = EmailTemplate::getById($this->job->getEmailTemplate(), $this->getDatabase()); |
182 | 182 | |
183 | 183 | if ($this->emailTemplate === false) { |
@@ -185,20 +185,20 @@ discard block |
||
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
188 | - if($this->job->getParameters() !== null) { |
|
188 | + if ($this->job->getParameters() !== null) { |
|
189 | 189 | $this->parameters = json_decode($this->job->getParameters()); |
190 | 190 | |
191 | 191 | if (json_last_error() !== JSON_ERROR_NONE) { |
192 | - throw new ApplicationLogicException('JSON decode: ' . json_last_error_msg()); |
|
192 | + throw new ApplicationLogicException('JSON decode: '.json_last_error_msg()); |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | |
196 | 196 | // Should we wait for a parent job? |
197 | - if($this->job->getParent() !== null) { |
|
197 | + if ($this->job->getParent() !== null) { |
|
198 | 198 | /** @var JobQueue $parentJob */ |
199 | 199 | $parentJob = JobQueue::getById($this->job->getParent(), $this->getDatabase()); |
200 | 200 | |
201 | - if($parentJob === false) { |
|
201 | + if ($parentJob === false) { |
|
202 | 202 | $this->markFailed("Parent job could not be found"); |
203 | 203 | return; |
204 | 204 | } |
@@ -25,48 +25,48 @@ |
||
25 | 25 | |
26 | 26 | trait NavigationMenuAccessControl |
27 | 27 | { |
28 | - protected abstract function assign($name, $value); |
|
28 | + protected abstract function assign($name, $value); |
|
29 | 29 | |
30 | - /** |
|
31 | - * @return SecurityManager |
|
32 | - */ |
|
33 | - protected abstract function getSecurityManager(); |
|
30 | + /** |
|
31 | + * @return SecurityManager |
|
32 | + */ |
|
33 | + protected abstract function getSecurityManager(); |
|
34 | 34 | |
35 | - /** |
|
36 | - * @param $currentUser |
|
37 | - */ |
|
38 | - protected function setupNavMenuAccess($currentUser) |
|
39 | - { |
|
40 | - $this->assign('nav__canRequests', $this->getSecurityManager() |
|
41 | - ->allows(PageMain::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
35 | + /** |
|
36 | + * @param $currentUser |
|
37 | + */ |
|
38 | + protected function setupNavMenuAccess($currentUser) |
|
39 | + { |
|
40 | + $this->assign('nav__canRequests', $this->getSecurityManager() |
|
41 | + ->allows(PageMain::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
42 | 42 | |
43 | - $this->assign('nav__canLogs', $this->getSecurityManager() |
|
44 | - ->allows(PageLog::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
45 | - $this->assign('nav__canUsers', $this->getSecurityManager() |
|
46 | - ->allows(StatsUsers::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
47 | - $this->assign('nav__canSearch', $this->getSecurityManager() |
|
48 | - ->allows(PageSearch::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
49 | - $this->assign('nav__canStats', $this->getSecurityManager() |
|
50 | - ->allows(StatsMain::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
43 | + $this->assign('nav__canLogs', $this->getSecurityManager() |
|
44 | + ->allows(PageLog::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
45 | + $this->assign('nav__canUsers', $this->getSecurityManager() |
|
46 | + ->allows(StatsUsers::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
47 | + $this->assign('nav__canSearch', $this->getSecurityManager() |
|
48 | + ->allows(PageSearch::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
49 | + $this->assign('nav__canStats', $this->getSecurityManager() |
|
50 | + ->allows(StatsMain::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
51 | 51 | |
52 | - $this->assign('nav__canBan', $this->getSecurityManager() |
|
53 | - ->allows(PageBan::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
54 | - $this->assign('nav__canEmailMgmt', $this->getSecurityManager() |
|
55 | - ->allows(PageEmailManagement::class, RoleConfiguration::MAIN, |
|
56 | - $currentUser) === SecurityManager::ALLOWED); |
|
57 | - $this->assign('nav__canWelcomeMgmt', $this->getSecurityManager() |
|
58 | - ->allows(PageWelcomeTemplateManagement::class, RoleConfiguration::MAIN, |
|
59 | - $currentUser) === SecurityManager::ALLOWED); |
|
60 | - $this->assign('nav__canSiteNoticeMgmt', $this->getSecurityManager() |
|
61 | - ->allows(PageSiteNotice::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
62 | - $this->assign('nav__canUserMgmt', $this->getSecurityManager() |
|
63 | - ->allows(PageUserManagement::class, RoleConfiguration::MAIN, |
|
64 | - $currentUser) === SecurityManager::ALLOWED); |
|
65 | - $this->assign('nav__canJobQueue', $this->getSecurityManager() |
|
66 | - ->allows(PageJobQueue::class, RoleConfiguration::MAIN, |
|
67 | - $currentUser) === SecurityManager::ALLOWED); |
|
52 | + $this->assign('nav__canBan', $this->getSecurityManager() |
|
53 | + ->allows(PageBan::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
54 | + $this->assign('nav__canEmailMgmt', $this->getSecurityManager() |
|
55 | + ->allows(PageEmailManagement::class, RoleConfiguration::MAIN, |
|
56 | + $currentUser) === SecurityManager::ALLOWED); |
|
57 | + $this->assign('nav__canWelcomeMgmt', $this->getSecurityManager() |
|
58 | + ->allows(PageWelcomeTemplateManagement::class, RoleConfiguration::MAIN, |
|
59 | + $currentUser) === SecurityManager::ALLOWED); |
|
60 | + $this->assign('nav__canSiteNoticeMgmt', $this->getSecurityManager() |
|
61 | + ->allows(PageSiteNotice::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
62 | + $this->assign('nav__canUserMgmt', $this->getSecurityManager() |
|
63 | + ->allows(PageUserManagement::class, RoleConfiguration::MAIN, |
|
64 | + $currentUser) === SecurityManager::ALLOWED); |
|
65 | + $this->assign('nav__canJobQueue', $this->getSecurityManager() |
|
66 | + ->allows(PageJobQueue::class, RoleConfiguration::MAIN, |
|
67 | + $currentUser) === SecurityManager::ALLOWED); |
|
68 | 68 | |
69 | - $this->assign('nav__canViewRequest', $this->getSecurityManager() |
|
70 | - ->allows(PageViewRequest::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
71 | - } |
|
69 | + $this->assign('nav__canViewRequest', $this->getSecurityManager() |
|
70 | + ->allows(PageViewRequest::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
71 | + } |
|
72 | 72 | } |
73 | 73 | \ No newline at end of file |
@@ -17,9 +17,9 @@ |
||
17 | 17 | */ |
18 | 18 | class OAuthRequestRouter extends RequestRouter |
19 | 19 | { |
20 | - protected function getRouteFromPath($pathInfo) |
|
21 | - { |
|
22 | - // Hardcode the route for this entry point |
|
23 | - return array(PageOAuthCallback::class, 'authorise'); |
|
24 | - } |
|
20 | + protected function getRouteFromPath($pathInfo) |
|
21 | + { |
|
22 | + // Hardcode the route for this entry point |
|
23 | + return array(PageOAuthCallback::class, 'authorise'); |
|
24 | + } |
|
25 | 25 | } |
26 | 26 | \ No newline at end of file |
@@ -102,7 +102,7 @@ |
||
102 | 102 | $formParameters['limit'] = $this->limit; |
103 | 103 | $this->assign('searchParamsUrl', http_build_query($formParameters, '', '&')); |
104 | 104 | |
105 | - foreach ($formParameters as $key => $value) { |
|
105 | + foreach ($formParameters as $key => $value) { |
|
106 | 106 | $this->assign($key, $value); |
107 | 107 | } |
108 | 108 | } |
@@ -102,7 +102,7 @@ |
||
102 | 102 | $formParameters['limit'] = $this->limit; |
103 | 103 | $this->assign('searchParamsUrl', http_build_query($formParameters, '', '&')); |
104 | 104 | |
105 | - foreach ($formParameters as $key => $value) { |
|
105 | + foreach ($formParameters as $key => $value) { |
|
106 | 106 | $this->assign($key, $value); |
107 | 107 | } |
108 | 108 | } |
@@ -13,97 +13,97 @@ |
||
13 | 13 | |
14 | 14 | abstract class PagedInternalPageBase extends InternalPageBase |
15 | 15 | { |
16 | - /** @var SearchHelperBase */ |
|
17 | - private $searchHelper; |
|
18 | - private $page; |
|
19 | - private $limit; |
|
20 | - |
|
21 | - /** |
|
22 | - * Sets up the pager with the current page, current limit, and total number of records. |
|
23 | - * |
|
24 | - * @param int $count |
|
25 | - * @param array $formParameters |
|
26 | - */ |
|
27 | - protected function setupPageData($count, $formParameters) |
|
28 | - { |
|
29 | - $page = $this->page; |
|
30 | - $limit = $this->limit; |
|
31 | - |
|
32 | - // The number of pages on the pager to show. Must be odd |
|
33 | - $pageLimit = 9; |
|
34 | - |
|
35 | - $pageData = array( |
|
36 | - // Can the user go to the previous page? |
|
37 | - 'canprev' => $page != 1, |
|
38 | - // Can the user go to the next page? |
|
39 | - 'cannext' => ($page * $limit) < $count, |
|
40 | - // Maximum page number |
|
41 | - 'maxpage' => max(1, ceil($count / $limit)), |
|
42 | - // Limit to the number of pages to display |
|
43 | - 'pagelimit' => $pageLimit, |
|
44 | - ); |
|
45 | - |
|
46 | - // number of pages either side of the current to show |
|
47 | - $pageMargin = (($pageLimit - 1) / 2); |
|
48 | - |
|
49 | - // Calculate the number of pages either side to show - this is for situations like: |
|
50 | - // [1] [2] [[3]] [4] [5] [6] [7] [8] [9] - where you can't just use the page margin calculated |
|
51 | - $pageData['lowpage'] = max(1, $page - $pageMargin); |
|
52 | - $pageData['hipage'] = min($pageData['maxpage'], $page + $pageMargin); |
|
53 | - $pageCount = ($pageData['hipage'] - $pageData['lowpage']) + 1; |
|
54 | - |
|
55 | - if ($pageCount < $pageLimit) { |
|
56 | - if ($pageData['lowpage'] == 1 && $pageData['hipage'] < $pageData['maxpage']) { |
|
57 | - $pageData['hipage'] = min($pageLimit, $pageData['maxpage']); |
|
58 | - } |
|
59 | - elseif ($pageData['lowpage'] > 1 && $pageData['hipage'] == $pageData['maxpage']) { |
|
60 | - $pageData['lowpage'] = max(1, $pageData['maxpage'] - $pageLimit + 1); |
|
61 | - } |
|
62 | - } |
|
63 | - |
|
64 | - // Put the range of pages into the page data |
|
65 | - $pageData['pages'] = range($pageData['lowpage'], $pageData['hipage']); |
|
66 | - |
|
67 | - $this->assign("pagedata", $pageData); |
|
68 | - |
|
69 | - $this->assign("limit", $limit); |
|
70 | - $this->assign("page", $page); |
|
71 | - |
|
72 | - $this->setupFormParameters($formParameters); |
|
73 | - } |
|
74 | - |
|
75 | - protected function setSearchHelper(SearchHelperBase $searchHelper) |
|
76 | - { |
|
77 | - $this->searchHelper = $searchHelper; |
|
78 | - } |
|
79 | - |
|
80 | - protected function setupLimits() |
|
81 | - { |
|
82 | - $limit = WebRequest::getInt('limit'); |
|
83 | - if ($limit === null) { |
|
84 | - $limit = 100; |
|
85 | - } |
|
86 | - |
|
87 | - $page = WebRequest::getInt('page'); |
|
88 | - if ($page === null) { |
|
89 | - $page = 1; |
|
90 | - } |
|
91 | - |
|
92 | - $offset = ($page - 1) * $limit; |
|
93 | - |
|
94 | - $this->searchHelper->limit($limit, $offset); |
|
95 | - |
|
96 | - $this->page = $page; |
|
97 | - $this->limit = $limit; |
|
98 | - } |
|
99 | - |
|
100 | - private function setupFormParameters($formParameters) |
|
101 | - { |
|
102 | - $formParameters['limit'] = $this->limit; |
|
103 | - $this->assign('searchParamsUrl', http_build_query($formParameters, '', '&')); |
|
104 | - |
|
105 | - foreach ($formParameters as $key => $value) { |
|
106 | - $this->assign($key, $value); |
|
107 | - } |
|
108 | - } |
|
16 | + /** @var SearchHelperBase */ |
|
17 | + private $searchHelper; |
|
18 | + private $page; |
|
19 | + private $limit; |
|
20 | + |
|
21 | + /** |
|
22 | + * Sets up the pager with the current page, current limit, and total number of records. |
|
23 | + * |
|
24 | + * @param int $count |
|
25 | + * @param array $formParameters |
|
26 | + */ |
|
27 | + protected function setupPageData($count, $formParameters) |
|
28 | + { |
|
29 | + $page = $this->page; |
|
30 | + $limit = $this->limit; |
|
31 | + |
|
32 | + // The number of pages on the pager to show. Must be odd |
|
33 | + $pageLimit = 9; |
|
34 | + |
|
35 | + $pageData = array( |
|
36 | + // Can the user go to the previous page? |
|
37 | + 'canprev' => $page != 1, |
|
38 | + // Can the user go to the next page? |
|
39 | + 'cannext' => ($page * $limit) < $count, |
|
40 | + // Maximum page number |
|
41 | + 'maxpage' => max(1, ceil($count / $limit)), |
|
42 | + // Limit to the number of pages to display |
|
43 | + 'pagelimit' => $pageLimit, |
|
44 | + ); |
|
45 | + |
|
46 | + // number of pages either side of the current to show |
|
47 | + $pageMargin = (($pageLimit - 1) / 2); |
|
48 | + |
|
49 | + // Calculate the number of pages either side to show - this is for situations like: |
|
50 | + // [1] [2] [[3]] [4] [5] [6] [7] [8] [9] - where you can't just use the page margin calculated |
|
51 | + $pageData['lowpage'] = max(1, $page - $pageMargin); |
|
52 | + $pageData['hipage'] = min($pageData['maxpage'], $page + $pageMargin); |
|
53 | + $pageCount = ($pageData['hipage'] - $pageData['lowpage']) + 1; |
|
54 | + |
|
55 | + if ($pageCount < $pageLimit) { |
|
56 | + if ($pageData['lowpage'] == 1 && $pageData['hipage'] < $pageData['maxpage']) { |
|
57 | + $pageData['hipage'] = min($pageLimit, $pageData['maxpage']); |
|
58 | + } |
|
59 | + elseif ($pageData['lowpage'] > 1 && $pageData['hipage'] == $pageData['maxpage']) { |
|
60 | + $pageData['lowpage'] = max(1, $pageData['maxpage'] - $pageLimit + 1); |
|
61 | + } |
|
62 | + } |
|
63 | + |
|
64 | + // Put the range of pages into the page data |
|
65 | + $pageData['pages'] = range($pageData['lowpage'], $pageData['hipage']); |
|
66 | + |
|
67 | + $this->assign("pagedata", $pageData); |
|
68 | + |
|
69 | + $this->assign("limit", $limit); |
|
70 | + $this->assign("page", $page); |
|
71 | + |
|
72 | + $this->setupFormParameters($formParameters); |
|
73 | + } |
|
74 | + |
|
75 | + protected function setSearchHelper(SearchHelperBase $searchHelper) |
|
76 | + { |
|
77 | + $this->searchHelper = $searchHelper; |
|
78 | + } |
|
79 | + |
|
80 | + protected function setupLimits() |
|
81 | + { |
|
82 | + $limit = WebRequest::getInt('limit'); |
|
83 | + if ($limit === null) { |
|
84 | + $limit = 100; |
|
85 | + } |
|
86 | + |
|
87 | + $page = WebRequest::getInt('page'); |
|
88 | + if ($page === null) { |
|
89 | + $page = 1; |
|
90 | + } |
|
91 | + |
|
92 | + $offset = ($page - 1) * $limit; |
|
93 | + |
|
94 | + $this->searchHelper->limit($limit, $offset); |
|
95 | + |
|
96 | + $this->page = $page; |
|
97 | + $this->limit = $limit; |
|
98 | + } |
|
99 | + |
|
100 | + private function setupFormParameters($formParameters) |
|
101 | + { |
|
102 | + $formParameters['limit'] = $this->limit; |
|
103 | + $this->assign('searchParamsUrl', http_build_query($formParameters, '', '&')); |
|
104 | + |
|
105 | + foreach ($formParameters as $key => $value) { |
|
106 | + $this->assign($key, $value); |
|
107 | + } |
|
108 | + } |
|
109 | 109 | } |
@@ -23,149 +23,149 @@ |
||
23 | 23 | |
24 | 24 | interface ITask |
25 | 25 | { |
26 | - /** |
|
27 | - * @return IEmailHelper |
|
28 | - */ |
|
29 | - public function getEmailHelper(); |
|
30 | - |
|
31 | - /** |
|
32 | - * @param IEmailHelper $emailHelper |
|
33 | - * |
|
34 | - * @return void |
|
35 | - */ |
|
36 | - public function setEmailHelper($emailHelper); |
|
37 | - |
|
38 | - /** |
|
39 | - * @return HttpHelper |
|
40 | - */ |
|
41 | - public function getHttpHelper(); |
|
42 | - |
|
43 | - /** |
|
44 | - * @param HttpHelper $httpHelper |
|
45 | - * |
|
46 | - * @return void |
|
47 | - */ |
|
48 | - public function setHttpHelper($httpHelper); |
|
49 | - |
|
50 | - /** |
|
51 | - * @return WikiTextHelper |
|
52 | - */ |
|
53 | - public function getWikiTextHelper(); |
|
54 | - |
|
55 | - /** |
|
56 | - * @param WikiTextHelper $wikiTextHelper |
|
57 | - * |
|
58 | - * @return void |
|
59 | - */ |
|
60 | - public function setWikiTextHelper($wikiTextHelper); |
|
61 | - |
|
62 | - /** |
|
63 | - * @return ILocationProvider |
|
64 | - */ |
|
65 | - public function getLocationProvider(); |
|
66 | - |
|
67 | - /** |
|
68 | - * @param ILocationProvider $locationProvider |
|
69 | - * |
|
70 | - * @return void |
|
71 | - */ |
|
72 | - public function setLocationProvider(ILocationProvider $locationProvider); |
|
73 | - |
|
74 | - /** |
|
75 | - * @return IXffTrustProvider |
|
76 | - */ |
|
77 | - public function getXffTrustProvider(); |
|
78 | - |
|
79 | - /** |
|
80 | - * @param IXffTrustProvider $xffTrustProvider |
|
81 | - * |
|
82 | - * @return void |
|
83 | - */ |
|
84 | - public function setXffTrustProvider(IXffTrustProvider $xffTrustProvider); |
|
85 | - |
|
86 | - /** |
|
87 | - * @return IRDnsProvider |
|
88 | - */ |
|
89 | - public function getRdnsProvider(); |
|
90 | - |
|
91 | - /** |
|
92 | - * @param IRDnsProvider $rdnsProvider |
|
93 | - * |
|
94 | - * @return void |
|
95 | - */ |
|
96 | - public function setRdnsProvider($rdnsProvider); |
|
97 | - |
|
98 | - /** |
|
99 | - * @return IAntiSpoofProvider |
|
100 | - */ |
|
101 | - public function getAntiSpoofProvider(); |
|
102 | - |
|
103 | - /** |
|
104 | - * @param IAntiSpoofProvider $antiSpoofProvider |
|
105 | - * |
|
106 | - * @return void |
|
107 | - */ |
|
108 | - public function setAntiSpoofProvider($antiSpoofProvider); |
|
109 | - |
|
110 | - /** |
|
111 | - * @return PdoDatabase |
|
112 | - */ |
|
113 | - public function getDatabase(); |
|
114 | - |
|
115 | - /** |
|
116 | - * @param PdoDatabase $database |
|
117 | - * |
|
118 | - * @return void |
|
119 | - */ |
|
120 | - public function setDatabase($database); |
|
121 | - |
|
122 | - /** |
|
123 | - * @return IOAuthProtocolHelper |
|
124 | - */ |
|
125 | - public function getOAuthProtocolHelper(); |
|
126 | - |
|
127 | - /** |
|
128 | - * @param IOAuthProtocolHelper $oauthProtocolHelper |
|
129 | - * |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - public function setOAuthProtocolHelper($oauthProtocolHelper); |
|
133 | - |
|
134 | - /** |
|
135 | - * @return void |
|
136 | - */ |
|
137 | - public function execute(); |
|
138 | - |
|
139 | - /** |
|
140 | - * Sets the site configuration object for this page |
|
141 | - * |
|
142 | - * @param SiteConfiguration $configuration |
|
143 | - * |
|
144 | - * @return void |
|
145 | - */ |
|
146 | - public function setSiteConfiguration($configuration); |
|
147 | - |
|
148 | - /** |
|
149 | - * @return IrcNotificationHelper |
|
150 | - */ |
|
151 | - public function getNotificationHelper(); |
|
152 | - |
|
153 | - /** |
|
154 | - * @param IrcNotificationHelper $notificationHelper |
|
155 | - * |
|
156 | - * @return void |
|
157 | - */ |
|
158 | - public function setNotificationHelper($notificationHelper); |
|
159 | - |
|
160 | - /** |
|
161 | - * @return TorExitProvider |
|
162 | - */ |
|
163 | - public function getTorExitProvider(); |
|
164 | - |
|
165 | - /** |
|
166 | - * @param TorExitProvider $torExitProvider |
|
167 | - * |
|
168 | - * @return void |
|
169 | - */ |
|
170 | - public function setTorExitProvider($torExitProvider); |
|
26 | + /** |
|
27 | + * @return IEmailHelper |
|
28 | + */ |
|
29 | + public function getEmailHelper(); |
|
30 | + |
|
31 | + /** |
|
32 | + * @param IEmailHelper $emailHelper |
|
33 | + * |
|
34 | + * @return void |
|
35 | + */ |
|
36 | + public function setEmailHelper($emailHelper); |
|
37 | + |
|
38 | + /** |
|
39 | + * @return HttpHelper |
|
40 | + */ |
|
41 | + public function getHttpHelper(); |
|
42 | + |
|
43 | + /** |
|
44 | + * @param HttpHelper $httpHelper |
|
45 | + * |
|
46 | + * @return void |
|
47 | + */ |
|
48 | + public function setHttpHelper($httpHelper); |
|
49 | + |
|
50 | + /** |
|
51 | + * @return WikiTextHelper |
|
52 | + */ |
|
53 | + public function getWikiTextHelper(); |
|
54 | + |
|
55 | + /** |
|
56 | + * @param WikiTextHelper $wikiTextHelper |
|
57 | + * |
|
58 | + * @return void |
|
59 | + */ |
|
60 | + public function setWikiTextHelper($wikiTextHelper); |
|
61 | + |
|
62 | + /** |
|
63 | + * @return ILocationProvider |
|
64 | + */ |
|
65 | + public function getLocationProvider(); |
|
66 | + |
|
67 | + /** |
|
68 | + * @param ILocationProvider $locationProvider |
|
69 | + * |
|
70 | + * @return void |
|
71 | + */ |
|
72 | + public function setLocationProvider(ILocationProvider $locationProvider); |
|
73 | + |
|
74 | + /** |
|
75 | + * @return IXffTrustProvider |
|
76 | + */ |
|
77 | + public function getXffTrustProvider(); |
|
78 | + |
|
79 | + /** |
|
80 | + * @param IXffTrustProvider $xffTrustProvider |
|
81 | + * |
|
82 | + * @return void |
|
83 | + */ |
|
84 | + public function setXffTrustProvider(IXffTrustProvider $xffTrustProvider); |
|
85 | + |
|
86 | + /** |
|
87 | + * @return IRDnsProvider |
|
88 | + */ |
|
89 | + public function getRdnsProvider(); |
|
90 | + |
|
91 | + /** |
|
92 | + * @param IRDnsProvider $rdnsProvider |
|
93 | + * |
|
94 | + * @return void |
|
95 | + */ |
|
96 | + public function setRdnsProvider($rdnsProvider); |
|
97 | + |
|
98 | + /** |
|
99 | + * @return IAntiSpoofProvider |
|
100 | + */ |
|
101 | + public function getAntiSpoofProvider(); |
|
102 | + |
|
103 | + /** |
|
104 | + * @param IAntiSpoofProvider $antiSpoofProvider |
|
105 | + * |
|
106 | + * @return void |
|
107 | + */ |
|
108 | + public function setAntiSpoofProvider($antiSpoofProvider); |
|
109 | + |
|
110 | + /** |
|
111 | + * @return PdoDatabase |
|
112 | + */ |
|
113 | + public function getDatabase(); |
|
114 | + |
|
115 | + /** |
|
116 | + * @param PdoDatabase $database |
|
117 | + * |
|
118 | + * @return void |
|
119 | + */ |
|
120 | + public function setDatabase($database); |
|
121 | + |
|
122 | + /** |
|
123 | + * @return IOAuthProtocolHelper |
|
124 | + */ |
|
125 | + public function getOAuthProtocolHelper(); |
|
126 | + |
|
127 | + /** |
|
128 | + * @param IOAuthProtocolHelper $oauthProtocolHelper |
|
129 | + * |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + public function setOAuthProtocolHelper($oauthProtocolHelper); |
|
133 | + |
|
134 | + /** |
|
135 | + * @return void |
|
136 | + */ |
|
137 | + public function execute(); |
|
138 | + |
|
139 | + /** |
|
140 | + * Sets the site configuration object for this page |
|
141 | + * |
|
142 | + * @param SiteConfiguration $configuration |
|
143 | + * |
|
144 | + * @return void |
|
145 | + */ |
|
146 | + public function setSiteConfiguration($configuration); |
|
147 | + |
|
148 | + /** |
|
149 | + * @return IrcNotificationHelper |
|
150 | + */ |
|
151 | + public function getNotificationHelper(); |
|
152 | + |
|
153 | + /** |
|
154 | + * @param IrcNotificationHelper $notificationHelper |
|
155 | + * |
|
156 | + * @return void |
|
157 | + */ |
|
158 | + public function setNotificationHelper($notificationHelper); |
|
159 | + |
|
160 | + /** |
|
161 | + * @return TorExitProvider |
|
162 | + */ |
|
163 | + public function getTorExitProvider(); |
|
164 | + |
|
165 | + /** |
|
166 | + * @param TorExitProvider $torExitProvider |
|
167 | + * |
|
168 | + * @return void |
|
169 | + */ |
|
170 | + public function setTorExitProvider($torExitProvider); |
|
171 | 171 | } |
172 | 172 | \ No newline at end of file |