@@ -62,7 +62,7 @@ |
||
62 | 62 | } |
63 | 63 | |
64 | 64 | $safeUsername = htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8'); |
65 | - $this->setHtmlTitle($safeUsername . ' :: Users :: Statistics'); |
|
65 | + $this->setHtmlTitle($safeUsername.' :: Users :: Statistics'); |
|
66 | 66 | |
67 | 67 | $activitySummary = $database->prepare(<<<SQL |
68 | 68 | SELECT COALESCE(closes.mail_desc, log.action) AS action, COUNT(*) AS count |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | |
23 | 23 | class StatsUsers extends InternalPageBase |
24 | 24 | { |
25 | - public function main() |
|
26 | - { |
|
27 | - $this->setHtmlTitle('Users :: Statistics'); |
|
25 | + public function main() |
|
26 | + { |
|
27 | + $this->setHtmlTitle('Users :: Statistics'); |
|
28 | 28 | |
29 | - $database = $this->getDatabase(); |
|
29 | + $database = $this->getDatabase(); |
|
30 | 30 | |
31 | - $query = <<<SQL |
|
31 | + $query = <<<SQL |
|
32 | 32 | SELECT |
33 | 33 | u.id |
34 | 34 | , u.username |
@@ -44,36 +44,36 @@ discard block |
||
44 | 44 | WHERE u.status = 'Active' |
45 | 45 | SQL; |
46 | 46 | |
47 | - $users = $database->query($query)->fetchAll(PDO::FETCH_ASSOC); |
|
48 | - $this->assign('users', $users); |
|
47 | + $users = $database->query($query)->fetchAll(PDO::FETCH_ASSOC); |
|
48 | + $this->assign('users', $users); |
|
49 | 49 | |
50 | - $this->assign('statsPageTitle', 'Account Creation Tool users'); |
|
51 | - $this->setTemplate("statistics/users.tpl"); |
|
52 | - } |
|
50 | + $this->assign('statsPageTitle', 'Account Creation Tool users'); |
|
51 | + $this->setTemplate("statistics/users.tpl"); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Entry point for the detail action. |
|
56 | - * |
|
57 | - * @throws ApplicationLogicException |
|
58 | - */ |
|
59 | - protected function detail() |
|
60 | - { |
|
61 | - $userId = WebRequest::getInt('user'); |
|
62 | - if ($userId === null) { |
|
63 | - throw new ApplicationLogicException("User not found"); |
|
64 | - } |
|
54 | + /** |
|
55 | + * Entry point for the detail action. |
|
56 | + * |
|
57 | + * @throws ApplicationLogicException |
|
58 | + */ |
|
59 | + protected function detail() |
|
60 | + { |
|
61 | + $userId = WebRequest::getInt('user'); |
|
62 | + if ($userId === null) { |
|
63 | + throw new ApplicationLogicException("User not found"); |
|
64 | + } |
|
65 | 65 | |
66 | - $database = $this->getDatabase(); |
|
66 | + $database = $this->getDatabase(); |
|
67 | 67 | |
68 | - $user = User::getById($userId, $database); |
|
69 | - if ($user == false) { |
|
70 | - throw new ApplicationLogicException('User not found'); |
|
71 | - } |
|
68 | + $user = User::getById($userId, $database); |
|
69 | + if ($user == false) { |
|
70 | + throw new ApplicationLogicException('User not found'); |
|
71 | + } |
|
72 | 72 | |
73 | - $safeUsername = htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8'); |
|
74 | - $this->setHtmlTitle($safeUsername . ' :: Users :: Statistics'); |
|
73 | + $safeUsername = htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8'); |
|
74 | + $this->setHtmlTitle($safeUsername . ' :: Users :: Statistics'); |
|
75 | 75 | |
76 | - $activitySummary = $database->prepare(<<<SQL |
|
76 | + $activitySummary = $database->prepare(<<<SQL |
|
77 | 77 | SELECT COALESCE(closes.mail_desc, log.action) AS action, COUNT(*) AS count |
78 | 78 | FROM log |
79 | 79 | INNER JOIN user ON log.user = user.id |
@@ -81,14 +81,14 @@ discard block |
||
81 | 81 | WHERE user.username = :username |
82 | 82 | GROUP BY action; |
83 | 83 | SQL |
84 | - ); |
|
85 | - $activitySummary->execute(array(":username" => $user->getUsername())); |
|
86 | - $activitySummaryData = $activitySummary->fetchAll(PDO::FETCH_ASSOC); |
|
84 | + ); |
|
85 | + $activitySummary->execute(array(":username" => $user->getUsername())); |
|
86 | + $activitySummaryData = $activitySummary->fetchAll(PDO::FETCH_ASSOC); |
|
87 | 87 | |
88 | - $this->assign("user", $user); |
|
89 | - $this->assign("activity", $activitySummaryData); |
|
88 | + $this->assign("user", $user); |
|
89 | + $this->assign("activity", $activitySummaryData); |
|
90 | 90 | |
91 | - $usersCreatedQuery = $database->prepare(<<<SQL |
|
91 | + $usersCreatedQuery = $database->prepare(<<<SQL |
|
92 | 92 | SELECT log.timestamp time, request.name name, request.id id |
93 | 93 | FROM log |
94 | 94 | INNER JOIN request ON (request.id = log.objectid AND log.objecttype = 'Request') |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | AND (emailtemplate.oncreated = '1' OR log.action = 'Closed custom-y') |
100 | 100 | ORDER BY log.timestamp; |
101 | 101 | SQL |
102 | - ); |
|
103 | - $usersCreatedQuery->execute(array(":username" => $user->getUsername())); |
|
104 | - $usersCreated = $usersCreatedQuery->fetchAll(PDO::FETCH_ASSOC); |
|
105 | - $this->assign("created", $usersCreated); |
|
102 | + ); |
|
103 | + $usersCreatedQuery->execute(array(":username" => $user->getUsername())); |
|
104 | + $usersCreated = $usersCreatedQuery->fetchAll(PDO::FETCH_ASSOC); |
|
105 | + $this->assign("created", $usersCreated); |
|
106 | 106 | |
107 | - $usersNotCreatedQuery = $database->prepare(<<<SQL |
|
107 | + $usersNotCreatedQuery = $database->prepare(<<<SQL |
|
108 | 108 | SELECT log.timestamp time, request.name name, request.id id |
109 | 109 | FROM log |
110 | 110 | JOIN request ON request.id = log.objectid AND log.objecttype = 'Request' |
@@ -115,45 +115,45 @@ discard block |
||
115 | 115 | AND (emailtemplate.oncreated = '0' OR log.action = 'Closed custom-n' OR log.action = 'Closed 0') |
116 | 116 | ORDER BY log.timestamp; |
117 | 117 | SQL |
118 | - ); |
|
119 | - $usersNotCreatedQuery->execute(array(":username" => $user->getUsername())); |
|
120 | - $usersNotCreated = $usersNotCreatedQuery->fetchAll(PDO::FETCH_ASSOC); |
|
121 | - $this->assign("notcreated", $usersNotCreated); |
|
122 | - |
|
123 | - /** @var Log[] $logs */ |
|
124 | - $logs = LogSearchHelper::get($database) |
|
125 | - ->byObjectType('User') |
|
126 | - ->byObjectId($user->getId()) |
|
127 | - ->getRecordCount($logCount) |
|
128 | - ->fetch(); |
|
129 | - |
|
130 | - if ($logCount === 0) { |
|
131 | - $this->assign('accountlog', array()); |
|
132 | - } |
|
133 | - else { |
|
134 | - list($users, $logData) = LogHelper::prepareLogsForTemplate($logs, $database, $this->getSiteConfiguration()); |
|
135 | - |
|
136 | - $this->assign("accountlog", $logData); |
|
137 | - $this->assign("users", $users); |
|
138 | - } |
|
139 | - |
|
140 | - $currentUser = User::getCurrent($database); |
|
141 | - $this->assign('canApprove', $this->barrierTest('approve', $currentUser, PageUserManagement::class)); |
|
142 | - $this->assign('canDecline', $this->barrierTest('decline', $currentUser, PageUserManagement::class)); |
|
143 | - $this->assign('canRename', $this->barrierTest('rename', $currentUser, PageUserManagement::class)); |
|
144 | - $this->assign('canEditUser', $this->barrierTest('editUser', $currentUser, PageUserManagement::class)); |
|
145 | - $this->assign('canSuspend', $this->barrierTest('suspend', $currentUser, PageUserManagement::class)); |
|
146 | - $this->assign('canEditRoles', $this->barrierTest('editRoles', $currentUser, PageUserManagement::class)); |
|
147 | - |
|
148 | - $oauth = new OAuthUserHelper($user, $database, $this->getOAuthProtocolHelper(), $this->getSiteConfiguration()); |
|
149 | - $this->assign('oauth', $oauth); |
|
150 | - |
|
151 | - if ($oauth->isFullyLinked()) { |
|
152 | - $this->assign('identity', $oauth->getIdentity(true)); |
|
153 | - $this->assign('identityExpired', $oauth->identityExpired()); |
|
154 | - } |
|
155 | - |
|
156 | - $this->assign('statsPageTitle', 'Account Creation Tool users'); |
|
157 | - $this->setTemplate("statistics/userdetail.tpl"); |
|
158 | - } |
|
118 | + ); |
|
119 | + $usersNotCreatedQuery->execute(array(":username" => $user->getUsername())); |
|
120 | + $usersNotCreated = $usersNotCreatedQuery->fetchAll(PDO::FETCH_ASSOC); |
|
121 | + $this->assign("notcreated", $usersNotCreated); |
|
122 | + |
|
123 | + /** @var Log[] $logs */ |
|
124 | + $logs = LogSearchHelper::get($database) |
|
125 | + ->byObjectType('User') |
|
126 | + ->byObjectId($user->getId()) |
|
127 | + ->getRecordCount($logCount) |
|
128 | + ->fetch(); |
|
129 | + |
|
130 | + if ($logCount === 0) { |
|
131 | + $this->assign('accountlog', array()); |
|
132 | + } |
|
133 | + else { |
|
134 | + list($users, $logData) = LogHelper::prepareLogsForTemplate($logs, $database, $this->getSiteConfiguration()); |
|
135 | + |
|
136 | + $this->assign("accountlog", $logData); |
|
137 | + $this->assign("users", $users); |
|
138 | + } |
|
139 | + |
|
140 | + $currentUser = User::getCurrent($database); |
|
141 | + $this->assign('canApprove', $this->barrierTest('approve', $currentUser, PageUserManagement::class)); |
|
142 | + $this->assign('canDecline', $this->barrierTest('decline', $currentUser, PageUserManagement::class)); |
|
143 | + $this->assign('canRename', $this->barrierTest('rename', $currentUser, PageUserManagement::class)); |
|
144 | + $this->assign('canEditUser', $this->barrierTest('editUser', $currentUser, PageUserManagement::class)); |
|
145 | + $this->assign('canSuspend', $this->barrierTest('suspend', $currentUser, PageUserManagement::class)); |
|
146 | + $this->assign('canEditRoles', $this->barrierTest('editRoles', $currentUser, PageUserManagement::class)); |
|
147 | + |
|
148 | + $oauth = new OAuthUserHelper($user, $database, $this->getOAuthProtocolHelper(), $this->getSiteConfiguration()); |
|
149 | + $this->assign('oauth', $oauth); |
|
150 | + |
|
151 | + if ($oauth->isFullyLinked()) { |
|
152 | + $this->assign('identity', $oauth->getIdentity(true)); |
|
153 | + $this->assign('identityExpired', $oauth->identityExpired()); |
|
154 | + } |
|
155 | + |
|
156 | + $this->assign('statsPageTitle', 'Account Creation Tool users'); |
|
157 | + $this->setTemplate("statistics/userdetail.tpl"); |
|
158 | + } |
|
159 | 159 | } |
@@ -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 |
@@ -48,8 +48,8 @@ |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | //Look for and detect IPv4/IPv6 addresses in comment text, and warn the commenter. |
51 | - $ipv4Regex = '/\b' . RegexConstants::IPV4 . '\b/'; |
|
52 | - $ipv6Regex = '/\b' . RegexConstants::IPV6 . '\b/'; |
|
51 | + $ipv4Regex = '/\b'.RegexConstants::IPV4.'\b/'; |
|
52 | + $ipv6Regex = '/\b'.RegexConstants::IPV6.'\b/'; |
|
53 | 53 | |
54 | 54 | $overridePolicy = WebRequest::postBoolean('privpol-check-override'); |
55 | 55 |
@@ -15,51 +15,51 @@ |
||
15 | 15 | |
16 | 16 | class PageComment extends RequestActionBase |
17 | 17 | { |
18 | - /** |
|
19 | - * Main function for this page, when no specific actions are called. |
|
20 | - * @return void |
|
21 | - */ |
|
22 | - protected function main() |
|
23 | - { |
|
24 | - $this->checkPosted(); |
|
25 | - $database = $this->getDatabase(); |
|
26 | - $request = $this->getRequest($database); |
|
18 | + /** |
|
19 | + * Main function for this page, when no specific actions are called. |
|
20 | + * @return void |
|
21 | + */ |
|
22 | + protected function main() |
|
23 | + { |
|
24 | + $this->checkPosted(); |
|
25 | + $database = $this->getDatabase(); |
|
26 | + $request = $this->getRequest($database); |
|
27 | 27 | |
28 | - $commentText = WebRequest::postString('comment'); |
|
29 | - if ($commentText === false || $commentText == '') { |
|
30 | - $this->redirect('viewRequest', null, array('id' => $request->getId())); |
|
28 | + $commentText = WebRequest::postString('comment'); |
|
29 | + if ($commentText === false || $commentText == '') { |
|
30 | + $this->redirect('viewRequest', null, array('id' => $request->getId())); |
|
31 | 31 | |
32 | - return; |
|
33 | - } |
|
32 | + return; |
|
33 | + } |
|
34 | 34 | |
35 | - //Look for and detect IPv4/IPv6 addresses in comment text, and warn the commenter. |
|
36 | - $ipv4Regex = '/\b' . RegexConstants::IPV4 . '\b/'; |
|
37 | - $ipv6Regex = '/\b' . RegexConstants::IPV6 . '\b/'; |
|
35 | + //Look for and detect IPv4/IPv6 addresses in comment text, and warn the commenter. |
|
36 | + $ipv4Regex = '/\b' . RegexConstants::IPV4 . '\b/'; |
|
37 | + $ipv6Regex = '/\b' . RegexConstants::IPV6 . '\b/'; |
|
38 | 38 | |
39 | - $overridePolicy = WebRequest::postBoolean('privpol-check-override'); |
|
39 | + $overridePolicy = WebRequest::postBoolean('privpol-check-override'); |
|
40 | 40 | |
41 | - if ((preg_match($ipv4Regex, $commentText) || preg_match($ipv6Regex, $commentText)) && !$overridePolicy) { |
|
42 | - $this->assignCSRFToken(); |
|
43 | - $this->assign("request", $request); |
|
44 | - $this->assign("comment", $commentText); |
|
45 | - $this->setTemplate("privpol-warning.tpl"); |
|
41 | + if ((preg_match($ipv4Regex, $commentText) || preg_match($ipv6Regex, $commentText)) && !$overridePolicy) { |
|
42 | + $this->assignCSRFToken(); |
|
43 | + $this->assign("request", $request); |
|
44 | + $this->assign("comment", $commentText); |
|
45 | + $this->setTemplate("privpol-warning.tpl"); |
|
46 | 46 | |
47 | - return; |
|
48 | - } |
|
47 | + return; |
|
48 | + } |
|
49 | 49 | |
50 | - $visibility = WebRequest::postBoolean('adminOnly') ? 'admin' : 'user'; |
|
50 | + $visibility = WebRequest::postBoolean('adminOnly') ? 'admin' : 'user'; |
|
51 | 51 | |
52 | - $comment = new Comment(); |
|
53 | - $comment->setDatabase($database); |
|
52 | + $comment = new Comment(); |
|
53 | + $comment->setDatabase($database); |
|
54 | 54 | |
55 | - $comment->setRequest($request->getId()); |
|
56 | - $comment->setVisibility($visibility); |
|
57 | - $comment->setUser(User::getCurrent($database)->getId()); |
|
58 | - $comment->setComment($commentText); |
|
55 | + $comment->setRequest($request->getId()); |
|
56 | + $comment->setVisibility($visibility); |
|
57 | + $comment->setUser(User::getCurrent($database)->getId()); |
|
58 | + $comment->setComment($commentText); |
|
59 | 59 | |
60 | - $comment->save(); |
|
60 | + $comment->save(); |
|
61 | 61 | |
62 | - $this->getNotificationHelper()->commentCreated($comment, $request); |
|
63 | - $this->redirect('viewRequest', null, array('id' => $request->getId())); |
|
64 | - } |
|
62 | + $this->getNotificationHelper()->commentCreated($comment, $request); |
|
63 | + $this->redirect('viewRequest', null, array('id' => $request->getId())); |
|
64 | + } |
|
65 | 65 | } |
@@ -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 | } |
@@ -21,22 +21,22 @@ |
||
21 | 21 | */ |
22 | 22 | abstract class ReadableException extends Exception |
23 | 23 | { |
24 | - use TemplateOutput; |
|
24 | + use TemplateOutput; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Returns a readable HTML error message that's displayable to the user using templates. |
|
28 | - * @return string |
|
29 | - */ |
|
30 | - abstract public function getReadableError(); |
|
26 | + /** |
|
27 | + * Returns a readable HTML error message that's displayable to the user using templates. |
|
28 | + * @return string |
|
29 | + */ |
|
30 | + abstract public function getReadableError(); |
|
31 | 31 | |
32 | - /** |
|
33 | - * @return SiteConfiguration |
|
34 | - */ |
|
35 | - protected function getSiteConfiguration() |
|
36 | - { |
|
37 | - // Uck. However, we have encountered an exception. |
|
38 | - global $siteConfiguration; |
|
32 | + /** |
|
33 | + * @return SiteConfiguration |
|
34 | + */ |
|
35 | + protected function getSiteConfiguration() |
|
36 | + { |
|
37 | + // Uck. However, we have encountered an exception. |
|
38 | + global $siteConfiguration; |
|
39 | 39 | |
40 | - return $siteConfiguration; |
|
41 | - } |
|
40 | + return $siteConfiguration; |
|
41 | + } |
|
42 | 42 | } |
43 | 43 | \ No newline at end of file |
@@ -21,13 +21,13 @@ |
||
21 | 21 | */ |
22 | 22 | class EnvironmentException extends Exception |
23 | 23 | { |
24 | - /** |
|
25 | - * EnvironmentException constructor. |
|
26 | - * |
|
27 | - * @param string $friendlyMessage |
|
28 | - */ |
|
29 | - public function __construct($friendlyMessage) |
|
30 | - { |
|
31 | - parent::__construct($friendlyMessage); |
|
32 | - } |
|
24 | + /** |
|
25 | + * EnvironmentException constructor. |
|
26 | + * |
|
27 | + * @param string $friendlyMessage |
|
28 | + */ |
|
29 | + public function __construct($friendlyMessage) |
|
30 | + { |
|
31 | + parent::__construct($friendlyMessage); |
|
32 | + } |
|
33 | 33 | } |
34 | 34 | \ No newline at end of file |