@@ -13,30 +13,30 @@ |
||
13 | 13 | |
14 | 14 | class Page404 extends InternalPageBase |
15 | 15 | { |
16 | - /** |
|
17 | - * Main function for this page, when no actions are called. |
|
18 | - */ |
|
19 | - protected function main() |
|
20 | - { |
|
21 | - if (!headers_sent()) { |
|
22 | - header("HTTP/1.1 404 Not Found"); |
|
23 | - } |
|
16 | + /** |
|
17 | + * Main function for this page, when no actions are called. |
|
18 | + */ |
|
19 | + protected function main() |
|
20 | + { |
|
21 | + if (!headers_sent()) { |
|
22 | + header("HTTP/1.1 404 Not Found"); |
|
23 | + } |
|
24 | 24 | |
25 | - $this->setTemplate("404.tpl"); |
|
26 | - } |
|
25 | + $this->setTemplate("404.tpl"); |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * Sets up the security for this page. If certain actions have different permissions, this should be reflected in |
|
30 | - * the return value from this function. |
|
31 | - * |
|
32 | - * If this page even supports actions, you will need to check the route |
|
33 | - * |
|
34 | - * @return SecurityConfiguration |
|
35 | - * @category Security-Critical |
|
36 | - */ |
|
37 | - protected function getSecurityConfiguration() |
|
38 | - { |
|
39 | - // public because 404s will never contain private data. |
|
40 | - return $this->getSecurityManager()->configure()->asPublicPage(); |
|
41 | - } |
|
28 | + /** |
|
29 | + * Sets up the security for this page. If certain actions have different permissions, this should be reflected in |
|
30 | + * the return value from this function. |
|
31 | + * |
|
32 | + * If this page even supports actions, you will need to check the route |
|
33 | + * |
|
34 | + * @return SecurityConfiguration |
|
35 | + * @category Security-Critical |
|
36 | + */ |
|
37 | + protected function getSecurityConfiguration() |
|
38 | + { |
|
39 | + // public because 404s will never contain private data. |
|
40 | + return $this->getSecurityManager()->configure()->asPublicPage(); |
|
41 | + } |
|
42 | 42 | } |
43 | 43 | \ No newline at end of file |
@@ -18,158 +18,158 @@ |
||
18 | 18 | |
19 | 19 | class PageForgotPassword extends InternalPageBase |
20 | 20 | { |
21 | - /** |
|
22 | - * Main function for this page, when no specific actions are called. |
|
23 | - * |
|
24 | - * This is the forgotten password reset form |
|
25 | - * @category Security-Critical |
|
26 | - */ |
|
27 | - protected function main() |
|
28 | - { |
|
29 | - if (WebRequest::wasPosted()) { |
|
30 | - $this->validateCSRFToken(); |
|
31 | - $username = WebRequest::postString('username'); |
|
32 | - $email = WebRequest::postEmail('email'); |
|
33 | - $database = $this->getDatabase(); |
|
34 | - |
|
35 | - if ($username === null || trim($username) === "" || $email === null || trim($email) === "") { |
|
36 | - throw new ApplicationLogicException("Both username and email address must be specified!"); |
|
37 | - } |
|
38 | - |
|
39 | - $user = User::getByUsername($username, $database); |
|
40 | - $this->sendResetMail($user, $email); |
|
41 | - |
|
42 | - SessionAlert::success('<strong>Your password reset request has been completed.</strong> Please check your e-mail.'); |
|
43 | - |
|
44 | - $this->redirect('login'); |
|
45 | - } |
|
46 | - else { |
|
47 | - $this->assignCSRFToken(); |
|
48 | - $this->setTemplate('forgot-password/forgotpw.tpl'); |
|
49 | - } |
|
50 | - } |
|
51 | - |
|
52 | - /** |
|
53 | - * Sends a reset email if the user is authenticated |
|
54 | - * |
|
55 | - * @param User|boolean $user The user located from the database, or false. Doesn't really matter, since we do the |
|
56 | - * check anyway within this method and silently skip if we don't have a user. |
|
57 | - * @param string $email The provided email address |
|
58 | - */ |
|
59 | - private function sendResetMail($user, $email) |
|
60 | - { |
|
61 | - // If the user isn't found, or the email address is wrong, skip sending the details silently. |
|
62 | - if (!$user instanceof User) { |
|
63 | - return; |
|
64 | - } |
|
65 | - |
|
66 | - if (strtolower($user->getEmail()) === strtolower($email)) { |
|
67 | - $clientIp = $this->getXffTrustProvider() |
|
68 | - ->getTrustedClientIp(WebRequest::remoteAddress(), WebRequest::forwardedAddress()); |
|
69 | - |
|
70 | - $this->assign("user", $user); |
|
71 | - $this->assign("hash", $user->getForgottenPasswordHash()); |
|
72 | - $this->assign("remoteAddress", $clientIp); |
|
73 | - |
|
74 | - $emailContent = $this->fetchTemplate('forgot-password/reset-mail.tpl'); |
|
75 | - |
|
76 | - $this->getEmailHelper()->sendMail($user->getEmail(), "", $emailContent); |
|
77 | - } |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * Entry point for the reset action |
|
82 | - * |
|
83 | - * This is the reset password part of the form. |
|
84 | - * @category Security-Critical |
|
85 | - */ |
|
86 | - protected function reset() |
|
87 | - { |
|
88 | - $si = WebRequest::getString('si'); |
|
89 | - $id = WebRequest::getString('id'); |
|
90 | - |
|
91 | - if ($si === null || trim($si) === "" || $id === null || trim($id) === "") { |
|
92 | - throw new ApplicationLogicException("Link not valid, please ensure it has copied correctly"); |
|
93 | - } |
|
94 | - |
|
95 | - $database = $this->getDatabase(); |
|
96 | - $user = $this->getResettingUser($id, $database, $si); |
|
97 | - |
|
98 | - // Dual mode |
|
99 | - if (WebRequest::wasPosted()) { |
|
100 | - $this->validateCSRFToken(); |
|
101 | - try { |
|
102 | - $this->doReset($user); |
|
103 | - } |
|
104 | - catch (ApplicationLogicException $ex) { |
|
105 | - SessionAlert::error($ex->getMessage()); |
|
106 | - $this->redirect('forgotPassword', 'reset', array('si' => $si, 'id' => $id)); |
|
107 | - |
|
108 | - return; |
|
109 | - } |
|
110 | - } |
|
111 | - else { |
|
112 | - $this->assignCSRFToken(); |
|
113 | - $this->assign('user', $user); |
|
114 | - $this->setTemplate('forgot-password/forgotpwreset.tpl'); |
|
115 | - } |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * Gets the user resetting their password from the database, or throwing an exception if that is not possible. |
|
120 | - * |
|
121 | - * @param integer $id The ID of the user to retrieve |
|
122 | - * @param PdoDatabase $database The database object to use |
|
123 | - * @param string $si The reset hash provided |
|
124 | - * |
|
125 | - * @return User |
|
126 | - * @throws ApplicationLogicException |
|
127 | - */ |
|
128 | - private function getResettingUser($id, $database, $si) |
|
129 | - { |
|
130 | - $user = User::getById($id, $database); |
|
131 | - |
|
132 | - if ($user === false || $user->getForgottenPasswordHash() !== $si || $user->isCommunityUser()) { |
|
133 | - throw new ApplicationLogicException("User not found"); |
|
134 | - } |
|
135 | - |
|
136 | - return $user; |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * Performs the setting of the new password |
|
141 | - * |
|
142 | - * @param User $user The user to set the password for |
|
143 | - * |
|
144 | - * @throws ApplicationLogicException |
|
145 | - */ |
|
146 | - private function doReset(User $user) |
|
147 | - { |
|
148 | - $pw = WebRequest::postString('pw'); |
|
149 | - $pw2 = WebRequest::postString('pw2'); |
|
150 | - |
|
151 | - if ($pw !== $pw2) { |
|
152 | - throw new ApplicationLogicException('Passwords do not match!'); |
|
153 | - } |
|
154 | - |
|
155 | - $user->setPassword($pw); |
|
156 | - $user->save(); |
|
157 | - |
|
158 | - SessionAlert::success('You may now log in!'); |
|
159 | - $this->redirect('login'); |
|
160 | - } |
|
161 | - |
|
162 | - /** |
|
163 | - * Sets up the security for this page. If certain actions have different permissions, this should be reflected in |
|
164 | - * the return value from this function. |
|
165 | - * |
|
166 | - * If this page even supports actions, you will need to check the route |
|
167 | - * |
|
168 | - * @return SecurityConfiguration |
|
169 | - * @category Security-Critical |
|
170 | - */ |
|
171 | - protected function getSecurityConfiguration() |
|
172 | - { |
|
173 | - return $this->getSecurityManager()->configure()->asPublicPage(); |
|
174 | - } |
|
21 | + /** |
|
22 | + * Main function for this page, when no specific actions are called. |
|
23 | + * |
|
24 | + * This is the forgotten password reset form |
|
25 | + * @category Security-Critical |
|
26 | + */ |
|
27 | + protected function main() |
|
28 | + { |
|
29 | + if (WebRequest::wasPosted()) { |
|
30 | + $this->validateCSRFToken(); |
|
31 | + $username = WebRequest::postString('username'); |
|
32 | + $email = WebRequest::postEmail('email'); |
|
33 | + $database = $this->getDatabase(); |
|
34 | + |
|
35 | + if ($username === null || trim($username) === "" || $email === null || trim($email) === "") { |
|
36 | + throw new ApplicationLogicException("Both username and email address must be specified!"); |
|
37 | + } |
|
38 | + |
|
39 | + $user = User::getByUsername($username, $database); |
|
40 | + $this->sendResetMail($user, $email); |
|
41 | + |
|
42 | + SessionAlert::success('<strong>Your password reset request has been completed.</strong> Please check your e-mail.'); |
|
43 | + |
|
44 | + $this->redirect('login'); |
|
45 | + } |
|
46 | + else { |
|
47 | + $this->assignCSRFToken(); |
|
48 | + $this->setTemplate('forgot-password/forgotpw.tpl'); |
|
49 | + } |
|
50 | + } |
|
51 | + |
|
52 | + /** |
|
53 | + * Sends a reset email if the user is authenticated |
|
54 | + * |
|
55 | + * @param User|boolean $user The user located from the database, or false. Doesn't really matter, since we do the |
|
56 | + * check anyway within this method and silently skip if we don't have a user. |
|
57 | + * @param string $email The provided email address |
|
58 | + */ |
|
59 | + private function sendResetMail($user, $email) |
|
60 | + { |
|
61 | + // If the user isn't found, or the email address is wrong, skip sending the details silently. |
|
62 | + if (!$user instanceof User) { |
|
63 | + return; |
|
64 | + } |
|
65 | + |
|
66 | + if (strtolower($user->getEmail()) === strtolower($email)) { |
|
67 | + $clientIp = $this->getXffTrustProvider() |
|
68 | + ->getTrustedClientIp(WebRequest::remoteAddress(), WebRequest::forwardedAddress()); |
|
69 | + |
|
70 | + $this->assign("user", $user); |
|
71 | + $this->assign("hash", $user->getForgottenPasswordHash()); |
|
72 | + $this->assign("remoteAddress", $clientIp); |
|
73 | + |
|
74 | + $emailContent = $this->fetchTemplate('forgot-password/reset-mail.tpl'); |
|
75 | + |
|
76 | + $this->getEmailHelper()->sendMail($user->getEmail(), "", $emailContent); |
|
77 | + } |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * Entry point for the reset action |
|
82 | + * |
|
83 | + * This is the reset password part of the form. |
|
84 | + * @category Security-Critical |
|
85 | + */ |
|
86 | + protected function reset() |
|
87 | + { |
|
88 | + $si = WebRequest::getString('si'); |
|
89 | + $id = WebRequest::getString('id'); |
|
90 | + |
|
91 | + if ($si === null || trim($si) === "" || $id === null || trim($id) === "") { |
|
92 | + throw new ApplicationLogicException("Link not valid, please ensure it has copied correctly"); |
|
93 | + } |
|
94 | + |
|
95 | + $database = $this->getDatabase(); |
|
96 | + $user = $this->getResettingUser($id, $database, $si); |
|
97 | + |
|
98 | + // Dual mode |
|
99 | + if (WebRequest::wasPosted()) { |
|
100 | + $this->validateCSRFToken(); |
|
101 | + try { |
|
102 | + $this->doReset($user); |
|
103 | + } |
|
104 | + catch (ApplicationLogicException $ex) { |
|
105 | + SessionAlert::error($ex->getMessage()); |
|
106 | + $this->redirect('forgotPassword', 'reset', array('si' => $si, 'id' => $id)); |
|
107 | + |
|
108 | + return; |
|
109 | + } |
|
110 | + } |
|
111 | + else { |
|
112 | + $this->assignCSRFToken(); |
|
113 | + $this->assign('user', $user); |
|
114 | + $this->setTemplate('forgot-password/forgotpwreset.tpl'); |
|
115 | + } |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * Gets the user resetting their password from the database, or throwing an exception if that is not possible. |
|
120 | + * |
|
121 | + * @param integer $id The ID of the user to retrieve |
|
122 | + * @param PdoDatabase $database The database object to use |
|
123 | + * @param string $si The reset hash provided |
|
124 | + * |
|
125 | + * @return User |
|
126 | + * @throws ApplicationLogicException |
|
127 | + */ |
|
128 | + private function getResettingUser($id, $database, $si) |
|
129 | + { |
|
130 | + $user = User::getById($id, $database); |
|
131 | + |
|
132 | + if ($user === false || $user->getForgottenPasswordHash() !== $si || $user->isCommunityUser()) { |
|
133 | + throw new ApplicationLogicException("User not found"); |
|
134 | + } |
|
135 | + |
|
136 | + return $user; |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * Performs the setting of the new password |
|
141 | + * |
|
142 | + * @param User $user The user to set the password for |
|
143 | + * |
|
144 | + * @throws ApplicationLogicException |
|
145 | + */ |
|
146 | + private function doReset(User $user) |
|
147 | + { |
|
148 | + $pw = WebRequest::postString('pw'); |
|
149 | + $pw2 = WebRequest::postString('pw2'); |
|
150 | + |
|
151 | + if ($pw !== $pw2) { |
|
152 | + throw new ApplicationLogicException('Passwords do not match!'); |
|
153 | + } |
|
154 | + |
|
155 | + $user->setPassword($pw); |
|
156 | + $user->save(); |
|
157 | + |
|
158 | + SessionAlert::success('You may now log in!'); |
|
159 | + $this->redirect('login'); |
|
160 | + } |
|
161 | + |
|
162 | + /** |
|
163 | + * Sets up the security for this page. If certain actions have different permissions, this should be reflected in |
|
164 | + * the return value from this function. |
|
165 | + * |
|
166 | + * If this page even supports actions, you will need to check the route |
|
167 | + * |
|
168 | + * @return SecurityConfiguration |
|
169 | + * @category Security-Critical |
|
170 | + */ |
|
171 | + protected function getSecurityConfiguration() |
|
172 | + { |
|
173 | + return $this->getSecurityManager()->configure()->asPublicPage(); |
|
174 | + } |
|
175 | 175 | } |
176 | 176 | \ No newline at end of file |
@@ -21,86 +21,86 @@ |
||
21 | 21 | |
22 | 22 | class PageEditComment extends InternalPageBase |
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 | - switch ($this->getRouteName()) { |
|
36 | - case 'editOthers': |
|
37 | - return $this->getSecurityManager()->configure()->asAdminPage(); |
|
38 | - default: |
|
39 | - return $this->getSecurityManager()->configure()->asInternalPage(); |
|
40 | - } |
|
41 | - } |
|
42 | - |
|
43 | - /** |
|
44 | - * Main function for this page, when no specific actions are called. |
|
45 | - * @throws ApplicationLogicException |
|
46 | - */ |
|
47 | - protected function main() |
|
48 | - { |
|
49 | - $commentId = WebRequest::getInt('id'); |
|
50 | - if ($commentId === null) { |
|
51 | - throw new ApplicationLogicException('Comment ID not specified'); |
|
52 | - } |
|
53 | - |
|
54 | - $database = $this->getDatabase(); |
|
55 | - |
|
56 | - /** @var Comment $comment */ |
|
57 | - $comment = Comment::getById($commentId, $database); |
|
58 | - if ($comment === false) { |
|
59 | - throw new ApplicationLogicException('Comment not found'); |
|
60 | - } |
|
61 | - |
|
62 | - $currentUser = User::getCurrent($database); |
|
63 | - if ($comment->getUser() !== $currentUser->getId() && !$this->barrierTest('editOthers')) { |
|
64 | - throw new AccessDeniedException(); |
|
65 | - } |
|
66 | - |
|
67 | - /** @var Request $request */ |
|
68 | - $request = Request::getById($comment->getRequest(), $database); |
|
69 | - |
|
70 | - if ($request === false) { |
|
71 | - throw new ApplicationLogicException('Request was not found.'); |
|
72 | - } |
|
73 | - |
|
74 | - if (WebRequest::wasPosted()) { |
|
75 | - $this->validateCSRFToken(); |
|
76 | - $newComment = WebRequest::postString('newcomment'); |
|
77 | - $visibility = WebRequest::postString('visibility'); |
|
78 | - |
|
79 | - if ($visibility !== 'user' && $visibility !== 'admin') { |
|
80 | - throw new ApplicationLogicException('Comment visibility is not valid'); |
|
81 | - } |
|
82 | - |
|
83 | - // optimisticly lock from the load of the edit comment form |
|
84 | - $updateVersion = WebRequest::postInt('updateversion'); |
|
85 | - $comment->setUpdateVersion($updateVersion); |
|
86 | - |
|
87 | - $comment->setComment($newComment); |
|
88 | - $comment->setVisibility($visibility); |
|
89 | - |
|
90 | - $comment->save(); |
|
91 | - |
|
92 | - Logger::editComment($database, $comment, $request); |
|
93 | - $this->getNotificationHelper()->commentEdited($comment, $request); |
|
94 | - SessionAlert::success("Comment has been saved successfully"); |
|
95 | - |
|
96 | - $this->redirect('viewRequest', null, array('id' => $comment->getRequest())); |
|
97 | - } |
|
98 | - else { |
|
99 | - $this->assignCSRFToken(); |
|
100 | - $this->assign('comment', $comment); |
|
101 | - $this->assign('request', $request); |
|
102 | - $this->assign('user', User::getById($comment->getUser(), $database)); |
|
103 | - $this->setTemplate('edit-comment.tpl'); |
|
104 | - } |
|
105 | - } |
|
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 | + switch ($this->getRouteName()) { |
|
36 | + case 'editOthers': |
|
37 | + return $this->getSecurityManager()->configure()->asAdminPage(); |
|
38 | + default: |
|
39 | + return $this->getSecurityManager()->configure()->asInternalPage(); |
|
40 | + } |
|
41 | + } |
|
42 | + |
|
43 | + /** |
|
44 | + * Main function for this page, when no specific actions are called. |
|
45 | + * @throws ApplicationLogicException |
|
46 | + */ |
|
47 | + protected function main() |
|
48 | + { |
|
49 | + $commentId = WebRequest::getInt('id'); |
|
50 | + if ($commentId === null) { |
|
51 | + throw new ApplicationLogicException('Comment ID not specified'); |
|
52 | + } |
|
53 | + |
|
54 | + $database = $this->getDatabase(); |
|
55 | + |
|
56 | + /** @var Comment $comment */ |
|
57 | + $comment = Comment::getById($commentId, $database); |
|
58 | + if ($comment === false) { |
|
59 | + throw new ApplicationLogicException('Comment not found'); |
|
60 | + } |
|
61 | + |
|
62 | + $currentUser = User::getCurrent($database); |
|
63 | + if ($comment->getUser() !== $currentUser->getId() && !$this->barrierTest('editOthers')) { |
|
64 | + throw new AccessDeniedException(); |
|
65 | + } |
|
66 | + |
|
67 | + /** @var Request $request */ |
|
68 | + $request = Request::getById($comment->getRequest(), $database); |
|
69 | + |
|
70 | + if ($request === false) { |
|
71 | + throw new ApplicationLogicException('Request was not found.'); |
|
72 | + } |
|
73 | + |
|
74 | + if (WebRequest::wasPosted()) { |
|
75 | + $this->validateCSRFToken(); |
|
76 | + $newComment = WebRequest::postString('newcomment'); |
|
77 | + $visibility = WebRequest::postString('visibility'); |
|
78 | + |
|
79 | + if ($visibility !== 'user' && $visibility !== 'admin') { |
|
80 | + throw new ApplicationLogicException('Comment visibility is not valid'); |
|
81 | + } |
|
82 | + |
|
83 | + // optimisticly lock from the load of the edit comment form |
|
84 | + $updateVersion = WebRequest::postInt('updateversion'); |
|
85 | + $comment->setUpdateVersion($updateVersion); |
|
86 | + |
|
87 | + $comment->setComment($newComment); |
|
88 | + $comment->setVisibility($visibility); |
|
89 | + |
|
90 | + $comment->save(); |
|
91 | + |
|
92 | + Logger::editComment($database, $comment, $request); |
|
93 | + $this->getNotificationHelper()->commentEdited($comment, $request); |
|
94 | + SessionAlert::success("Comment has been saved successfully"); |
|
95 | + |
|
96 | + $this->redirect('viewRequest', null, array('id' => $comment->getRequest())); |
|
97 | + } |
|
98 | + else { |
|
99 | + $this->assignCSRFToken(); |
|
100 | + $this->assign('comment', $comment); |
|
101 | + $this->assign('request', $request); |
|
102 | + $this->assign('user', User::getById($comment->getUser(), $database)); |
|
103 | + $this->setTemplate('edit-comment.tpl'); |
|
104 | + } |
|
105 | + } |
|
106 | 106 | } |
107 | 107 | \ No newline at end of file |
@@ -16,71 +16,71 @@ discard block |
||
16 | 16 | |
17 | 17 | class PageMain extends InternalPageBase |
18 | 18 | { |
19 | - /** |
|
20 | - * Main function for this page, when no actions are called. |
|
21 | - */ |
|
22 | - protected function main() |
|
23 | - { |
|
24 | - $this->assignCSRFToken(); |
|
25 | - |
|
26 | - $config = $this->getSiteConfiguration(); |
|
27 | - |
|
28 | - $database = $this->getDatabase(); |
|
29 | - |
|
30 | - $requestSectionData = array(); |
|
31 | - |
|
32 | - if ($config->getEmailConfirmationEnabled()) { |
|
33 | - $query = "SELECT * FROM request WHERE status = :type AND emailconfirm = 'Confirmed' LIMIT :lim;"; |
|
34 | - $totalQuery = "SELECT COUNT(id) FROM request WHERE status = :type AND emailconfirm = 'Confirmed';"; |
|
35 | - } |
|
36 | - else { |
|
37 | - $query = "SELECT * FROM request WHERE status = :type LIMIT :lim;"; |
|
38 | - $totalQuery = "SELECT COUNT(id) FROM request WHERE status = :type;"; |
|
39 | - } |
|
40 | - |
|
41 | - $statement = $database->prepare($query); |
|
42 | - $statement->bindValue(':lim', $config->getMiserModeLimit(), PDO::PARAM_INT); |
|
43 | - |
|
44 | - $totalRequestsStatement = $database->prepare($totalQuery); |
|
45 | - |
|
46 | - $this->assign('defaultRequestState', $config->getDefaultRequestStateKey()); |
|
47 | - |
|
48 | - foreach ($config->getRequestStates() as $type => $v) { |
|
49 | - $statement->bindValue(":type", $type); |
|
50 | - $statement->execute(); |
|
51 | - |
|
52 | - $requests = $statement->fetchAll(PDO::FETCH_CLASS, Request::class); |
|
53 | - |
|
54 | - /** @var Request $req */ |
|
55 | - foreach ($requests as $req) { |
|
56 | - $req->setDatabase($database); |
|
57 | - } |
|
58 | - |
|
59 | - $totalRequestsStatement->bindValue(':type', $type); |
|
60 | - $totalRequestsStatement->execute(); |
|
61 | - $totalRequests = $totalRequestsStatement->fetchColumn(); |
|
62 | - $totalRequestsStatement->closeCursor(); |
|
63 | - |
|
64 | - $userIds = array_map( |
|
65 | - function(Request $entry) { |
|
66 | - return $entry->getReserved(); |
|
67 | - }, |
|
68 | - $requests); |
|
69 | - $userList = User::getUsernames($userIds, $this->getDatabase()); |
|
70 | - $this->assign('userlist', $userList); |
|
71 | - |
|
72 | - $requestSectionData[$v['header']] = array( |
|
73 | - 'requests' => $requests, |
|
74 | - 'total' => $totalRequests, |
|
75 | - 'api' => $v['api'], |
|
76 | - 'type' => $type, |
|
77 | - 'userlist' => $userList, |
|
78 | - ); |
|
79 | - } |
|
80 | - |
|
81 | - $this->assign('requestLimitShowOnly', $config->getMiserModeLimit()); |
|
82 | - |
|
83 | - $query = <<<SQL |
|
19 | + /** |
|
20 | + * Main function for this page, when no actions are called. |
|
21 | + */ |
|
22 | + protected function main() |
|
23 | + { |
|
24 | + $this->assignCSRFToken(); |
|
25 | + |
|
26 | + $config = $this->getSiteConfiguration(); |
|
27 | + |
|
28 | + $database = $this->getDatabase(); |
|
29 | + |
|
30 | + $requestSectionData = array(); |
|
31 | + |
|
32 | + if ($config->getEmailConfirmationEnabled()) { |
|
33 | + $query = "SELECT * FROM request WHERE status = :type AND emailconfirm = 'Confirmed' LIMIT :lim;"; |
|
34 | + $totalQuery = "SELECT COUNT(id) FROM request WHERE status = :type AND emailconfirm = 'Confirmed';"; |
|
35 | + } |
|
36 | + else { |
|
37 | + $query = "SELECT * FROM request WHERE status = :type LIMIT :lim;"; |
|
38 | + $totalQuery = "SELECT COUNT(id) FROM request WHERE status = :type;"; |
|
39 | + } |
|
40 | + |
|
41 | + $statement = $database->prepare($query); |
|
42 | + $statement->bindValue(':lim', $config->getMiserModeLimit(), PDO::PARAM_INT); |
|
43 | + |
|
44 | + $totalRequestsStatement = $database->prepare($totalQuery); |
|
45 | + |
|
46 | + $this->assign('defaultRequestState', $config->getDefaultRequestStateKey()); |
|
47 | + |
|
48 | + foreach ($config->getRequestStates() as $type => $v) { |
|
49 | + $statement->bindValue(":type", $type); |
|
50 | + $statement->execute(); |
|
51 | + |
|
52 | + $requests = $statement->fetchAll(PDO::FETCH_CLASS, Request::class); |
|
53 | + |
|
54 | + /** @var Request $req */ |
|
55 | + foreach ($requests as $req) { |
|
56 | + $req->setDatabase($database); |
|
57 | + } |
|
58 | + |
|
59 | + $totalRequestsStatement->bindValue(':type', $type); |
|
60 | + $totalRequestsStatement->execute(); |
|
61 | + $totalRequests = $totalRequestsStatement->fetchColumn(); |
|
62 | + $totalRequestsStatement->closeCursor(); |
|
63 | + |
|
64 | + $userIds = array_map( |
|
65 | + function(Request $entry) { |
|
66 | + return $entry->getReserved(); |
|
67 | + }, |
|
68 | + $requests); |
|
69 | + $userList = User::getUsernames($userIds, $this->getDatabase()); |
|
70 | + $this->assign('userlist', $userList); |
|
71 | + |
|
72 | + $requestSectionData[$v['header']] = array( |
|
73 | + 'requests' => $requests, |
|
74 | + 'total' => $totalRequests, |
|
75 | + 'api' => $v['api'], |
|
76 | + 'type' => $type, |
|
77 | + 'userlist' => $userList, |
|
78 | + ); |
|
79 | + } |
|
80 | + |
|
81 | + $this->assign('requestLimitShowOnly', $config->getMiserModeLimit()); |
|
82 | + |
|
83 | + $query = <<<SQL |
|
84 | 84 | SELECT request.id, request.name, request.updateversion |
85 | 85 | FROM request /* PageMain::main() */ |
86 | 86 | JOIN log ON log.objectid = request.id AND log.objecttype = 'Request' |
@@ -89,28 +89,28 @@ discard block |
||
89 | 89 | LIMIT 5; |
90 | 90 | SQL; |
91 | 91 | |
92 | - $statement = $database->prepare($query); |
|
93 | - $statement->execute(); |
|
94 | - |
|
95 | - $last5result = $statement->fetchAll(PDO::FETCH_ASSOC); |
|
96 | - |
|
97 | - $this->assign('lastFive', $last5result); |
|
98 | - $this->assign('requestSectionData', $requestSectionData); |
|
99 | - |
|
100 | - $this->setTemplate('mainpage/mainpage.tpl'); |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * Sets up the security for this page. If certain actions have different permissions, this should be reflected in |
|
105 | - * the return value from this function. |
|
106 | - * |
|
107 | - * If this page even supports actions, you will need to check the route |
|
108 | - * |
|
109 | - * @return SecurityConfiguration |
|
110 | - * @category Security-Critical |
|
111 | - */ |
|
112 | - protected function getSecurityConfiguration() |
|
113 | - { |
|
114 | - return $this->getSecurityManager()->configure()->asInternalPage(); |
|
115 | - } |
|
92 | + $statement = $database->prepare($query); |
|
93 | + $statement->execute(); |
|
94 | + |
|
95 | + $last5result = $statement->fetchAll(PDO::FETCH_ASSOC); |
|
96 | + |
|
97 | + $this->assign('lastFive', $last5result); |
|
98 | + $this->assign('requestSectionData', $requestSectionData); |
|
99 | + |
|
100 | + $this->setTemplate('mainpage/mainpage.tpl'); |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * Sets up the security for this page. If certain actions have different permissions, this should be reflected in |
|
105 | + * the return value from this function. |
|
106 | + * |
|
107 | + * If this page even supports actions, you will need to check the route |
|
108 | + * |
|
109 | + * @return SecurityConfiguration |
|
110 | + * @category Security-Critical |
|
111 | + */ |
|
112 | + protected function getSecurityConfiguration() |
|
113 | + { |
|
114 | + return $this->getSecurityManager()->configure()->asInternalPage(); |
|
115 | + } |
|
116 | 116 | } |
117 | 117 | \ No newline at end of file |
@@ -17,153 +17,153 @@ |
||
17 | 17 | |
18 | 18 | class PageOAuth extends InternalPageBase |
19 | 19 | { |
20 | - /** |
|
21 | - * Attach entry point |
|
22 | - * |
|
23 | - * must be posted, or will redirect to preferences |
|
24 | - */ |
|
25 | - protected function attach() |
|
26 | - { |
|
27 | - if (!WebRequest::wasPosted()) { |
|
28 | - $this->redirect('preferences'); |
|
29 | - |
|
30 | - return; |
|
31 | - } |
|
32 | - |
|
33 | - $this->validateCSRFToken(); |
|
34 | - |
|
35 | - $oauthHelper = $this->getOAuthHelper(); |
|
36 | - $user = User::getCurrent($this->getDatabase()); |
|
37 | - |
|
38 | - $requestToken = $oauthHelper->getRequestToken(); |
|
39 | - |
|
40 | - $user->setOAuthRequestToken($requestToken->key); |
|
41 | - $user->setOAuthRequestSecret($requestToken->secret); |
|
42 | - $user->save(); |
|
43 | - |
|
44 | - $this->redirectUrl($oauthHelper->getAuthoriseUrl($requestToken->key)); |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * Detach account entry point |
|
49 | - */ |
|
50 | - protected function detach() |
|
51 | - { |
|
52 | - $user = User::getCurrent($this->getDatabase()); |
|
53 | - |
|
54 | - $user->setOnWikiName($user->getOnWikiName()); |
|
55 | - $user->setOAuthAccessSecret(null); |
|
56 | - $user->setOAuthAccessToken(null); |
|
57 | - $user->setOAuthRequestSecret(null); |
|
58 | - $user->setOAuthRequestToken(null); |
|
59 | - |
|
60 | - $user->clearOAuthData(); |
|
61 | - |
|
62 | - $user->setForcelogout(true); |
|
63 | - |
|
64 | - $user->save(); |
|
65 | - |
|
66 | - // force the user to log out |
|
67 | - Session::destroy(); |
|
68 | - |
|
69 | - $this->redirect('login'); |
|
70 | - } |
|
71 | - |
|
72 | - /** |
|
73 | - * Callback entry point |
|
74 | - */ |
|
75 | - protected function callback() |
|
76 | - { |
|
77 | - $oauthToken = WebRequest::getString('oauth_token'); |
|
78 | - $oauthVerifier = WebRequest::getString('oauth_verifier'); |
|
79 | - |
|
80 | - $this->doCallbackValidation($oauthToken, $oauthVerifier); |
|
81 | - |
|
82 | - $user = User::getByRequestToken($oauthToken, $this->getDatabase()); |
|
83 | - if ($user === false) { |
|
84 | - throw new ApplicationLogicException('Token not found in store, please try again'); |
|
85 | - } |
|
86 | - |
|
87 | - $accessToken = $this->getOAuthHelper()->callbackCompleted( |
|
88 | - $user->getOAuthRequestToken(), |
|
89 | - $user->getOAuthRequestSecret(), |
|
90 | - $oauthVerifier); |
|
91 | - |
|
92 | - $user->setOAuthRequestSecret(null); |
|
93 | - $user->setOAuthRequestToken(null); |
|
94 | - $user->setOAuthAccessToken($accessToken->key); |
|
95 | - $user->setOAuthAccessSecret($accessToken->secret); |
|
96 | - |
|
97 | - // @todo we really should stop doing this kind of thing... it adds performance bottlenecks and breaks 3NF |
|
98 | - $user->setOnWikiName('##OAUTH##'); |
|
99 | - |
|
100 | - $user->save(); |
|
101 | - |
|
102 | - // OK, we're the same session that just did a partial login that was redirected to OAuth. Let's upgrade the |
|
103 | - // login to a full login |
|
104 | - if (WebRequest::getPartialLogin() === $user->getId()) { |
|
105 | - WebRequest::setLoggedInUser($user); |
|
106 | - } |
|
107 | - |
|
108 | - // My thinking is there are three cases here: |
|
109 | - // a) new user => redirect to prefs - it's the only thing they can access other than stats |
|
110 | - // b) existing user hit the connect button in prefs => redirect to prefs since it's where they were |
|
111 | - // c) existing user logging in => redirect to wherever they came from |
|
112 | - $redirectDestination = WebRequest::clearPostLoginRedirect(); |
|
113 | - if ($redirectDestination !== null && !$user->isNewUser()) { |
|
114 | - $this->redirectUrl($redirectDestination); |
|
115 | - } |
|
116 | - else { |
|
117 | - $this->redirect('preferences', null, null, 'internal.php'); |
|
118 | - } |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * Sets up the security for this page. If certain actions have different permissions, this should be reflected in |
|
123 | - * the return value from this function. |
|
124 | - * |
|
125 | - * If this page even supports actions, you will need to check the route |
|
126 | - * |
|
127 | - * @return SecurityConfiguration |
|
128 | - * @category Security-Critical |
|
129 | - */ |
|
130 | - protected function getSecurityConfiguration() |
|
131 | - { |
|
132 | - if ($this->getRouteName() === 'callback') { |
|
133 | - return $this->getSecurityManager()->configure()->asPublicPage(); |
|
134 | - } |
|
135 | - |
|
136 | - if ($this->getRouteName() === 'detach' && $this->getSiteConfiguration()->getEnforceOAuth()) { |
|
137 | - // Deny detach when this OAuth is enforced. |
|
138 | - return $this->getSecurityManager()->configure()->asNone(); |
|
139 | - } |
|
140 | - |
|
141 | - return $this->getSecurityManager()->configure()->asAllLoggedInUsersPage(); |
|
142 | - } |
|
143 | - |
|
144 | - /** |
|
145 | - * Main function for this page, when no specific actions are called. |
|
146 | - * @return void |
|
147 | - */ |
|
148 | - protected function main() |
|
149 | - { |
|
150 | - $this->redirect('preferences'); |
|
151 | - } |
|
152 | - |
|
153 | - /** |
|
154 | - * @param string $oauthToken |
|
155 | - * @param string $oauthVerifier |
|
156 | - * |
|
157 | - * @throws ApplicationLogicException |
|
158 | - */ |
|
159 | - protected function doCallbackValidation($oauthToken, $oauthVerifier) |
|
160 | - { |
|
161 | - if ($oauthToken === null) { |
|
162 | - throw new ApplicationLogicException('No token provided'); |
|
163 | - } |
|
164 | - |
|
165 | - if ($oauthVerifier === null) { |
|
166 | - throw new ApplicationLogicException('No oauth verifier provided.'); |
|
167 | - } |
|
168 | - } |
|
20 | + /** |
|
21 | + * Attach entry point |
|
22 | + * |
|
23 | + * must be posted, or will redirect to preferences |
|
24 | + */ |
|
25 | + protected function attach() |
|
26 | + { |
|
27 | + if (!WebRequest::wasPosted()) { |
|
28 | + $this->redirect('preferences'); |
|
29 | + |
|
30 | + return; |
|
31 | + } |
|
32 | + |
|
33 | + $this->validateCSRFToken(); |
|
34 | + |
|
35 | + $oauthHelper = $this->getOAuthHelper(); |
|
36 | + $user = User::getCurrent($this->getDatabase()); |
|
37 | + |
|
38 | + $requestToken = $oauthHelper->getRequestToken(); |
|
39 | + |
|
40 | + $user->setOAuthRequestToken($requestToken->key); |
|
41 | + $user->setOAuthRequestSecret($requestToken->secret); |
|
42 | + $user->save(); |
|
43 | + |
|
44 | + $this->redirectUrl($oauthHelper->getAuthoriseUrl($requestToken->key)); |
|
45 | + } |
|
46 | + |
|
47 | + /** |
|
48 | + * Detach account entry point |
|
49 | + */ |
|
50 | + protected function detach() |
|
51 | + { |
|
52 | + $user = User::getCurrent($this->getDatabase()); |
|
53 | + |
|
54 | + $user->setOnWikiName($user->getOnWikiName()); |
|
55 | + $user->setOAuthAccessSecret(null); |
|
56 | + $user->setOAuthAccessToken(null); |
|
57 | + $user->setOAuthRequestSecret(null); |
|
58 | + $user->setOAuthRequestToken(null); |
|
59 | + |
|
60 | + $user->clearOAuthData(); |
|
61 | + |
|
62 | + $user->setForcelogout(true); |
|
63 | + |
|
64 | + $user->save(); |
|
65 | + |
|
66 | + // force the user to log out |
|
67 | + Session::destroy(); |
|
68 | + |
|
69 | + $this->redirect('login'); |
|
70 | + } |
|
71 | + |
|
72 | + /** |
|
73 | + * Callback entry point |
|
74 | + */ |
|
75 | + protected function callback() |
|
76 | + { |
|
77 | + $oauthToken = WebRequest::getString('oauth_token'); |
|
78 | + $oauthVerifier = WebRequest::getString('oauth_verifier'); |
|
79 | + |
|
80 | + $this->doCallbackValidation($oauthToken, $oauthVerifier); |
|
81 | + |
|
82 | + $user = User::getByRequestToken($oauthToken, $this->getDatabase()); |
|
83 | + if ($user === false) { |
|
84 | + throw new ApplicationLogicException('Token not found in store, please try again'); |
|
85 | + } |
|
86 | + |
|
87 | + $accessToken = $this->getOAuthHelper()->callbackCompleted( |
|
88 | + $user->getOAuthRequestToken(), |
|
89 | + $user->getOAuthRequestSecret(), |
|
90 | + $oauthVerifier); |
|
91 | + |
|
92 | + $user->setOAuthRequestSecret(null); |
|
93 | + $user->setOAuthRequestToken(null); |
|
94 | + $user->setOAuthAccessToken($accessToken->key); |
|
95 | + $user->setOAuthAccessSecret($accessToken->secret); |
|
96 | + |
|
97 | + // @todo we really should stop doing this kind of thing... it adds performance bottlenecks and breaks 3NF |
|
98 | + $user->setOnWikiName('##OAUTH##'); |
|
99 | + |
|
100 | + $user->save(); |
|
101 | + |
|
102 | + // OK, we're the same session that just did a partial login that was redirected to OAuth. Let's upgrade the |
|
103 | + // login to a full login |
|
104 | + if (WebRequest::getPartialLogin() === $user->getId()) { |
|
105 | + WebRequest::setLoggedInUser($user); |
|
106 | + } |
|
107 | + |
|
108 | + // My thinking is there are three cases here: |
|
109 | + // a) new user => redirect to prefs - it's the only thing they can access other than stats |
|
110 | + // b) existing user hit the connect button in prefs => redirect to prefs since it's where they were |
|
111 | + // c) existing user logging in => redirect to wherever they came from |
|
112 | + $redirectDestination = WebRequest::clearPostLoginRedirect(); |
|
113 | + if ($redirectDestination !== null && !$user->isNewUser()) { |
|
114 | + $this->redirectUrl($redirectDestination); |
|
115 | + } |
|
116 | + else { |
|
117 | + $this->redirect('preferences', null, null, 'internal.php'); |
|
118 | + } |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * Sets up the security for this page. If certain actions have different permissions, this should be reflected in |
|
123 | + * the return value from this function. |
|
124 | + * |
|
125 | + * If this page even supports actions, you will need to check the route |
|
126 | + * |
|
127 | + * @return SecurityConfiguration |
|
128 | + * @category Security-Critical |
|
129 | + */ |
|
130 | + protected function getSecurityConfiguration() |
|
131 | + { |
|
132 | + if ($this->getRouteName() === 'callback') { |
|
133 | + return $this->getSecurityManager()->configure()->asPublicPage(); |
|
134 | + } |
|
135 | + |
|
136 | + if ($this->getRouteName() === 'detach' && $this->getSiteConfiguration()->getEnforceOAuth()) { |
|
137 | + // Deny detach when this OAuth is enforced. |
|
138 | + return $this->getSecurityManager()->configure()->asNone(); |
|
139 | + } |
|
140 | + |
|
141 | + return $this->getSecurityManager()->configure()->asAllLoggedInUsersPage(); |
|
142 | + } |
|
143 | + |
|
144 | + /** |
|
145 | + * Main function for this page, when no specific actions are called. |
|
146 | + * @return void |
|
147 | + */ |
|
148 | + protected function main() |
|
149 | + { |
|
150 | + $this->redirect('preferences'); |
|
151 | + } |
|
152 | + |
|
153 | + /** |
|
154 | + * @param string $oauthToken |
|
155 | + * @param string $oauthVerifier |
|
156 | + * |
|
157 | + * @throws ApplicationLogicException |
|
158 | + */ |
|
159 | + protected function doCallbackValidation($oauthToken, $oauthVerifier) |
|
160 | + { |
|
161 | + if ($oauthToken === null) { |
|
162 | + throw new ApplicationLogicException('No token provided'); |
|
163 | + } |
|
164 | + |
|
165 | + if ($oauthVerifier === null) { |
|
166 | + throw new ApplicationLogicException('No oauth verifier provided.'); |
|
167 | + } |
|
168 | + } |
|
169 | 169 | } |
170 | 170 | \ No newline at end of file |
@@ -20,245 +20,245 @@ |
||
20 | 20 | |
21 | 21 | class PageWelcomeTemplateManagement extends InternalPageBase |
22 | 22 | { |
23 | - /** |
|
24 | - * Main function for this page, when no specific actions are called. |
|
25 | - * @return void |
|
26 | - */ |
|
27 | - protected function main() |
|
28 | - { |
|
29 | - $templateList = WelcomeTemplate::getAll($this->getDatabase()); |
|
30 | - |
|
31 | - $this->assignCSRFToken(); |
|
23 | + /** |
|
24 | + * Main function for this page, when no specific actions are called. |
|
25 | + * @return void |
|
26 | + */ |
|
27 | + protected function main() |
|
28 | + { |
|
29 | + $templateList = WelcomeTemplate::getAll($this->getDatabase()); |
|
30 | + |
|
31 | + $this->assignCSRFToken(); |
|
32 | 32 | |
33 | - $this->assign('templateList', $templateList); |
|
34 | - $this->setTemplate('welcome-template/list.tpl'); |
|
35 | - } |
|
33 | + $this->assign('templateList', $templateList); |
|
34 | + $this->setTemplate('welcome-template/list.tpl'); |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * Handles the requests for selecting a template to use. |
|
39 | - * |
|
40 | - * @throws ApplicationLogicException |
|
41 | - */ |
|
42 | - protected function select() |
|
43 | - { |
|
44 | - // get rid of GETs |
|
45 | - if (!WebRequest::wasPosted()) { |
|
46 | - $this->redirect('welcomeTemplates'); |
|
47 | - } |
|
48 | - |
|
49 | - $this->validateCSRFToken(); |
|
50 | - |
|
51 | - $user = User::getCurrent($this->getDatabase()); |
|
52 | - |
|
53 | - if (WebRequest::postBoolean('disable')) { |
|
54 | - $user->setWelcomeTemplate(null); |
|
55 | - $user->save(); |
|
56 | - |
|
57 | - SessionAlert::success('Disabled automatic user welcoming.'); |
|
58 | - $this->redirect('welcomeTemplates'); |
|
59 | - |
|
60 | - return; |
|
61 | - } |
|
62 | - |
|
63 | - $database = $this->getDatabase(); |
|
37 | + /** |
|
38 | + * Handles the requests for selecting a template to use. |
|
39 | + * |
|
40 | + * @throws ApplicationLogicException |
|
41 | + */ |
|
42 | + protected function select() |
|
43 | + { |
|
44 | + // get rid of GETs |
|
45 | + if (!WebRequest::wasPosted()) { |
|
46 | + $this->redirect('welcomeTemplates'); |
|
47 | + } |
|
48 | + |
|
49 | + $this->validateCSRFToken(); |
|
50 | + |
|
51 | + $user = User::getCurrent($this->getDatabase()); |
|
52 | + |
|
53 | + if (WebRequest::postBoolean('disable')) { |
|
54 | + $user->setWelcomeTemplate(null); |
|
55 | + $user->save(); |
|
56 | + |
|
57 | + SessionAlert::success('Disabled automatic user welcoming.'); |
|
58 | + $this->redirect('welcomeTemplates'); |
|
59 | + |
|
60 | + return; |
|
61 | + } |
|
62 | + |
|
63 | + $database = $this->getDatabase(); |
|
64 | 64 | |
65 | - $templateId = WebRequest::postInt('template'); |
|
66 | - /** @var false|WelcomeTemplate $template */ |
|
67 | - $template = WelcomeTemplate::getById($templateId, $database); |
|
65 | + $templateId = WebRequest::postInt('template'); |
|
66 | + /** @var false|WelcomeTemplate $template */ |
|
67 | + $template = WelcomeTemplate::getById($templateId, $database); |
|
68 | 68 | |
69 | - if ($template === false || $template->isDeleted()) { |
|
70 | - throw new ApplicationLogicException('Unknown template'); |
|
71 | - } |
|
69 | + if ($template === false || $template->isDeleted()) { |
|
70 | + throw new ApplicationLogicException('Unknown template'); |
|
71 | + } |
|
72 | 72 | |
73 | - $user->setWelcomeTemplate($template->getId()); |
|
74 | - $user->save(); |
|
73 | + $user->setWelcomeTemplate($template->getId()); |
|
74 | + $user->save(); |
|
75 | 75 | |
76 | - SessionAlert::success("Updated selected welcome template for automatic welcoming."); |
|
76 | + SessionAlert::success("Updated selected welcome template for automatic welcoming."); |
|
77 | 77 | |
78 | - $this->redirect('welcomeTemplates'); |
|
79 | - } |
|
78 | + $this->redirect('welcomeTemplates'); |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * Handles the requests for viewing a template. |
|
83 | - * |
|
84 | - * @throws ApplicationLogicException |
|
85 | - */ |
|
86 | - protected function view() |
|
87 | - { |
|
88 | - $database = $this->getDatabase(); |
|
81 | + /** |
|
82 | + * Handles the requests for viewing a template. |
|
83 | + * |
|
84 | + * @throws ApplicationLogicException |
|
85 | + */ |
|
86 | + protected function view() |
|
87 | + { |
|
88 | + $database = $this->getDatabase(); |
|
89 | 89 | |
90 | - $templateId = WebRequest::getInt('template'); |
|
90 | + $templateId = WebRequest::getInt('template'); |
|
91 | 91 | |
92 | - /** @var WelcomeTemplate $template */ |
|
93 | - $template = WelcomeTemplate::getById($templateId, $database); |
|
92 | + /** @var WelcomeTemplate $template */ |
|
93 | + $template = WelcomeTemplate::getById($templateId, $database); |
|
94 | 94 | |
95 | - if ($template === false) { |
|
96 | - throw new ApplicationLogicException('Cannot find requested template'); |
|
97 | - } |
|
95 | + if ($template === false) { |
|
96 | + throw new ApplicationLogicException('Cannot find requested template'); |
|
97 | + } |
|
98 | 98 | |
99 | - $templateHtml = $this->getWikiTextHelper()->getHtmlForWikiText($template->getBotCode()); |
|
99 | + $templateHtml = $this->getWikiTextHelper()->getHtmlForWikiText($template->getBotCode()); |
|
100 | 100 | |
101 | - $this->assign('templateHtml', $templateHtml); |
|
102 | - $this->assign('template', $template); |
|
103 | - $this->setTemplate('welcome-template/view.tpl'); |
|
104 | - } |
|
101 | + $this->assign('templateHtml', $templateHtml); |
|
102 | + $this->assign('template', $template); |
|
103 | + $this->setTemplate('welcome-template/view.tpl'); |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * Handler for the add action to create a new welcome template |
|
108 | - * |
|
109 | - * @throws Exception |
|
110 | - */ |
|
111 | - protected function add() |
|
112 | - { |
|
113 | - if (WebRequest::wasPosted()) { |
|
114 | - $this->validateCSRFToken(); |
|
115 | - $database = $this->getDatabase(); |
|
106 | + /** |
|
107 | + * Handler for the add action to create a new welcome template |
|
108 | + * |
|
109 | + * @throws Exception |
|
110 | + */ |
|
111 | + protected function add() |
|
112 | + { |
|
113 | + if (WebRequest::wasPosted()) { |
|
114 | + $this->validateCSRFToken(); |
|
115 | + $database = $this->getDatabase(); |
|
116 | 116 | |
117 | - $userCode = WebRequest::postString('usercode'); |
|
118 | - $botCode = WebRequest::postString('botcode'); |
|
117 | + $userCode = WebRequest::postString('usercode'); |
|
118 | + $botCode = WebRequest::postString('botcode'); |
|
119 | 119 | |
120 | - $this->validate($userCode, $botCode); |
|
120 | + $this->validate($userCode, $botCode); |
|
121 | 121 | |
122 | - $template = new WelcomeTemplate(); |
|
123 | - $template->setDatabase($database); |
|
124 | - $template->setUserCode($userCode); |
|
125 | - $template->setBotCode($botCode); |
|
126 | - $template->save(); |
|
122 | + $template = new WelcomeTemplate(); |
|
123 | + $template->setDatabase($database); |
|
124 | + $template->setUserCode($userCode); |
|
125 | + $template->setBotCode($botCode); |
|
126 | + $template->save(); |
|
127 | 127 | |
128 | - Logger::welcomeTemplateCreated($database, $template); |
|
128 | + Logger::welcomeTemplateCreated($database, $template); |
|
129 | 129 | |
130 | - $this->getNotificationHelper()->welcomeTemplateCreated($template); |
|
130 | + $this->getNotificationHelper()->welcomeTemplateCreated($template); |
|
131 | 131 | |
132 | - SessionAlert::success("Template successfully created."); |
|
132 | + SessionAlert::success("Template successfully created."); |
|
133 | 133 | |
134 | - $this->redirect('welcomeTemplates'); |
|
135 | - } |
|
136 | - else { |
|
137 | - $this->assignCSRFToken(); |
|
138 | - $this->setTemplate("welcome-template/add.tpl"); |
|
139 | - } |
|
140 | - } |
|
134 | + $this->redirect('welcomeTemplates'); |
|
135 | + } |
|
136 | + else { |
|
137 | + $this->assignCSRFToken(); |
|
138 | + $this->setTemplate("welcome-template/add.tpl"); |
|
139 | + } |
|
140 | + } |
|
141 | 141 | |
142 | - /** |
|
143 | - * Hander for editing templates |
|
144 | - */ |
|
145 | - protected function edit() |
|
146 | - { |
|
147 | - $database = $this->getDatabase(); |
|
142 | + /** |
|
143 | + * Hander for editing templates |
|
144 | + */ |
|
145 | + protected function edit() |
|
146 | + { |
|
147 | + $database = $this->getDatabase(); |
|
148 | 148 | |
149 | - $templateId = WebRequest::getInt('template'); |
|
149 | + $templateId = WebRequest::getInt('template'); |
|
150 | 150 | |
151 | - /** @var WelcomeTemplate $template */ |
|
152 | - $template = WelcomeTemplate::getById($templateId, $database); |
|
153 | - |
|
154 | - if ($template === false) { |
|
155 | - throw new ApplicationLogicException('Cannot find requested template'); |
|
156 | - } |
|
157 | - |
|
158 | - if ($template->isDeleted()) { |
|
159 | - throw new ApplicationLogicException('The specified template has been deleted'); |
|
160 | - } |
|
161 | - |
|
162 | - if (WebRequest::wasPosted()) { |
|
163 | - $this->validateCSRFToken(); |
|
164 | - |
|
165 | - $userCode = WebRequest::postString('usercode'); |
|
166 | - $botCode = WebRequest::postString('botcode'); |
|
167 | - |
|
168 | - $this->validate($userCode, $botCode); |
|
169 | - |
|
170 | - $template->setUserCode($userCode); |
|
171 | - $template->setBotCode($botCode); |
|
172 | - $template->setUpdateVersion(WebRequest::postInt('updateversion')); |
|
173 | - $template->save(); |
|
174 | - |
|
175 | - Logger::welcomeTemplateEdited($database, $template); |
|
176 | - |
|
177 | - SessionAlert::success("Template updated."); |
|
178 | - |
|
179 | - $this->getNotificationHelper()->welcomeTemplateEdited($template); |
|
180 | - |
|
181 | - $this->redirect('welcomeTemplates'); |
|
182 | - } |
|
183 | - else { |
|
184 | - $this->assignCSRFToken(); |
|
185 | - $this->assign('template', $template); |
|
186 | - $this->setTemplate('welcome-template/edit.tpl'); |
|
187 | - } |
|
188 | - } |
|
189 | - |
|
190 | - protected function delete() |
|
191 | - { |
|
192 | - $this->redirect('welcomeTemplates'); |
|
193 | - |
|
194 | - if (!WebRequest::wasPosted()) { |
|
195 | - return; |
|
196 | - } |
|
197 | - |
|
198 | - $this->validateCSRFToken(); |
|
199 | - |
|
200 | - $database = $this->getDatabase(); |
|
201 | - |
|
202 | - $templateId = WebRequest::postInt('template'); |
|
203 | - $updateVersion = WebRequest::postInt('updateversion'); |
|
204 | - |
|
205 | - /** @var WelcomeTemplate $template */ |
|
206 | - $template = WelcomeTemplate::getById($templateId, $database); |
|
207 | - |
|
208 | - if ($template === false || $template->isDeleted()) { |
|
209 | - throw new ApplicationLogicException('Cannot find requested template'); |
|
210 | - } |
|
211 | - |
|
212 | - // set the update version to the version sent by the client (optimisticly lock from initial page load) |
|
213 | - $template->setUpdateVersion($updateVersion); |
|
214 | - |
|
215 | - $database |
|
216 | - ->prepare("UPDATE user SET welcome_template = NULL WHERE welcome_template = :id;") |
|
217 | - ->execute(array(":id" => $templateId)); |
|
218 | - |
|
219 | - Logger::welcomeTemplateDeleted($database, $template); |
|
220 | - |
|
221 | - $template->delete(); |
|
222 | - |
|
223 | - SessionAlert::success( |
|
224 | - "Template deleted. Any users who were using this template have had automatic welcoming disabled."); |
|
225 | - $this->getNotificationHelper()->welcomeTemplateDeleted($templateId); |
|
226 | - } |
|
227 | - |
|
228 | - /** |
|
229 | - * Sets up the security for this page. If certain actions have different permissions, this should be reflected in |
|
230 | - * the return value from this function. |
|
231 | - * |
|
232 | - * If this page even supports actions, you will need to check the route |
|
233 | - * |
|
234 | - * @return SecurityConfiguration |
|
235 | - * @category Security-Critical |
|
236 | - */ |
|
237 | - protected function getSecurityConfiguration() |
|
238 | - { |
|
239 | - switch ($this->getRouteName()) { |
|
240 | - case 'edit': |
|
241 | - case 'add': |
|
242 | - case 'delete': |
|
243 | - // WARNING: if you want to unlink edit/add/delete, you'll want to change the barrier tests in the |
|
244 | - // template |
|
245 | - return $this->getSecurityManager()->configure()->asAdminPage(); |
|
246 | - case 'view': |
|
247 | - case 'select': |
|
248 | - return $this->getSecurityManager()->configure()->asInternalPage(); |
|
249 | - default: |
|
250 | - return $this->getSecurityManager()->configure()->asInternalPage(); |
|
251 | - } |
|
252 | - } |
|
253 | - |
|
254 | - private function validate($userCode, $botCode) |
|
255 | - { |
|
256 | - if ($userCode === null) { |
|
257 | - throw new ApplicationLogicException('User code cannot be null'); |
|
258 | - } |
|
259 | - |
|
260 | - if ($botCode === null) { |
|
261 | - throw new ApplicationLogicException('Bot code cannot be null'); |
|
262 | - } |
|
263 | - } |
|
151 | + /** @var WelcomeTemplate $template */ |
|
152 | + $template = WelcomeTemplate::getById($templateId, $database); |
|
153 | + |
|
154 | + if ($template === false) { |
|
155 | + throw new ApplicationLogicException('Cannot find requested template'); |
|
156 | + } |
|
157 | + |
|
158 | + if ($template->isDeleted()) { |
|
159 | + throw new ApplicationLogicException('The specified template has been deleted'); |
|
160 | + } |
|
161 | + |
|
162 | + if (WebRequest::wasPosted()) { |
|
163 | + $this->validateCSRFToken(); |
|
164 | + |
|
165 | + $userCode = WebRequest::postString('usercode'); |
|
166 | + $botCode = WebRequest::postString('botcode'); |
|
167 | + |
|
168 | + $this->validate($userCode, $botCode); |
|
169 | + |
|
170 | + $template->setUserCode($userCode); |
|
171 | + $template->setBotCode($botCode); |
|
172 | + $template->setUpdateVersion(WebRequest::postInt('updateversion')); |
|
173 | + $template->save(); |
|
174 | + |
|
175 | + Logger::welcomeTemplateEdited($database, $template); |
|
176 | + |
|
177 | + SessionAlert::success("Template updated."); |
|
178 | + |
|
179 | + $this->getNotificationHelper()->welcomeTemplateEdited($template); |
|
180 | + |
|
181 | + $this->redirect('welcomeTemplates'); |
|
182 | + } |
|
183 | + else { |
|
184 | + $this->assignCSRFToken(); |
|
185 | + $this->assign('template', $template); |
|
186 | + $this->setTemplate('welcome-template/edit.tpl'); |
|
187 | + } |
|
188 | + } |
|
189 | + |
|
190 | + protected function delete() |
|
191 | + { |
|
192 | + $this->redirect('welcomeTemplates'); |
|
193 | + |
|
194 | + if (!WebRequest::wasPosted()) { |
|
195 | + return; |
|
196 | + } |
|
197 | + |
|
198 | + $this->validateCSRFToken(); |
|
199 | + |
|
200 | + $database = $this->getDatabase(); |
|
201 | + |
|
202 | + $templateId = WebRequest::postInt('template'); |
|
203 | + $updateVersion = WebRequest::postInt('updateversion'); |
|
204 | + |
|
205 | + /** @var WelcomeTemplate $template */ |
|
206 | + $template = WelcomeTemplate::getById($templateId, $database); |
|
207 | + |
|
208 | + if ($template === false || $template->isDeleted()) { |
|
209 | + throw new ApplicationLogicException('Cannot find requested template'); |
|
210 | + } |
|
211 | + |
|
212 | + // set the update version to the version sent by the client (optimisticly lock from initial page load) |
|
213 | + $template->setUpdateVersion($updateVersion); |
|
214 | + |
|
215 | + $database |
|
216 | + ->prepare("UPDATE user SET welcome_template = NULL WHERE welcome_template = :id;") |
|
217 | + ->execute(array(":id" => $templateId)); |
|
218 | + |
|
219 | + Logger::welcomeTemplateDeleted($database, $template); |
|
220 | + |
|
221 | + $template->delete(); |
|
222 | + |
|
223 | + SessionAlert::success( |
|
224 | + "Template deleted. Any users who were using this template have had automatic welcoming disabled."); |
|
225 | + $this->getNotificationHelper()->welcomeTemplateDeleted($templateId); |
|
226 | + } |
|
227 | + |
|
228 | + /** |
|
229 | + * Sets up the security for this page. If certain actions have different permissions, this should be reflected in |
|
230 | + * the return value from this function. |
|
231 | + * |
|
232 | + * If this page even supports actions, you will need to check the route |
|
233 | + * |
|
234 | + * @return SecurityConfiguration |
|
235 | + * @category Security-Critical |
|
236 | + */ |
|
237 | + protected function getSecurityConfiguration() |
|
238 | + { |
|
239 | + switch ($this->getRouteName()) { |
|
240 | + case 'edit': |
|
241 | + case 'add': |
|
242 | + case 'delete': |
|
243 | + // WARNING: if you want to unlink edit/add/delete, you'll want to change the barrier tests in the |
|
244 | + // template |
|
245 | + return $this->getSecurityManager()->configure()->asAdminPage(); |
|
246 | + case 'view': |
|
247 | + case 'select': |
|
248 | + return $this->getSecurityManager()->configure()->asInternalPage(); |
|
249 | + default: |
|
250 | + return $this->getSecurityManager()->configure()->asInternalPage(); |
|
251 | + } |
|
252 | + } |
|
253 | + |
|
254 | + private function validate($userCode, $botCode) |
|
255 | + { |
|
256 | + if ($userCode === null) { |
|
257 | + throw new ApplicationLogicException('User code cannot be null'); |
|
258 | + } |
|
259 | + |
|
260 | + if ($botCode === null) { |
|
261 | + throw new ApplicationLogicException('Bot code cannot be null'); |
|
262 | + } |
|
263 | + } |
|
264 | 264 | } |
265 | 265 | \ No newline at end of file |
@@ -23,229 +23,229 @@ |
||
23 | 23 | |
24 | 24 | class PageViewRequest extends InternalPageBase |
25 | 25 | { |
26 | - use RequestData; |
|
27 | - const PRIVATE_DATA_BARRIER = 'privateData'; |
|
28 | - const SET_BAN_BARRIER = 'setBan'; |
|
29 | - const STATUS_SYMBOL_OPEN = '☐'; |
|
30 | - const STATUS_SYMBOL_ACCEPTED = '☑'; |
|
31 | - const STATUS_SYMBOL_REJECTED = '☒'; |
|
32 | - |
|
33 | - /** |
|
34 | - * Main function for this page, when no specific actions are called. |
|
35 | - * @throws ApplicationLogicException |
|
36 | - */ |
|
37 | - protected function main() |
|
38 | - { |
|
39 | - // set up csrf protection |
|
40 | - $this->assignCSRFToken(); |
|
41 | - |
|
42 | - // get some useful objects |
|
43 | - $database = $this->getDatabase(); |
|
44 | - $request = $this->getRequest($database, WebRequest::getInt('id')); |
|
45 | - $config = $this->getSiteConfiguration(); |
|
46 | - $currentUser = User::getCurrent($database); |
|
47 | - |
|
48 | - // Test we should be able to look at this request |
|
49 | - if ($config->getEmailConfirmationEnabled()) { |
|
50 | - if ($request->getEmailConfirm() !== 'Confirmed') { |
|
51 | - // Not allowed to look at this yet. |
|
52 | - throw new ApplicationLogicException('The email address has not yet been confirmed for this request.'); |
|
53 | - } |
|
54 | - } |
|
55 | - |
|
56 | - $this->setupBasicData($request, $config); |
|
57 | - |
|
58 | - $this->setupUsernameData($request); |
|
59 | - |
|
60 | - $this->setupTitle($request); |
|
61 | - |
|
62 | - $this->setupReservationDetails($request->getReserved(), $database, $currentUser); |
|
63 | - $this->setupGeneralData($database); |
|
64 | - |
|
65 | - $this->assign('requestDataCleared', false); |
|
66 | - if ($request->getEmail() === $this->getSiteConfiguration()->getDataClearEmail()) { |
|
67 | - $this->assign('requestDataCleared', true); |
|
68 | - } |
|
69 | - |
|
70 | - $allowedPrivateData = $this->isAllowedPrivateData($request, $currentUser); |
|
71 | - |
|
72 | - $this->setupLogData($request, $database); |
|
73 | - |
|
74 | - if ($allowedPrivateData) { |
|
75 | - $this->setTemplate('view-request/main-with-data.tpl'); |
|
76 | - $this->setupPrivateData($request, $currentUser, $this->getSiteConfiguration(), $database); |
|
77 | - |
|
78 | - if ($currentUser->isCheckuser()) { |
|
79 | - $this->setTemplate('view-request/main-with-checkuser-data.tpl'); |
|
80 | - $this->setupCheckUserData($request); |
|
81 | - } |
|
82 | - } |
|
83 | - else { |
|
84 | - $this->setTemplate('view-request/main.tpl'); |
|
85 | - } |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * @param Request $request |
|
90 | - */ |
|
91 | - protected function setupTitle(Request $request) |
|
92 | - { |
|
93 | - $statusSymbol = self::STATUS_SYMBOL_OPEN; |
|
94 | - if ($request->getStatus() === 'Closed') { |
|
95 | - if ($request->getWasCreated()) { |
|
96 | - $statusSymbol = self::STATUS_SYMBOL_ACCEPTED; |
|
97 | - } |
|
98 | - else { |
|
99 | - $statusSymbol = self::STATUS_SYMBOL_REJECTED; |
|
100 | - } |
|
101 | - } |
|
102 | - |
|
103 | - $this->setHtmlTitle($statusSymbol . ' #' . $request->getId()); |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * Sets up data unrelated to the request, such as the email template information |
|
108 | - * |
|
109 | - * @param PdoDatabase $database |
|
110 | - */ |
|
111 | - protected function setupGeneralData(PdoDatabase $database) |
|
112 | - { |
|
113 | - $config = $this->getSiteConfiguration(); |
|
114 | - |
|
115 | - $this->assign('createAccountReason', 'Requested account at [[WP:ACC]], request #'); |
|
116 | - |
|
117 | - $this->assign('defaultRequestState', $config->getDefaultRequestStateKey()); |
|
118 | - |
|
119 | - $this->assign('requestStates', $config->getRequestStates()); |
|
120 | - |
|
121 | - /** @var EmailTemplate $createdTemplate */ |
|
122 | - $createdTemplate = EmailTemplate::getById($config->getDefaultCreatedTemplateId(), $database); |
|
123 | - |
|
124 | - $this->assign('createdHasJsQuestion', $createdTemplate->getJsquestion() != ''); |
|
125 | - $this->assign('createdJsQuestion', $createdTemplate->getJsquestion()); |
|
126 | - $this->assign('createdId', $createdTemplate->getId()); |
|
127 | - $this->assign('createdName', $createdTemplate->getName()); |
|
128 | - |
|
129 | - $createReasons = EmailTemplate::getActiveTemplates(EmailTemplate::CREATED, $database); |
|
130 | - $this->assign("createReasons", $createReasons); |
|
131 | - $declineReasons = EmailTemplate::getActiveTemplates(EmailTemplate::NOT_CREATED, $database); |
|
132 | - $this->assign("declineReasons", $declineReasons); |
|
133 | - |
|
134 | - $allCreateReasons = EmailTemplate::getAllActiveTemplates(EmailTemplate::CREATED, $database); |
|
135 | - $this->assign("allCreateReasons", $allCreateReasons); |
|
136 | - $allDeclineReasons = EmailTemplate::getAllActiveTemplates(EmailTemplate::NOT_CREATED, $database); |
|
137 | - $this->assign("allDeclineReasons", $allDeclineReasons); |
|
138 | - $allOtherReasons = EmailTemplate::getAllActiveTemplates(false, $database); |
|
139 | - $this->assign("allOtherReasons", $allOtherReasons); |
|
140 | - |
|
141 | - $this->getTypeAheadHelper()->defineTypeAheadSource('username-typeahead', function() use ($database) { |
|
142 | - return User::getAllUsernames($database, true); |
|
143 | - }); |
|
144 | - } |
|
145 | - |
|
146 | - private function setupLogData(Request $request, PdoDatabase $database) |
|
147 | - { |
|
148 | - $currentUser = User::getCurrent($database); |
|
149 | - |
|
150 | - $logs = LogHelper::getRequestLogsWithComments($request->getId(), $database); |
|
151 | - $requestLogs = array(); |
|
152 | - |
|
153 | - if (trim($request->getComment()) !== "") { |
|
154 | - $requestLogs[] = array( |
|
155 | - 'type' => 'comment', |
|
156 | - 'security' => 'user', |
|
157 | - 'userid' => null, |
|
158 | - 'user' => $request->getName(), |
|
159 | - 'entry' => null, |
|
160 | - 'time' => $request->getDate(), |
|
161 | - 'canedit' => false, |
|
162 | - 'id' => $request->getId(), |
|
163 | - 'comment' => $request->getComment(), |
|
164 | - ); |
|
165 | - } |
|
166 | - |
|
167 | - /** @var User[] $nameCache */ |
|
168 | - $nameCache = array(); |
|
169 | - |
|
170 | - $editableComments = $this->allowEditingComments($currentUser); |
|
171 | - |
|
172 | - /** @var Log|Comment $entry */ |
|
173 | - foreach ($logs as $entry) { |
|
174 | - // both log and comment have a 'user' field |
|
175 | - if (!array_key_exists($entry->getUser(), $nameCache)) { |
|
176 | - $entryUser = User::getById($entry->getUser(), $database); |
|
177 | - $nameCache[$entry->getUser()] = $entryUser; |
|
178 | - } |
|
179 | - |
|
180 | - if ($entry instanceof Comment) { |
|
181 | - $requestLogs[] = array( |
|
182 | - 'type' => 'comment', |
|
183 | - 'security' => $entry->getVisibility(), |
|
184 | - 'user' => $nameCache[$entry->getUser()]->getUsername(), |
|
185 | - 'userid' => $entry->getUser() == -1 ? null : $entry->getUser(), |
|
186 | - 'entry' => null, |
|
187 | - 'time' => $entry->getTime(), |
|
188 | - 'canedit' => ($editableComments || $entry->getUser() == $currentUser->getId()), |
|
189 | - 'id' => $entry->getId(), |
|
190 | - 'comment' => $entry->getComment(), |
|
191 | - ); |
|
192 | - } |
|
193 | - |
|
194 | - if ($entry instanceof Log) { |
|
195 | - $invalidUserId = $entry->getUser() === -1 || $entry->getUser() === 0; |
|
196 | - $entryUser = $invalidUserId ? User::getCommunity() : $nameCache[$entry->getUser()]; |
|
197 | - |
|
198 | - $requestLogs[] = array( |
|
199 | - 'type' => 'log', |
|
200 | - 'security' => 'user', |
|
201 | - 'userid' => $entry->getUser() == -1 ? null : $entry->getUser(), |
|
202 | - 'user' => $entryUser->getUsername(), |
|
203 | - 'entry' => LogHelper::getLogDescription($entry), |
|
204 | - 'time' => $entry->getTimestamp(), |
|
205 | - 'canedit' => false, |
|
206 | - 'id' => $entry->getId(), |
|
207 | - 'comment' => $entry->getComment(), |
|
208 | - ); |
|
209 | - } |
|
210 | - } |
|
211 | - |
|
212 | - $this->assign("requestLogs", $requestLogs); |
|
213 | - } |
|
214 | - |
|
215 | - /** |
|
216 | - * @param Request $request |
|
217 | - */ |
|
218 | - protected function setupUsernameData(Request $request) |
|
219 | - { |
|
220 | - $blacklistData = $this->getBlacklistHelper()->isBlacklisted($request->getName()); |
|
221 | - |
|
222 | - $this->assign('requestIsBlacklisted', $blacklistData !== false); |
|
223 | - $this->assign('requestBlacklist', $blacklistData); |
|
224 | - |
|
225 | - try { |
|
226 | - $spoofs = $this->getAntiSpoofProvider()->getSpoofs($request->getName()); |
|
227 | - } |
|
228 | - catch (Exception $ex) { |
|
229 | - $spoofs = $ex->getMessage(); |
|
230 | - } |
|
231 | - |
|
232 | - $this->assign("spoofs", $spoofs); |
|
233 | - } |
|
234 | - |
|
235 | - /** |
|
236 | - * @param User $currentUser |
|
237 | - * |
|
238 | - * @return bool |
|
239 | - */ |
|
240 | - private function allowEditingComments(User $currentUser) |
|
241 | - { |
|
242 | - $editableComments = false; |
|
243 | - if ($currentUser->isAdmin() || $currentUser->isCheckuser()) { |
|
244 | - $editableComments = true; |
|
245 | - |
|
246 | - return $editableComments; |
|
247 | - } |
|
248 | - |
|
249 | - return $editableComments; |
|
250 | - } |
|
26 | + use RequestData; |
|
27 | + const PRIVATE_DATA_BARRIER = 'privateData'; |
|
28 | + const SET_BAN_BARRIER = 'setBan'; |
|
29 | + const STATUS_SYMBOL_OPEN = '☐'; |
|
30 | + const STATUS_SYMBOL_ACCEPTED = '☑'; |
|
31 | + const STATUS_SYMBOL_REJECTED = '☒'; |
|
32 | + |
|
33 | + /** |
|
34 | + * Main function for this page, when no specific actions are called. |
|
35 | + * @throws ApplicationLogicException |
|
36 | + */ |
|
37 | + protected function main() |
|
38 | + { |
|
39 | + // set up csrf protection |
|
40 | + $this->assignCSRFToken(); |
|
41 | + |
|
42 | + // get some useful objects |
|
43 | + $database = $this->getDatabase(); |
|
44 | + $request = $this->getRequest($database, WebRequest::getInt('id')); |
|
45 | + $config = $this->getSiteConfiguration(); |
|
46 | + $currentUser = User::getCurrent($database); |
|
47 | + |
|
48 | + // Test we should be able to look at this request |
|
49 | + if ($config->getEmailConfirmationEnabled()) { |
|
50 | + if ($request->getEmailConfirm() !== 'Confirmed') { |
|
51 | + // Not allowed to look at this yet. |
|
52 | + throw new ApplicationLogicException('The email address has not yet been confirmed for this request.'); |
|
53 | + } |
|
54 | + } |
|
55 | + |
|
56 | + $this->setupBasicData($request, $config); |
|
57 | + |
|
58 | + $this->setupUsernameData($request); |
|
59 | + |
|
60 | + $this->setupTitle($request); |
|
61 | + |
|
62 | + $this->setupReservationDetails($request->getReserved(), $database, $currentUser); |
|
63 | + $this->setupGeneralData($database); |
|
64 | + |
|
65 | + $this->assign('requestDataCleared', false); |
|
66 | + if ($request->getEmail() === $this->getSiteConfiguration()->getDataClearEmail()) { |
|
67 | + $this->assign('requestDataCleared', true); |
|
68 | + } |
|
69 | + |
|
70 | + $allowedPrivateData = $this->isAllowedPrivateData($request, $currentUser); |
|
71 | + |
|
72 | + $this->setupLogData($request, $database); |
|
73 | + |
|
74 | + if ($allowedPrivateData) { |
|
75 | + $this->setTemplate('view-request/main-with-data.tpl'); |
|
76 | + $this->setupPrivateData($request, $currentUser, $this->getSiteConfiguration(), $database); |
|
77 | + |
|
78 | + if ($currentUser->isCheckuser()) { |
|
79 | + $this->setTemplate('view-request/main-with-checkuser-data.tpl'); |
|
80 | + $this->setupCheckUserData($request); |
|
81 | + } |
|
82 | + } |
|
83 | + else { |
|
84 | + $this->setTemplate('view-request/main.tpl'); |
|
85 | + } |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * @param Request $request |
|
90 | + */ |
|
91 | + protected function setupTitle(Request $request) |
|
92 | + { |
|
93 | + $statusSymbol = self::STATUS_SYMBOL_OPEN; |
|
94 | + if ($request->getStatus() === 'Closed') { |
|
95 | + if ($request->getWasCreated()) { |
|
96 | + $statusSymbol = self::STATUS_SYMBOL_ACCEPTED; |
|
97 | + } |
|
98 | + else { |
|
99 | + $statusSymbol = self::STATUS_SYMBOL_REJECTED; |
|
100 | + } |
|
101 | + } |
|
102 | + |
|
103 | + $this->setHtmlTitle($statusSymbol . ' #' . $request->getId()); |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * Sets up data unrelated to the request, such as the email template information |
|
108 | + * |
|
109 | + * @param PdoDatabase $database |
|
110 | + */ |
|
111 | + protected function setupGeneralData(PdoDatabase $database) |
|
112 | + { |
|
113 | + $config = $this->getSiteConfiguration(); |
|
114 | + |
|
115 | + $this->assign('createAccountReason', 'Requested account at [[WP:ACC]], request #'); |
|
116 | + |
|
117 | + $this->assign('defaultRequestState', $config->getDefaultRequestStateKey()); |
|
118 | + |
|
119 | + $this->assign('requestStates', $config->getRequestStates()); |
|
120 | + |
|
121 | + /** @var EmailTemplate $createdTemplate */ |
|
122 | + $createdTemplate = EmailTemplate::getById($config->getDefaultCreatedTemplateId(), $database); |
|
123 | + |
|
124 | + $this->assign('createdHasJsQuestion', $createdTemplate->getJsquestion() != ''); |
|
125 | + $this->assign('createdJsQuestion', $createdTemplate->getJsquestion()); |
|
126 | + $this->assign('createdId', $createdTemplate->getId()); |
|
127 | + $this->assign('createdName', $createdTemplate->getName()); |
|
128 | + |
|
129 | + $createReasons = EmailTemplate::getActiveTemplates(EmailTemplate::CREATED, $database); |
|
130 | + $this->assign("createReasons", $createReasons); |
|
131 | + $declineReasons = EmailTemplate::getActiveTemplates(EmailTemplate::NOT_CREATED, $database); |
|
132 | + $this->assign("declineReasons", $declineReasons); |
|
133 | + |
|
134 | + $allCreateReasons = EmailTemplate::getAllActiveTemplates(EmailTemplate::CREATED, $database); |
|
135 | + $this->assign("allCreateReasons", $allCreateReasons); |
|
136 | + $allDeclineReasons = EmailTemplate::getAllActiveTemplates(EmailTemplate::NOT_CREATED, $database); |
|
137 | + $this->assign("allDeclineReasons", $allDeclineReasons); |
|
138 | + $allOtherReasons = EmailTemplate::getAllActiveTemplates(false, $database); |
|
139 | + $this->assign("allOtherReasons", $allOtherReasons); |
|
140 | + |
|
141 | + $this->getTypeAheadHelper()->defineTypeAheadSource('username-typeahead', function() use ($database) { |
|
142 | + return User::getAllUsernames($database, true); |
|
143 | + }); |
|
144 | + } |
|
145 | + |
|
146 | + private function setupLogData(Request $request, PdoDatabase $database) |
|
147 | + { |
|
148 | + $currentUser = User::getCurrent($database); |
|
149 | + |
|
150 | + $logs = LogHelper::getRequestLogsWithComments($request->getId(), $database); |
|
151 | + $requestLogs = array(); |
|
152 | + |
|
153 | + if (trim($request->getComment()) !== "") { |
|
154 | + $requestLogs[] = array( |
|
155 | + 'type' => 'comment', |
|
156 | + 'security' => 'user', |
|
157 | + 'userid' => null, |
|
158 | + 'user' => $request->getName(), |
|
159 | + 'entry' => null, |
|
160 | + 'time' => $request->getDate(), |
|
161 | + 'canedit' => false, |
|
162 | + 'id' => $request->getId(), |
|
163 | + 'comment' => $request->getComment(), |
|
164 | + ); |
|
165 | + } |
|
166 | + |
|
167 | + /** @var User[] $nameCache */ |
|
168 | + $nameCache = array(); |
|
169 | + |
|
170 | + $editableComments = $this->allowEditingComments($currentUser); |
|
171 | + |
|
172 | + /** @var Log|Comment $entry */ |
|
173 | + foreach ($logs as $entry) { |
|
174 | + // both log and comment have a 'user' field |
|
175 | + if (!array_key_exists($entry->getUser(), $nameCache)) { |
|
176 | + $entryUser = User::getById($entry->getUser(), $database); |
|
177 | + $nameCache[$entry->getUser()] = $entryUser; |
|
178 | + } |
|
179 | + |
|
180 | + if ($entry instanceof Comment) { |
|
181 | + $requestLogs[] = array( |
|
182 | + 'type' => 'comment', |
|
183 | + 'security' => $entry->getVisibility(), |
|
184 | + 'user' => $nameCache[$entry->getUser()]->getUsername(), |
|
185 | + 'userid' => $entry->getUser() == -1 ? null : $entry->getUser(), |
|
186 | + 'entry' => null, |
|
187 | + 'time' => $entry->getTime(), |
|
188 | + 'canedit' => ($editableComments || $entry->getUser() == $currentUser->getId()), |
|
189 | + 'id' => $entry->getId(), |
|
190 | + 'comment' => $entry->getComment(), |
|
191 | + ); |
|
192 | + } |
|
193 | + |
|
194 | + if ($entry instanceof Log) { |
|
195 | + $invalidUserId = $entry->getUser() === -1 || $entry->getUser() === 0; |
|
196 | + $entryUser = $invalidUserId ? User::getCommunity() : $nameCache[$entry->getUser()]; |
|
197 | + |
|
198 | + $requestLogs[] = array( |
|
199 | + 'type' => 'log', |
|
200 | + 'security' => 'user', |
|
201 | + 'userid' => $entry->getUser() == -1 ? null : $entry->getUser(), |
|
202 | + 'user' => $entryUser->getUsername(), |
|
203 | + 'entry' => LogHelper::getLogDescription($entry), |
|
204 | + 'time' => $entry->getTimestamp(), |
|
205 | + 'canedit' => false, |
|
206 | + 'id' => $entry->getId(), |
|
207 | + 'comment' => $entry->getComment(), |
|
208 | + ); |
|
209 | + } |
|
210 | + } |
|
211 | + |
|
212 | + $this->assign("requestLogs", $requestLogs); |
|
213 | + } |
|
214 | + |
|
215 | + /** |
|
216 | + * @param Request $request |
|
217 | + */ |
|
218 | + protected function setupUsernameData(Request $request) |
|
219 | + { |
|
220 | + $blacklistData = $this->getBlacklistHelper()->isBlacklisted($request->getName()); |
|
221 | + |
|
222 | + $this->assign('requestIsBlacklisted', $blacklistData !== false); |
|
223 | + $this->assign('requestBlacklist', $blacklistData); |
|
224 | + |
|
225 | + try { |
|
226 | + $spoofs = $this->getAntiSpoofProvider()->getSpoofs($request->getName()); |
|
227 | + } |
|
228 | + catch (Exception $ex) { |
|
229 | + $spoofs = $ex->getMessage(); |
|
230 | + } |
|
231 | + |
|
232 | + $this->assign("spoofs", $spoofs); |
|
233 | + } |
|
234 | + |
|
235 | + /** |
|
236 | + * @param User $currentUser |
|
237 | + * |
|
238 | + * @return bool |
|
239 | + */ |
|
240 | + private function allowEditingComments(User $currentUser) |
|
241 | + { |
|
242 | + $editableComments = false; |
|
243 | + if ($currentUser->isAdmin() || $currentUser->isCheckuser()) { |
|
244 | + $editableComments = true; |
|
245 | + |
|
246 | + return $editableComments; |
|
247 | + } |
|
248 | + |
|
249 | + return $editableComments; |
|
250 | + } |
|
251 | 251 | } |
252 | 252 | \ No newline at end of file |
@@ -18,127 +18,127 @@ |
||
18 | 18 | |
19 | 19 | class PageLog extends InternalPageBase |
20 | 20 | { |
21 | - /** |
|
22 | - * Main function for this page, when no specific actions are called. |
|
23 | - */ |
|
24 | - protected function main() |
|
25 | - { |
|
26 | - $this->setHtmlTitle('Logs'); |
|
27 | - |
|
28 | - $filterUser = WebRequest::getString('filterUser'); |
|
29 | - $filterAction = WebRequest::getString('filterAction'); |
|
30 | - |
|
31 | - $database = $this->getDatabase(); |
|
32 | - |
|
33 | - $this->getTypeAheadHelper()->defineTypeAheadSource('username-typeahead', function() use ($database) { |
|
34 | - return User::getAllUsernames($database); |
|
35 | - }); |
|
36 | - |
|
37 | - $limit = WebRequest::getInt('limit'); |
|
38 | - if ($limit === null) { |
|
39 | - $limit = 100; |
|
40 | - } |
|
41 | - |
|
42 | - $page = WebRequest::getInt('page'); |
|
43 | - if ($page === null) { |
|
44 | - $page = 1; |
|
45 | - } |
|
46 | - |
|
47 | - $offset = ($page - 1) * $limit; |
|
48 | - |
|
49 | - $logSearch = LogSearchHelper::get($database)->limit($limit, $offset); |
|
50 | - if ($filterUser !== null) { |
|
51 | - $logSearch->byUser(User::getByUsername($filterUser, $database)->getId()); |
|
52 | - } |
|
53 | - |
|
54 | - if ($filterAction !== null) { |
|
55 | - $logSearch->byAction($filterAction); |
|
56 | - } |
|
57 | - |
|
58 | - /** @var Log[] $logs */ |
|
59 | - $logs = $logSearch->getRecordCount($count)->fetch(); |
|
60 | - |
|
61 | - if ($count === 0) { |
|
62 | - $this->assign('logs', array()); |
|
63 | - $this->setTemplate('logs/main.tpl'); |
|
64 | - |
|
65 | - return; |
|
66 | - } |
|
67 | - |
|
68 | - list($users, $logData) = LogHelper::prepareLogsForTemplate($logs, $database, $this->getSiteConfiguration()); |
|
69 | - |
|
70 | - $this->setupPageData($page, $limit, $count); |
|
71 | - |
|
72 | - $this->assign("logs", $logData); |
|
73 | - $this->assign("users", $users); |
|
74 | - |
|
75 | - $this->assign("filterUser", $filterUser); |
|
76 | - $this->assign("filterAction", $filterAction); |
|
77 | - |
|
78 | - $this->assign('allLogActions', LogHelper::getLogActions($this->getDatabase())); |
|
79 | - |
|
80 | - $this->setTemplate("logs/main.tpl"); |
|
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * Sets up the security for this page. If certain actions have different permissions, this should be reflected in |
|
85 | - * the return value from this function. |
|
86 | - * |
|
87 | - * If this page even supports actions, you will need to check the route |
|
88 | - * |
|
89 | - * @return SecurityConfiguration |
|
90 | - * @category Security-Critical |
|
91 | - */ |
|
92 | - protected function getSecurityConfiguration() |
|
93 | - { |
|
94 | - return $this->getSecurityManager()->configure()->asInternalPage(); |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * @param int $page |
|
99 | - * @param int $limit |
|
100 | - * @param int $count |
|
101 | - */ |
|
102 | - protected function setupPageData($page, $limit, $count) |
|
103 | - { |
|
104 | - // The number of pages on the pager to show. Must be odd |
|
105 | - $pageLimit = 9; |
|
106 | - |
|
107 | - $pageData = array( |
|
108 | - // Can the user go to the previous page? |
|
109 | - 'canprev' => $page != 1, |
|
110 | - // Can the user go to the next page? |
|
111 | - 'cannext' => ($page * $limit) < $count, |
|
112 | - // Maximum page number |
|
113 | - 'maxpage' => ceil($count / $limit), |
|
114 | - // Limit to the number of pages to display |
|
115 | - 'pagelimit' => $pageLimit, |
|
116 | - ); |
|
117 | - |
|
118 | - // number of pages either side of the current to show |
|
119 | - $pageMargin = (($pageLimit - 1) / 2); |
|
120 | - |
|
121 | - // Calculate the number of pages either side to show - this is for situations like: |
|
122 | - // [1] [2] [[3]] [4] [5] [6] [7] [8] [9] - where you can't just use the page margin calculated |
|
123 | - $pageData['lowpage'] = max(1, $page - $pageMargin); |
|
124 | - $pageData['hipage'] = min($pageData['maxpage'], $page + $pageMargin); |
|
125 | - $pageCount = ($pageData['hipage'] - $pageData['lowpage']) + 1; |
|
126 | - |
|
127 | - if ($pageCount < $pageLimit) { |
|
128 | - if ($pageData['lowpage'] == 1 && $pageData['hipage'] < $pageData['maxpage']) { |
|
129 | - $pageData['hipage'] = min($pageLimit, $pageData['maxpage']); |
|
130 | - } |
|
131 | - elseif ($pageData['lowpage'] > 1 && $pageData['hipage'] == $pageData['maxpage']) { |
|
132 | - $pageData['lowpage'] = max(1, $pageData['maxpage'] - $pageLimit + 1); |
|
133 | - } |
|
134 | - } |
|
135 | - |
|
136 | - // Put the range of pages into the page data |
|
137 | - $pageData['pages'] = range($pageData['lowpage'], $pageData['hipage']); |
|
138 | - |
|
139 | - $this->assign("pagedata", $pageData); |
|
140 | - |
|
141 | - $this->assign("limit", $limit); |
|
142 | - $this->assign("page", $page); |
|
143 | - } |
|
21 | + /** |
|
22 | + * Main function for this page, when no specific actions are called. |
|
23 | + */ |
|
24 | + protected function main() |
|
25 | + { |
|
26 | + $this->setHtmlTitle('Logs'); |
|
27 | + |
|
28 | + $filterUser = WebRequest::getString('filterUser'); |
|
29 | + $filterAction = WebRequest::getString('filterAction'); |
|
30 | + |
|
31 | + $database = $this->getDatabase(); |
|
32 | + |
|
33 | + $this->getTypeAheadHelper()->defineTypeAheadSource('username-typeahead', function() use ($database) { |
|
34 | + return User::getAllUsernames($database); |
|
35 | + }); |
|
36 | + |
|
37 | + $limit = WebRequest::getInt('limit'); |
|
38 | + if ($limit === null) { |
|
39 | + $limit = 100; |
|
40 | + } |
|
41 | + |
|
42 | + $page = WebRequest::getInt('page'); |
|
43 | + if ($page === null) { |
|
44 | + $page = 1; |
|
45 | + } |
|
46 | + |
|
47 | + $offset = ($page - 1) * $limit; |
|
48 | + |
|
49 | + $logSearch = LogSearchHelper::get($database)->limit($limit, $offset); |
|
50 | + if ($filterUser !== null) { |
|
51 | + $logSearch->byUser(User::getByUsername($filterUser, $database)->getId()); |
|
52 | + } |
|
53 | + |
|
54 | + if ($filterAction !== null) { |
|
55 | + $logSearch->byAction($filterAction); |
|
56 | + } |
|
57 | + |
|
58 | + /** @var Log[] $logs */ |
|
59 | + $logs = $logSearch->getRecordCount($count)->fetch(); |
|
60 | + |
|
61 | + if ($count === 0) { |
|
62 | + $this->assign('logs', array()); |
|
63 | + $this->setTemplate('logs/main.tpl'); |
|
64 | + |
|
65 | + return; |
|
66 | + } |
|
67 | + |
|
68 | + list($users, $logData) = LogHelper::prepareLogsForTemplate($logs, $database, $this->getSiteConfiguration()); |
|
69 | + |
|
70 | + $this->setupPageData($page, $limit, $count); |
|
71 | + |
|
72 | + $this->assign("logs", $logData); |
|
73 | + $this->assign("users", $users); |
|
74 | + |
|
75 | + $this->assign("filterUser", $filterUser); |
|
76 | + $this->assign("filterAction", $filterAction); |
|
77 | + |
|
78 | + $this->assign('allLogActions', LogHelper::getLogActions($this->getDatabase())); |
|
79 | + |
|
80 | + $this->setTemplate("logs/main.tpl"); |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * Sets up the security for this page. If certain actions have different permissions, this should be reflected in |
|
85 | + * the return value from this function. |
|
86 | + * |
|
87 | + * If this page even supports actions, you will need to check the route |
|
88 | + * |
|
89 | + * @return SecurityConfiguration |
|
90 | + * @category Security-Critical |
|
91 | + */ |
|
92 | + protected function getSecurityConfiguration() |
|
93 | + { |
|
94 | + return $this->getSecurityManager()->configure()->asInternalPage(); |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * @param int $page |
|
99 | + * @param int $limit |
|
100 | + * @param int $count |
|
101 | + */ |
|
102 | + protected function setupPageData($page, $limit, $count) |
|
103 | + { |
|
104 | + // The number of pages on the pager to show. Must be odd |
|
105 | + $pageLimit = 9; |
|
106 | + |
|
107 | + $pageData = array( |
|
108 | + // Can the user go to the previous page? |
|
109 | + 'canprev' => $page != 1, |
|
110 | + // Can the user go to the next page? |
|
111 | + 'cannext' => ($page * $limit) < $count, |
|
112 | + // Maximum page number |
|
113 | + 'maxpage' => ceil($count / $limit), |
|
114 | + // Limit to the number of pages to display |
|
115 | + 'pagelimit' => $pageLimit, |
|
116 | + ); |
|
117 | + |
|
118 | + // number of pages either side of the current to show |
|
119 | + $pageMargin = (($pageLimit - 1) / 2); |
|
120 | + |
|
121 | + // Calculate the number of pages either side to show - this is for situations like: |
|
122 | + // [1] [2] [[3]] [4] [5] [6] [7] [8] [9] - where you can't just use the page margin calculated |
|
123 | + $pageData['lowpage'] = max(1, $page - $pageMargin); |
|
124 | + $pageData['hipage'] = min($pageData['maxpage'], $page + $pageMargin); |
|
125 | + $pageCount = ($pageData['hipage'] - $pageData['lowpage']) + 1; |
|
126 | + |
|
127 | + if ($pageCount < $pageLimit) { |
|
128 | + if ($pageData['lowpage'] == 1 && $pageData['hipage'] < $pageData['maxpage']) { |
|
129 | + $pageData['hipage'] = min($pageLimit, $pageData['maxpage']); |
|
130 | + } |
|
131 | + elseif ($pageData['lowpage'] > 1 && $pageData['hipage'] == $pageData['maxpage']) { |
|
132 | + $pageData['lowpage'] = max(1, $pageData['maxpage'] - $pageLimit + 1); |
|
133 | + } |
|
134 | + } |
|
135 | + |
|
136 | + // Put the range of pages into the page data |
|
137 | + $pageData['pages'] = range($pageData['lowpage'], $pageData['hipage']); |
|
138 | + |
|
139 | + $this->assign("pagedata", $pageData); |
|
140 | + |
|
141 | + $this->assign("limit", $limit); |
|
142 | + $this->assign("page", $page); |
|
143 | + } |
|
144 | 144 | } |
145 | 145 | \ No newline at end of file |
@@ -10,27 +10,27 @@ |
||
10 | 10 | |
11 | 11 | class IrcColourCode |
12 | 12 | { |
13 | - const BOLD = "\x02"; |
|
14 | - const ITALIC = "\x09"; |
|
15 | - const STRIKE = "\x13"; |
|
16 | - const UNDERLINE = "\x15"; |
|
17 | - const UNDERLINE2 = "\x1f"; |
|
18 | - const REVERSE = "\x16"; |
|
19 | - const RESET = "\x0f"; |
|
20 | - const WHITE = "\x0300"; |
|
21 | - const BLACK = "\x0301"; |
|
22 | - const DARK_BLUE = "\x0302"; |
|
23 | - const DARK_GREEN = "\x0303"; |
|
24 | - const RED = "\x0304"; |
|
25 | - const DARK_RED = "\x0305"; |
|
26 | - const DARK_VIOLET = "\x0306"; |
|
27 | - const ORANGE = "\x0307"; |
|
28 | - const YELLOW = "\x0308"; |
|
29 | - const LIGHT_GREEN = "\x0309"; |
|
30 | - const CYAN = "\x0310"; |
|
31 | - const LIGHT_CYAN = "\x0311"; |
|
32 | - const BLUE = "\x0312"; |
|
33 | - const VIOLET = "\x0313"; |
|
34 | - const DARK_GREY = "\x0314"; |
|
35 | - const LIGHT_GREY = "\x0315"; |
|
13 | + const BOLD = "\x02"; |
|
14 | + const ITALIC = "\x09"; |
|
15 | + const STRIKE = "\x13"; |
|
16 | + const UNDERLINE = "\x15"; |
|
17 | + const UNDERLINE2 = "\x1f"; |
|
18 | + const REVERSE = "\x16"; |
|
19 | + const RESET = "\x0f"; |
|
20 | + const WHITE = "\x0300"; |
|
21 | + const BLACK = "\x0301"; |
|
22 | + const DARK_BLUE = "\x0302"; |
|
23 | + const DARK_GREEN = "\x0303"; |
|
24 | + const RED = "\x0304"; |
|
25 | + const DARK_RED = "\x0305"; |
|
26 | + const DARK_VIOLET = "\x0306"; |
|
27 | + const ORANGE = "\x0307"; |
|
28 | + const YELLOW = "\x0308"; |
|
29 | + const LIGHT_GREEN = "\x0309"; |
|
30 | + const CYAN = "\x0310"; |
|
31 | + const LIGHT_CYAN = "\x0311"; |
|
32 | + const BLUE = "\x0312"; |
|
33 | + const VIOLET = "\x0313"; |
|
34 | + const DARK_GREY = "\x0314"; |
|
35 | + const LIGHT_GREY = "\x0315"; |
|
36 | 36 | } |