@@ -12,12 +12,12 @@ |
||
12 | 12 | |
13 | 13 | class PageEmailConfirmationRequired extends PublicInterfacePageBase |
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->setTemplate('request/email-confirmation.tpl'); |
|
22 | - } |
|
15 | + /** |
|
16 | + * Main function for this page, when no specific actions are called. |
|
17 | + * @return void |
|
18 | + */ |
|
19 | + protected function main() |
|
20 | + { |
|
21 | + $this->setTemplate('request/email-confirmation.tpl'); |
|
22 | + } |
|
23 | 23 | } |
24 | 24 | \ No newline at end of file |
@@ -19,150 +19,150 @@ |
||
19 | 19 | |
20 | 20 | class PageRequestAccount extends PublicInterfacePageBase |
21 | 21 | { |
22 | - /** |
|
23 | - * Main function for this page, when no specific actions are called. |
|
24 | - * @return void |
|
25 | - */ |
|
26 | - protected function main() |
|
27 | - { |
|
28 | - // dual mode page |
|
29 | - if (WebRequest::wasPosted()) { |
|
30 | - $request = $this->createNewRequest(); |
|
31 | - |
|
32 | - $validationErrors = $this->validateRequest($request); |
|
33 | - |
|
34 | - if (count($validationErrors) > 0) { |
|
35 | - foreach ($validationErrors as $validationError) { |
|
36 | - SessionAlert::error($validationError->getErrorMessage()); |
|
37 | - } |
|
38 | - |
|
39 | - // Preserve the data after an error |
|
40 | - WebRequest::setSessionContext('accountReq', |
|
41 | - array( |
|
42 | - 'username' => WebRequest::postString('name'), |
|
43 | - 'email' => WebRequest::postEmail('email'), |
|
44 | - 'comments' => WebRequest::postString('comments'), |
|
45 | - ) |
|
46 | - ); |
|
47 | - |
|
48 | - // Validation error, bomb out early. |
|
49 | - $this->redirect(); |
|
50 | - |
|
51 | - return; |
|
52 | - } |
|
53 | - |
|
54 | - // actually save the request to the database |
|
55 | - if ($this->getSiteConfiguration()->getEmailConfirmationEnabled()) { |
|
56 | - $this->saveAsEmailConfirmation($request); |
|
57 | - } |
|
58 | - else { |
|
59 | - $this->saveWithoutEmailConfirmation($request); |
|
60 | - } |
|
61 | - } |
|
62 | - else { |
|
63 | - // set the form values from the session context |
|
64 | - $context = WebRequest::getSessionContext('accountReq'); |
|
65 | - if ($context !== null && is_array($context)) { |
|
66 | - $this->assign('username', $context['username']); |
|
67 | - $this->assign('email', $context['email']); |
|
68 | - $this->assign('comments', $context['comments']); |
|
69 | - } |
|
70 | - |
|
71 | - // Clear it for a refresh |
|
72 | - WebRequest::setSessionContext('accountReq', null); |
|
73 | - |
|
74 | - $this->setTemplate('request/request-form.tpl'); |
|
75 | - } |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * @return Request |
|
80 | - */ |
|
81 | - protected function createNewRequest() |
|
82 | - { |
|
83 | - $request = new Request(); |
|
84 | - $request->setDatabase($this->getDatabase()); |
|
85 | - |
|
86 | - $request->setName(WebRequest::postString('name')); |
|
87 | - $request->setEmail(WebRequest::postEmail('email')); |
|
88 | - $request->setComment(WebRequest::postString('comments')); |
|
89 | - |
|
90 | - $request->setIp(WebRequest::remoteAddress()); |
|
91 | - $request->setForwardedIp(WebRequest::forwardedAddress()); |
|
92 | - |
|
93 | - $request->setUserAgent(WebRequest::userAgent()); |
|
94 | - |
|
95 | - return $request; |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * @param Request $request |
|
100 | - * |
|
101 | - * @return ValidationError[] |
|
102 | - */ |
|
103 | - protected function validateRequest($request) |
|
104 | - { |
|
105 | - $validationHelper = new RequestValidationHelper( |
|
106 | - new BanHelper($this->getDatabase()), |
|
107 | - $request, |
|
108 | - WebRequest::postEmail('emailconfirm'), |
|
109 | - $this->getDatabase(), |
|
110 | - $this->getAntiSpoofProvider(), |
|
111 | - $this->getXffTrustProvider(), |
|
112 | - $this->getHttpHelper(), |
|
113 | - $this->getSiteConfiguration()->getMediawikiWebServiceEndpoint(), |
|
114 | - $this->getSiteConfiguration()->getTitleBlacklistEnabled(), |
|
115 | - $this->getTorExitProvider()); |
|
116 | - |
|
117 | - // These are arrays of ValidationError. |
|
118 | - $nameValidation = $validationHelper->validateName(); |
|
119 | - $emailValidation = $validationHelper->validateEmail(); |
|
120 | - $otherValidation = $validationHelper->validateOther(); |
|
121 | - |
|
122 | - $validationErrors = array_merge($nameValidation, $emailValidation, $otherValidation); |
|
123 | - |
|
124 | - return $validationErrors; |
|
125 | - } |
|
126 | - |
|
127 | - /** |
|
128 | - * @param Request $request |
|
129 | - * |
|
130 | - * @throws Exception |
|
131 | - */ |
|
132 | - protected function saveAsEmailConfirmation(Request $request) |
|
133 | - { |
|
134 | - $request->generateEmailConfirmationHash(); |
|
135 | - $request->save(); |
|
136 | - |
|
137 | - $trustedIp = $this->getXffTrustProvider()->getTrustedClientIp( |
|
138 | - $request->getIp(), |
|
139 | - $request->getForwardedIp()); |
|
140 | - |
|
141 | - $this->assign("ip", $trustedIp); |
|
142 | - $this->assign("id", $request->getId()); |
|
143 | - $this->assign("hash", $request->getEmailConfirm()); |
|
144 | - |
|
145 | - // Sends the confirmation email to the user. |
|
146 | - $this->getEmailHelper()->sendMail( |
|
147 | - $request->getEmail(), |
|
148 | - "[ACC #{$request->getId()}] English Wikipedia Account Request", |
|
149 | - $this->fetchTemplate('request/confirmation-mail.tpl')); |
|
150 | - |
|
151 | - $this->redirect('emailConfirmationRequired'); |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * @param Request $request |
|
156 | - * |
|
157 | - * @throws Exception |
|
158 | - */ |
|
159 | - protected function saveWithoutEmailConfirmation(Request $request) |
|
160 | - { |
|
161 | - $request->setEmailConfirm(0); // fixme Since it can't be null |
|
162 | - $request->save(); |
|
163 | - |
|
164 | - $this->getNotificationHelper()->requestReceived($request); |
|
165 | - |
|
166 | - $this->redirect('requestSubmitted'); |
|
167 | - } |
|
22 | + /** |
|
23 | + * Main function for this page, when no specific actions are called. |
|
24 | + * @return void |
|
25 | + */ |
|
26 | + protected function main() |
|
27 | + { |
|
28 | + // dual mode page |
|
29 | + if (WebRequest::wasPosted()) { |
|
30 | + $request = $this->createNewRequest(); |
|
31 | + |
|
32 | + $validationErrors = $this->validateRequest($request); |
|
33 | + |
|
34 | + if (count($validationErrors) > 0) { |
|
35 | + foreach ($validationErrors as $validationError) { |
|
36 | + SessionAlert::error($validationError->getErrorMessage()); |
|
37 | + } |
|
38 | + |
|
39 | + // Preserve the data after an error |
|
40 | + WebRequest::setSessionContext('accountReq', |
|
41 | + array( |
|
42 | + 'username' => WebRequest::postString('name'), |
|
43 | + 'email' => WebRequest::postEmail('email'), |
|
44 | + 'comments' => WebRequest::postString('comments'), |
|
45 | + ) |
|
46 | + ); |
|
47 | + |
|
48 | + // Validation error, bomb out early. |
|
49 | + $this->redirect(); |
|
50 | + |
|
51 | + return; |
|
52 | + } |
|
53 | + |
|
54 | + // actually save the request to the database |
|
55 | + if ($this->getSiteConfiguration()->getEmailConfirmationEnabled()) { |
|
56 | + $this->saveAsEmailConfirmation($request); |
|
57 | + } |
|
58 | + else { |
|
59 | + $this->saveWithoutEmailConfirmation($request); |
|
60 | + } |
|
61 | + } |
|
62 | + else { |
|
63 | + // set the form values from the session context |
|
64 | + $context = WebRequest::getSessionContext('accountReq'); |
|
65 | + if ($context !== null && is_array($context)) { |
|
66 | + $this->assign('username', $context['username']); |
|
67 | + $this->assign('email', $context['email']); |
|
68 | + $this->assign('comments', $context['comments']); |
|
69 | + } |
|
70 | + |
|
71 | + // Clear it for a refresh |
|
72 | + WebRequest::setSessionContext('accountReq', null); |
|
73 | + |
|
74 | + $this->setTemplate('request/request-form.tpl'); |
|
75 | + } |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * @return Request |
|
80 | + */ |
|
81 | + protected function createNewRequest() |
|
82 | + { |
|
83 | + $request = new Request(); |
|
84 | + $request->setDatabase($this->getDatabase()); |
|
85 | + |
|
86 | + $request->setName(WebRequest::postString('name')); |
|
87 | + $request->setEmail(WebRequest::postEmail('email')); |
|
88 | + $request->setComment(WebRequest::postString('comments')); |
|
89 | + |
|
90 | + $request->setIp(WebRequest::remoteAddress()); |
|
91 | + $request->setForwardedIp(WebRequest::forwardedAddress()); |
|
92 | + |
|
93 | + $request->setUserAgent(WebRequest::userAgent()); |
|
94 | + |
|
95 | + return $request; |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * @param Request $request |
|
100 | + * |
|
101 | + * @return ValidationError[] |
|
102 | + */ |
|
103 | + protected function validateRequest($request) |
|
104 | + { |
|
105 | + $validationHelper = new RequestValidationHelper( |
|
106 | + new BanHelper($this->getDatabase()), |
|
107 | + $request, |
|
108 | + WebRequest::postEmail('emailconfirm'), |
|
109 | + $this->getDatabase(), |
|
110 | + $this->getAntiSpoofProvider(), |
|
111 | + $this->getXffTrustProvider(), |
|
112 | + $this->getHttpHelper(), |
|
113 | + $this->getSiteConfiguration()->getMediawikiWebServiceEndpoint(), |
|
114 | + $this->getSiteConfiguration()->getTitleBlacklistEnabled(), |
|
115 | + $this->getTorExitProvider()); |
|
116 | + |
|
117 | + // These are arrays of ValidationError. |
|
118 | + $nameValidation = $validationHelper->validateName(); |
|
119 | + $emailValidation = $validationHelper->validateEmail(); |
|
120 | + $otherValidation = $validationHelper->validateOther(); |
|
121 | + |
|
122 | + $validationErrors = array_merge($nameValidation, $emailValidation, $otherValidation); |
|
123 | + |
|
124 | + return $validationErrors; |
|
125 | + } |
|
126 | + |
|
127 | + /** |
|
128 | + * @param Request $request |
|
129 | + * |
|
130 | + * @throws Exception |
|
131 | + */ |
|
132 | + protected function saveAsEmailConfirmation(Request $request) |
|
133 | + { |
|
134 | + $request->generateEmailConfirmationHash(); |
|
135 | + $request->save(); |
|
136 | + |
|
137 | + $trustedIp = $this->getXffTrustProvider()->getTrustedClientIp( |
|
138 | + $request->getIp(), |
|
139 | + $request->getForwardedIp()); |
|
140 | + |
|
141 | + $this->assign("ip", $trustedIp); |
|
142 | + $this->assign("id", $request->getId()); |
|
143 | + $this->assign("hash", $request->getEmailConfirm()); |
|
144 | + |
|
145 | + // Sends the confirmation email to the user. |
|
146 | + $this->getEmailHelper()->sendMail( |
|
147 | + $request->getEmail(), |
|
148 | + "[ACC #{$request->getId()}] English Wikipedia Account Request", |
|
149 | + $this->fetchTemplate('request/confirmation-mail.tpl')); |
|
150 | + |
|
151 | + $this->redirect('emailConfirmationRequired'); |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * @param Request $request |
|
156 | + * |
|
157 | + * @throws Exception |
|
158 | + */ |
|
159 | + protected function saveWithoutEmailConfirmation(Request $request) |
|
160 | + { |
|
161 | + $request->setEmailConfirm(0); // fixme Since it can't be null |
|
162 | + $request->save(); |
|
163 | + |
|
164 | + $this->getNotificationHelper()->requestReceived($request); |
|
165 | + |
|
166 | + $this->redirect('requestSubmitted'); |
|
167 | + } |
|
168 | 168 | } |
169 | 169 | \ No newline at end of file |
@@ -12,12 +12,12 @@ |
||
12 | 12 | |
13 | 13 | class PageRequestSubmitted extends PublicInterfacePageBase |
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->setTemplate('request/email-confirmed.tpl'); |
|
22 | - } |
|
15 | + /** |
|
16 | + * Main function for this page, when no specific actions are called. |
|
17 | + * @return void |
|
18 | + */ |
|
19 | + protected function main() |
|
20 | + { |
|
21 | + $this->setTemplate('request/email-confirmed.tpl'); |
|
22 | + } |
|
23 | 23 | } |
24 | 24 | \ No newline at end of file |
@@ -18,67 +18,67 @@ |
||
18 | 18 | |
19 | 19 | class PageConfirmEmail extends PublicInterfacePageBase |
20 | 20 | { |
21 | - /** |
|
22 | - * Main function for this page, when no specific actions are called. |
|
23 | - * @throws ApplicationLogicException |
|
24 | - * @throws Exception |
|
25 | - */ |
|
26 | - protected function main() |
|
27 | - { |
|
28 | - $id = WebRequest::getInt('id'); |
|
29 | - $si = WebRequest::getString('si'); |
|
30 | - |
|
31 | - if ($id === null || $si === null) { |
|
32 | - throw new ApplicationLogicException('Link incomplete - please double check the link you received.'); |
|
33 | - } |
|
34 | - |
|
35 | - /** @var Request|false $request */ |
|
36 | - $request = Request::getById($id, $this->getDatabase()); |
|
37 | - |
|
38 | - if ($request === false) { |
|
39 | - throw new ApplicationLogicException('Request not found'); |
|
40 | - } |
|
41 | - |
|
42 | - if ($request->getEmailConfirm() === 'Confirmed') { |
|
43 | - // request has already been confirmed. Bomb out silently. |
|
44 | - $this->redirect('requestSubmitted'); |
|
45 | - |
|
46 | - return; |
|
47 | - } |
|
48 | - |
|
49 | - if ($request->getEmailConfirm() === $si) { |
|
50 | - $request->setEmailConfirm('Confirmed'); |
|
51 | - } |
|
52 | - else { |
|
53 | - throw new ApplicationLogicException('The confirmation value does not appear to match the expected value'); |
|
54 | - } |
|
55 | - |
|
56 | - try { |
|
57 | - $request->save(); |
|
58 | - } |
|
59 | - catch (OptimisticLockFailedException $ex) { |
|
60 | - // Okay. Someone's edited this in the time between us loading this page and doing the checks, and us getting |
|
61 | - // to saving the page. We *do not* want to show an optimistic lock failure, the most likely problem is they |
|
62 | - // double-loaded this page (see #255). Let's confirm this, and bomb out with a success message if it's the |
|
63 | - // case. |
|
64 | - |
|
65 | - $request = Request::getById($id, $this->getDatabase()); |
|
66 | - if ($request->getEmailConfirm() === 'Confirmed') { |
|
67 | - // we've already done the sanity checks above |
|
68 | - |
|
69 | - $this->redirect('requestSubmitted'); |
|
70 | - |
|
71 | - // skip the log and notification |
|
72 | - return; |
|
73 | - } |
|
74 | - |
|
75 | - // something really weird happened. Another race condition? |
|
76 | - throw $ex; |
|
77 | - } |
|
78 | - |
|
79 | - Logger::emailConfirmed($this->getDatabase(), $request); |
|
80 | - $this->getNotificationHelper()->requestReceived($request); |
|
81 | - |
|
82 | - $this->redirect('requestSubmitted'); |
|
83 | - } |
|
21 | + /** |
|
22 | + * Main function for this page, when no specific actions are called. |
|
23 | + * @throws ApplicationLogicException |
|
24 | + * @throws Exception |
|
25 | + */ |
|
26 | + protected function main() |
|
27 | + { |
|
28 | + $id = WebRequest::getInt('id'); |
|
29 | + $si = WebRequest::getString('si'); |
|
30 | + |
|
31 | + if ($id === null || $si === null) { |
|
32 | + throw new ApplicationLogicException('Link incomplete - please double check the link you received.'); |
|
33 | + } |
|
34 | + |
|
35 | + /** @var Request|false $request */ |
|
36 | + $request = Request::getById($id, $this->getDatabase()); |
|
37 | + |
|
38 | + if ($request === false) { |
|
39 | + throw new ApplicationLogicException('Request not found'); |
|
40 | + } |
|
41 | + |
|
42 | + if ($request->getEmailConfirm() === 'Confirmed') { |
|
43 | + // request has already been confirmed. Bomb out silently. |
|
44 | + $this->redirect('requestSubmitted'); |
|
45 | + |
|
46 | + return; |
|
47 | + } |
|
48 | + |
|
49 | + if ($request->getEmailConfirm() === $si) { |
|
50 | + $request->setEmailConfirm('Confirmed'); |
|
51 | + } |
|
52 | + else { |
|
53 | + throw new ApplicationLogicException('The confirmation value does not appear to match the expected value'); |
|
54 | + } |
|
55 | + |
|
56 | + try { |
|
57 | + $request->save(); |
|
58 | + } |
|
59 | + catch (OptimisticLockFailedException $ex) { |
|
60 | + // Okay. Someone's edited this in the time between us loading this page and doing the checks, and us getting |
|
61 | + // to saving the page. We *do not* want to show an optimistic lock failure, the most likely problem is they |
|
62 | + // double-loaded this page (see #255). Let's confirm this, and bomb out with a success message if it's the |
|
63 | + // case. |
|
64 | + |
|
65 | + $request = Request::getById($id, $this->getDatabase()); |
|
66 | + if ($request->getEmailConfirm() === 'Confirmed') { |
|
67 | + // we've already done the sanity checks above |
|
68 | + |
|
69 | + $this->redirect('requestSubmitted'); |
|
70 | + |
|
71 | + // skip the log and notification |
|
72 | + return; |
|
73 | + } |
|
74 | + |
|
75 | + // something really weird happened. Another race condition? |
|
76 | + throw $ex; |
|
77 | + } |
|
78 | + |
|
79 | + Logger::emailConfirmed($this->getDatabase(), $request); |
|
80 | + $this->getNotificationHelper()->requestReceived($request); |
|
81 | + |
|
82 | + $this->redirect('requestSubmitted'); |
|
83 | + } |
|
84 | 84 | } |
85 | 85 | \ No newline at end of file |
@@ -16,37 +16,37 @@ |
||
16 | 16 | |
17 | 17 | abstract class RequestActionBase extends InternalPageBase |
18 | 18 | { |
19 | - /** |
|
20 | - * @param PdoDatabase $database |
|
21 | - * |
|
22 | - * @return Request |
|
23 | - * @throws ApplicationLogicException |
|
24 | - */ |
|
25 | - protected function getRequest(PdoDatabase $database) |
|
26 | - { |
|
27 | - $requestId = WebRequest::postInt('request'); |
|
28 | - if ($requestId === null) { |
|
29 | - throw new ApplicationLogicException('Request ID not found'); |
|
30 | - } |
|
31 | - |
|
32 | - /** @var Request $request */ |
|
33 | - $request = Request::getById($requestId, $database); |
|
34 | - |
|
35 | - if ($request === false) { |
|
36 | - throw new ApplicationLogicException('Request not found'); |
|
37 | - } |
|
38 | - |
|
39 | - return $request; |
|
40 | - } |
|
41 | - |
|
42 | - final protected function checkPosted() |
|
43 | - { |
|
44 | - // if the request was not posted, send the user away. |
|
45 | - if (!WebRequest::wasPosted()) { |
|
46 | - throw new ApplicationLogicException('This page does not support GET methods.'); |
|
47 | - } |
|
48 | - |
|
49 | - // validate the CSRF token |
|
50 | - $this->validateCSRFToken(); |
|
51 | - } |
|
19 | + /** |
|
20 | + * @param PdoDatabase $database |
|
21 | + * |
|
22 | + * @return Request |
|
23 | + * @throws ApplicationLogicException |
|
24 | + */ |
|
25 | + protected function getRequest(PdoDatabase $database) |
|
26 | + { |
|
27 | + $requestId = WebRequest::postInt('request'); |
|
28 | + if ($requestId === null) { |
|
29 | + throw new ApplicationLogicException('Request ID not found'); |
|
30 | + } |
|
31 | + |
|
32 | + /** @var Request $request */ |
|
33 | + $request = Request::getById($requestId, $database); |
|
34 | + |
|
35 | + if ($request === false) { |
|
36 | + throw new ApplicationLogicException('Request not found'); |
|
37 | + } |
|
38 | + |
|
39 | + return $request; |
|
40 | + } |
|
41 | + |
|
42 | + final protected function checkPosted() |
|
43 | + { |
|
44 | + // if the request was not posted, send the user away. |
|
45 | + if (!WebRequest::wasPosted()) { |
|
46 | + throw new ApplicationLogicException('This page does not support GET methods.'); |
|
47 | + } |
|
48 | + |
|
49 | + // validate the CSRF token |
|
50 | + $this->validateCSRFToken(); |
|
51 | + } |
|
52 | 52 | } |
53 | 53 | \ No newline at end of file |
@@ -15,22 +15,22 @@ |
||
15 | 15 | |
16 | 16 | class PageDropRequest extends PageCloseRequest |
17 | 17 | { |
18 | - protected function getTemplate(PdoDatabase $database) |
|
19 | - { |
|
20 | - return EmailTemplate::getDroppedTemplate(); |
|
21 | - } |
|
18 | + protected function getTemplate(PdoDatabase $database) |
|
19 | + { |
|
20 | + return EmailTemplate::getDroppedTemplate(); |
|
21 | + } |
|
22 | 22 | |
23 | - protected function confirmEmailAlreadySent(Request $request, EmailTemplate $template) |
|
24 | - { |
|
25 | - return false; |
|
26 | - } |
|
23 | + protected function confirmEmailAlreadySent(Request $request, EmailTemplate $template) |
|
24 | + { |
|
25 | + return false; |
|
26 | + } |
|
27 | 27 | |
28 | - protected function confirmAccountCreated(Request $request, EmailTemplate $template) |
|
29 | - { |
|
30 | - return false; |
|
31 | - } |
|
28 | + protected function confirmAccountCreated(Request $request, EmailTemplate $template) |
|
29 | + { |
|
30 | + return false; |
|
31 | + } |
|
32 | 32 | |
33 | - protected function sendMail(Request $request, EmailTemplate $template, User $currentUser, $ccMailingList) |
|
34 | - { |
|
35 | - } |
|
33 | + protected function sendMail(Request $request, EmailTemplate $template, User $currentUser, $ccMailingList) |
|
34 | + { |
|
35 | + } |
|
36 | 36 | } |
37 | 37 | \ No newline at end of file |
@@ -20,99 +20,99 @@ |
||
20 | 20 | |
21 | 21 | class PageBreakReservation extends RequestActionBase |
22 | 22 | { |
23 | - protected function main() |
|
24 | - { |
|
25 | - $this->checkPosted(); |
|
26 | - $database = $this->getDatabase(); |
|
27 | - $request = $this->getRequest($database); |
|
23 | + protected function main() |
|
24 | + { |
|
25 | + $this->checkPosted(); |
|
26 | + $database = $this->getDatabase(); |
|
27 | + $request = $this->getRequest($database); |
|
28 | 28 | |
29 | - if ($request->getReserved() === null) { |
|
30 | - throw new ApplicationLogicException('Request is not reserved!'); |
|
31 | - } |
|
29 | + if ($request->getReserved() === null) { |
|
30 | + throw new ApplicationLogicException('Request is not reserved!'); |
|
31 | + } |
|
32 | 32 | |
33 | - $currentUser = User::getCurrent($database); |
|
33 | + $currentUser = User::getCurrent($database); |
|
34 | 34 | |
35 | - if ($currentUser->getId() === $request->getReserved()) { |
|
36 | - $this->doUnreserve($request, $database); |
|
37 | - } |
|
38 | - else { |
|
39 | - // not the same user! |
|
40 | - if ($this->barrierTest('force')) { |
|
41 | - $this->doBreakReserve($request, $database); |
|
42 | - } |
|
43 | - else { |
|
44 | - throw new AccessDeniedException(); |
|
45 | - } |
|
46 | - } |
|
47 | - } |
|
35 | + if ($currentUser->getId() === $request->getReserved()) { |
|
36 | + $this->doUnreserve($request, $database); |
|
37 | + } |
|
38 | + else { |
|
39 | + // not the same user! |
|
40 | + if ($this->barrierTest('force')) { |
|
41 | + $this->doBreakReserve($request, $database); |
|
42 | + } |
|
43 | + else { |
|
44 | + throw new AccessDeniedException(); |
|
45 | + } |
|
46 | + } |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @param Request $request |
|
51 | - * @param PdoDatabase $database |
|
52 | - * |
|
53 | - * @throws Exception |
|
54 | - */ |
|
55 | - protected function doUnreserve(Request $request, PdoDatabase $database) |
|
56 | - { |
|
57 | - // same user! we allow people to unreserve their own stuff |
|
58 | - $request->setReserved(null); |
|
59 | - $request->setUpdateVersion(WebRequest::postInt('updateversion')); |
|
60 | - $request->save(); |
|
49 | + /** |
|
50 | + * @param Request $request |
|
51 | + * @param PdoDatabase $database |
|
52 | + * |
|
53 | + * @throws Exception |
|
54 | + */ |
|
55 | + protected function doUnreserve(Request $request, PdoDatabase $database) |
|
56 | + { |
|
57 | + // same user! we allow people to unreserve their own stuff |
|
58 | + $request->setReserved(null); |
|
59 | + $request->setUpdateVersion(WebRequest::postInt('updateversion')); |
|
60 | + $request->save(); |
|
61 | 61 | |
62 | - Logger::unreserve($database, $request); |
|
63 | - $this->getNotificationHelper()->requestUnreserved($request); |
|
62 | + Logger::unreserve($database, $request); |
|
63 | + $this->getNotificationHelper()->requestUnreserved($request); |
|
64 | 64 | |
65 | - // Redirect home! |
|
66 | - $this->redirect(); |
|
67 | - } |
|
65 | + // Redirect home! |
|
66 | + $this->redirect(); |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @param Request $request |
|
71 | - * @param PdoDatabase $database |
|
72 | - * |
|
73 | - * @throws Exception |
|
74 | - */ |
|
75 | - protected function doBreakReserve(Request $request, PdoDatabase $database) |
|
76 | - { |
|
77 | - if (!WebRequest::postBoolean("confirm")) { |
|
78 | - $this->assignCSRFToken(); |
|
69 | + /** |
|
70 | + * @param Request $request |
|
71 | + * @param PdoDatabase $database |
|
72 | + * |
|
73 | + * @throws Exception |
|
74 | + */ |
|
75 | + protected function doBreakReserve(Request $request, PdoDatabase $database) |
|
76 | + { |
|
77 | + if (!WebRequest::postBoolean("confirm")) { |
|
78 | + $this->assignCSRFToken(); |
|
79 | 79 | |
80 | - $this->assign("request", $request->getId()); |
|
81 | - $this->assign("reservedUser", User::getById($request->getReserved(), $database)); |
|
82 | - $this->assign("updateversion", WebRequest::postInt('updateversion')); |
|
80 | + $this->assign("request", $request->getId()); |
|
81 | + $this->assign("reservedUser", User::getById($request->getReserved(), $database)); |
|
82 | + $this->assign("updateversion", WebRequest::postInt('updateversion')); |
|
83 | 83 | |
84 | - $this->setTemplate("confirmations/breakreserve.tpl"); |
|
85 | - } |
|
86 | - else { |
|
87 | - $request->setReserved(null); |
|
88 | - $request->setUpdateVersion(WebRequest::postInt('updateversion')); |
|
89 | - $request->save(); |
|
84 | + $this->setTemplate("confirmations/breakreserve.tpl"); |
|
85 | + } |
|
86 | + else { |
|
87 | + $request->setReserved(null); |
|
88 | + $request->setUpdateVersion(WebRequest::postInt('updateversion')); |
|
89 | + $request->save(); |
|
90 | 90 | |
91 | - Logger::breakReserve($database, $request); |
|
92 | - $this->getNotificationHelper()->requestReserveBroken($request); |
|
91 | + Logger::breakReserve($database, $request); |
|
92 | + $this->getNotificationHelper()->requestReserveBroken($request); |
|
93 | 93 | |
94 | - // Redirect home! |
|
95 | - $this->redirect(); |
|
96 | - } |
|
97 | - } |
|
94 | + // Redirect home! |
|
95 | + $this->redirect(); |
|
96 | + } |
|
97 | + } |
|
98 | 98 | |
99 | - /** |
|
100 | - * Sets up the security for this page. If certain actions have different permissions, this should be reflected in |
|
101 | - * the return value from this function. |
|
102 | - * |
|
103 | - * If this page even supports actions, you will need to check the route |
|
104 | - * |
|
105 | - * @return SecurityConfiguration |
|
106 | - * @category Security-Critical |
|
107 | - */ |
|
108 | - protected function getSecurityConfiguration() |
|
109 | - { |
|
110 | - switch ($this->getRouteName()) { |
|
111 | - case 'force': |
|
112 | - // note, this is a virtual route that's only used in barrier tests |
|
113 | - return $this->getSecurityManager()->configure()->asAdminPage(); |
|
114 | - default: |
|
115 | - return $this->getSecurityManager()->configure()->asInternalPage(); |
|
116 | - } |
|
117 | - } |
|
99 | + /** |
|
100 | + * Sets up the security for this page. If certain actions have different permissions, this should be reflected in |
|
101 | + * the return value from this function. |
|
102 | + * |
|
103 | + * If this page even supports actions, you will need to check the route |
|
104 | + * |
|
105 | + * @return SecurityConfiguration |
|
106 | + * @category Security-Critical |
|
107 | + */ |
|
108 | + protected function getSecurityConfiguration() |
|
109 | + { |
|
110 | + switch ($this->getRouteName()) { |
|
111 | + case 'force': |
|
112 | + // note, this is a virtual route that's only used in barrier tests |
|
113 | + return $this->getSecurityManager()->configure()->asAdminPage(); |
|
114 | + default: |
|
115 | + return $this->getSecurityManager()->configure()->asInternalPage(); |
|
116 | + } |
|
117 | + } |
|
118 | 118 | } |
119 | 119 | \ No newline at end of file |
@@ -21,254 +21,254 @@ |
||
21 | 21 | |
22 | 22 | class PageCloseRequest extends RequestActionBase |
23 | 23 | { |
24 | - /** |
|
25 | - * Sets up the security for this page. If certain actions have different permissions, this should be reflected in |
|
26 | - * the return value from this function. |
|
27 | - * |
|
28 | - * If this page even supports actions, you will need to check the route |
|
29 | - * |
|
30 | - * @return SecurityConfiguration |
|
31 | - * @category Security-Critical |
|
32 | - */ |
|
33 | - protected function getSecurityConfiguration() |
|
34 | - { |
|
35 | - return $this->getSecurityManager()->configure()->asInternalPage(); |
|
36 | - } |
|
37 | - |
|
38 | - protected function main() |
|
39 | - { |
|
40 | - $this->processClose(); |
|
41 | - } |
|
42 | - |
|
43 | - /** |
|
44 | - * Main function for this page, when no specific actions are called. |
|
45 | - * @throws ApplicationLogicException |
|
46 | - */ |
|
47 | - final protected function processClose() |
|
48 | - { |
|
49 | - $this->checkPosted(); |
|
50 | - $database = $this->getDatabase(); |
|
51 | - |
|
52 | - $currentUser = User::getCurrent($database); |
|
53 | - $template = $this->getTemplate($database); |
|
54 | - $request = $this->getRequest($database); |
|
55 | - |
|
56 | - if ($request->getStatus() === 'Closed') { |
|
57 | - throw new ApplicationLogicException('Request is already closed'); |
|
58 | - } |
|
59 | - |
|
60 | - if ($this->confirmEmailAlreadySent($request, $template)) { |
|
61 | - return; |
|
62 | - } |
|
63 | - |
|
64 | - if ($this->confirmReserveOverride($request, $template, $currentUser, $database)) { |
|
65 | - return; |
|
66 | - } |
|
67 | - |
|
68 | - if ($this->confirmAccountCreated($request, $template)) { |
|
69 | - return; |
|
70 | - } |
|
71 | - |
|
72 | - // I think we're good here... |
|
73 | - $request->setStatus('Closed'); |
|
74 | - $request->setReserved(null); |
|
75 | - |
|
76 | - Logger::closeRequest($database, $request, $template->getId(), null); |
|
77 | - |
|
78 | - $request->setUpdateVersion(WebRequest::postInt('updateversion')); |
|
79 | - $request->save(); |
|
80 | - |
|
81 | - // Perform the notifications and stuff *after* we've successfully saved, since the save can throw an OLE and |
|
82 | - // be rolled back. |
|
83 | - |
|
84 | - $this->getNotificationHelper()->requestClosed($request, $template->getName()); |
|
85 | - SessionAlert::success("Request {$request->getId()} has been closed"); |
|
86 | - |
|
87 | - $this->sendMail($request, $template->getText(), $currentUser, false); |
|
88 | - |
|
89 | - $this->redirect(); |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * @param PdoDatabase $database |
|
94 | - * |
|
95 | - * @return EmailTemplate |
|
96 | - * @throws ApplicationLogicException |
|
97 | - */ |
|
98 | - protected function getTemplate(PdoDatabase $database) |
|
99 | - { |
|
100 | - $templateId = WebRequest::postInt('template'); |
|
101 | - if ($templateId === null) { |
|
102 | - throw new ApplicationLogicException('No template specified'); |
|
103 | - } |
|
104 | - |
|
105 | - /** @var EmailTemplate $template */ |
|
106 | - $template = EmailTemplate::getById($templateId, $database); |
|
107 | - if ($template === false || !$template->getActive()) { |
|
108 | - throw new ApplicationLogicException('Invalid or inactive template specified'); |
|
109 | - } |
|
110 | - |
|
111 | - return $template; |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * @param Request $request |
|
116 | - * @param EmailTemplate $template |
|
117 | - * |
|
118 | - * @return bool |
|
119 | - */ |
|
120 | - protected function confirmEmailAlreadySent(Request $request, EmailTemplate $template) |
|
121 | - { |
|
122 | - if ($this->checkEmailAlreadySent($request)) { |
|
123 | - $this->showConfirmation($request, $template, 'close-confirmations/email-sent.tpl'); |
|
124 | - |
|
125 | - return true; |
|
126 | - } |
|
127 | - |
|
128 | - return false; |
|
129 | - } |
|
130 | - |
|
131 | - protected function checkEmailAlreadySent(Request $request) |
|
132 | - { |
|
133 | - if ($request->getEmailSent() && !WebRequest::postBoolean('emailSentOverride')) { |
|
134 | - return true; |
|
135 | - } |
|
136 | - |
|
137 | - return false; |
|
138 | - } |
|
139 | - |
|
140 | - protected function checkReserveOverride(Request $request, User $currentUser) |
|
141 | - { |
|
142 | - $reservationId = $request->getReserved(); |
|
143 | - |
|
144 | - if ($reservationId !== 0 && $reservationId !== null) { |
|
145 | - if (!WebRequest::postBoolean('reserveOverride')) { |
|
146 | - if ($currentUser->getId() !== $reservationId) { |
|
147 | - return true; |
|
148 | - } |
|
149 | - } |
|
150 | - } |
|
151 | - |
|
152 | - return false; |
|
153 | - } |
|
154 | - |
|
155 | - /** |
|
156 | - * @param Request $request |
|
157 | - * @param EmailTemplate $template |
|
158 | - * @param User $currentUser |
|
159 | - * @param PdoDatabase $database |
|
160 | - * |
|
161 | - * @return bool |
|
162 | - */ |
|
163 | - protected function confirmReserveOverride( |
|
164 | - Request $request, |
|
165 | - EmailTemplate $template, |
|
166 | - User $currentUser, |
|
167 | - PdoDatabase $database |
|
168 | - ) { |
|
169 | - if ($this->checkReserveOverride($request, $currentUser)) { |
|
170 | - $this->assign('reserveUser', User::getById($request->getReserved(), $database)->getUsername()); |
|
171 | - $this->showConfirmation($request, $template, 'close-confirmations/reserve-override.tpl'); |
|
172 | - |
|
173 | - return true; |
|
174 | - } |
|
175 | - |
|
176 | - return false; |
|
177 | - } |
|
178 | - |
|
179 | - /** |
|
180 | - * @param Request $request |
|
181 | - * @param EmailTemplate $template |
|
182 | - * |
|
183 | - * @return bool |
|
184 | - * @throws \Waca\Exceptions\CurlException |
|
185 | - */ |
|
186 | - protected function confirmAccountCreated(Request $request, EmailTemplate $template) |
|
187 | - { |
|
188 | - if ($this->checkAccountCreated($request, $template)) { |
|
189 | - $this->showConfirmation($request, $template, 'close-confirmations/account-created.tpl'); |
|
190 | - |
|
191 | - return true; |
|
192 | - } |
|
193 | - |
|
194 | - return false; |
|
195 | - } |
|
196 | - |
|
197 | - protected function checkAccountCreated(Request $request, EmailTemplate $template) |
|
198 | - { |
|
199 | - if ($template->getDefaultAction() === EmailTemplate::CREATED && !WebRequest::postBoolean('createOverride')) { |
|
200 | - $parameters = array( |
|
201 | - 'action' => 'query', |
|
202 | - 'list' => 'users', |
|
203 | - 'format' => 'php', |
|
204 | - 'ususers' => $request->getName(), |
|
205 | - ); |
|
206 | - |
|
207 | - $content = $this->getHttpHelper()->get($this->getSiteConfiguration()->getMediawikiWebServiceEndpoint(), |
|
208 | - $parameters); |
|
209 | - |
|
210 | - $apiResult = unserialize($content); |
|
211 | - $exists = !isset($apiResult['query']['users']['0']['missing']); |
|
212 | - |
|
213 | - if (!$exists) { |
|
214 | - return true; |
|
215 | - } |
|
216 | - } |
|
217 | - |
|
218 | - return false; |
|
219 | - } |
|
220 | - |
|
221 | - /** |
|
222 | - * @param Request $request |
|
223 | - * @param string $mailText |
|
224 | - * @param User $currentUser |
|
225 | - * @param boolean $ccMailingList |
|
226 | - */ |
|
227 | - protected function sendMail(Request $request, $mailText, User $currentUser, $ccMailingList) |
|
228 | - { |
|
229 | - $headers = array( |
|
230 | - 'X-ACC-Request' => $request->getId(), |
|
231 | - 'X-ACC-UserID' => $currentUser->getId(), |
|
232 | - ); |
|
233 | - |
|
234 | - if ($ccMailingList) { |
|
235 | - $headers['Cc'] = '[email protected]'; |
|
236 | - } |
|
237 | - |
|
238 | - $helper = $this->getEmailHelper(); |
|
239 | - |
|
240 | - $emailSig = $currentUser->getEmailSig(); |
|
241 | - if ($emailSig !== '' || $emailSig !== null) { |
|
242 | - $emailSig = "\n\n" . $emailSig; |
|
243 | - } |
|
244 | - |
|
245 | - $subject = "RE: [ACC #{$request->getId()}] English Wikipedia Account Request"; |
|
246 | - $content = $mailText . $emailSig; |
|
247 | - |
|
248 | - $helper->sendMail($request->getEmail(), $subject, $content, $headers); |
|
249 | - |
|
250 | - $request->setEmailSent(true); |
|
251 | - } |
|
252 | - |
|
253 | - /** |
|
254 | - * @param Request $request |
|
255 | - * @param EmailTemplate $template |
|
256 | - * @param string $templateName |
|
257 | - * |
|
258 | - * @throws Exception |
|
259 | - * @return void |
|
260 | - */ |
|
261 | - protected function showConfirmation(Request $request, EmailTemplate $template, $templateName) |
|
262 | - { |
|
263 | - $this->assignCSRFToken(); |
|
264 | - |
|
265 | - $this->assign('request', $request->getId()); |
|
266 | - $this->assign('template', $template->getId()); |
|
267 | - |
|
268 | - $this->assign('emailSentOverride', WebRequest::postBoolean('emailSentOverride') ? 'true' : 'false'); |
|
269 | - $this->assign('reserveOverride', WebRequest::postBoolean('reserveOverride') ? 'true' : 'false'); |
|
270 | - $this->assign('createOverride', WebRequest::postBoolean('createOverride') ? 'true' : 'false'); |
|
271 | - |
|
272 | - $this->setTemplate($templateName); |
|
273 | - } |
|
24 | + /** |
|
25 | + * Sets up the security for this page. If certain actions have different permissions, this should be reflected in |
|
26 | + * the return value from this function. |
|
27 | + * |
|
28 | + * If this page even supports actions, you will need to check the route |
|
29 | + * |
|
30 | + * @return SecurityConfiguration |
|
31 | + * @category Security-Critical |
|
32 | + */ |
|
33 | + protected function getSecurityConfiguration() |
|
34 | + { |
|
35 | + return $this->getSecurityManager()->configure()->asInternalPage(); |
|
36 | + } |
|
37 | + |
|
38 | + protected function main() |
|
39 | + { |
|
40 | + $this->processClose(); |
|
41 | + } |
|
42 | + |
|
43 | + /** |
|
44 | + * Main function for this page, when no specific actions are called. |
|
45 | + * @throws ApplicationLogicException |
|
46 | + */ |
|
47 | + final protected function processClose() |
|
48 | + { |
|
49 | + $this->checkPosted(); |
|
50 | + $database = $this->getDatabase(); |
|
51 | + |
|
52 | + $currentUser = User::getCurrent($database); |
|
53 | + $template = $this->getTemplate($database); |
|
54 | + $request = $this->getRequest($database); |
|
55 | + |
|
56 | + if ($request->getStatus() === 'Closed') { |
|
57 | + throw new ApplicationLogicException('Request is already closed'); |
|
58 | + } |
|
59 | + |
|
60 | + if ($this->confirmEmailAlreadySent($request, $template)) { |
|
61 | + return; |
|
62 | + } |
|
63 | + |
|
64 | + if ($this->confirmReserveOverride($request, $template, $currentUser, $database)) { |
|
65 | + return; |
|
66 | + } |
|
67 | + |
|
68 | + if ($this->confirmAccountCreated($request, $template)) { |
|
69 | + return; |
|
70 | + } |
|
71 | + |
|
72 | + // I think we're good here... |
|
73 | + $request->setStatus('Closed'); |
|
74 | + $request->setReserved(null); |
|
75 | + |
|
76 | + Logger::closeRequest($database, $request, $template->getId(), null); |
|
77 | + |
|
78 | + $request->setUpdateVersion(WebRequest::postInt('updateversion')); |
|
79 | + $request->save(); |
|
80 | + |
|
81 | + // Perform the notifications and stuff *after* we've successfully saved, since the save can throw an OLE and |
|
82 | + // be rolled back. |
|
83 | + |
|
84 | + $this->getNotificationHelper()->requestClosed($request, $template->getName()); |
|
85 | + SessionAlert::success("Request {$request->getId()} has been closed"); |
|
86 | + |
|
87 | + $this->sendMail($request, $template->getText(), $currentUser, false); |
|
88 | + |
|
89 | + $this->redirect(); |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * @param PdoDatabase $database |
|
94 | + * |
|
95 | + * @return EmailTemplate |
|
96 | + * @throws ApplicationLogicException |
|
97 | + */ |
|
98 | + protected function getTemplate(PdoDatabase $database) |
|
99 | + { |
|
100 | + $templateId = WebRequest::postInt('template'); |
|
101 | + if ($templateId === null) { |
|
102 | + throw new ApplicationLogicException('No template specified'); |
|
103 | + } |
|
104 | + |
|
105 | + /** @var EmailTemplate $template */ |
|
106 | + $template = EmailTemplate::getById($templateId, $database); |
|
107 | + if ($template === false || !$template->getActive()) { |
|
108 | + throw new ApplicationLogicException('Invalid or inactive template specified'); |
|
109 | + } |
|
110 | + |
|
111 | + return $template; |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * @param Request $request |
|
116 | + * @param EmailTemplate $template |
|
117 | + * |
|
118 | + * @return bool |
|
119 | + */ |
|
120 | + protected function confirmEmailAlreadySent(Request $request, EmailTemplate $template) |
|
121 | + { |
|
122 | + if ($this->checkEmailAlreadySent($request)) { |
|
123 | + $this->showConfirmation($request, $template, 'close-confirmations/email-sent.tpl'); |
|
124 | + |
|
125 | + return true; |
|
126 | + } |
|
127 | + |
|
128 | + return false; |
|
129 | + } |
|
130 | + |
|
131 | + protected function checkEmailAlreadySent(Request $request) |
|
132 | + { |
|
133 | + if ($request->getEmailSent() && !WebRequest::postBoolean('emailSentOverride')) { |
|
134 | + return true; |
|
135 | + } |
|
136 | + |
|
137 | + return false; |
|
138 | + } |
|
139 | + |
|
140 | + protected function checkReserveOverride(Request $request, User $currentUser) |
|
141 | + { |
|
142 | + $reservationId = $request->getReserved(); |
|
143 | + |
|
144 | + if ($reservationId !== 0 && $reservationId !== null) { |
|
145 | + if (!WebRequest::postBoolean('reserveOverride')) { |
|
146 | + if ($currentUser->getId() !== $reservationId) { |
|
147 | + return true; |
|
148 | + } |
|
149 | + } |
|
150 | + } |
|
151 | + |
|
152 | + return false; |
|
153 | + } |
|
154 | + |
|
155 | + /** |
|
156 | + * @param Request $request |
|
157 | + * @param EmailTemplate $template |
|
158 | + * @param User $currentUser |
|
159 | + * @param PdoDatabase $database |
|
160 | + * |
|
161 | + * @return bool |
|
162 | + */ |
|
163 | + protected function confirmReserveOverride( |
|
164 | + Request $request, |
|
165 | + EmailTemplate $template, |
|
166 | + User $currentUser, |
|
167 | + PdoDatabase $database |
|
168 | + ) { |
|
169 | + if ($this->checkReserveOverride($request, $currentUser)) { |
|
170 | + $this->assign('reserveUser', User::getById($request->getReserved(), $database)->getUsername()); |
|
171 | + $this->showConfirmation($request, $template, 'close-confirmations/reserve-override.tpl'); |
|
172 | + |
|
173 | + return true; |
|
174 | + } |
|
175 | + |
|
176 | + return false; |
|
177 | + } |
|
178 | + |
|
179 | + /** |
|
180 | + * @param Request $request |
|
181 | + * @param EmailTemplate $template |
|
182 | + * |
|
183 | + * @return bool |
|
184 | + * @throws \Waca\Exceptions\CurlException |
|
185 | + */ |
|
186 | + protected function confirmAccountCreated(Request $request, EmailTemplate $template) |
|
187 | + { |
|
188 | + if ($this->checkAccountCreated($request, $template)) { |
|
189 | + $this->showConfirmation($request, $template, 'close-confirmations/account-created.tpl'); |
|
190 | + |
|
191 | + return true; |
|
192 | + } |
|
193 | + |
|
194 | + return false; |
|
195 | + } |
|
196 | + |
|
197 | + protected function checkAccountCreated(Request $request, EmailTemplate $template) |
|
198 | + { |
|
199 | + if ($template->getDefaultAction() === EmailTemplate::CREATED && !WebRequest::postBoolean('createOverride')) { |
|
200 | + $parameters = array( |
|
201 | + 'action' => 'query', |
|
202 | + 'list' => 'users', |
|
203 | + 'format' => 'php', |
|
204 | + 'ususers' => $request->getName(), |
|
205 | + ); |
|
206 | + |
|
207 | + $content = $this->getHttpHelper()->get($this->getSiteConfiguration()->getMediawikiWebServiceEndpoint(), |
|
208 | + $parameters); |
|
209 | + |
|
210 | + $apiResult = unserialize($content); |
|
211 | + $exists = !isset($apiResult['query']['users']['0']['missing']); |
|
212 | + |
|
213 | + if (!$exists) { |
|
214 | + return true; |
|
215 | + } |
|
216 | + } |
|
217 | + |
|
218 | + return false; |
|
219 | + } |
|
220 | + |
|
221 | + /** |
|
222 | + * @param Request $request |
|
223 | + * @param string $mailText |
|
224 | + * @param User $currentUser |
|
225 | + * @param boolean $ccMailingList |
|
226 | + */ |
|
227 | + protected function sendMail(Request $request, $mailText, User $currentUser, $ccMailingList) |
|
228 | + { |
|
229 | + $headers = array( |
|
230 | + 'X-ACC-Request' => $request->getId(), |
|
231 | + 'X-ACC-UserID' => $currentUser->getId(), |
|
232 | + ); |
|
233 | + |
|
234 | + if ($ccMailingList) { |
|
235 | + $headers['Cc'] = '[email protected]'; |
|
236 | + } |
|
237 | + |
|
238 | + $helper = $this->getEmailHelper(); |
|
239 | + |
|
240 | + $emailSig = $currentUser->getEmailSig(); |
|
241 | + if ($emailSig !== '' || $emailSig !== null) { |
|
242 | + $emailSig = "\n\n" . $emailSig; |
|
243 | + } |
|
244 | + |
|
245 | + $subject = "RE: [ACC #{$request->getId()}] English Wikipedia Account Request"; |
|
246 | + $content = $mailText . $emailSig; |
|
247 | + |
|
248 | + $helper->sendMail($request->getEmail(), $subject, $content, $headers); |
|
249 | + |
|
250 | + $request->setEmailSent(true); |
|
251 | + } |
|
252 | + |
|
253 | + /** |
|
254 | + * @param Request $request |
|
255 | + * @param EmailTemplate $template |
|
256 | + * @param string $templateName |
|
257 | + * |
|
258 | + * @throws Exception |
|
259 | + * @return void |
|
260 | + */ |
|
261 | + protected function showConfirmation(Request $request, EmailTemplate $template, $templateName) |
|
262 | + { |
|
263 | + $this->assignCSRFToken(); |
|
264 | + |
|
265 | + $this->assign('request', $request->getId()); |
|
266 | + $this->assign('template', $template->getId()); |
|
267 | + |
|
268 | + $this->assign('emailSentOverride', WebRequest::postBoolean('emailSentOverride') ? 'true' : 'false'); |
|
269 | + $this->assign('reserveOverride', WebRequest::postBoolean('reserveOverride') ? 'true' : 'false'); |
|
270 | + $this->assign('createOverride', WebRequest::postBoolean('createOverride') ? 'true' : 'false'); |
|
271 | + |
|
272 | + $this->setTemplate($templateName); |
|
273 | + } |
|
274 | 274 | } |
275 | 275 | \ No newline at end of file |
@@ -239,11 +239,11 @@ |
||
239 | 239 | |
240 | 240 | $emailSig = $currentUser->getEmailSig(); |
241 | 241 | if ($emailSig !== '' || $emailSig !== null) { |
242 | - $emailSig = "\n\n" . $emailSig; |
|
242 | + $emailSig = "\n\n".$emailSig; |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | $subject = "RE: [ACC #{$request->getId()}] English Wikipedia Account Request"; |
246 | - $content = $mailText . $emailSig; |
|
246 | + $content = $mailText.$emailSig; |
|
247 | 247 | |
248 | 248 | $helper->sendMail($request->getEmail(), $subject, $content, $headers); |
249 | 249 |
@@ -18,68 +18,68 @@ |
||
18 | 18 | |
19 | 19 | class PageDeferRequest extends RequestActionBase |
20 | 20 | { |
21 | - /** |
|
22 | - * Sets up the security for this page. If certain actions have different permissions, this should be reflected in |
|
23 | - * the return value from this function. |
|
24 | - * |
|
25 | - * If this page even supports actions, you will need to check the route |
|
26 | - * |
|
27 | - * @return SecurityConfiguration |
|
28 | - * @category Security-Critical |
|
29 | - */ |
|
30 | - protected function getSecurityConfiguration() |
|
31 | - { |
|
32 | - return $this->getSecurityManager()->configure()->asInternalPage(); |
|
33 | - } |
|
21 | + /** |
|
22 | + * Sets up the security for this page. If certain actions have different permissions, this should be reflected in |
|
23 | + * the return value from this function. |
|
24 | + * |
|
25 | + * If this page even supports actions, you will need to check the route |
|
26 | + * |
|
27 | + * @return SecurityConfiguration |
|
28 | + * @category Security-Critical |
|
29 | + */ |
|
30 | + protected function getSecurityConfiguration() |
|
31 | + { |
|
32 | + return $this->getSecurityManager()->configure()->asInternalPage(); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Main function for this page, when no specific actions are called. |
|
37 | - * @throws ApplicationLogicException |
|
38 | - */ |
|
39 | - protected function main() |
|
40 | - { |
|
41 | - $this->checkPosted(); |
|
42 | - $database = $this->getDatabase(); |
|
43 | - $request = $this->getRequest($database); |
|
44 | - $currentUser = User::getCurrent($database); |
|
35 | + /** |
|
36 | + * Main function for this page, when no specific actions are called. |
|
37 | + * @throws ApplicationLogicException |
|
38 | + */ |
|
39 | + protected function main() |
|
40 | + { |
|
41 | + $this->checkPosted(); |
|
42 | + $database = $this->getDatabase(); |
|
43 | + $request = $this->getRequest($database); |
|
44 | + $currentUser = User::getCurrent($database); |
|
45 | 45 | |
46 | - $target = WebRequest::postString('target'); |
|
47 | - $requestStates = $this->getSiteConfiguration()->getRequestStates(); |
|
46 | + $target = WebRequest::postString('target'); |
|
47 | + $requestStates = $this->getSiteConfiguration()->getRequestStates(); |
|
48 | 48 | |
49 | - if (!array_key_exists($target, $requestStates)) { |
|
50 | - throw new ApplicationLogicException('Defer target not valid'); |
|
51 | - } |
|
49 | + if (!array_key_exists($target, $requestStates)) { |
|
50 | + throw new ApplicationLogicException('Defer target not valid'); |
|
51 | + } |
|
52 | 52 | |
53 | - if ($request->getStatus() == $target) { |
|
54 | - SessionAlert::warning('This request is already in the specified queue.'); |
|
55 | - $this->redirect('viewRequest', null, array('id' => $request->getId())); |
|
53 | + if ($request->getStatus() == $target) { |
|
54 | + SessionAlert::warning('This request is already in the specified queue.'); |
|
55 | + $this->redirect('viewRequest', null, array('id' => $request->getId())); |
|
56 | 56 | |
57 | - return; |
|
58 | - } |
|
57 | + return; |
|
58 | + } |
|
59 | 59 | |
60 | - $closureDate = $request->getClosureDate(); |
|
61 | - $date = new DateTime(); |
|
62 | - $date->modify("-7 days"); |
|
63 | - $oneweek = $date->format("Y-m-d H:i:s"); |
|
60 | + $closureDate = $request->getClosureDate(); |
|
61 | + $date = new DateTime(); |
|
62 | + $date->modify("-7 days"); |
|
63 | + $oneweek = $date->format("Y-m-d H:i:s"); |
|
64 | 64 | |
65 | - if ($request->getStatus() == "Closed" && $closureDate < $oneweek && !$currentUser->isAdmin()) { |
|
66 | - throw new ApplicationLogicException( |
|
67 | - "Only administrators and checkusers can reserve a request that has been closed for over a week."); |
|
68 | - } |
|
65 | + if ($request->getStatus() == "Closed" && $closureDate < $oneweek && !$currentUser->isAdmin()) { |
|
66 | + throw new ApplicationLogicException( |
|
67 | + "Only administrators and checkusers can reserve a request that has been closed for over a week."); |
|
68 | + } |
|
69 | 69 | |
70 | - $request->setReserved(null); |
|
71 | - $request->setStatus($target); |
|
72 | - $request->setUpdateVersion(WebRequest::postInt('updateversion')); |
|
73 | - $request->save(); |
|
70 | + $request->setReserved(null); |
|
71 | + $request->setStatus($target); |
|
72 | + $request->setUpdateVersion(WebRequest::postInt('updateversion')); |
|
73 | + $request->save(); |
|
74 | 74 | |
75 | - $deto = $requestStates[$target]['deferto']; |
|
76 | - $detolog = $requestStates[$target]['defertolog']; |
|
75 | + $deto = $requestStates[$target]['deferto']; |
|
76 | + $detolog = $requestStates[$target]['defertolog']; |
|
77 | 77 | |
78 | - Logger::deferRequest($database, $request, $detolog); |
|
78 | + Logger::deferRequest($database, $request, $detolog); |
|
79 | 79 | |
80 | - $this->getNotificationHelper()->requestDeferred($request); |
|
81 | - SessionAlert::success("Request {$request->getId()} deferred to {$deto}"); |
|
80 | + $this->getNotificationHelper()->requestDeferred($request); |
|
81 | + SessionAlert::success("Request {$request->getId()} deferred to {$deto}"); |
|
82 | 82 | |
83 | - $this->redirect(); |
|
84 | - } |
|
83 | + $this->redirect(); |
|
84 | + } |
|
85 | 85 | } |
86 | 86 | \ No newline at end of file |