@@ -17,62 +17,62 @@ |
||
17 | 17 | |
18 | 18 | class PageLog extends PagedInternalPageBase |
19 | 19 | { |
20 | - /** |
|
21 | - * Main function for this page, when no specific actions are called. |
|
22 | - */ |
|
23 | - protected function main() |
|
24 | - { |
|
25 | - $this->setHtmlTitle('Logs'); |
|
26 | - |
|
27 | - $filterUser = WebRequest::getString('filterUser'); |
|
28 | - $filterAction = WebRequest::getString('filterAction'); |
|
29 | - $filterObjectType = WebRequest::getString('filterObjectType'); |
|
30 | - $filterObjectId = WebRequest::getInt('filterObjectId'); |
|
31 | - |
|
32 | - $database = $this->getDatabase(); |
|
33 | - |
|
34 | - if (!array_key_exists($filterObjectType, LogHelper::getObjectTypes())) { |
|
35 | - $filterObjectType = null; |
|
36 | - } |
|
37 | - |
|
38 | - $this->addJs("/api.php?action=users&all=true&targetVariable=typeaheaddata"); |
|
39 | - |
|
40 | - $logSearch = LogSearchHelper::get($database); |
|
41 | - |
|
42 | - if ($filterUser !== null) { |
|
43 | - $userObj = User::getByUsername($filterUser, $database); |
|
44 | - if ($userObj !== false) { |
|
45 | - $logSearch->byUser($userObj->getId()); |
|
46 | - } else { |
|
47 | - $logSearch->byUser(-1); |
|
48 | - } |
|
49 | - } |
|
50 | - if ($filterAction !== null) { |
|
51 | - $logSearch->byAction($filterAction); |
|
52 | - } |
|
53 | - if ($filterObjectType !== null) { |
|
54 | - $logSearch->byObjectType($filterObjectType); |
|
55 | - } |
|
56 | - if ($filterObjectId !== null) { |
|
57 | - $logSearch->byObjectId($filterObjectId); |
|
58 | - } |
|
59 | - |
|
60 | - $this->setSearchHelper($logSearch); |
|
61 | - $this->setupLimits(); |
|
62 | - |
|
63 | - /** @var Log[] $logs */ |
|
64 | - $logs = $logSearch->getRecordCount($count)->fetch(); |
|
65 | - |
|
66 | - list($users, $logData) = LogHelper::prepareLogsForTemplate($logs, $database, $this->getSiteConfiguration()); |
|
67 | - |
|
68 | - $this->setupPageData($count, array('filterUser' => $filterUser, 'filterAction' => $filterAction, 'filterObjectType' => $filterObjectType, 'filterObjectId' => $filterObjectId)); |
|
69 | - |
|
70 | - $this->assign("logs", $logData); |
|
71 | - $this->assign("users", $users); |
|
72 | - |
|
73 | - $this->assign('allLogActions', LogHelper::getLogActions($this->getDatabase())); |
|
74 | - $this->assign('allObjectTypes', LogHelper::getObjectTypes()); |
|
75 | - |
|
76 | - $this->setTemplate("logs/main.tpl"); |
|
77 | - } |
|
20 | + /** |
|
21 | + * Main function for this page, when no specific actions are called. |
|
22 | + */ |
|
23 | + protected function main() |
|
24 | + { |
|
25 | + $this->setHtmlTitle('Logs'); |
|
26 | + |
|
27 | + $filterUser = WebRequest::getString('filterUser'); |
|
28 | + $filterAction = WebRequest::getString('filterAction'); |
|
29 | + $filterObjectType = WebRequest::getString('filterObjectType'); |
|
30 | + $filterObjectId = WebRequest::getInt('filterObjectId'); |
|
31 | + |
|
32 | + $database = $this->getDatabase(); |
|
33 | + |
|
34 | + if (!array_key_exists($filterObjectType, LogHelper::getObjectTypes())) { |
|
35 | + $filterObjectType = null; |
|
36 | + } |
|
37 | + |
|
38 | + $this->addJs("/api.php?action=users&all=true&targetVariable=typeaheaddata"); |
|
39 | + |
|
40 | + $logSearch = LogSearchHelper::get($database); |
|
41 | + |
|
42 | + if ($filterUser !== null) { |
|
43 | + $userObj = User::getByUsername($filterUser, $database); |
|
44 | + if ($userObj !== false) { |
|
45 | + $logSearch->byUser($userObj->getId()); |
|
46 | + } else { |
|
47 | + $logSearch->byUser(-1); |
|
48 | + } |
|
49 | + } |
|
50 | + if ($filterAction !== null) { |
|
51 | + $logSearch->byAction($filterAction); |
|
52 | + } |
|
53 | + if ($filterObjectType !== null) { |
|
54 | + $logSearch->byObjectType($filterObjectType); |
|
55 | + } |
|
56 | + if ($filterObjectId !== null) { |
|
57 | + $logSearch->byObjectId($filterObjectId); |
|
58 | + } |
|
59 | + |
|
60 | + $this->setSearchHelper($logSearch); |
|
61 | + $this->setupLimits(); |
|
62 | + |
|
63 | + /** @var Log[] $logs */ |
|
64 | + $logs = $logSearch->getRecordCount($count)->fetch(); |
|
65 | + |
|
66 | + list($users, $logData) = LogHelper::prepareLogsForTemplate($logs, $database, $this->getSiteConfiguration()); |
|
67 | + |
|
68 | + $this->setupPageData($count, array('filterUser' => $filterUser, 'filterAction' => $filterAction, 'filterObjectType' => $filterObjectType, 'filterObjectId' => $filterObjectId)); |
|
69 | + |
|
70 | + $this->assign("logs", $logData); |
|
71 | + $this->assign("users", $users); |
|
72 | + |
|
73 | + $this->assign('allLogActions', LogHelper::getLogActions($this->getDatabase())); |
|
74 | + $this->assign('allObjectTypes', LogHelper::getObjectTypes()); |
|
75 | + |
|
76 | + $this->setTemplate("logs/main.tpl"); |
|
77 | + } |
|
78 | 78 | } |
@@ -12,18 +12,18 @@ |
||
12 | 12 | |
13 | 13 | class PageRegisterOption extends InternalPageBase |
14 | 14 | { |
15 | - /** |
|
16 | - * Main function for this page, when no specific actions are called. |
|
17 | - * @return void |
|
18 | - */ |
|
19 | - protected function main() |
|
20 | - { |
|
21 | - $this->assign('allowRegistration', $this->getSiteConfiguration()->isRegistrationAllowed()); |
|
22 | - $this->setTemplate('registration/option.tpl'); |
|
23 | - } |
|
15 | + /** |
|
16 | + * Main function for this page, when no specific actions are called. |
|
17 | + * @return void |
|
18 | + */ |
|
19 | + protected function main() |
|
20 | + { |
|
21 | + $this->assign('allowRegistration', $this->getSiteConfiguration()->isRegistrationAllowed()); |
|
22 | + $this->setTemplate('registration/option.tpl'); |
|
23 | + } |
|
24 | 24 | |
25 | - protected function isProtectedPage() |
|
26 | - { |
|
27 | - return false; |
|
28 | - } |
|
25 | + protected function isProtectedPage() |
|
26 | + { |
|
27 | + return false; |
|
28 | + } |
|
29 | 29 | } |
@@ -22,222 +22,222 @@ |
||
22 | 22 | |
23 | 23 | abstract class PageRegisterBase extends InternalPageBase |
24 | 24 | { |
25 | - /** |
|
26 | - * Main function for this page, when no specific actions are called. |
|
27 | - * @throws AccessDeniedException |
|
28 | - * @throws ApplicationLogicException |
|
29 | - * @throws Exception |
|
30 | - */ |
|
31 | - protected function main() |
|
32 | - { |
|
33 | - $useOAuthSignup = $this->getSiteConfiguration()->getUseOAuthSignup(); |
|
34 | - if (! $this->getSiteConfiguration()->isRegistrationAllowed()) { |
|
35 | - throw new AccessDeniedException(); |
|
36 | - } |
|
37 | - |
|
38 | - // Dual-mode page |
|
39 | - if (WebRequest::wasPosted()) { |
|
40 | - $this->validateCSRFToken(); |
|
41 | - |
|
42 | - try { |
|
43 | - $this->handlePost($useOAuthSignup); |
|
44 | - } |
|
45 | - catch (ApplicationLogicException $ex) { |
|
46 | - SessionAlert::error($ex->getMessage()); |
|
47 | - |
|
48 | - $this->getDatabase()->rollBack(); |
|
49 | - |
|
50 | - $this->assignCSRFToken(); |
|
51 | - $this->assign("useOAuthSignup", $useOAuthSignup); |
|
52 | - $this->applyErrorValues(); |
|
53 | - $this->setTemplate($this->getRegistrationTemplate()); |
|
54 | - $this->addJs("/vendor/dropbox/zxcvbn/dist/zxcvbn.js"); |
|
55 | - } |
|
56 | - } |
|
57 | - else { |
|
58 | - $this->assignCSRFToken(); |
|
59 | - $this->assign("useOAuthSignup", $useOAuthSignup); |
|
60 | - $this->setTemplate($this->getRegistrationTemplate()); |
|
61 | - $this->addJs("/vendor/dropbox/zxcvbn/dist/zxcvbn.js"); |
|
62 | - } |
|
63 | - } |
|
64 | - |
|
65 | - protected abstract function getRegistrationTemplate(); |
|
66 | - |
|
67 | - protected function isProtectedPage() |
|
68 | - { |
|
69 | - return false; |
|
70 | - } |
|
71 | - |
|
72 | - /** |
|
73 | - * @param string $emailAddress |
|
74 | - * |
|
75 | - * @throws ApplicationLogicException |
|
76 | - */ |
|
77 | - protected function validateUniqueEmail($emailAddress) |
|
78 | - { |
|
79 | - $query = 'SELECT COUNT(id) FROM user WHERE email = :email'; |
|
80 | - $statement = $this->getDatabase()->prepare($query); |
|
81 | - $statement->execute(array(':email' => $emailAddress)); |
|
82 | - |
|
83 | - if ($statement->fetchColumn() > 0) { |
|
84 | - throw new ApplicationLogicException('That email address is already in use on this system.'); |
|
85 | - } |
|
86 | - |
|
87 | - $statement->closeCursor(); |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * @param $emailAddress |
|
92 | - * @param $password |
|
93 | - * @param $username |
|
94 | - * @param $useOAuthSignup |
|
95 | - * @param $confirmationId |
|
96 | - * @param $onwikiUsername |
|
97 | - * |
|
98 | - * @throws ApplicationLogicException |
|
99 | - */ |
|
100 | - protected function validateRequest( |
|
101 | - $emailAddress, |
|
102 | - $password, |
|
103 | - $username, |
|
104 | - $useOAuthSignup, |
|
105 | - $confirmationId, |
|
106 | - $onwikiUsername |
|
107 | - ) { |
|
108 | - if (!WebRequest::postBoolean('guidelines')) { |
|
109 | - throw new ApplicationLogicException('You must read the interface guidelines before your request may be submitted.'); |
|
110 | - } |
|
111 | - |
|
112 | - $this->validateGeneralInformation($emailAddress, $password, $username); |
|
113 | - $this->validateUniqueEmail($emailAddress); |
|
114 | - $this->validateNonOAuthFields($useOAuthSignup, $confirmationId, $onwikiUsername); |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * @param $useOAuthSignup |
|
119 | - * @param $confirmationId |
|
120 | - * @param $onwikiUsername |
|
121 | - * |
|
122 | - * @throws ApplicationLogicException |
|
123 | - */ |
|
124 | - protected function validateNonOAuthFields($useOAuthSignup, $confirmationId, $onwikiUsername) |
|
125 | - { |
|
126 | - if (!$useOAuthSignup) { |
|
127 | - if ($confirmationId === null || $confirmationId <= 0) { |
|
128 | - throw new ApplicationLogicException('Please enter the revision id of your confirmation edit.'); |
|
129 | - } |
|
130 | - |
|
131 | - if ($onwikiUsername === null) { |
|
132 | - throw new ApplicationLogicException('Please specify your on-wiki username.'); |
|
133 | - } |
|
134 | - } |
|
135 | - } |
|
136 | - |
|
137 | - /** |
|
138 | - * @param $emailAddress |
|
139 | - * @param $password |
|
140 | - * @param $username |
|
141 | - * |
|
142 | - * @throws ApplicationLogicException |
|
143 | - */ |
|
144 | - protected function validateGeneralInformation($emailAddress, $password, $username) |
|
145 | - { |
|
146 | - if ($emailAddress === null) { |
|
147 | - throw new ApplicationLogicException('Your email address appears to be invalid!'); |
|
148 | - } |
|
149 | - |
|
150 | - if ($password !== WebRequest::postString('pass2')) { |
|
151 | - throw new ApplicationLogicException('Your passwords did not match, please try again.'); |
|
152 | - } |
|
153 | - |
|
154 | - if (User::getByUsername($username, $this->getDatabase()) !== false) { |
|
155 | - throw new ApplicationLogicException('That username is already in use on this system.'); |
|
156 | - } |
|
157 | - } |
|
158 | - |
|
159 | - /** |
|
160 | - * @param $useOAuthSignup |
|
161 | - * |
|
162 | - * @throws ApplicationLogicException |
|
163 | - * @throws Exception |
|
164 | - */ |
|
165 | - protected function handlePost($useOAuthSignup) |
|
166 | - { |
|
167 | - // Get the data |
|
168 | - $emailAddress = WebRequest::postEmail('email'); |
|
169 | - $password = WebRequest::postString('pass'); |
|
170 | - $username = WebRequest::postString('name'); |
|
171 | - |
|
172 | - // Only set if OAuth is disabled |
|
173 | - $confirmationId = WebRequest::postInt('conf_revid'); |
|
174 | - $onwikiUsername = WebRequest::postString('wname'); |
|
175 | - |
|
176 | - // Do some validation |
|
177 | - $this->validateRequest($emailAddress, $password, $username, $useOAuthSignup, $confirmationId, |
|
178 | - $onwikiUsername); |
|
179 | - |
|
180 | - $database = $this->getDatabase(); |
|
181 | - |
|
182 | - $user = new User(); |
|
183 | - $user->setDatabase($database); |
|
184 | - |
|
185 | - $user->setUsername($username); |
|
186 | - $user->setEmail($emailAddress); |
|
187 | - |
|
188 | - if (!$useOAuthSignup) { |
|
189 | - $user->setOnWikiName($onwikiUsername); |
|
190 | - $user->setConfirmationDiff($confirmationId); |
|
191 | - } |
|
192 | - |
|
193 | - $user->save(); |
|
194 | - |
|
195 | - $passwordCredentialProvider = new PasswordCredentialProvider($database, $this->getSiteConfiguration()); |
|
196 | - $passwordCredentialProvider->setCredential($user, 1, $password); |
|
197 | - |
|
198 | - $defaultRole = $this->getDefaultRole(); |
|
199 | - |
|
200 | - $role = new UserRole(); |
|
201 | - $role->setDatabase($database); |
|
202 | - $role->setUser($user->getId()); |
|
203 | - $role->setRole($defaultRole); |
|
204 | - $role->save(); |
|
205 | - |
|
206 | - // Log now to get the signup date. |
|
207 | - Logger::newUser($database, $user); |
|
208 | - Logger::userRolesEdited($database, $user, 'Registration', array($defaultRole), array()); |
|
209 | - |
|
210 | - if ($useOAuthSignup) { |
|
211 | - $oauthProtocolHelper = $this->getOAuthProtocolHelper(); |
|
212 | - $oauth = new OAuthUserHelper($user, $database, $oauthProtocolHelper, $this->getSiteConfiguration()); |
|
213 | - |
|
214 | - $authoriseUrl = $oauth->getRequestToken(); |
|
215 | - WebRequest::setOAuthPartialLogin($user); |
|
216 | - $this->redirectUrl($authoriseUrl); |
|
217 | - } |
|
218 | - else { |
|
219 | - // only notify if we're not using the oauth signup. |
|
220 | - $this->getNotificationHelper()->userNew($user); |
|
221 | - WebRequest::setLoggedInUser($user); |
|
222 | - $this->redirect('preferences'); |
|
223 | - } |
|
224 | - } |
|
225 | - |
|
226 | - protected abstract function getDefaultRole(); |
|
227 | - |
|
228 | - /** |
|
229 | - * Entry point for registration complete |
|
230 | - * @throws Exception |
|
231 | - */ |
|
232 | - protected function done() |
|
233 | - { |
|
234 | - $this->setTemplate('registration/alert-registrationcomplete.tpl'); |
|
235 | - } |
|
236 | - |
|
237 | - protected function applyErrorValues() |
|
238 | - { |
|
239 | - $this->assign('tplUsername', WebRequest::postString('name')); |
|
240 | - $this->assign('tplEmail', WebRequest::postString('email')); |
|
241 | - $this->assign('tplWikipediaUsername', WebRequest::postString('wname')); |
|
242 | - $this->assign('tplConfRevId', WebRequest::postInt('conf_revid')); |
|
243 | - }} |
|
25 | + /** |
|
26 | + * Main function for this page, when no specific actions are called. |
|
27 | + * @throws AccessDeniedException |
|
28 | + * @throws ApplicationLogicException |
|
29 | + * @throws Exception |
|
30 | + */ |
|
31 | + protected function main() |
|
32 | + { |
|
33 | + $useOAuthSignup = $this->getSiteConfiguration()->getUseOAuthSignup(); |
|
34 | + if (! $this->getSiteConfiguration()->isRegistrationAllowed()) { |
|
35 | + throw new AccessDeniedException(); |
|
36 | + } |
|
37 | + |
|
38 | + // Dual-mode page |
|
39 | + if (WebRequest::wasPosted()) { |
|
40 | + $this->validateCSRFToken(); |
|
41 | + |
|
42 | + try { |
|
43 | + $this->handlePost($useOAuthSignup); |
|
44 | + } |
|
45 | + catch (ApplicationLogicException $ex) { |
|
46 | + SessionAlert::error($ex->getMessage()); |
|
47 | + |
|
48 | + $this->getDatabase()->rollBack(); |
|
49 | + |
|
50 | + $this->assignCSRFToken(); |
|
51 | + $this->assign("useOAuthSignup", $useOAuthSignup); |
|
52 | + $this->applyErrorValues(); |
|
53 | + $this->setTemplate($this->getRegistrationTemplate()); |
|
54 | + $this->addJs("/vendor/dropbox/zxcvbn/dist/zxcvbn.js"); |
|
55 | + } |
|
56 | + } |
|
57 | + else { |
|
58 | + $this->assignCSRFToken(); |
|
59 | + $this->assign("useOAuthSignup", $useOAuthSignup); |
|
60 | + $this->setTemplate($this->getRegistrationTemplate()); |
|
61 | + $this->addJs("/vendor/dropbox/zxcvbn/dist/zxcvbn.js"); |
|
62 | + } |
|
63 | + } |
|
64 | + |
|
65 | + protected abstract function getRegistrationTemplate(); |
|
66 | + |
|
67 | + protected function isProtectedPage() |
|
68 | + { |
|
69 | + return false; |
|
70 | + } |
|
71 | + |
|
72 | + /** |
|
73 | + * @param string $emailAddress |
|
74 | + * |
|
75 | + * @throws ApplicationLogicException |
|
76 | + */ |
|
77 | + protected function validateUniqueEmail($emailAddress) |
|
78 | + { |
|
79 | + $query = 'SELECT COUNT(id) FROM user WHERE email = :email'; |
|
80 | + $statement = $this->getDatabase()->prepare($query); |
|
81 | + $statement->execute(array(':email' => $emailAddress)); |
|
82 | + |
|
83 | + if ($statement->fetchColumn() > 0) { |
|
84 | + throw new ApplicationLogicException('That email address is already in use on this system.'); |
|
85 | + } |
|
86 | + |
|
87 | + $statement->closeCursor(); |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * @param $emailAddress |
|
92 | + * @param $password |
|
93 | + * @param $username |
|
94 | + * @param $useOAuthSignup |
|
95 | + * @param $confirmationId |
|
96 | + * @param $onwikiUsername |
|
97 | + * |
|
98 | + * @throws ApplicationLogicException |
|
99 | + */ |
|
100 | + protected function validateRequest( |
|
101 | + $emailAddress, |
|
102 | + $password, |
|
103 | + $username, |
|
104 | + $useOAuthSignup, |
|
105 | + $confirmationId, |
|
106 | + $onwikiUsername |
|
107 | + ) { |
|
108 | + if (!WebRequest::postBoolean('guidelines')) { |
|
109 | + throw new ApplicationLogicException('You must read the interface guidelines before your request may be submitted.'); |
|
110 | + } |
|
111 | + |
|
112 | + $this->validateGeneralInformation($emailAddress, $password, $username); |
|
113 | + $this->validateUniqueEmail($emailAddress); |
|
114 | + $this->validateNonOAuthFields($useOAuthSignup, $confirmationId, $onwikiUsername); |
|
115 | + } |
|
116 | + |
|
117 | + /** |
|
118 | + * @param $useOAuthSignup |
|
119 | + * @param $confirmationId |
|
120 | + * @param $onwikiUsername |
|
121 | + * |
|
122 | + * @throws ApplicationLogicException |
|
123 | + */ |
|
124 | + protected function validateNonOAuthFields($useOAuthSignup, $confirmationId, $onwikiUsername) |
|
125 | + { |
|
126 | + if (!$useOAuthSignup) { |
|
127 | + if ($confirmationId === null || $confirmationId <= 0) { |
|
128 | + throw new ApplicationLogicException('Please enter the revision id of your confirmation edit.'); |
|
129 | + } |
|
130 | + |
|
131 | + if ($onwikiUsername === null) { |
|
132 | + throw new ApplicationLogicException('Please specify your on-wiki username.'); |
|
133 | + } |
|
134 | + } |
|
135 | + } |
|
136 | + |
|
137 | + /** |
|
138 | + * @param $emailAddress |
|
139 | + * @param $password |
|
140 | + * @param $username |
|
141 | + * |
|
142 | + * @throws ApplicationLogicException |
|
143 | + */ |
|
144 | + protected function validateGeneralInformation($emailAddress, $password, $username) |
|
145 | + { |
|
146 | + if ($emailAddress === null) { |
|
147 | + throw new ApplicationLogicException('Your email address appears to be invalid!'); |
|
148 | + } |
|
149 | + |
|
150 | + if ($password !== WebRequest::postString('pass2')) { |
|
151 | + throw new ApplicationLogicException('Your passwords did not match, please try again.'); |
|
152 | + } |
|
153 | + |
|
154 | + if (User::getByUsername($username, $this->getDatabase()) !== false) { |
|
155 | + throw new ApplicationLogicException('That username is already in use on this system.'); |
|
156 | + } |
|
157 | + } |
|
158 | + |
|
159 | + /** |
|
160 | + * @param $useOAuthSignup |
|
161 | + * |
|
162 | + * @throws ApplicationLogicException |
|
163 | + * @throws Exception |
|
164 | + */ |
|
165 | + protected function handlePost($useOAuthSignup) |
|
166 | + { |
|
167 | + // Get the data |
|
168 | + $emailAddress = WebRequest::postEmail('email'); |
|
169 | + $password = WebRequest::postString('pass'); |
|
170 | + $username = WebRequest::postString('name'); |
|
171 | + |
|
172 | + // Only set if OAuth is disabled |
|
173 | + $confirmationId = WebRequest::postInt('conf_revid'); |
|
174 | + $onwikiUsername = WebRequest::postString('wname'); |
|
175 | + |
|
176 | + // Do some validation |
|
177 | + $this->validateRequest($emailAddress, $password, $username, $useOAuthSignup, $confirmationId, |
|
178 | + $onwikiUsername); |
|
179 | + |
|
180 | + $database = $this->getDatabase(); |
|
181 | + |
|
182 | + $user = new User(); |
|
183 | + $user->setDatabase($database); |
|
184 | + |
|
185 | + $user->setUsername($username); |
|
186 | + $user->setEmail($emailAddress); |
|
187 | + |
|
188 | + if (!$useOAuthSignup) { |
|
189 | + $user->setOnWikiName($onwikiUsername); |
|
190 | + $user->setConfirmationDiff($confirmationId); |
|
191 | + } |
|
192 | + |
|
193 | + $user->save(); |
|
194 | + |
|
195 | + $passwordCredentialProvider = new PasswordCredentialProvider($database, $this->getSiteConfiguration()); |
|
196 | + $passwordCredentialProvider->setCredential($user, 1, $password); |
|
197 | + |
|
198 | + $defaultRole = $this->getDefaultRole(); |
|
199 | + |
|
200 | + $role = new UserRole(); |
|
201 | + $role->setDatabase($database); |
|
202 | + $role->setUser($user->getId()); |
|
203 | + $role->setRole($defaultRole); |
|
204 | + $role->save(); |
|
205 | + |
|
206 | + // Log now to get the signup date. |
|
207 | + Logger::newUser($database, $user); |
|
208 | + Logger::userRolesEdited($database, $user, 'Registration', array($defaultRole), array()); |
|
209 | + |
|
210 | + if ($useOAuthSignup) { |
|
211 | + $oauthProtocolHelper = $this->getOAuthProtocolHelper(); |
|
212 | + $oauth = new OAuthUserHelper($user, $database, $oauthProtocolHelper, $this->getSiteConfiguration()); |
|
213 | + |
|
214 | + $authoriseUrl = $oauth->getRequestToken(); |
|
215 | + WebRequest::setOAuthPartialLogin($user); |
|
216 | + $this->redirectUrl($authoriseUrl); |
|
217 | + } |
|
218 | + else { |
|
219 | + // only notify if we're not using the oauth signup. |
|
220 | + $this->getNotificationHelper()->userNew($user); |
|
221 | + WebRequest::setLoggedInUser($user); |
|
222 | + $this->redirect('preferences'); |
|
223 | + } |
|
224 | + } |
|
225 | + |
|
226 | + protected abstract function getDefaultRole(); |
|
227 | + |
|
228 | + /** |
|
229 | + * Entry point for registration complete |
|
230 | + * @throws Exception |
|
231 | + */ |
|
232 | + protected function done() |
|
233 | + { |
|
234 | + $this->setTemplate('registration/alert-registrationcomplete.tpl'); |
|
235 | + } |
|
236 | + |
|
237 | + protected function applyErrorValues() |
|
238 | + { |
|
239 | + $this->assign('tplUsername', WebRequest::postString('name')); |
|
240 | + $this->assign('tplEmail', WebRequest::postString('email')); |
|
241 | + $this->assign('tplWikipediaUsername', WebRequest::postString('wname')); |
|
242 | + $this->assign('tplConfRevId', WebRequest::postInt('conf_revid')); |
|
243 | + }} |
@@ -31,7 +31,7 @@ |
||
31 | 31 | protected function main() |
32 | 32 | { |
33 | 33 | $useOAuthSignup = $this->getSiteConfiguration()->getUseOAuthSignup(); |
34 | - if (! $this->getSiteConfiguration()->isRegistrationAllowed()) { |
|
34 | + if (!$this->getSiteConfiguration()->isRegistrationAllowed()) { |
|
35 | 35 | throw new AccessDeniedException(); |
36 | 36 | } |
37 | 37 |
@@ -53,8 +53,7 @@ discard block |
||
53 | 53 | $this->setTemplate($this->getRegistrationTemplate()); |
54 | 54 | $this->addJs("/vendor/dropbox/zxcvbn/dist/zxcvbn.js"); |
55 | 55 | } |
56 | - } |
|
57 | - else { |
|
56 | + } else { |
|
58 | 57 | $this->assignCSRFToken(); |
59 | 58 | $this->assign("useOAuthSignup", $useOAuthSignup); |
60 | 59 | $this->setTemplate($this->getRegistrationTemplate()); |
@@ -214,8 +213,7 @@ discard block |
||
214 | 213 | $authoriseUrl = $oauth->getRequestToken(); |
215 | 214 | WebRequest::setOAuthPartialLogin($user); |
216 | 215 | $this->redirectUrl($authoriseUrl); |
217 | - } |
|
218 | - else { |
|
216 | + } else { |
|
219 | 217 | // only notify if we're not using the oauth signup. |
220 | 218 | $this->getNotificationHelper()->userNew($user); |
221 | 219 | WebRequest::setLoggedInUser($user); |
@@ -26,241 +26,241 @@ |
||
26 | 26 | |
27 | 27 | class PageJobQueue extends PagedInternalPageBase |
28 | 28 | { |
29 | - /** |
|
30 | - * Main function for this page, when no specific actions are called. |
|
31 | - * @return void |
|
32 | - */ |
|
33 | - protected function main() |
|
34 | - { |
|
35 | - $this->setHtmlTitle('Job Queue Management'); |
|
29 | + /** |
|
30 | + * Main function for this page, when no specific actions are called. |
|
31 | + * @return void |
|
32 | + */ |
|
33 | + protected function main() |
|
34 | + { |
|
35 | + $this->setHtmlTitle('Job Queue Management'); |
|
36 | 36 | |
37 | - $this->prepareMaps(); |
|
37 | + $this->prepareMaps(); |
|
38 | 38 | |
39 | - $database = $this->getDatabase(); |
|
39 | + $database = $this->getDatabase(); |
|
40 | 40 | |
41 | - /** @var JobQueue[] $jobList */ |
|
42 | - $jobList = JobQueueSearchHelper::get($database) |
|
43 | - ->statusIn(array('ready', 'waiting', 'running', 'failed')) |
|
44 | - ->notAcknowledged() |
|
45 | - ->fetch(); |
|
41 | + /** @var JobQueue[] $jobList */ |
|
42 | + $jobList = JobQueueSearchHelper::get($database) |
|
43 | + ->statusIn(array('ready', 'waiting', 'running', 'failed')) |
|
44 | + ->notAcknowledged() |
|
45 | + ->fetch(); |
|
46 | 46 | |
47 | - $userIds = array(); |
|
48 | - $requestIds = array(); |
|
47 | + $userIds = array(); |
|
48 | + $requestIds = array(); |
|
49 | 49 | |
50 | - foreach ($jobList as $job) { |
|
51 | - $userIds[] = $job->getTriggerUserId(); |
|
52 | - $requestIds[] = $job->getRequest(); |
|
50 | + foreach ($jobList as $job) { |
|
51 | + $userIds[] = $job->getTriggerUserId(); |
|
52 | + $requestIds[] = $job->getRequest(); |
|
53 | 53 | |
54 | - $job->setDatabase($database); |
|
55 | - } |
|
54 | + $job->setDatabase($database); |
|
55 | + } |
|
56 | 56 | |
57 | - $this->assign('canSeeAll', $this->barrierTest('all', User::getCurrent($database))); |
|
57 | + $this->assign('canSeeAll', $this->barrierTest('all', User::getCurrent($database))); |
|
58 | 58 | |
59 | - $this->assign('users', UserSearchHelper::get($database)->inIds($userIds)->fetchMap('username')); |
|
60 | - $this->assign('requests', RequestSearchHelper::get($database)->inIds($requestIds)->fetchMap('name')); |
|
59 | + $this->assign('users', UserSearchHelper::get($database)->inIds($userIds)->fetchMap('username')); |
|
60 | + $this->assign('requests', RequestSearchHelper::get($database)->inIds($requestIds)->fetchMap('name')); |
|
61 | 61 | |
62 | - $this->assign('joblist', $jobList); |
|
63 | - $this->setTemplate('jobqueue/main.tpl'); |
|
64 | - } |
|
62 | + $this->assign('joblist', $jobList); |
|
63 | + $this->setTemplate('jobqueue/main.tpl'); |
|
64 | + } |
|
65 | 65 | |
66 | - protected function all() |
|
67 | - { |
|
68 | - $this->setHtmlTitle('All Jobs'); |
|
66 | + protected function all() |
|
67 | + { |
|
68 | + $this->setHtmlTitle('All Jobs'); |
|
69 | 69 | |
70 | - $this->prepareMaps(); |
|
70 | + $this->prepareMaps(); |
|
71 | 71 | |
72 | - $database = $this->getDatabase(); |
|
72 | + $database = $this->getDatabase(); |
|
73 | 73 | |
74 | - $searchHelper = JobQueueSearchHelper::get($database); |
|
75 | - $this->setSearchHelper($searchHelper); |
|
76 | - $this->setupLimits(); |
|
74 | + $searchHelper = JobQueueSearchHelper::get($database); |
|
75 | + $this->setSearchHelper($searchHelper); |
|
76 | + $this->setupLimits(); |
|
77 | 77 | |
78 | - $filterUser = WebRequest::getString('filterUser'); |
|
79 | - $filterTask = WebRequest::getString('filterTask'); |
|
80 | - $filterStatus = WebRequest::getString('filterStatus'); |
|
81 | - $filterRequest = WebRequest::getString('filterRequest'); |
|
78 | + $filterUser = WebRequest::getString('filterUser'); |
|
79 | + $filterTask = WebRequest::getString('filterTask'); |
|
80 | + $filterStatus = WebRequest::getString('filterStatus'); |
|
81 | + $filterRequest = WebRequest::getString('filterRequest'); |
|
82 | 82 | |
83 | - if ($filterUser !== null) { |
|
84 | - $searchHelper->byUser(User::getByUsername($filterUser, $database)->getId()); |
|
85 | - } |
|
83 | + if ($filterUser !== null) { |
|
84 | + $searchHelper->byUser(User::getByUsername($filterUser, $database)->getId()); |
|
85 | + } |
|
86 | 86 | |
87 | - if ($filterTask !== null) { |
|
88 | - $searchHelper->byTask($filterTask); |
|
89 | - } |
|
87 | + if ($filterTask !== null) { |
|
88 | + $searchHelper->byTask($filterTask); |
|
89 | + } |
|
90 | 90 | |
91 | - if ($filterStatus !== null) { |
|
92 | - $searchHelper->byStatus($filterStatus); |
|
93 | - } |
|
91 | + if ($filterStatus !== null) { |
|
92 | + $searchHelper->byStatus($filterStatus); |
|
93 | + } |
|
94 | 94 | |
95 | - if ($filterRequest !== null) { |
|
96 | - $searchHelper->byRequest($filterRequest); |
|
97 | - } |
|
95 | + if ($filterRequest !== null) { |
|
96 | + $searchHelper->byRequest($filterRequest); |
|
97 | + } |
|
98 | 98 | |
99 | - /** @var JobQueue[] $jobList */ |
|
100 | - $jobList = $searchHelper->getRecordCount($count)->fetch(); |
|
99 | + /** @var JobQueue[] $jobList */ |
|
100 | + $jobList = $searchHelper->getRecordCount($count)->fetch(); |
|
101 | 101 | |
102 | - $this->setupPageData($count, array( |
|
103 | - 'filterUser' => $filterUser, |
|
104 | - 'filterTask' => $filterTask, |
|
105 | - 'filterStatus' => $filterStatus, |
|
106 | - 'filterRequest' => $filterRequest, |
|
107 | - )); |
|
102 | + $this->setupPageData($count, array( |
|
103 | + 'filterUser' => $filterUser, |
|
104 | + 'filterTask' => $filterTask, |
|
105 | + 'filterStatus' => $filterStatus, |
|
106 | + 'filterRequest' => $filterRequest, |
|
107 | + )); |
|
108 | 108 | |
109 | - $userIds = array(); |
|
110 | - $requestIds = array(); |
|
109 | + $userIds = array(); |
|
110 | + $requestIds = array(); |
|
111 | 111 | |
112 | - foreach ($jobList as $job) { |
|
113 | - $userIds[] = $job->getTriggerUserId(); |
|
114 | - $requestIds[] = $job->getRequest(); |
|
112 | + foreach ($jobList as $job) { |
|
113 | + $userIds[] = $job->getTriggerUserId(); |
|
114 | + $requestIds[] = $job->getRequest(); |
|
115 | 115 | |
116 | - $job->setDatabase($database); |
|
117 | - } |
|
116 | + $job->setDatabase($database); |
|
117 | + } |
|
118 | 118 | |
119 | - $this->getTypeAheadHelper()->defineTypeAheadSource('username-typeahead', function() use ($database) { |
|
120 | - return UserSearchHelper::get($database)->fetchColumn('username'); |
|
121 | - }); |
|
119 | + $this->getTypeAheadHelper()->defineTypeAheadSource('username-typeahead', function() use ($database) { |
|
120 | + return UserSearchHelper::get($database)->fetchColumn('username'); |
|
121 | + }); |
|
122 | 122 | |
123 | - $this->assign('users', UserSearchHelper::get($database)->inIds($userIds)->fetchMap('username')); |
|
124 | - $this->assign('requests', RequestSearchHelper::get($database)->inIds($requestIds)->fetchMap('name')); |
|
123 | + $this->assign('users', UserSearchHelper::get($database)->inIds($userIds)->fetchMap('username')); |
|
124 | + $this->assign('requests', RequestSearchHelper::get($database)->inIds($requestIds)->fetchMap('name')); |
|
125 | 125 | |
126 | - $this->assign('joblist', $jobList); |
|
126 | + $this->assign('joblist', $jobList); |
|
127 | 127 | |
128 | - $this->addJs("/api.php?action=users&all=true&targetVariable=typeaheaddata"); |
|
128 | + $this->addJs("/api.php?action=users&all=true&targetVariable=typeaheaddata"); |
|
129 | 129 | |
130 | - $this->setTemplate('jobqueue/all.tpl'); |
|
131 | - } |
|
130 | + $this->setTemplate('jobqueue/all.tpl'); |
|
131 | + } |
|
132 | 132 | |
133 | - protected function view() |
|
134 | - { |
|
135 | - $jobId = WebRequest::getInt('id'); |
|
136 | - $database = $this->getDatabase(); |
|
133 | + protected function view() |
|
134 | + { |
|
135 | + $jobId = WebRequest::getInt('id'); |
|
136 | + $database = $this->getDatabase(); |
|
137 | 137 | |
138 | - if ($jobId === null) { |
|
139 | - throw new ApplicationLogicException('No job specified'); |
|
140 | - } |
|
138 | + if ($jobId === null) { |
|
139 | + throw new ApplicationLogicException('No job specified'); |
|
140 | + } |
|
141 | 141 | |
142 | - /** @var JobQueue $job */ |
|
143 | - $job = JobQueue::getById($jobId, $database); |
|
142 | + /** @var JobQueue $job */ |
|
143 | + $job = JobQueue::getById($jobId, $database); |
|
144 | 144 | |
145 | - if ($job === false) { |
|
146 | - throw new ApplicationLogicException('Could not find requested job'); |
|
147 | - } |
|
145 | + if ($job === false) { |
|
146 | + throw new ApplicationLogicException('Could not find requested job'); |
|
147 | + } |
|
148 | 148 | |
149 | - $this->prepareMaps(); |
|
149 | + $this->prepareMaps(); |
|
150 | 150 | |
151 | - $this->assign('user', User::getById($job->getTriggerUserId(), $database)); |
|
152 | - $this->assign('request', Request::getById($job->getRequest(), $database)); |
|
153 | - $this->assign('emailTemplate', EmailTemplate::getById($job->getEmailTemplate(), $database)); |
|
154 | - $this->assign('parent', JobQueue::getById($job->getParent(), $database)); |
|
151 | + $this->assign('user', User::getById($job->getTriggerUserId(), $database)); |
|
152 | + $this->assign('request', Request::getById($job->getRequest(), $database)); |
|
153 | + $this->assign('emailTemplate', EmailTemplate::getById($job->getEmailTemplate(), $database)); |
|
154 | + $this->assign('parent', JobQueue::getById($job->getParent(), $database)); |
|
155 | 155 | |
156 | - /** @var Log[] $logs */ |
|
157 | - $logs = LogSearchHelper::get($database)->byObjectType('JobQueue') |
|
158 | - ->byObjectId($job->getId())->getRecordCount($logCount)->fetch(); |
|
159 | - if ($logCount === 0) { |
|
160 | - $this->assign('log', array()); |
|
161 | - } |
|
162 | - else { |
|
163 | - list($users, $logData) = LogHelper::prepareLogsForTemplate($logs, $database, $this->getSiteConfiguration()); |
|
156 | + /** @var Log[] $logs */ |
|
157 | + $logs = LogSearchHelper::get($database)->byObjectType('JobQueue') |
|
158 | + ->byObjectId($job->getId())->getRecordCount($logCount)->fetch(); |
|
159 | + if ($logCount === 0) { |
|
160 | + $this->assign('log', array()); |
|
161 | + } |
|
162 | + else { |
|
163 | + list($users, $logData) = LogHelper::prepareLogsForTemplate($logs, $database, $this->getSiteConfiguration()); |
|
164 | 164 | |
165 | - $this->assign("log", $logData); |
|
166 | - $this->assign("users", $users); |
|
167 | - } |
|
165 | + $this->assign("log", $logData); |
|
166 | + $this->assign("users", $users); |
|
167 | + } |
|
168 | 168 | |
169 | - $this->assignCSRFToken(); |
|
169 | + $this->assignCSRFToken(); |
|
170 | 170 | |
171 | - $this->assign('job', $job); |
|
171 | + $this->assign('job', $job); |
|
172 | 172 | |
173 | - $this->assign('canAcknowledge', $this->barrierTest('acknowledge', User::getCurrent($database))); |
|
174 | - $this->assign('canRequeue', $this->barrierTest('requeue', User::getCurrent($database))); |
|
173 | + $this->assign('canAcknowledge', $this->barrierTest('acknowledge', User::getCurrent($database))); |
|
174 | + $this->assign('canRequeue', $this->barrierTest('requeue', User::getCurrent($database))); |
|
175 | 175 | |
176 | - $this->setHtmlTitle('Job #{$job->getId()|escape}'); |
|
177 | - $this->setTemplate('jobqueue/view.tpl'); |
|
178 | - } |
|
176 | + $this->setHtmlTitle('Job #{$job->getId()|escape}'); |
|
177 | + $this->setTemplate('jobqueue/view.tpl'); |
|
178 | + } |
|
179 | 179 | |
180 | - protected function acknowledge() |
|
181 | - { |
|
182 | - if (!WebRequest::wasPosted()) { |
|
183 | - throw new ApplicationLogicException('This page does not support GET methods.'); |
|
184 | - } |
|
180 | + protected function acknowledge() |
|
181 | + { |
|
182 | + if (!WebRequest::wasPosted()) { |
|
183 | + throw new ApplicationLogicException('This page does not support GET methods.'); |
|
184 | + } |
|
185 | 185 | |
186 | - $this->validateCSRFToken(); |
|
186 | + $this->validateCSRFToken(); |
|
187 | 187 | |
188 | - $jobId = WebRequest::postInt('job'); |
|
189 | - $database = $this->getDatabase(); |
|
188 | + $jobId = WebRequest::postInt('job'); |
|
189 | + $database = $this->getDatabase(); |
|
190 | 190 | |
191 | - if ($jobId === null) { |
|
192 | - throw new ApplicationLogicException('No job specified'); |
|
193 | - } |
|
191 | + if ($jobId === null) { |
|
192 | + throw new ApplicationLogicException('No job specified'); |
|
193 | + } |
|
194 | 194 | |
195 | - /** @var JobQueue $job */ |
|
196 | - $job = JobQueue::getById($jobId, $database); |
|
195 | + /** @var JobQueue $job */ |
|
196 | + $job = JobQueue::getById($jobId, $database); |
|
197 | 197 | |
198 | - if ($job === false) { |
|
199 | - throw new ApplicationLogicException('Could not find requested job'); |
|
200 | - } |
|
198 | + if ($job === false) { |
|
199 | + throw new ApplicationLogicException('Could not find requested job'); |
|
200 | + } |
|
201 | 201 | |
202 | - $job->setUpdateVersion(WebRequest::postInt('updateVersion')); |
|
203 | - $job->setAcknowledged(true); |
|
204 | - $job->save(); |
|
202 | + $job->setUpdateVersion(WebRequest::postInt('updateVersion')); |
|
203 | + $job->setAcknowledged(true); |
|
204 | + $job->save(); |
|
205 | 205 | |
206 | - Logger::backgroundJobAcknowledged($database, $job); |
|
206 | + Logger::backgroundJobAcknowledged($database, $job); |
|
207 | 207 | |
208 | - $this->redirect('jobQueue', 'view', array('id' => $jobId)); |
|
209 | - } |
|
208 | + $this->redirect('jobQueue', 'view', array('id' => $jobId)); |
|
209 | + } |
|
210 | 210 | |
211 | - protected function requeue() |
|
212 | - { |
|
213 | - if (!WebRequest::wasPosted()) { |
|
214 | - throw new ApplicationLogicException('This page does not support GET methods.'); |
|
215 | - } |
|
211 | + protected function requeue() |
|
212 | + { |
|
213 | + if (!WebRequest::wasPosted()) { |
|
214 | + throw new ApplicationLogicException('This page does not support GET methods.'); |
|
215 | + } |
|
216 | 216 | |
217 | - $this->validateCSRFToken(); |
|
217 | + $this->validateCSRFToken(); |
|
218 | 218 | |
219 | - $jobId = WebRequest::postInt('job'); |
|
220 | - $database = $this->getDatabase(); |
|
219 | + $jobId = WebRequest::postInt('job'); |
|
220 | + $database = $this->getDatabase(); |
|
221 | 221 | |
222 | - if ($jobId === null) { |
|
223 | - throw new ApplicationLogicException('No job specified'); |
|
224 | - } |
|
222 | + if ($jobId === null) { |
|
223 | + throw new ApplicationLogicException('No job specified'); |
|
224 | + } |
|
225 | 225 | |
226 | - /** @var JobQueue $job */ |
|
227 | - $job = JobQueue::getById($jobId, $database); |
|
226 | + /** @var JobQueue $job */ |
|
227 | + $job = JobQueue::getById($jobId, $database); |
|
228 | 228 | |
229 | - if ($job === false) { |
|
230 | - throw new ApplicationLogicException('Could not find requested job'); |
|
231 | - } |
|
229 | + if ($job === false) { |
|
230 | + throw new ApplicationLogicException('Could not find requested job'); |
|
231 | + } |
|
232 | 232 | |
233 | - $job->setStatus(JobQueue::STATUS_READY); |
|
234 | - $job->setUpdateVersion(WebRequest::postInt('updateVersion')); |
|
235 | - $job->setAcknowledged(null); |
|
236 | - $job->setError(null); |
|
237 | - $job->save(); |
|
238 | - |
|
239 | - /** @var Request $request */ |
|
240 | - $request = Request::getById($job->getRequest(), $database); |
|
241 | - $request->setStatus(RequestStatus::JOBQUEUE); |
|
242 | - $request->save(); |
|
233 | + $job->setStatus(JobQueue::STATUS_READY); |
|
234 | + $job->setUpdateVersion(WebRequest::postInt('updateVersion')); |
|
235 | + $job->setAcknowledged(null); |
|
236 | + $job->setError(null); |
|
237 | + $job->save(); |
|
238 | + |
|
239 | + /** @var Request $request */ |
|
240 | + $request = Request::getById($job->getRequest(), $database); |
|
241 | + $request->setStatus(RequestStatus::JOBQUEUE); |
|
242 | + $request->save(); |
|
243 | 243 | |
244 | - Logger::enqueuedJobQueue($database, $request); |
|
245 | - Logger::backgroundJobRequeued($database, $job); |
|
246 | - |
|
247 | - $this->redirect('jobQueue', 'view', array('id' => $jobId)); |
|
248 | - } |
|
249 | - |
|
250 | - protected function prepareMaps() |
|
251 | - { |
|
252 | - $taskNameMap = JobQueue::getTaskDescriptions(); |
|
253 | - |
|
254 | - $statusDecriptionMap = array( |
|
255 | - JobQueue::STATUS_CANCELLED => 'The job was cancelled', |
|
256 | - JobQueue::STATUS_COMPLETE => 'The job completed successfully', |
|
257 | - JobQueue::STATUS_FAILED => 'The job encountered an error', |
|
258 | - JobQueue::STATUS_READY => 'The job is ready to be picked up by the next job runner execution', |
|
259 | - JobQueue::STATUS_RUNNING => 'The job is being run right now by the job runner', |
|
260 | - JobQueue::STATUS_WAITING => 'The job has been picked up by a job runner', |
|
261 | - JobQueue::STATUS_HELD => 'The job has manually held from processing', |
|
262 | - ); |
|
263 | - $this->assign('taskNameMap', $taskNameMap); |
|
264 | - $this->assign('statusDescriptionMap', $statusDecriptionMap); |
|
265 | - } |
|
244 | + Logger::enqueuedJobQueue($database, $request); |
|
245 | + Logger::backgroundJobRequeued($database, $job); |
|
246 | + |
|
247 | + $this->redirect('jobQueue', 'view', array('id' => $jobId)); |
|
248 | + } |
|
249 | + |
|
250 | + protected function prepareMaps() |
|
251 | + { |
|
252 | + $taskNameMap = JobQueue::getTaskDescriptions(); |
|
253 | + |
|
254 | + $statusDecriptionMap = array( |
|
255 | + JobQueue::STATUS_CANCELLED => 'The job was cancelled', |
|
256 | + JobQueue::STATUS_COMPLETE => 'The job completed successfully', |
|
257 | + JobQueue::STATUS_FAILED => 'The job encountered an error', |
|
258 | + JobQueue::STATUS_READY => 'The job is ready to be picked up by the next job runner execution', |
|
259 | + JobQueue::STATUS_RUNNING => 'The job is being run right now by the job runner', |
|
260 | + JobQueue::STATUS_WAITING => 'The job has been picked up by a job runner', |
|
261 | + JobQueue::STATUS_HELD => 'The job has manually held from processing', |
|
262 | + ); |
|
263 | + $this->assign('taskNameMap', $taskNameMap); |
|
264 | + $this->assign('statusDescriptionMap', $statusDecriptionMap); |
|
265 | + } |
|
266 | 266 | } |
@@ -116,7 +116,8 @@ discard block |
||
116 | 116 | $job->setDatabase($database); |
117 | 117 | } |
118 | 118 | |
119 | - $this->getTypeAheadHelper()->defineTypeAheadSource('username-typeahead', function() use ($database) { |
|
119 | + $this->getTypeAheadHelper()->defineTypeAheadSource('username-typeahead', function() use ($database) |
|
120 | + { |
|
120 | 121 | return UserSearchHelper::get($database)->fetchColumn('username'); |
121 | 122 | }); |
122 | 123 | |
@@ -158,8 +159,7 @@ discard block |
||
158 | 159 | ->byObjectId($job->getId())->getRecordCount($logCount)->fetch(); |
159 | 160 | if ($logCount === 0) { |
160 | 161 | $this->assign('log', array()); |
161 | - } |
|
162 | - else { |
|
162 | + } else { |
|
163 | 163 | list($users, $logData) = LogHelper::prepareLogsForTemplate($logs, $database, $this->getSiteConfiguration()); |
164 | 164 | |
165 | 165 | $this->assign("log", $logData); |
@@ -16,12 +16,12 @@ |
||
16 | 16 | */ |
17 | 17 | interface IXmlApiAction extends IRoutedTask, IApiAction |
18 | 18 | { |
19 | - /** |
|
20 | - * Method that runs API action |
|
21 | - * |
|
22 | - * @param DOMElement $apiDocument |
|
23 | - * |
|
24 | - * @return DOMElement The modified API document |
|
25 | - */ |
|
26 | - public function executeApiAction(DOMElement $apiDocument); |
|
19 | + /** |
|
20 | + * Method that runs API action |
|
21 | + * |
|
22 | + * @param DOMElement $apiDocument |
|
23 | + * |
|
24 | + * @return DOMElement The modified API document |
|
25 | + */ |
|
26 | + public function executeApiAction(DOMElement $apiDocument); |
|
27 | 27 | } |
@@ -15,10 +15,10 @@ |
||
15 | 15 | */ |
16 | 16 | interface IJsonApiAction extends IRoutedTask, IApiAction |
17 | 17 | { |
18 | - /** |
|
19 | - * Method that runs API action |
|
20 | - * |
|
21 | - * @return object|array The modified API document |
|
22 | - */ |
|
23 | - public function executeApiAction(); |
|
18 | + /** |
|
19 | + * Method that runs API action |
|
20 | + * |
|
21 | + * @return object|array The modified API document |
|
22 | + */ |
|
23 | + public function executeApiAction(); |
|
24 | 24 | } |
@@ -16,15 +16,15 @@ |
||
16 | 16 | */ |
17 | 17 | class UnknownAction extends HelpAction implements IXmlApiAction |
18 | 18 | { |
19 | - public function executeApiAction(DOMElement $apiDocument) |
|
20 | - { |
|
21 | - $errorText = "Unknown API action specified."; |
|
22 | - $errorNode = $this->document->createElement("error", $errorText); |
|
23 | - $apiDocument->appendChild($errorNode); |
|
19 | + public function executeApiAction(DOMElement $apiDocument) |
|
20 | + { |
|
21 | + $errorText = "Unknown API action specified."; |
|
22 | + $errorNode = $this->document->createElement("error", $errorText); |
|
23 | + $apiDocument->appendChild($errorNode); |
|
24 | 24 | |
25 | - $helpElement = $this->getHelpElement(); |
|
26 | - $apiDocument->appendChild($helpElement); |
|
25 | + $helpElement = $this->getHelpElement(); |
|
26 | + $apiDocument->appendChild($helpElement); |
|
27 | 27 | |
28 | - return $apiDocument; |
|
29 | - } |
|
28 | + return $apiDocument; |
|
29 | + } |
|
30 | 30 | } |
@@ -16,18 +16,18 @@ |
||
16 | 16 | |
17 | 17 | class JsUsersAction extends JsonApiPageBase implements IJsonApiAction |
18 | 18 | { |
19 | - public function executeApiAction() |
|
20 | - { |
|
21 | - $this->getDatabase(); |
|
19 | + public function executeApiAction() |
|
20 | + { |
|
21 | + $this->getDatabase(); |
|
22 | 22 | |
23 | - $userSearchHelper = UserSearchHelper::get($this->getDatabase()); |
|
23 | + $userSearchHelper = UserSearchHelper::get($this->getDatabase()); |
|
24 | 24 | |
25 | - if (WebRequest::getString('all') === null) { |
|
26 | - $userSearchHelper->byStatus(User::STATUS_ACTIVE); |
|
25 | + if (WebRequest::getString('all') === null) { |
|
26 | + $userSearchHelper->byStatus(User::STATUS_ACTIVE); |
|
27 | 27 | |
28 | - } |
|
28 | + } |
|
29 | 29 | |
30 | - $dataset = $userSearchHelper->fetchColumn('username'); |
|
31 | - return $dataset; |
|
32 | - } |
|
30 | + $dataset = $userSearchHelper->fetchColumn('username'); |
|
31 | + return $dataset; |
|
32 | + } |
|
33 | 33 | } |
@@ -18,34 +18,34 @@ |
||
18 | 18 | */ |
19 | 19 | class HelpAction extends XmlApiPageBase implements IXmlApiAction |
20 | 20 | { |
21 | - public function executeApiAction(DOMElement $apiDocument) |
|
22 | - { |
|
23 | - $helpElement = $this->getHelpElement(); |
|
24 | - $apiDocument->appendChild($helpElement); |
|
25 | - |
|
26 | - return $apiDocument; |
|
27 | - } |
|
28 | - |
|
29 | - /** |
|
30 | - * Gets the help information |
|
31 | - * @return DOMElement |
|
32 | - */ |
|
33 | - protected function getHelpElement() |
|
34 | - { |
|
35 | - $helpInfo = "API help can be found at https://github.com/enwikipedia-acc/waca/wiki/API"; |
|
36 | - |
|
37 | - $help = $this->document->createElement("help"); |
|
38 | - $helptext = $this->document->createElement("info", $helpInfo); |
|
39 | - $helpactions = $this->document->createElement("actions"); |
|
40 | - |
|
41 | - foreach (ApiRequestRouter::getActionList() as $action) { |
|
42 | - $actionElement = $this->document->createElement("action", $action); |
|
43 | - $helpactions->appendChild($actionElement); |
|
44 | - } |
|
45 | - |
|
46 | - $help->appendChild($helptext); |
|
47 | - $help->appendChild($helpactions); |
|
48 | - |
|
49 | - return $help; |
|
50 | - } |
|
21 | + public function executeApiAction(DOMElement $apiDocument) |
|
22 | + { |
|
23 | + $helpElement = $this->getHelpElement(); |
|
24 | + $apiDocument->appendChild($helpElement); |
|
25 | + |
|
26 | + return $apiDocument; |
|
27 | + } |
|
28 | + |
|
29 | + /** |
|
30 | + * Gets the help information |
|
31 | + * @return DOMElement |
|
32 | + */ |
|
33 | + protected function getHelpElement() |
|
34 | + { |
|
35 | + $helpInfo = "API help can be found at https://github.com/enwikipedia-acc/waca/wiki/API"; |
|
36 | + |
|
37 | + $help = $this->document->createElement("help"); |
|
38 | + $helptext = $this->document->createElement("info", $helpInfo); |
|
39 | + $helpactions = $this->document->createElement("actions"); |
|
40 | + |
|
41 | + foreach (ApiRequestRouter::getActionList() as $action) { |
|
42 | + $actionElement = $this->document->createElement("action", $action); |
|
43 | + $helpactions->appendChild($actionElement); |
|
44 | + } |
|
45 | + |
|
46 | + $help->appendChild($helptext); |
|
47 | + $help->appendChild($helpactions); |
|
48 | + |
|
49 | + return $help; |
|
50 | + } |
|
51 | 51 | } |