Completed
Pull Request — rbac (#446)
by Simon
04:22
created
includes/Pages/RequestAction/PageSendToUser.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -17,43 +17,43 @@
 block discarded – undo
17 17
 
18 18
 class PageSendToUser extends RequestActionBase
19 19
 {
20
-    /**
21
-     * Main function for this page, when no specific actions are called.
22
-     * @throws ApplicationLogicException
23
-     * @throws Exception
24
-     */
25
-    protected function main()
26
-    {
27
-        $this->checkPosted();
28
-        $database = $this->getDatabase();
29
-        $request = $this->getRequest($database);
30
-
31
-        if ($request->getReserved() !== User::getCurrent($database)->getId()) {
32
-            throw new ApplicationLogicException('You don\'t have this request reserved!');
33
-        }
34
-
35
-        $username = WebRequest::postString('user');
36
-        if ($username === null) {
37
-            throw new ApplicationLogicException('User must be specified');
38
-        }
39
-
40
-        $user = User::getByUsername($username, $database);
41
-        if ($user === false) {
42
-            throw new ApplicationLogicException('User not found');
43
-        }
44
-
45
-        if (!$user->isActive()) {
46
-            throw new ApplicationLogicException('User is currently not active on the tool');
47
-        }
48
-
49
-        $request->setReserved($user->getId());
50
-        $request->setUpdateVersion(WebRequest::postInt('updateversion'));
51
-        $request->save();
52
-
53
-        Logger::sendReservation($database, $request, $user);
54
-        $this->getNotificationHelper()->requestReservationSent($request, $user);
55
-        SessionAlert::success("Reservation sent successfully");
56
-
57
-        $this->redirect('viewRequest', null, array('id' => $request->getId()));
58
-    }
20
+	/**
21
+	 * Main function for this page, when no specific actions are called.
22
+	 * @throws ApplicationLogicException
23
+	 * @throws Exception
24
+	 */
25
+	protected function main()
26
+	{
27
+		$this->checkPosted();
28
+		$database = $this->getDatabase();
29
+		$request = $this->getRequest($database);
30
+
31
+		if ($request->getReserved() !== User::getCurrent($database)->getId()) {
32
+			throw new ApplicationLogicException('You don\'t have this request reserved!');
33
+		}
34
+
35
+		$username = WebRequest::postString('user');
36
+		if ($username === null) {
37
+			throw new ApplicationLogicException('User must be specified');
38
+		}
39
+
40
+		$user = User::getByUsername($username, $database);
41
+		if ($user === false) {
42
+			throw new ApplicationLogicException('User not found');
43
+		}
44
+
45
+		if (!$user->isActive()) {
46
+			throw new ApplicationLogicException('User is currently not active on the tool');
47
+		}
48
+
49
+		$request->setReserved($user->getId());
50
+		$request->setUpdateVersion(WebRequest::postInt('updateversion'));
51
+		$request->save();
52
+
53
+		Logger::sendReservation($database, $request, $user);
54
+		$this->getNotificationHelper()->requestReservationSent($request, $user);
55
+		SessionAlert::success("Reservation sent successfully");
56
+
57
+		$this->redirect('viewRequest', null, array('id' => $request->getId()));
58
+	}
59 59
 }
Please login to merge, or discard this patch.
includes/Pages/PageForgotPassword.php 1 patch
Indentation   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -17,149 +17,149 @@
 block discarded – undo
17 17
 
18 18
 class PageForgotPassword extends InternalPageBase
19 19
 {
20
-    /**
21
-     * Main function for this page, when no specific actions are called.
22
-     *
23
-     * This is the forgotten password reset form
24
-     * @category Security-Critical
25
-     */
26
-    protected function main()
27
-    {
28
-        if (WebRequest::wasPosted()) {
29
-            $this->validateCSRFToken();
30
-            $username = WebRequest::postString('username');
31
-            $email = WebRequest::postEmail('email');
32
-            $database = $this->getDatabase();
33
-
34
-            if ($username === null || trim($username) === "" || $email === null || trim($email) === "") {
35
-                throw new ApplicationLogicException("Both username and email address must be specified!");
36
-            }
37
-
38
-            $user = User::getByUsername($username, $database);
39
-            $this->sendResetMail($user, $email);
40
-
41
-            SessionAlert::success('<strong>Your password reset request has been completed.</strong> Please check your e-mail.');
42
-
43
-            $this->redirect('login');
44
-        }
45
-        else {
46
-            $this->assignCSRFToken();
47
-            $this->setTemplate('forgot-password/forgotpw.tpl');
48
-        }
49
-    }
50
-
51
-    /**
52
-     * Sends a reset email if the user is authenticated
53
-     *
54
-     * @param User|boolean $user  The user located from the database, or false. Doesn't really matter, since we do the
55
-     *                            check anyway within this method and silently skip if we don't have a user.
56
-     * @param string       $email The provided email address
57
-     */
58
-    private function sendResetMail($user, $email)
59
-    {
60
-        // If the user isn't found, or the email address is wrong, skip sending the details silently.
61
-        if (!$user instanceof User) {
62
-            return;
63
-        }
64
-
65
-        if (strtolower($user->getEmail()) === strtolower($email)) {
66
-            $clientIp = $this->getXffTrustProvider()
67
-                ->getTrustedClientIp(WebRequest::remoteAddress(), WebRequest::forwardedAddress());
68
-
69
-            $this->assign("user", $user);
70
-            $this->assign("hash", $user->getForgottenPasswordHash());
71
-            $this->assign("remoteAddress", $clientIp);
72
-
73
-            $emailContent = $this->fetchTemplate('forgot-password/reset-mail.tpl');
74
-
75
-            $this->getEmailHelper()->sendMail($user->getEmail(), "", $emailContent);
76
-        }
77
-    }
78
-
79
-    /**
80
-     * Entry point for the reset action
81
-     *
82
-     * This is the reset password part of the form.
83
-     * @category Security-Critical
84
-     */
85
-    protected function reset()
86
-    {
87
-        $si = WebRequest::getString('si');
88
-        $id = WebRequest::getString('id');
89
-
90
-        if ($si === null || trim($si) === "" || $id === null || trim($id) === "") {
91
-            throw new ApplicationLogicException("Link not valid, please ensure it has copied correctly");
92
-        }
93
-
94
-        $database = $this->getDatabase();
95
-        $user = $this->getResettingUser($id, $database, $si);
96
-
97
-        // Dual mode
98
-        if (WebRequest::wasPosted()) {
99
-            $this->validateCSRFToken();
100
-            try {
101
-                $this->doReset($user);
102
-            }
103
-            catch (ApplicationLogicException $ex) {
104
-                SessionAlert::error($ex->getMessage());
105
-                $this->redirect('forgotPassword', 'reset', array('si' => $si, 'id' => $id));
106
-
107
-                return;
108
-            }
109
-        }
110
-        else {
111
-            $this->assignCSRFToken();
112
-            $this->assign('user', $user);
113
-            $this->setTemplate('forgot-password/forgotpwreset.tpl');
114
-        }
115
-    }
116
-
117
-    /**
118
-     * Gets the user resetting their password from the database, or throwing an exception if that is not possible.
119
-     *
120
-     * @param integer     $id       The ID of the user to retrieve
121
-     * @param PdoDatabase $database The database object to use
122
-     * @param string      $si       The reset hash provided
123
-     *
124
-     * @return User
125
-     * @throws ApplicationLogicException
126
-     */
127
-    private function getResettingUser($id, $database, $si)
128
-    {
129
-        $user = User::getById($id, $database);
130
-
131
-        if ($user === false || $user->getForgottenPasswordHash() !== $si || $user->isCommunityUser()) {
132
-            throw new ApplicationLogicException("User not found");
133
-        }
134
-
135
-        return $user;
136
-    }
137
-
138
-    /**
139
-     * Performs the setting of the new password
140
-     *
141
-     * @param User $user The user to set the password for
142
-     *
143
-     * @throws ApplicationLogicException
144
-     */
145
-    private function doReset(User $user)
146
-    {
147
-        $pw = WebRequest::postString('pw');
148
-        $pw2 = WebRequest::postString('pw2');
149
-
150
-        if ($pw !== $pw2) {
151
-            throw new ApplicationLogicException('Passwords do not match!');
152
-        }
153
-
154
-        $user->setPassword($pw);
155
-        $user->save();
156
-
157
-        SessionAlert::success('You may now log in!');
158
-        $this->redirect('login');
159
-    }
160
-
161
-    protected function isProtectedPage()
162
-    {
163
-        return false;
164
-    }
20
+	/**
21
+	 * Main function for this page, when no specific actions are called.
22
+	 *
23
+	 * This is the forgotten password reset form
24
+	 * @category Security-Critical
25
+	 */
26
+	protected function main()
27
+	{
28
+		if (WebRequest::wasPosted()) {
29
+			$this->validateCSRFToken();
30
+			$username = WebRequest::postString('username');
31
+			$email = WebRequest::postEmail('email');
32
+			$database = $this->getDatabase();
33
+
34
+			if ($username === null || trim($username) === "" || $email === null || trim($email) === "") {
35
+				throw new ApplicationLogicException("Both username and email address must be specified!");
36
+			}
37
+
38
+			$user = User::getByUsername($username, $database);
39
+			$this->sendResetMail($user, $email);
40
+
41
+			SessionAlert::success('<strong>Your password reset request has been completed.</strong> Please check your e-mail.');
42
+
43
+			$this->redirect('login');
44
+		}
45
+		else {
46
+			$this->assignCSRFToken();
47
+			$this->setTemplate('forgot-password/forgotpw.tpl');
48
+		}
49
+	}
50
+
51
+	/**
52
+	 * Sends a reset email if the user is authenticated
53
+	 *
54
+	 * @param User|boolean $user  The user located from the database, or false. Doesn't really matter, since we do the
55
+	 *                            check anyway within this method and silently skip if we don't have a user.
56
+	 * @param string       $email The provided email address
57
+	 */
58
+	private function sendResetMail($user, $email)
59
+	{
60
+		// If the user isn't found, or the email address is wrong, skip sending the details silently.
61
+		if (!$user instanceof User) {
62
+			return;
63
+		}
64
+
65
+		if (strtolower($user->getEmail()) === strtolower($email)) {
66
+			$clientIp = $this->getXffTrustProvider()
67
+				->getTrustedClientIp(WebRequest::remoteAddress(), WebRequest::forwardedAddress());
68
+
69
+			$this->assign("user", $user);
70
+			$this->assign("hash", $user->getForgottenPasswordHash());
71
+			$this->assign("remoteAddress", $clientIp);
72
+
73
+			$emailContent = $this->fetchTemplate('forgot-password/reset-mail.tpl');
74
+
75
+			$this->getEmailHelper()->sendMail($user->getEmail(), "", $emailContent);
76
+		}
77
+	}
78
+
79
+	/**
80
+	 * Entry point for the reset action
81
+	 *
82
+	 * This is the reset password part of the form.
83
+	 * @category Security-Critical
84
+	 */
85
+	protected function reset()
86
+	{
87
+		$si = WebRequest::getString('si');
88
+		$id = WebRequest::getString('id');
89
+
90
+		if ($si === null || trim($si) === "" || $id === null || trim($id) === "") {
91
+			throw new ApplicationLogicException("Link not valid, please ensure it has copied correctly");
92
+		}
93
+
94
+		$database = $this->getDatabase();
95
+		$user = $this->getResettingUser($id, $database, $si);
96
+
97
+		// Dual mode
98
+		if (WebRequest::wasPosted()) {
99
+			$this->validateCSRFToken();
100
+			try {
101
+				$this->doReset($user);
102
+			}
103
+			catch (ApplicationLogicException $ex) {
104
+				SessionAlert::error($ex->getMessage());
105
+				$this->redirect('forgotPassword', 'reset', array('si' => $si, 'id' => $id));
106
+
107
+				return;
108
+			}
109
+		}
110
+		else {
111
+			$this->assignCSRFToken();
112
+			$this->assign('user', $user);
113
+			$this->setTemplate('forgot-password/forgotpwreset.tpl');
114
+		}
115
+	}
116
+
117
+	/**
118
+	 * Gets the user resetting their password from the database, or throwing an exception if that is not possible.
119
+	 *
120
+	 * @param integer     $id       The ID of the user to retrieve
121
+	 * @param PdoDatabase $database The database object to use
122
+	 * @param string      $si       The reset hash provided
123
+	 *
124
+	 * @return User
125
+	 * @throws ApplicationLogicException
126
+	 */
127
+	private function getResettingUser($id, $database, $si)
128
+	{
129
+		$user = User::getById($id, $database);
130
+
131
+		if ($user === false || $user->getForgottenPasswordHash() !== $si || $user->isCommunityUser()) {
132
+			throw new ApplicationLogicException("User not found");
133
+		}
134
+
135
+		return $user;
136
+	}
137
+
138
+	/**
139
+	 * Performs the setting of the new password
140
+	 *
141
+	 * @param User $user The user to set the password for
142
+	 *
143
+	 * @throws ApplicationLogicException
144
+	 */
145
+	private function doReset(User $user)
146
+	{
147
+		$pw = WebRequest::postString('pw');
148
+		$pw2 = WebRequest::postString('pw2');
149
+
150
+		if ($pw !== $pw2) {
151
+			throw new ApplicationLogicException('Passwords do not match!');
152
+		}
153
+
154
+		$user->setPassword($pw);
155
+		$user->save();
156
+
157
+		SessionAlert::success('You may now log in!');
158
+		$this->redirect('login');
159
+	}
160
+
161
+	protected function isProtectedPage()
162
+	{
163
+		return false;
164
+	}
165 165
 }
Please login to merge, or discard this patch.
includes/Pages/PageUserManagement.php 2 patches
Indentation   +529 added lines, -529 removed lines patch added patch discarded remove patch
@@ -23,533 +23,533 @@
 block discarded – undo
23 23
  */
24 24
 class PageUserManagement extends InternalPageBase
25 25
 {
26
-    /** @var string */
27
-    private $adminMailingList = '[email protected]';
28
-
29
-    /**
30
-     * Main function for this page, when no specific actions are called.
31
-     */
32
-    protected function main()
33
-    {
34
-        $this->setHtmlTitle('User Management');
35
-
36
-        $database = $this->getDatabase();
37
-        $currentUser = User::getCurrent($database);
38
-
39
-        if (WebRequest::getBoolean("showAll")) {
40
-            $this->assign("showAll", true);
41
-
42
-            $this->assign("suspendedUsers",
43
-                UserSearchHelper::get($database)->byStatus(User::STATUS_SUSPENDED)->fetch());
44
-            $this->assign("declinedUsers", UserSearchHelper::get($database)->byStatus(User::STATUS_DECLINED)->fetch());
45
-
46
-            UserSearchHelper::get($database)->getRoleMap($roleMap);
47
-        }
48
-        else {
49
-            $this->assign("showAll", false);
50
-            $this->assign("suspendedUsers", array());
51
-            $this->assign("declinedUsers", array());
52
-
53
-            UserSearchHelper::get($database)->statusIn(array('New', 'Active'))->getRoleMap($roleMap);
54
-        }
55
-
56
-        $this->assign('newUsers', UserSearchHelper::get($database)->byStatus(User::STATUS_NEW)->fetch());
57
-        $this->assign('normalUsers',
58
-            UserSearchHelper::get($database)->byStatus(User::STATUS_ACTIVE)->byRole('user')->fetch());
59
-        $this->assign('adminUsers',
60
-            UserSearchHelper::get($database)->byStatus(User::STATUS_ACTIVE)->byRole('admin')->fetch());
61
-        $this->assign('checkUsers',
62
-            UserSearchHelper::get($database)->byStatus(User::STATUS_ACTIVE)->byRole('checkuser')->fetch());
63
-        $this->assign('toolRoots',
64
-            UserSearchHelper::get($database)->byStatus(User::STATUS_ACTIVE)->byRole('toolRoot')->fetch());
65
-
66
-        $this->assign('roles', $roleMap);
67
-
68
-        $this->getTypeAheadHelper()->defineTypeAheadSource('username-typeahead', function() use ($database) {
69
-            return UserSearchHelper::get($database)->fetchColumn('username');
70
-        });
71
-
72
-        $this->assign('canApprove', $this->barrierTest('approve', $currentUser));
73
-        $this->assign('canDecline', $this->barrierTest('decline', $currentUser));
74
-        $this->assign('canRename', $this->barrierTest('rename', $currentUser));
75
-        $this->assign('canEditUser', $this->barrierTest('editUser', $currentUser));
76
-        $this->assign('canSuspend', $this->barrierTest('suspend', $currentUser));
77
-        $this->assign('canEditRoles', $this->barrierTest('editRoles', $currentUser));
78
-
79
-        $this->setTemplate("usermanagement/main.tpl");
80
-    }
81
-
82
-    #region Access control
83
-
84
-    /**
85
-     * Action target for editing the roles assigned to a user
86
-     */
87
-    protected function editRoles()
88
-    {
89
-        $this->setHtmlTitle('User Management');
90
-        $database = $this->getDatabase();
91
-        $userId = WebRequest::getInt('user');
92
-
93
-        /** @var User $user */
94
-        $user = User::getById($userId, $database);
95
-
96
-        if ($user === false) {
97
-            throw new ApplicationLogicException('Sorry, the user you are trying to edit could not be found.');
98
-        }
99
-
100
-        $roleData = $this->getRoleData(UserRole::getForUser($user->getId(), $database));
101
-
102
-        // Dual-mode action
103
-        if (WebRequest::wasPosted()) {
104
-            $this->validateCSRFToken();
105
-
106
-            $reason = WebRequest::postString('reason');
107
-            if ($reason === false || trim($reason) === '') {
108
-                throw new ApplicationLogicException('No reason specified for roles change');
109
-            }
110
-
111
-            /** @var UserRole[] $delete */
112
-            $delete = array();
113
-            /** @var string[] $delete */
114
-            $add = array();
115
-
116
-            foreach ($roleData as $name => $r) {
117
-                if ($r['allowEdit'] !== 1) {
118
-                    // not allowed, to touch this, so ignore it
119
-                    continue;
120
-                }
121
-
122
-                $newValue = WebRequest::postBoolean('role-' . $name) ? 1 : 0;
123
-                if ($newValue !== $r['active']) {
124
-                    if ($newValue === 0) {
125
-                        $delete[] = $r['object'];
126
-                    }
127
-
128
-                    if ($newValue === 1) {
129
-                        $add[] = $name;
130
-                    }
131
-                }
132
-            }
133
-
134
-            // Check there's something to do
135
-            if ((count($add) + count($delete)) === 0) {
136
-                $this->redirect('statistics/users', 'detail', array('user' => $user->getId()));
137
-                SessionAlert::warning('No changes made to roles.');
138
-
139
-                return;
140
-            }
141
-
142
-            $removed = array();
143
-
144
-            /** @var UserRole $d */
145
-            foreach ($delete as $d) {
146
-                $removed[] = $d->getRole();
147
-                $d->delete();
148
-            }
149
-
150
-            foreach ($add as $x) {
151
-                $a = new UserRole();
152
-                $a->setUser($user->getId());
153
-                $a->setRole($x);
154
-                $a->setDatabase($database);
155
-                $a->save();
156
-            }
157
-
158
-            Logger::userRolesEdited($database, $user, $reason, $add, $removed);
159
-
160
-            // dummy save for optimistic locking. If this fails, the entire txn will roll back.
161
-            $user->setUpdateVersion(WebRequest::postInt('updateversion'));
162
-            $user->save();
163
-
164
-            $this->getNotificationHelper()->userRolesEdited($user, $reason);
165
-            SessionAlert::quick('Roles changed for user ' . htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8'));
166
-
167
-            $this->redirect('statistics/users', 'detail', array('user' => $user->getId()));
168
-            return;
169
-        }
170
-        else {
171
-            $this->assignCSRFToken();
172
-            $this->setTemplate('usermanagement/roleedit.tpl');
173
-            $this->assign('user', $user);
174
-            $this->assign('roleData', $roleData);
175
-        }
176
-    }
177
-
178
-    /**
179
-     * Action target for suspending users
180
-     *
181
-     * @throws ApplicationLogicException
182
-     */
183
-    protected function suspend()
184
-    {
185
-        $this->setHtmlTitle('User Management');
186
-
187
-        $database = $this->getDatabase();
188
-
189
-        $userId = WebRequest::getInt('user');
190
-
191
-        /** @var User $user */
192
-        $user = User::getById($userId, $database);
193
-
194
-        if ($user === false) {
195
-            throw new ApplicationLogicException('Sorry, the user you are trying to suspend could not be found.');
196
-        }
197
-
198
-        if ($user->isSuspended()) {
199
-            throw new ApplicationLogicException('Sorry, the user you are trying to suspend is already suspended.');
200
-        }
201
-
202
-        // Dual-mode action
203
-        if (WebRequest::wasPosted()) {
204
-            $this->validateCSRFToken();
205
-            $reason = WebRequest::postString('reason');
206
-
207
-            if ($reason === null || trim($reason) === "") {
208
-                throw new ApplicationLogicException('No reason provided');
209
-            }
210
-
211
-            $user->setStatus(User::STATUS_SUSPENDED);
212
-            $user->setUpdateVersion(WebRequest::postInt('updateversion'));
213
-            $user->save();
214
-            Logger::suspendedUser($database, $user, $reason);
215
-
216
-            $this->getNotificationHelper()->userSuspended($user, $reason);
217
-            SessionAlert::quick('Suspended user ' . htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8'));
218
-
219
-            // send email
220
-            $this->sendStatusChangeEmail(
221
-                'Your WP:ACC account has been suspended',
222
-                'usermanagement/emails/suspended.tpl',
223
-                $reason,
224
-                $user,
225
-                User::getCurrent($database)->getUsername()
226
-            );
227
-
228
-            $this->redirect('userManagement');
229
-
230
-            return;
231
-        }
232
-        else {
233
-            $this->assignCSRFToken();
234
-            $this->setTemplate('usermanagement/changelevel-reason.tpl');
235
-            $this->assign('user', $user);
236
-            $this->assign('status', 'Suspended');
237
-            $this->assign("showReason", true);
238
-        }
239
-    }
240
-
241
-    /**
242
-     * Entry point for the decline action
243
-     *
244
-     * @throws ApplicationLogicException
245
-     */
246
-    protected function decline()
247
-    {
248
-        $this->setHtmlTitle('User Management');
249
-
250
-        $database = $this->getDatabase();
251
-
252
-        $userId = WebRequest::getInt('user');
253
-        $user = User::getById($userId, $database);
254
-
255
-        if ($user === false) {
256
-            throw new ApplicationLogicException('Sorry, the user you are trying to decline could not be found.');
257
-        }
258
-
259
-        if (!$user->isNewUser()) {
260
-            throw new ApplicationLogicException('Sorry, the user you are trying to decline is not new.');
261
-        }
262
-
263
-        // Dual-mode action
264
-        if (WebRequest::wasPosted()) {
265
-            $this->validateCSRFToken();
266
-            $reason = WebRequest::postString('reason');
267
-
268
-            if ($reason === null || trim($reason) === "") {
269
-                throw new ApplicationLogicException('No reason provided');
270
-            }
271
-
272
-            $user->setStatus(User::STATUS_DECLINED);
273
-            $user->setUpdateVersion(WebRequest::postInt('updateversion'));
274
-            $user->save();
275
-            Logger::declinedUser($database, $user, $reason);
276
-
277
-            $this->getNotificationHelper()->userDeclined($user, $reason);
278
-            SessionAlert::quick('Declined user ' . htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8'));
279
-
280
-            // send email
281
-            $this->sendStatusChangeEmail(
282
-                'Your WP:ACC account has been declined',
283
-                'usermanagement/emails/declined.tpl',
284
-                $reason,
285
-                $user,
286
-                User::getCurrent($database)->getUsername()
287
-            );
288
-
289
-            $this->redirect('userManagement');
290
-
291
-            return;
292
-        }
293
-        else {
294
-            $this->assignCSRFToken();
295
-            $this->setTemplate('usermanagement/changelevel-reason.tpl');
296
-            $this->assign('user', $user);
297
-            $this->assign('status', 'Declined');
298
-            $this->assign("showReason", true);
299
-        }
300
-    }
301
-
302
-    /**
303
-     * Entry point for the approve action
304
-     *
305
-     * @throws ApplicationLogicException
306
-     */
307
-    protected function approve()
308
-    {
309
-        $this->setHtmlTitle('User Management');
310
-
311
-        $database = $this->getDatabase();
312
-
313
-        $userId = WebRequest::getInt('user');
314
-        $user = User::getById($userId, $database);
315
-
316
-        if ($user === false) {
317
-            throw new ApplicationLogicException('Sorry, the user you are trying to approve could not be found.');
318
-        }
319
-
320
-        if ($user->isActive()) {
321
-            throw new ApplicationLogicException('Sorry, the user you are trying to approve is already an active user.');
322
-        }
323
-
324
-        // Dual-mode action
325
-        if (WebRequest::wasPosted()) {
326
-            $this->validateCSRFToken();
327
-            $user->setStatus(User::STATUS_ACTIVE);
328
-            $user->setUpdateVersion(WebRequest::postInt('updateversion'));
329
-            $user->save();
330
-            Logger::approvedUser($database, $user);
331
-
332
-            $this->getNotificationHelper()->userApproved($user);
333
-            SessionAlert::quick('Approved user ' . htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8'));
334
-
335
-            // send email
336
-            $this->sendStatusChangeEmail(
337
-                'Your WP:ACC account has been approved',
338
-                'usermanagement/emails/approved.tpl',
339
-                null,
340
-                $user,
341
-                User::getCurrent($database)->getUsername()
342
-            );
343
-
344
-            $this->redirect("userManagement");
345
-
346
-            return;
347
-        }
348
-        else {
349
-            $this->assignCSRFToken();
350
-            $this->setTemplate("usermanagement/changelevel-reason.tpl");
351
-            $this->assign("user", $user);
352
-            $this->assign("status", "User");
353
-            $this->assign("showReason", false);
354
-        }
355
-    }
356
-
357
-    #endregion
358
-
359
-    #region Renaming / Editing
360
-
361
-    /**
362
-     * Entry point for the rename action
363
-     *
364
-     * @throws ApplicationLogicException
365
-     */
366
-    protected function rename()
367
-    {
368
-        $this->setHtmlTitle('User Management');
369
-
370
-        $database = $this->getDatabase();
371
-
372
-        $userId = WebRequest::getInt('user');
373
-        $user = User::getById($userId, $database);
374
-
375
-        if ($user === false) {
376
-            throw new ApplicationLogicException('Sorry, the user you are trying to rename could not be found.');
377
-        }
378
-
379
-        // Dual-mode action
380
-        if (WebRequest::wasPosted()) {
381
-            $this->validateCSRFToken();
382
-            $newUsername = WebRequest::postString('newname');
383
-
384
-            if ($newUsername === null || trim($newUsername) === "") {
385
-                throw new ApplicationLogicException('The new username cannot be empty');
386
-            }
387
-
388
-            if (User::getByUsername($newUsername, $database) != false) {
389
-                throw new ApplicationLogicException('The new username already exists');
390
-            }
391
-
392
-            $oldUsername = $user->getUsername();
393
-            $user->setUsername($newUsername);
394
-            $user->setUpdateVersion(WebRequest::postInt('updateversion'));
395
-
396
-            $user->save();
397
-
398
-            $logEntryData = serialize(array(
399
-                'old' => $oldUsername,
400
-                'new' => $newUsername,
401
-            ));
402
-
403
-            Logger::renamedUser($database, $user, $logEntryData);
404
-
405
-            SessionAlert::quick("Changed User "
406
-                . htmlentities($oldUsername, ENT_COMPAT, 'UTF-8')
407
-                . " name to "
408
-                . htmlentities($newUsername, ENT_COMPAT, 'UTF-8'));
409
-
410
-            $this->getNotificationHelper()->userRenamed($user, $oldUsername);
411
-
412
-            // send an email to the user.
413
-            $this->assign('targetUsername', $user->getUsername());
414
-            $this->assign('toolAdmin', User::getCurrent($database)->getUsername());
415
-            $this->assign('oldUsername', $oldUsername);
416
-            $this->assign('mailingList', $this->adminMailingList);
417
-
418
-            $this->getEmailHelper()->sendMail(
419
-                $user->getEmail(),
420
-                'Your username on WP:ACC has been changed',
421
-                $this->fetchTemplate('usermanagement/emails/renamed.tpl'),
422
-                array('Reply-To' => $this->adminMailingList)
423
-            );
424
-
425
-            $this->redirect("userManagement");
426
-
427
-            return;
428
-        }
429
-        else {
430
-            $this->assignCSRFToken();
431
-            $this->setTemplate('usermanagement/renameuser.tpl');
432
-            $this->assign('user', $user);
433
-        }
434
-    }
435
-
436
-    /**
437
-     * Entry point for the edit action
438
-     *
439
-     * @throws ApplicationLogicException
440
-     */
441
-    protected function editUser()
442
-    {
443
-        $this->setHtmlTitle('User Management');
444
-
445
-        $database = $this->getDatabase();
446
-
447
-        $userId = WebRequest::getInt('user');
448
-        $user = User::getById($userId, $database);
449
-
450
-        if ($user === false) {
451
-            throw new ApplicationLogicException('Sorry, the user you are trying to edit could not be found.');
452
-        }
453
-
454
-        // Dual-mode action
455
-        if (WebRequest::wasPosted()) {
456
-            $this->validateCSRFToken();
457
-            $newEmail = WebRequest::postEmail('user_email');
458
-            $newOnWikiName = WebRequest::postString('user_onwikiname');
459
-
460
-            if ($newEmail === null) {
461
-                throw new ApplicationLogicException('Invalid email address');
462
-            }
463
-
464
-            if (!$user->isOAuthLinked()) {
465
-                if (trim($newOnWikiName) == "") {
466
-                    throw new ApplicationLogicException('New on-wiki username cannot be blank');
467
-                }
468
-
469
-                $user->setOnWikiName($newOnWikiName);
470
-            }
471
-
472
-            $user->setEmail($newEmail);
473
-
474
-            $user->setUpdateVersion(WebRequest::postInt('updateversion'));
475
-
476
-            $user->save();
477
-
478
-            Logger::userPreferencesChange($database, $user);
479
-            $this->getNotificationHelper()->userPrefChange($user);
480
-            SessionAlert::quick('Changes to user\'s preferences have been saved');
481
-
482
-            $this->redirect("userManagement");
483
-
484
-            return;
485
-        }
486
-        else {
487
-            $this->assignCSRFToken();
488
-            $this->setTemplate('usermanagement/edituser.tpl');
489
-            $this->assign('user', $user);
490
-        }
491
-    }
492
-
493
-    #endregion
494
-
495
-    /**
496
-     * Sends a status change email to the user.
497
-     *
498
-     * @param string      $subject           The subject of the email
499
-     * @param string      $template          The smarty template to use
500
-     * @param string|null $reason            The reason for performing the status change
501
-     * @param User        $user              The user affected
502
-     * @param string      $toolAdminUsername The tool admin's username who is making the edit
503
-     */
504
-    private function sendStatusChangeEmail($subject, $template, $reason, $user, $toolAdminUsername)
505
-    {
506
-        $this->assign('targetUsername', $user->getUsername());
507
-        $this->assign('toolAdmin', $toolAdminUsername);
508
-        $this->assign('actionReason', $reason);
509
-        $this->assign('mailingList', $this->adminMailingList);
510
-
511
-        $this->getEmailHelper()->sendMail(
512
-            $user->getEmail(),
513
-            $subject,
514
-            $this->fetchTemplate($template),
515
-            array('Reply-To' => $this->adminMailingList)
516
-        );
517
-    }
518
-
519
-    /**
520
-     * @param UserRole[] $activeRoles
521
-     *
522
-     * @return array
523
-     */
524
-    private function getRoleData($activeRoles)
525
-    {
526
-        $availableRoles = $this->getSecurityManager()->getRoleConfiguration()->getAvailableRoles();
527
-
528
-        $currentUser = User::getCurrent($this->getDatabase());
529
-        $this->getSecurityManager()->getActiveRoles($currentUser, $userRoles, $inactiveRoles);
530
-
531
-        $initialValue = array('active' => 0, 'allowEdit' => 0, 'description' => '???', 'object' => null);
532
-
533
-        $roleData = array();
534
-        foreach ($availableRoles as $role => $data) {
535
-            $intersection = array_intersect($data['editableBy'], $userRoles);
536
-
537
-            $roleData[$role] = $initialValue;
538
-            $roleData[$role]['allowEdit'] = count($intersection) > 0 ? 1 : 0;
539
-            $roleData[$role]['description'] = $data['description'];
540
-        }
541
-
542
-        foreach ($activeRoles as $role) {
543
-            if (!isset($roleData[$role->getRole()])) {
544
-                // This value is no longer available in the configuration, allow changing (aka removing) it.
545
-                $roleData[$role->getRole()] = $initialValue;
546
-                $roleData[$role->getRole()]['allowEdit'] = 1;
547
-            }
548
-
549
-            $roleData[$role->getRole()]['object'] = $role;
550
-            $roleData[$role->getRole()]['active'] = 1;
551
-        }
552
-
553
-        return $roleData;
554
-    }
26
+	/** @var string */
27
+	private $adminMailingList = '[email protected]';
28
+
29
+	/**
30
+	 * Main function for this page, when no specific actions are called.
31
+	 */
32
+	protected function main()
33
+	{
34
+		$this->setHtmlTitle('User Management');
35
+
36
+		$database = $this->getDatabase();
37
+		$currentUser = User::getCurrent($database);
38
+
39
+		if (WebRequest::getBoolean("showAll")) {
40
+			$this->assign("showAll", true);
41
+
42
+			$this->assign("suspendedUsers",
43
+				UserSearchHelper::get($database)->byStatus(User::STATUS_SUSPENDED)->fetch());
44
+			$this->assign("declinedUsers", UserSearchHelper::get($database)->byStatus(User::STATUS_DECLINED)->fetch());
45
+
46
+			UserSearchHelper::get($database)->getRoleMap($roleMap);
47
+		}
48
+		else {
49
+			$this->assign("showAll", false);
50
+			$this->assign("suspendedUsers", array());
51
+			$this->assign("declinedUsers", array());
52
+
53
+			UserSearchHelper::get($database)->statusIn(array('New', 'Active'))->getRoleMap($roleMap);
54
+		}
55
+
56
+		$this->assign('newUsers', UserSearchHelper::get($database)->byStatus(User::STATUS_NEW)->fetch());
57
+		$this->assign('normalUsers',
58
+			UserSearchHelper::get($database)->byStatus(User::STATUS_ACTIVE)->byRole('user')->fetch());
59
+		$this->assign('adminUsers',
60
+			UserSearchHelper::get($database)->byStatus(User::STATUS_ACTIVE)->byRole('admin')->fetch());
61
+		$this->assign('checkUsers',
62
+			UserSearchHelper::get($database)->byStatus(User::STATUS_ACTIVE)->byRole('checkuser')->fetch());
63
+		$this->assign('toolRoots',
64
+			UserSearchHelper::get($database)->byStatus(User::STATUS_ACTIVE)->byRole('toolRoot')->fetch());
65
+
66
+		$this->assign('roles', $roleMap);
67
+
68
+		$this->getTypeAheadHelper()->defineTypeAheadSource('username-typeahead', function() use ($database) {
69
+			return UserSearchHelper::get($database)->fetchColumn('username');
70
+		});
71
+
72
+		$this->assign('canApprove', $this->barrierTest('approve', $currentUser));
73
+		$this->assign('canDecline', $this->barrierTest('decline', $currentUser));
74
+		$this->assign('canRename', $this->barrierTest('rename', $currentUser));
75
+		$this->assign('canEditUser', $this->barrierTest('editUser', $currentUser));
76
+		$this->assign('canSuspend', $this->barrierTest('suspend', $currentUser));
77
+		$this->assign('canEditRoles', $this->barrierTest('editRoles', $currentUser));
78
+
79
+		$this->setTemplate("usermanagement/main.tpl");
80
+	}
81
+
82
+	#region Access control
83
+
84
+	/**
85
+	 * Action target for editing the roles assigned to a user
86
+	 */
87
+	protected function editRoles()
88
+	{
89
+		$this->setHtmlTitle('User Management');
90
+		$database = $this->getDatabase();
91
+		$userId = WebRequest::getInt('user');
92
+
93
+		/** @var User $user */
94
+		$user = User::getById($userId, $database);
95
+
96
+		if ($user === false) {
97
+			throw new ApplicationLogicException('Sorry, the user you are trying to edit could not be found.');
98
+		}
99
+
100
+		$roleData = $this->getRoleData(UserRole::getForUser($user->getId(), $database));
101
+
102
+		// Dual-mode action
103
+		if (WebRequest::wasPosted()) {
104
+			$this->validateCSRFToken();
105
+
106
+			$reason = WebRequest::postString('reason');
107
+			if ($reason === false || trim($reason) === '') {
108
+				throw new ApplicationLogicException('No reason specified for roles change');
109
+			}
110
+
111
+			/** @var UserRole[] $delete */
112
+			$delete = array();
113
+			/** @var string[] $delete */
114
+			$add = array();
115
+
116
+			foreach ($roleData as $name => $r) {
117
+				if ($r['allowEdit'] !== 1) {
118
+					// not allowed, to touch this, so ignore it
119
+					continue;
120
+				}
121
+
122
+				$newValue = WebRequest::postBoolean('role-' . $name) ? 1 : 0;
123
+				if ($newValue !== $r['active']) {
124
+					if ($newValue === 0) {
125
+						$delete[] = $r['object'];
126
+					}
127
+
128
+					if ($newValue === 1) {
129
+						$add[] = $name;
130
+					}
131
+				}
132
+			}
133
+
134
+			// Check there's something to do
135
+			if ((count($add) + count($delete)) === 0) {
136
+				$this->redirect('statistics/users', 'detail', array('user' => $user->getId()));
137
+				SessionAlert::warning('No changes made to roles.');
138
+
139
+				return;
140
+			}
141
+
142
+			$removed = array();
143
+
144
+			/** @var UserRole $d */
145
+			foreach ($delete as $d) {
146
+				$removed[] = $d->getRole();
147
+				$d->delete();
148
+			}
149
+
150
+			foreach ($add as $x) {
151
+				$a = new UserRole();
152
+				$a->setUser($user->getId());
153
+				$a->setRole($x);
154
+				$a->setDatabase($database);
155
+				$a->save();
156
+			}
157
+
158
+			Logger::userRolesEdited($database, $user, $reason, $add, $removed);
159
+
160
+			// dummy save for optimistic locking. If this fails, the entire txn will roll back.
161
+			$user->setUpdateVersion(WebRequest::postInt('updateversion'));
162
+			$user->save();
163
+
164
+			$this->getNotificationHelper()->userRolesEdited($user, $reason);
165
+			SessionAlert::quick('Roles changed for user ' . htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8'));
166
+
167
+			$this->redirect('statistics/users', 'detail', array('user' => $user->getId()));
168
+			return;
169
+		}
170
+		else {
171
+			$this->assignCSRFToken();
172
+			$this->setTemplate('usermanagement/roleedit.tpl');
173
+			$this->assign('user', $user);
174
+			$this->assign('roleData', $roleData);
175
+		}
176
+	}
177
+
178
+	/**
179
+	 * Action target for suspending users
180
+	 *
181
+	 * @throws ApplicationLogicException
182
+	 */
183
+	protected function suspend()
184
+	{
185
+		$this->setHtmlTitle('User Management');
186
+
187
+		$database = $this->getDatabase();
188
+
189
+		$userId = WebRequest::getInt('user');
190
+
191
+		/** @var User $user */
192
+		$user = User::getById($userId, $database);
193
+
194
+		if ($user === false) {
195
+			throw new ApplicationLogicException('Sorry, the user you are trying to suspend could not be found.');
196
+		}
197
+
198
+		if ($user->isSuspended()) {
199
+			throw new ApplicationLogicException('Sorry, the user you are trying to suspend is already suspended.');
200
+		}
201
+
202
+		// Dual-mode action
203
+		if (WebRequest::wasPosted()) {
204
+			$this->validateCSRFToken();
205
+			$reason = WebRequest::postString('reason');
206
+
207
+			if ($reason === null || trim($reason) === "") {
208
+				throw new ApplicationLogicException('No reason provided');
209
+			}
210
+
211
+			$user->setStatus(User::STATUS_SUSPENDED);
212
+			$user->setUpdateVersion(WebRequest::postInt('updateversion'));
213
+			$user->save();
214
+			Logger::suspendedUser($database, $user, $reason);
215
+
216
+			$this->getNotificationHelper()->userSuspended($user, $reason);
217
+			SessionAlert::quick('Suspended user ' . htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8'));
218
+
219
+			// send email
220
+			$this->sendStatusChangeEmail(
221
+				'Your WP:ACC account has been suspended',
222
+				'usermanagement/emails/suspended.tpl',
223
+				$reason,
224
+				$user,
225
+				User::getCurrent($database)->getUsername()
226
+			);
227
+
228
+			$this->redirect('userManagement');
229
+
230
+			return;
231
+		}
232
+		else {
233
+			$this->assignCSRFToken();
234
+			$this->setTemplate('usermanagement/changelevel-reason.tpl');
235
+			$this->assign('user', $user);
236
+			$this->assign('status', 'Suspended');
237
+			$this->assign("showReason", true);
238
+		}
239
+	}
240
+
241
+	/**
242
+	 * Entry point for the decline action
243
+	 *
244
+	 * @throws ApplicationLogicException
245
+	 */
246
+	protected function decline()
247
+	{
248
+		$this->setHtmlTitle('User Management');
249
+
250
+		$database = $this->getDatabase();
251
+
252
+		$userId = WebRequest::getInt('user');
253
+		$user = User::getById($userId, $database);
254
+
255
+		if ($user === false) {
256
+			throw new ApplicationLogicException('Sorry, the user you are trying to decline could not be found.');
257
+		}
258
+
259
+		if (!$user->isNewUser()) {
260
+			throw new ApplicationLogicException('Sorry, the user you are trying to decline is not new.');
261
+		}
262
+
263
+		// Dual-mode action
264
+		if (WebRequest::wasPosted()) {
265
+			$this->validateCSRFToken();
266
+			$reason = WebRequest::postString('reason');
267
+
268
+			if ($reason === null || trim($reason) === "") {
269
+				throw new ApplicationLogicException('No reason provided');
270
+			}
271
+
272
+			$user->setStatus(User::STATUS_DECLINED);
273
+			$user->setUpdateVersion(WebRequest::postInt('updateversion'));
274
+			$user->save();
275
+			Logger::declinedUser($database, $user, $reason);
276
+
277
+			$this->getNotificationHelper()->userDeclined($user, $reason);
278
+			SessionAlert::quick('Declined user ' . htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8'));
279
+
280
+			// send email
281
+			$this->sendStatusChangeEmail(
282
+				'Your WP:ACC account has been declined',
283
+				'usermanagement/emails/declined.tpl',
284
+				$reason,
285
+				$user,
286
+				User::getCurrent($database)->getUsername()
287
+			);
288
+
289
+			$this->redirect('userManagement');
290
+
291
+			return;
292
+		}
293
+		else {
294
+			$this->assignCSRFToken();
295
+			$this->setTemplate('usermanagement/changelevel-reason.tpl');
296
+			$this->assign('user', $user);
297
+			$this->assign('status', 'Declined');
298
+			$this->assign("showReason", true);
299
+		}
300
+	}
301
+
302
+	/**
303
+	 * Entry point for the approve action
304
+	 *
305
+	 * @throws ApplicationLogicException
306
+	 */
307
+	protected function approve()
308
+	{
309
+		$this->setHtmlTitle('User Management');
310
+
311
+		$database = $this->getDatabase();
312
+
313
+		$userId = WebRequest::getInt('user');
314
+		$user = User::getById($userId, $database);
315
+
316
+		if ($user === false) {
317
+			throw new ApplicationLogicException('Sorry, the user you are trying to approve could not be found.');
318
+		}
319
+
320
+		if ($user->isActive()) {
321
+			throw new ApplicationLogicException('Sorry, the user you are trying to approve is already an active user.');
322
+		}
323
+
324
+		// Dual-mode action
325
+		if (WebRequest::wasPosted()) {
326
+			$this->validateCSRFToken();
327
+			$user->setStatus(User::STATUS_ACTIVE);
328
+			$user->setUpdateVersion(WebRequest::postInt('updateversion'));
329
+			$user->save();
330
+			Logger::approvedUser($database, $user);
331
+
332
+			$this->getNotificationHelper()->userApproved($user);
333
+			SessionAlert::quick('Approved user ' . htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8'));
334
+
335
+			// send email
336
+			$this->sendStatusChangeEmail(
337
+				'Your WP:ACC account has been approved',
338
+				'usermanagement/emails/approved.tpl',
339
+				null,
340
+				$user,
341
+				User::getCurrent($database)->getUsername()
342
+			);
343
+
344
+			$this->redirect("userManagement");
345
+
346
+			return;
347
+		}
348
+		else {
349
+			$this->assignCSRFToken();
350
+			$this->setTemplate("usermanagement/changelevel-reason.tpl");
351
+			$this->assign("user", $user);
352
+			$this->assign("status", "User");
353
+			$this->assign("showReason", false);
354
+		}
355
+	}
356
+
357
+	#endregion
358
+
359
+	#region Renaming / Editing
360
+
361
+	/**
362
+	 * Entry point for the rename action
363
+	 *
364
+	 * @throws ApplicationLogicException
365
+	 */
366
+	protected function rename()
367
+	{
368
+		$this->setHtmlTitle('User Management');
369
+
370
+		$database = $this->getDatabase();
371
+
372
+		$userId = WebRequest::getInt('user');
373
+		$user = User::getById($userId, $database);
374
+
375
+		if ($user === false) {
376
+			throw new ApplicationLogicException('Sorry, the user you are trying to rename could not be found.');
377
+		}
378
+
379
+		// Dual-mode action
380
+		if (WebRequest::wasPosted()) {
381
+			$this->validateCSRFToken();
382
+			$newUsername = WebRequest::postString('newname');
383
+
384
+			if ($newUsername === null || trim($newUsername) === "") {
385
+				throw new ApplicationLogicException('The new username cannot be empty');
386
+			}
387
+
388
+			if (User::getByUsername($newUsername, $database) != false) {
389
+				throw new ApplicationLogicException('The new username already exists');
390
+			}
391
+
392
+			$oldUsername = $user->getUsername();
393
+			$user->setUsername($newUsername);
394
+			$user->setUpdateVersion(WebRequest::postInt('updateversion'));
395
+
396
+			$user->save();
397
+
398
+			$logEntryData = serialize(array(
399
+				'old' => $oldUsername,
400
+				'new' => $newUsername,
401
+			));
402
+
403
+			Logger::renamedUser($database, $user, $logEntryData);
404
+
405
+			SessionAlert::quick("Changed User "
406
+				. htmlentities($oldUsername, ENT_COMPAT, 'UTF-8')
407
+				. " name to "
408
+				. htmlentities($newUsername, ENT_COMPAT, 'UTF-8'));
409
+
410
+			$this->getNotificationHelper()->userRenamed($user, $oldUsername);
411
+
412
+			// send an email to the user.
413
+			$this->assign('targetUsername', $user->getUsername());
414
+			$this->assign('toolAdmin', User::getCurrent($database)->getUsername());
415
+			$this->assign('oldUsername', $oldUsername);
416
+			$this->assign('mailingList', $this->adminMailingList);
417
+
418
+			$this->getEmailHelper()->sendMail(
419
+				$user->getEmail(),
420
+				'Your username on WP:ACC has been changed',
421
+				$this->fetchTemplate('usermanagement/emails/renamed.tpl'),
422
+				array('Reply-To' => $this->adminMailingList)
423
+			);
424
+
425
+			$this->redirect("userManagement");
426
+
427
+			return;
428
+		}
429
+		else {
430
+			$this->assignCSRFToken();
431
+			$this->setTemplate('usermanagement/renameuser.tpl');
432
+			$this->assign('user', $user);
433
+		}
434
+	}
435
+
436
+	/**
437
+	 * Entry point for the edit action
438
+	 *
439
+	 * @throws ApplicationLogicException
440
+	 */
441
+	protected function editUser()
442
+	{
443
+		$this->setHtmlTitle('User Management');
444
+
445
+		$database = $this->getDatabase();
446
+
447
+		$userId = WebRequest::getInt('user');
448
+		$user = User::getById($userId, $database);
449
+
450
+		if ($user === false) {
451
+			throw new ApplicationLogicException('Sorry, the user you are trying to edit could not be found.');
452
+		}
453
+
454
+		// Dual-mode action
455
+		if (WebRequest::wasPosted()) {
456
+			$this->validateCSRFToken();
457
+			$newEmail = WebRequest::postEmail('user_email');
458
+			$newOnWikiName = WebRequest::postString('user_onwikiname');
459
+
460
+			if ($newEmail === null) {
461
+				throw new ApplicationLogicException('Invalid email address');
462
+			}
463
+
464
+			if (!$user->isOAuthLinked()) {
465
+				if (trim($newOnWikiName) == "") {
466
+					throw new ApplicationLogicException('New on-wiki username cannot be blank');
467
+				}
468
+
469
+				$user->setOnWikiName($newOnWikiName);
470
+			}
471
+
472
+			$user->setEmail($newEmail);
473
+
474
+			$user->setUpdateVersion(WebRequest::postInt('updateversion'));
475
+
476
+			$user->save();
477
+
478
+			Logger::userPreferencesChange($database, $user);
479
+			$this->getNotificationHelper()->userPrefChange($user);
480
+			SessionAlert::quick('Changes to user\'s preferences have been saved');
481
+
482
+			$this->redirect("userManagement");
483
+
484
+			return;
485
+		}
486
+		else {
487
+			$this->assignCSRFToken();
488
+			$this->setTemplate('usermanagement/edituser.tpl');
489
+			$this->assign('user', $user);
490
+		}
491
+	}
492
+
493
+	#endregion
494
+
495
+	/**
496
+	 * Sends a status change email to the user.
497
+	 *
498
+	 * @param string      $subject           The subject of the email
499
+	 * @param string      $template          The smarty template to use
500
+	 * @param string|null $reason            The reason for performing the status change
501
+	 * @param User        $user              The user affected
502
+	 * @param string      $toolAdminUsername The tool admin's username who is making the edit
503
+	 */
504
+	private function sendStatusChangeEmail($subject, $template, $reason, $user, $toolAdminUsername)
505
+	{
506
+		$this->assign('targetUsername', $user->getUsername());
507
+		$this->assign('toolAdmin', $toolAdminUsername);
508
+		$this->assign('actionReason', $reason);
509
+		$this->assign('mailingList', $this->adminMailingList);
510
+
511
+		$this->getEmailHelper()->sendMail(
512
+			$user->getEmail(),
513
+			$subject,
514
+			$this->fetchTemplate($template),
515
+			array('Reply-To' => $this->adminMailingList)
516
+		);
517
+	}
518
+
519
+	/**
520
+	 * @param UserRole[] $activeRoles
521
+	 *
522
+	 * @return array
523
+	 */
524
+	private function getRoleData($activeRoles)
525
+	{
526
+		$availableRoles = $this->getSecurityManager()->getRoleConfiguration()->getAvailableRoles();
527
+
528
+		$currentUser = User::getCurrent($this->getDatabase());
529
+		$this->getSecurityManager()->getActiveRoles($currentUser, $userRoles, $inactiveRoles);
530
+
531
+		$initialValue = array('active' => 0, 'allowEdit' => 0, 'description' => '???', 'object' => null);
532
+
533
+		$roleData = array();
534
+		foreach ($availableRoles as $role => $data) {
535
+			$intersection = array_intersect($data['editableBy'], $userRoles);
536
+
537
+			$roleData[$role] = $initialValue;
538
+			$roleData[$role]['allowEdit'] = count($intersection) > 0 ? 1 : 0;
539
+			$roleData[$role]['description'] = $data['description'];
540
+		}
541
+
542
+		foreach ($activeRoles as $role) {
543
+			if (!isset($roleData[$role->getRole()])) {
544
+				// This value is no longer available in the configuration, allow changing (aka removing) it.
545
+				$roleData[$role->getRole()] = $initialValue;
546
+				$roleData[$role->getRole()]['allowEdit'] = 1;
547
+			}
548
+
549
+			$roleData[$role->getRole()]['object'] = $role;
550
+			$roleData[$role->getRole()]['active'] = 1;
551
+		}
552
+
553
+		return $roleData;
554
+	}
555 555
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
                     continue;
120 120
                 }
121 121
 
122
-                $newValue = WebRequest::postBoolean('role-' . $name) ? 1 : 0;
122
+                $newValue = WebRequest::postBoolean('role-'.$name) ? 1 : 0;
123 123
                 if ($newValue !== $r['active']) {
124 124
                     if ($newValue === 0) {
125 125
                         $delete[] = $r['object'];
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
             $user->save();
163 163
 
164 164
             $this->getNotificationHelper()->userRolesEdited($user, $reason);
165
-            SessionAlert::quick('Roles changed for user ' . htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8'));
165
+            SessionAlert::quick('Roles changed for user '.htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8'));
166 166
 
167 167
             $this->redirect('statistics/users', 'detail', array('user' => $user->getId()));
168 168
             return;
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
             Logger::suspendedUser($database, $user, $reason);
215 215
 
216 216
             $this->getNotificationHelper()->userSuspended($user, $reason);
217
-            SessionAlert::quick('Suspended user ' . htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8'));
217
+            SessionAlert::quick('Suspended user '.htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8'));
218 218
 
219 219
             // send email
220 220
             $this->sendStatusChangeEmail(
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
             Logger::declinedUser($database, $user, $reason);
276 276
 
277 277
             $this->getNotificationHelper()->userDeclined($user, $reason);
278
-            SessionAlert::quick('Declined user ' . htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8'));
278
+            SessionAlert::quick('Declined user '.htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8'));
279 279
 
280 280
             // send email
281 281
             $this->sendStatusChangeEmail(
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
             Logger::approvedUser($database, $user);
331 331
 
332 332
             $this->getNotificationHelper()->userApproved($user);
333
-            SessionAlert::quick('Approved user ' . htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8'));
333
+            SessionAlert::quick('Approved user '.htmlentities($user->getUsername(), ENT_COMPAT, 'UTF-8'));
334 334
 
335 335
             // send email
336 336
             $this->sendStatusChangeEmail(
Please login to merge, or discard this patch.
includes/Pages/PageEmailManagement.php 1 patch
Indentation   +171 added lines, -171 removed lines patch added patch discarded remove patch
@@ -19,175 +19,175 @@
 block discarded – undo
19 19
 
20 20
 class PageEmailManagement extends InternalPageBase
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
-        $this->setHtmlTitle('Close Emails');
29
-
30
-        // Get all active email templates
31
-        $activeTemplates = EmailTemplate::getAllActiveTemplates(null, $this->getDatabase());
32
-        $inactiveTemplates = EmailTemplate::getAllInactiveTemplates($this->getDatabase());
33
-
34
-        $this->assign('activeTemplates', $activeTemplates);
35
-        $this->assign('inactiveTemplates', $inactiveTemplates);
36
-
37
-        $user = User::getCurrent($this->getDatabase());
38
-        $this->assign('canCreate', $this->barrierTest('create', $user));
39
-        $this->assign('canEdit', $this->barrierTest('edit', $user));
40
-
41
-        $this->setTemplate('email-management/main.tpl');
42
-    }
43
-
44
-    protected function view()
45
-    {
46
-        $this->setHtmlTitle('Close Emails');
47
-
48
-        $database = $this->getDatabase();
49
-        $template = $this->getTemplate($database);
50
-
51
-        $createdId = $this->getSiteConfiguration()->getDefaultCreatedTemplateId();
52
-        $requestStates = $this->getSiteConfiguration()->getRequestStates();
53
-
54
-        $this->assign('id', $template->getId());
55
-        $this->assign('emailTemplate', $template);
56
-        $this->assign('createdid', $createdId);
57
-        $this->assign('requeststates', $requestStates);
58
-
59
-        $this->setTemplate('email-management/view.tpl');
60
-    }
61
-
62
-    /**
63
-     * @param PdoDatabase $database
64
-     *
65
-     * @return EmailTemplate
66
-     * @throws ApplicationLogicException
67
-     */
68
-    protected function getTemplate(PdoDatabase $database)
69
-    {
70
-        $templateId = WebRequest::getInt('id');
71
-        if ($templateId === null) {
72
-            throw new ApplicationLogicException('Template not specified');
73
-        }
74
-        $template = EmailTemplate::getById($templateId, $database);
75
-        if ($template === false || !is_a($template, EmailTemplate::class)) {
76
-            throw new ApplicationLogicException('Template not found');
77
-        }
78
-
79
-        return $template;
80
-    }
81
-
82
-    protected function edit()
83
-    {
84
-        $this->setHtmlTitle('Close Emails');
85
-
86
-        $database = $this->getDatabase();
87
-        $template = $this->getTemplate($database);
88
-
89
-        $createdId = $this->getSiteConfiguration()->getDefaultCreatedTemplateId();
90
-        $requestStates = $this->getSiteConfiguration()->getRequestStates();
91
-
92
-        if (WebRequest::wasPosted()) {
93
-            $this->validateCSRFToken();
94
-
95
-            $this->modifyTemplateData($template);
96
-
97
-            $other = EmailTemplate::getByName($template->getName(), $database);
98
-            if ($other !== false && $other->getId() !== $template->getId()) {
99
-                throw new ApplicationLogicException('A template with this name already exists');
100
-            }
101
-
102
-            if ($template->getId() === $createdId) {
103
-                $template->setDefaultAction(EmailTemplate::CREATED);
104
-                $template->setActive(true);
105
-                $template->setPreloadOnly(false);
106
-            }
107
-
108
-            // optimistically lock on load of edit form
109
-            $updateVersion = WebRequest::postInt('updateversion');
110
-            $template->setUpdateVersion($updateVersion);
111
-
112
-            $template->save();
113
-            Logger::editedEmail($database, $template);
114
-            $this->getNotificationHelper()->emailEdited($template);
115
-            SessionAlert::success("Email template has been saved successfully.");
116
-
117
-            $this->redirect('emailManagement');
118
-        }
119
-        else {
120
-            $this->assignCSRFToken();
121
-            $this->assign('id', $template->getId());
122
-            $this->assign('emailTemplate', $template);
123
-            $this->assign('createdid', $createdId);
124
-            $this->assign('requeststates', $requestStates);
125
-
126
-            $this->setTemplate('email-management/edit.tpl');
127
-        }
128
-    }
129
-
130
-    /**
131
-     * @param EmailTemplate $template
132
-     *
133
-     * @throws ApplicationLogicException
134
-     */
135
-    private function modifyTemplateData(EmailTemplate $template)
136
-    {
137
-        $name = WebRequest::postString('name');
138
-        if ($name === null || $name === '') {
139
-            throw new ApplicationLogicException('Name not specified');
140
-        }
141
-
142
-        $template->setName($name);
143
-
144
-        $text = WebRequest::postString('text');
145
-        if ($text === null || $text === '') {
146
-            throw new ApplicationLogicException('Text not specified');
147
-        }
148
-
149
-        $template->setText($text);
150
-
151
-        $template->setJsquestion(WebRequest::postString('jsquestion'));
152
-
153
-        $template->setDefaultAction(WebRequest::postString('defaultaction'));
154
-        $template->setActive(WebRequest::postBoolean('active'));
155
-        $template->setPreloadOnly(WebRequest::postBoolean('preloadonly'));
156
-    }
157
-
158
-    protected function create()
159
-    {
160
-        $this->setHtmlTitle('Close Emails');
161
-
162
-        $database = $this->getDatabase();
163
-
164
-        $requestStates = $this->getSiteConfiguration()->getRequestStates();
165
-
166
-        if (WebRequest::wasPosted()) {
167
-            $this->validateCSRFToken();
168
-            $template = new EmailTemplate();
169
-            $template->setDatabase($database);
170
-
171
-            $this->modifyTemplateData($template);
172
-
173
-            $other = EmailTemplate::getByName($template->getName(), $database);
174
-            if ($other !== false) {
175
-                throw new ApplicationLogicException('A template with this name already exists');
176
-            }
177
-
178
-            $template->save();
179
-
180
-            Logger::createEmail($database, $template);
181
-            $this->getNotificationHelper()->emailCreated($template);
182
-
183
-            SessionAlert::success("Email template has been saved successfully.");
184
-
185
-            $this->redirect('emailManagement');
186
-        }
187
-        else {
188
-            $this->assignCSRFToken();
189
-            $this->assign('requeststates', $requestStates);
190
-            $this->setTemplate('email-management/create.tpl');
191
-        }
192
-    }
22
+	/**
23
+	 * Main function for this page, when no specific actions are called.
24
+	 * @return void
25
+	 */
26
+	protected function main()
27
+	{
28
+		$this->setHtmlTitle('Close Emails');
29
+
30
+		// Get all active email templates
31
+		$activeTemplates = EmailTemplate::getAllActiveTemplates(null, $this->getDatabase());
32
+		$inactiveTemplates = EmailTemplate::getAllInactiveTemplates($this->getDatabase());
33
+
34
+		$this->assign('activeTemplates', $activeTemplates);
35
+		$this->assign('inactiveTemplates', $inactiveTemplates);
36
+
37
+		$user = User::getCurrent($this->getDatabase());
38
+		$this->assign('canCreate', $this->barrierTest('create', $user));
39
+		$this->assign('canEdit', $this->barrierTest('edit', $user));
40
+
41
+		$this->setTemplate('email-management/main.tpl');
42
+	}
43
+
44
+	protected function view()
45
+	{
46
+		$this->setHtmlTitle('Close Emails');
47
+
48
+		$database = $this->getDatabase();
49
+		$template = $this->getTemplate($database);
50
+
51
+		$createdId = $this->getSiteConfiguration()->getDefaultCreatedTemplateId();
52
+		$requestStates = $this->getSiteConfiguration()->getRequestStates();
53
+
54
+		$this->assign('id', $template->getId());
55
+		$this->assign('emailTemplate', $template);
56
+		$this->assign('createdid', $createdId);
57
+		$this->assign('requeststates', $requestStates);
58
+
59
+		$this->setTemplate('email-management/view.tpl');
60
+	}
61
+
62
+	/**
63
+	 * @param PdoDatabase $database
64
+	 *
65
+	 * @return EmailTemplate
66
+	 * @throws ApplicationLogicException
67
+	 */
68
+	protected function getTemplate(PdoDatabase $database)
69
+	{
70
+		$templateId = WebRequest::getInt('id');
71
+		if ($templateId === null) {
72
+			throw new ApplicationLogicException('Template not specified');
73
+		}
74
+		$template = EmailTemplate::getById($templateId, $database);
75
+		if ($template === false || !is_a($template, EmailTemplate::class)) {
76
+			throw new ApplicationLogicException('Template not found');
77
+		}
78
+
79
+		return $template;
80
+	}
81
+
82
+	protected function edit()
83
+	{
84
+		$this->setHtmlTitle('Close Emails');
85
+
86
+		$database = $this->getDatabase();
87
+		$template = $this->getTemplate($database);
88
+
89
+		$createdId = $this->getSiteConfiguration()->getDefaultCreatedTemplateId();
90
+		$requestStates = $this->getSiteConfiguration()->getRequestStates();
91
+
92
+		if (WebRequest::wasPosted()) {
93
+			$this->validateCSRFToken();
94
+
95
+			$this->modifyTemplateData($template);
96
+
97
+			$other = EmailTemplate::getByName($template->getName(), $database);
98
+			if ($other !== false && $other->getId() !== $template->getId()) {
99
+				throw new ApplicationLogicException('A template with this name already exists');
100
+			}
101
+
102
+			if ($template->getId() === $createdId) {
103
+				$template->setDefaultAction(EmailTemplate::CREATED);
104
+				$template->setActive(true);
105
+				$template->setPreloadOnly(false);
106
+			}
107
+
108
+			// optimistically lock on load of edit form
109
+			$updateVersion = WebRequest::postInt('updateversion');
110
+			$template->setUpdateVersion($updateVersion);
111
+
112
+			$template->save();
113
+			Logger::editedEmail($database, $template);
114
+			$this->getNotificationHelper()->emailEdited($template);
115
+			SessionAlert::success("Email template has been saved successfully.");
116
+
117
+			$this->redirect('emailManagement');
118
+		}
119
+		else {
120
+			$this->assignCSRFToken();
121
+			$this->assign('id', $template->getId());
122
+			$this->assign('emailTemplate', $template);
123
+			$this->assign('createdid', $createdId);
124
+			$this->assign('requeststates', $requestStates);
125
+
126
+			$this->setTemplate('email-management/edit.tpl');
127
+		}
128
+	}
129
+
130
+	/**
131
+	 * @param EmailTemplate $template
132
+	 *
133
+	 * @throws ApplicationLogicException
134
+	 */
135
+	private function modifyTemplateData(EmailTemplate $template)
136
+	{
137
+		$name = WebRequest::postString('name');
138
+		if ($name === null || $name === '') {
139
+			throw new ApplicationLogicException('Name not specified');
140
+		}
141
+
142
+		$template->setName($name);
143
+
144
+		$text = WebRequest::postString('text');
145
+		if ($text === null || $text === '') {
146
+			throw new ApplicationLogicException('Text not specified');
147
+		}
148
+
149
+		$template->setText($text);
150
+
151
+		$template->setJsquestion(WebRequest::postString('jsquestion'));
152
+
153
+		$template->setDefaultAction(WebRequest::postString('defaultaction'));
154
+		$template->setActive(WebRequest::postBoolean('active'));
155
+		$template->setPreloadOnly(WebRequest::postBoolean('preloadonly'));
156
+	}
157
+
158
+	protected function create()
159
+	{
160
+		$this->setHtmlTitle('Close Emails');
161
+
162
+		$database = $this->getDatabase();
163
+
164
+		$requestStates = $this->getSiteConfiguration()->getRequestStates();
165
+
166
+		if (WebRequest::wasPosted()) {
167
+			$this->validateCSRFToken();
168
+			$template = new EmailTemplate();
169
+			$template->setDatabase($database);
170
+
171
+			$this->modifyTemplateData($template);
172
+
173
+			$other = EmailTemplate::getByName($template->getName(), $database);
174
+			if ($other !== false) {
175
+				throw new ApplicationLogicException('A template with this name already exists');
176
+			}
177
+
178
+			$template->save();
179
+
180
+			Logger::createEmail($database, $template);
181
+			$this->getNotificationHelper()->emailCreated($template);
182
+
183
+			SessionAlert::success("Email template has been saved successfully.");
184
+
185
+			$this->redirect('emailManagement');
186
+		}
187
+		else {
188
+			$this->assignCSRFToken();
189
+			$this->assign('requeststates', $requestStates);
190
+			$this->setTemplate('email-management/create.tpl');
191
+		}
192
+	}
193 193
 }
Please login to merge, or discard this patch.
includes/Pages/PageWelcomeTemplateManagement.php 1 patch
Indentation   +171 added lines, -171 removed lines patch added patch discarded remove patch
@@ -19,223 +19,223 @@
 block discarded – undo
19 19
 
20 20
 class PageWelcomeTemplateManagement extends InternalPageBase
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
-        $templateList = WelcomeTemplate::getAll($this->getDatabase());
29
-
30
-        $this->assignCSRFToken();
31
-
32
-        $user = User::getCurrent($this->getDatabase());
33
-        $this->assign('canEdit', $this->barrierTest('edit', $user));
34
-        $this->assign('canAdd', $this->barrierTest('add', $user));
22
+	/**
23
+	 * Main function for this page, when no specific actions are called.
24
+	 * @return void
25
+	 */
26
+	protected function main()
27
+	{
28
+		$templateList = WelcomeTemplate::getAll($this->getDatabase());
29
+
30
+		$this->assignCSRFToken();
31
+
32
+		$user = User::getCurrent($this->getDatabase());
33
+		$this->assign('canEdit', $this->barrierTest('edit', $user));
34
+		$this->assign('canAdd', $this->barrierTest('add', $user));
35 35
 
36
-        $this->assign('templateList', $templateList);
37
-        $this->setTemplate('welcome-template/list.tpl');
38
-    }
36
+		$this->assign('templateList', $templateList);
37
+		$this->setTemplate('welcome-template/list.tpl');
38
+	}
39 39
 
40
-    /**
41
-     * Handles the requests for selecting a template to use.
42
-     *
43
-     * @throws ApplicationLogicException
44
-     */
45
-    protected function select()
46
-    {
47
-        // get rid of GETs
48
-        if (!WebRequest::wasPosted()) {
49
-            $this->redirect('welcomeTemplates');
50
-        }
51
-
52
-        $this->validateCSRFToken();
53
-
54
-        $user = User::getCurrent($this->getDatabase());
55
-
56
-        if (WebRequest::postBoolean('disable')) {
57
-            $user->setWelcomeTemplate(null);
58
-            $user->save();
59
-
60
-            SessionAlert::success('Disabled automatic user welcoming.');
61
-            $this->redirect('welcomeTemplates');
62
-
63
-            return;
64
-        }
65
-
66
-        $database = $this->getDatabase();
40
+	/**
41
+	 * Handles the requests for selecting a template to use.
42
+	 *
43
+	 * @throws ApplicationLogicException
44
+	 */
45
+	protected function select()
46
+	{
47
+		// get rid of GETs
48
+		if (!WebRequest::wasPosted()) {
49
+			$this->redirect('welcomeTemplates');
50
+		}
51
+
52
+		$this->validateCSRFToken();
53
+
54
+		$user = User::getCurrent($this->getDatabase());
55
+
56
+		if (WebRequest::postBoolean('disable')) {
57
+			$user->setWelcomeTemplate(null);
58
+			$user->save();
59
+
60
+			SessionAlert::success('Disabled automatic user welcoming.');
61
+			$this->redirect('welcomeTemplates');
62
+
63
+			return;
64
+		}
65
+
66
+		$database = $this->getDatabase();
67 67
 
68
-        $templateId = WebRequest::postInt('template');
69
-        /** @var false|WelcomeTemplate $template */
70
-        $template = WelcomeTemplate::getById($templateId, $database);
68
+		$templateId = WebRequest::postInt('template');
69
+		/** @var false|WelcomeTemplate $template */
70
+		$template = WelcomeTemplate::getById($templateId, $database);
71 71
 
72
-        if ($template === false || $template->isDeleted()) {
73
-            throw new ApplicationLogicException('Unknown template');
74
-        }
72
+		if ($template === false || $template->isDeleted()) {
73
+			throw new ApplicationLogicException('Unknown template');
74
+		}
75 75
 
76
-        $user->setWelcomeTemplate($template->getId());
77
-        $user->save();
76
+		$user->setWelcomeTemplate($template->getId());
77
+		$user->save();
78 78
 
79
-        SessionAlert::success("Updated selected welcome template for automatic welcoming.");
79
+		SessionAlert::success("Updated selected welcome template for automatic welcoming.");
80 80
 
81
-        $this->redirect('welcomeTemplates');
82
-    }
81
+		$this->redirect('welcomeTemplates');
82
+	}
83 83
 
84
-    /**
85
-     * Handles the requests for viewing a template.
86
-     *
87
-     * @throws ApplicationLogicException
88
-     */
89
-    protected function view()
90
-    {
91
-        $database = $this->getDatabase();
84
+	/**
85
+	 * Handles the requests for viewing a template.
86
+	 *
87
+	 * @throws ApplicationLogicException
88
+	 */
89
+	protected function view()
90
+	{
91
+		$database = $this->getDatabase();
92 92
 
93
-        $templateId = WebRequest::getInt('template');
93
+		$templateId = WebRequest::getInt('template');
94 94
 
95
-        /** @var WelcomeTemplate $template */
96
-        $template = WelcomeTemplate::getById($templateId, $database);
95
+		/** @var WelcomeTemplate $template */
96
+		$template = WelcomeTemplate::getById($templateId, $database);
97 97
 
98
-        if ($template === false) {
99
-            throw new ApplicationLogicException('Cannot find requested template');
100
-        }
98
+		if ($template === false) {
99
+			throw new ApplicationLogicException('Cannot find requested template');
100
+		}
101 101
 
102
-        $templateHtml = $this->getWikiTextHelper()->getHtmlForWikiText($template->getBotCode());
102
+		$templateHtml = $this->getWikiTextHelper()->getHtmlForWikiText($template->getBotCode());
103 103
 
104
-        $this->assign('templateHtml', $templateHtml);
105
-        $this->assign('template', $template);
106
-        $this->setTemplate('welcome-template/view.tpl');
107
-    }
104
+		$this->assign('templateHtml', $templateHtml);
105
+		$this->assign('template', $template);
106
+		$this->setTemplate('welcome-template/view.tpl');
107
+	}
108 108
 
109
-    /**
110
-     * Handler for the add action to create a new welcome template
111
-     *
112
-     * @throws Exception
113
-     */
114
-    protected function add()
115
-    {
116
-        if (WebRequest::wasPosted()) {
117
-            $this->validateCSRFToken();
118
-            $database = $this->getDatabase();
109
+	/**
110
+	 * Handler for the add action to create a new welcome template
111
+	 *
112
+	 * @throws Exception
113
+	 */
114
+	protected function add()
115
+	{
116
+		if (WebRequest::wasPosted()) {
117
+			$this->validateCSRFToken();
118
+			$database = $this->getDatabase();
119 119
 
120
-            $userCode = WebRequest::postString('usercode');
121
-            $botCode = WebRequest::postString('botcode');
120
+			$userCode = WebRequest::postString('usercode');
121
+			$botCode = WebRequest::postString('botcode');
122 122
 
123
-            $this->validate($userCode, $botCode);
123
+			$this->validate($userCode, $botCode);
124 124
 
125
-            $template = new WelcomeTemplate();
126
-            $template->setDatabase($database);
127
-            $template->setUserCode($userCode);
128
-            $template->setBotCode($botCode);
129
-            $template->save();
125
+			$template = new WelcomeTemplate();
126
+			$template->setDatabase($database);
127
+			$template->setUserCode($userCode);
128
+			$template->setBotCode($botCode);
129
+			$template->save();
130 130
 
131
-            Logger::welcomeTemplateCreated($database, $template);
131
+			Logger::welcomeTemplateCreated($database, $template);
132 132
 
133
-            $this->getNotificationHelper()->welcomeTemplateCreated($template);
133
+			$this->getNotificationHelper()->welcomeTemplateCreated($template);
134 134
 
135
-            SessionAlert::success("Template successfully created.");
135
+			SessionAlert::success("Template successfully created.");
136 136
 
137
-            $this->redirect('welcomeTemplates');
138
-        }
139
-        else {
140
-            $this->assignCSRFToken();
141
-            $this->setTemplate("welcome-template/add.tpl");
142
-        }
143
-    }
137
+			$this->redirect('welcomeTemplates');
138
+		}
139
+		else {
140
+			$this->assignCSRFToken();
141
+			$this->setTemplate("welcome-template/add.tpl");
142
+		}
143
+	}
144 144
 
145
-    /**
146
-     * Hander for editing templates
147
-     */
148
-    protected function edit()
149
-    {
150
-        $database = $this->getDatabase();
145
+	/**
146
+	 * Hander for editing templates
147
+	 */
148
+	protected function edit()
149
+	{
150
+		$database = $this->getDatabase();
151 151
 
152
-        $templateId = WebRequest::getInt('template');
152
+		$templateId = WebRequest::getInt('template');
153 153
 
154
-        /** @var WelcomeTemplate $template */
155
-        $template = WelcomeTemplate::getById($templateId, $database);
154
+		/** @var WelcomeTemplate $template */
155
+		$template = WelcomeTemplate::getById($templateId, $database);
156 156
 
157
-        if ($template === false) {
158
-            throw new ApplicationLogicException('Cannot find requested template');
159
-        }
157
+		if ($template === false) {
158
+			throw new ApplicationLogicException('Cannot find requested template');
159
+		}
160 160
 
161
-        if ($template->isDeleted()) {
162
-            throw new ApplicationLogicException('The specified template has been deleted');
163
-        }
161
+		if ($template->isDeleted()) {
162
+			throw new ApplicationLogicException('The specified template has been deleted');
163
+		}
164 164
 
165
-        if (WebRequest::wasPosted()) {
166
-            $this->validateCSRFToken();
165
+		if (WebRequest::wasPosted()) {
166
+			$this->validateCSRFToken();
167 167
 
168
-            $userCode = WebRequest::postString('usercode');
169
-            $botCode = WebRequest::postString('botcode');
168
+			$userCode = WebRequest::postString('usercode');
169
+			$botCode = WebRequest::postString('botcode');
170 170
 
171
-            $this->validate($userCode, $botCode);
171
+			$this->validate($userCode, $botCode);
172 172
 
173
-            $template->setUserCode($userCode);
174
-            $template->setBotCode($botCode);
175
-            $template->setUpdateVersion(WebRequest::postInt('updateversion'));
176
-            $template->save();
173
+			$template->setUserCode($userCode);
174
+			$template->setBotCode($botCode);
175
+			$template->setUpdateVersion(WebRequest::postInt('updateversion'));
176
+			$template->save();
177 177
 
178
-            Logger::welcomeTemplateEdited($database, $template);
178
+			Logger::welcomeTemplateEdited($database, $template);
179 179
 
180
-            SessionAlert::success("Template updated.");
180
+			SessionAlert::success("Template updated.");
181 181
 
182
-            $this->getNotificationHelper()->welcomeTemplateEdited($template);
182
+			$this->getNotificationHelper()->welcomeTemplateEdited($template);
183 183
 
184
-            $this->redirect('welcomeTemplates');
185
-        }
186
-        else {
187
-            $this->assignCSRFToken();
188
-            $this->assign('template', $template);
189
-            $this->setTemplate('welcome-template/edit.tpl');
190
-        }
191
-    }
184
+			$this->redirect('welcomeTemplates');
185
+		}
186
+		else {
187
+			$this->assignCSRFToken();
188
+			$this->assign('template', $template);
189
+			$this->setTemplate('welcome-template/edit.tpl');
190
+		}
191
+	}
192 192
 
193
-    protected function delete()
194
-    {
195
-        $this->redirect('welcomeTemplates');
193
+	protected function delete()
194
+	{
195
+		$this->redirect('welcomeTemplates');
196 196
 
197
-        if (!WebRequest::wasPosted()) {
198
-            return;
199
-        }
197
+		if (!WebRequest::wasPosted()) {
198
+			return;
199
+		}
200 200
 
201
-        $this->validateCSRFToken();
201
+		$this->validateCSRFToken();
202 202
 
203
-        $database = $this->getDatabase();
203
+		$database = $this->getDatabase();
204 204
 
205
-        $templateId = WebRequest::postInt('template');
206
-        $updateVersion = WebRequest::postInt('updateversion');
205
+		$templateId = WebRequest::postInt('template');
206
+		$updateVersion = WebRequest::postInt('updateversion');
207 207
 
208
-        /** @var WelcomeTemplate $template */
209
-        $template = WelcomeTemplate::getById($templateId, $database);
208
+		/** @var WelcomeTemplate $template */
209
+		$template = WelcomeTemplate::getById($templateId, $database);
210 210
 
211
-        if ($template === false || $template->isDeleted()) {
212
-            throw new ApplicationLogicException('Cannot find requested template');
213
-        }
211
+		if ($template === false || $template->isDeleted()) {
212
+			throw new ApplicationLogicException('Cannot find requested template');
213
+		}
214 214
 
215
-        // set the update version to the version sent by the client (optimisticly lock from initial page load)
216
-        $template->setUpdateVersion($updateVersion);
215
+		// set the update version to the version sent by the client (optimisticly lock from initial page load)
216
+		$template->setUpdateVersion($updateVersion);
217 217
 
218
-        $database
219
-            ->prepare("UPDATE user SET welcome_template = NULL WHERE welcome_template = :id;")
220
-            ->execute(array(":id" => $templateId));
218
+		$database
219
+			->prepare("UPDATE user SET welcome_template = NULL WHERE welcome_template = :id;")
220
+			->execute(array(":id" => $templateId));
221 221
 
222
-        Logger::welcomeTemplateDeleted($database, $template);
222
+		Logger::welcomeTemplateDeleted($database, $template);
223 223
 
224
-        $template->delete();
224
+		$template->delete();
225 225
 
226
-        SessionAlert::success(
227
-            "Template deleted. Any users who were using this template have had automatic welcoming disabled.");
228
-        $this->getNotificationHelper()->welcomeTemplateDeleted($templateId);
229
-    }
226
+		SessionAlert::success(
227
+			"Template deleted. Any users who were using this template have had automatic welcoming disabled.");
228
+		$this->getNotificationHelper()->welcomeTemplateDeleted($templateId);
229
+	}
230 230
 
231
-    private function validate($userCode, $botCode)
232
-    {
233
-        if ($userCode === null) {
234
-            throw new ApplicationLogicException('User code cannot be null');
235
-        }
231
+	private function validate($userCode, $botCode)
232
+	{
233
+		if ($userCode === null) {
234
+			throw new ApplicationLogicException('User code cannot be null');
235
+		}
236 236
 
237
-        if ($botCode === null) {
238
-            throw new ApplicationLogicException('Bot code cannot be null');
239
-        }
240
-    }
237
+		if ($botCode === null) {
238
+			throw new ApplicationLogicException('Bot code cannot be null');
239
+		}
240
+	}
241 241
 }
Please login to merge, or discard this patch.
includes/Pages/PageEditComment.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -20,67 +20,67 @@
 block discarded – undo
20 20
 
21 21
 class PageEditComment extends InternalPageBase
22 22
 {
23
-    /**
24
-     * Main function for this page, when no specific actions are called.
25
-     * @throws ApplicationLogicException
26
-     */
27
-    protected function main()
28
-    {
29
-        $commentId = WebRequest::getInt('id');
30
-        if ($commentId === null) {
31
-            throw new ApplicationLogicException('Comment ID not specified');
32
-        }
23
+	/**
24
+	 * Main function for this page, when no specific actions are called.
25
+	 * @throws ApplicationLogicException
26
+	 */
27
+	protected function main()
28
+	{
29
+		$commentId = WebRequest::getInt('id');
30
+		if ($commentId === null) {
31
+			throw new ApplicationLogicException('Comment ID not specified');
32
+		}
33 33
 
34
-        $database = $this->getDatabase();
34
+		$database = $this->getDatabase();
35 35
 
36
-        /** @var Comment $comment */
37
-        $comment = Comment::getById($commentId, $database);
38
-        if ($comment === false) {
39
-            throw new ApplicationLogicException('Comment not found');
40
-        }
36
+		/** @var Comment $comment */
37
+		$comment = Comment::getById($commentId, $database);
38
+		if ($comment === false) {
39
+			throw new ApplicationLogicException('Comment not found');
40
+		}
41 41
 
42
-        $currentUser = User::getCurrent($database);
43
-        if ($comment->getUser() !== $currentUser->getId() && !$this->barrierTest('editOthers', $currentUser)) {
44
-            throw new AccessDeniedException($this->getSecurityManager());
45
-        }
42
+		$currentUser = User::getCurrent($database);
43
+		if ($comment->getUser() !== $currentUser->getId() && !$this->barrierTest('editOthers', $currentUser)) {
44
+			throw new AccessDeniedException($this->getSecurityManager());
45
+		}
46 46
 
47
-        /** @var Request $request */
48
-        $request = Request::getById($comment->getRequest(), $database);
47
+		/** @var Request $request */
48
+		$request = Request::getById($comment->getRequest(), $database);
49 49
 
50
-        if ($request === false) {
51
-            throw new ApplicationLogicException('Request was not found.');
52
-        }
50
+		if ($request === false) {
51
+			throw new ApplicationLogicException('Request was not found.');
52
+		}
53 53
 
54
-        if (WebRequest::wasPosted()) {
55
-            $this->validateCSRFToken();
56
-            $newComment = WebRequest::postString('newcomment');
57
-            $visibility = WebRequest::postString('visibility');
54
+		if (WebRequest::wasPosted()) {
55
+			$this->validateCSRFToken();
56
+			$newComment = WebRequest::postString('newcomment');
57
+			$visibility = WebRequest::postString('visibility');
58 58
 
59
-            if ($visibility !== 'user' && $visibility !== 'admin') {
60
-                throw new ApplicationLogicException('Comment visibility is not valid');
61
-            }
59
+			if ($visibility !== 'user' && $visibility !== 'admin') {
60
+				throw new ApplicationLogicException('Comment visibility is not valid');
61
+			}
62 62
 
63
-            // optimisticly lock from the load of the edit comment form
64
-            $updateVersion = WebRequest::postInt('updateversion');
65
-            $comment->setUpdateVersion($updateVersion);
63
+			// optimisticly lock from the load of the edit comment form
64
+			$updateVersion = WebRequest::postInt('updateversion');
65
+			$comment->setUpdateVersion($updateVersion);
66 66
 
67
-            $comment->setComment($newComment);
68
-            $comment->setVisibility($visibility);
67
+			$comment->setComment($newComment);
68
+			$comment->setVisibility($visibility);
69 69
 
70
-            $comment->save();
70
+			$comment->save();
71 71
 
72
-            Logger::editComment($database, $comment, $request);
73
-            $this->getNotificationHelper()->commentEdited($comment, $request);
74
-            SessionAlert::success("Comment has been saved successfully");
72
+			Logger::editComment($database, $comment, $request);
73
+			$this->getNotificationHelper()->commentEdited($comment, $request);
74
+			SessionAlert::success("Comment has been saved successfully");
75 75
 
76
-            $this->redirect('viewRequest', null, array('id' => $comment->getRequest()));
77
-        }
78
-        else {
79
-            $this->assignCSRFToken();
80
-            $this->assign('comment', $comment);
81
-            $this->assign('request', $request);
82
-            $this->assign('user', User::getById($comment->getUser(), $database));
83
-            $this->setTemplate('edit-comment.tpl');
84
-        }
85
-    }
76
+			$this->redirect('viewRequest', null, array('id' => $comment->getRequest()));
77
+		}
78
+		else {
79
+			$this->assignCSRFToken();
80
+			$this->assign('comment', $comment);
81
+			$this->assign('request', $request);
82
+			$this->assign('user', User::getById($comment->getUser(), $database));
83
+			$this->setTemplate('edit-comment.tpl');
84
+		}
85
+	}
86 86
 }
Please login to merge, or discard this patch.
includes/Pages/PageOAuth.php 1 patch
Indentation   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -17,134 +17,134 @@
 block discarded – undo
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
-        if ($this->getSiteConfiguration()->getEnforceOAuth()) {
53
-            throw new AccessDeniedException($this->getSecurityManager());
54
-        }
55
-
56
-        $user = User::getCurrent($this->getDatabase());
57
-
58
-        $user->setOnWikiName($user->getOnWikiName());
59
-        $user->setOAuthAccessSecret(null);
60
-        $user->setOAuthAccessToken(null);
61
-        $user->setOAuthRequestSecret(null);
62
-        $user->setOAuthRequestToken(null);
63
-
64
-        $user->clearOAuthData();
65
-
66
-        $user->setForcelogout(true);
67
-
68
-        $user->save();
69
-
70
-        // force the user to log out
71
-        Session::destroy();
72
-
73
-        $this->redirect('login');
74
-    }
75
-
76
-    /**
77
-     * Callback entry point
78
-     */
79
-    protected function callback()
80
-    {
81
-        $oauthToken = WebRequest::getString('oauth_token');
82
-        $oauthVerifier = WebRequest::getString('oauth_verifier');
83
-
84
-        $this->doCallbackValidation($oauthToken, $oauthVerifier);
85
-
86
-        $user = User::getByRequestToken($oauthToken, $this->getDatabase());
87
-        if ($user === false) {
88
-            throw new ApplicationLogicException('Token not found in store, please try again');
89
-        }
90
-
91
-        $accessToken = $this->getOAuthHelper()->callbackCompleted(
92
-            $user->getOAuthRequestToken(),
93
-            $user->getOAuthRequestSecret(),
94
-            $oauthVerifier);
95
-
96
-        $user->setOAuthRequestSecret(null);
97
-        $user->setOAuthRequestToken(null);
98
-        $user->setOAuthAccessToken($accessToken->key);
99
-        $user->setOAuthAccessSecret($accessToken->secret);
100
-
101
-        // @todo we really should stop doing this kind of thing... it adds performance bottlenecks and breaks 3NF
102
-        $user->setOnWikiName('##OAUTH##');
103
-
104
-        $user->save();
105
-
106
-        // OK, we're the same session that just did a partial login that was redirected to OAuth. Let's upgrade the
107
-        // login to a full login
108
-        if (WebRequest::getPartialLogin() === $user->getId()) {
109
-            WebRequest::setLoggedInUser($user);
110
-        }
111
-
112
-        // My thinking is there are three cases here:
113
-        //   a) new user => redirect to prefs - it's the only thing they can access other than stats
114
-        //   b) existing user hit the connect button in prefs => redirect to prefs since it's where they were
115
-        //   c) existing user logging in => redirect to wherever they came from
116
-        $redirectDestination = WebRequest::clearPostLoginRedirect();
117
-        if ($redirectDestination !== null && !$user->isNewUser()) {
118
-            $this->redirectUrl($redirectDestination);
119
-        }
120
-        else {
121
-            $this->redirect('preferences', null, null, 'internal.php');
122
-        }
123
-    }
124
-
125
-    /**
126
-     * Main function for this page, when no specific actions are called.
127
-     * @return void
128
-     */
129
-    protected function main()
130
-    {
131
-        $this->redirect('preferences');
132
-    }
133
-
134
-    /**
135
-     * @param string $oauthToken
136
-     * @param string $oauthVerifier
137
-     *
138
-     * @throws ApplicationLogicException
139
-     */
140
-    protected function doCallbackValidation($oauthToken, $oauthVerifier)
141
-    {
142
-        if ($oauthToken === null) {
143
-            throw new ApplicationLogicException('No token provided');
144
-        }
145
-
146
-        if ($oauthVerifier === null) {
147
-            throw new ApplicationLogicException('No oauth verifier provided.');
148
-        }
149
-    }
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
+		if ($this->getSiteConfiguration()->getEnforceOAuth()) {
53
+			throw new AccessDeniedException($this->getSecurityManager());
54
+		}
55
+
56
+		$user = User::getCurrent($this->getDatabase());
57
+
58
+		$user->setOnWikiName($user->getOnWikiName());
59
+		$user->setOAuthAccessSecret(null);
60
+		$user->setOAuthAccessToken(null);
61
+		$user->setOAuthRequestSecret(null);
62
+		$user->setOAuthRequestToken(null);
63
+
64
+		$user->clearOAuthData();
65
+
66
+		$user->setForcelogout(true);
67
+
68
+		$user->save();
69
+
70
+		// force the user to log out
71
+		Session::destroy();
72
+
73
+		$this->redirect('login');
74
+	}
75
+
76
+	/**
77
+	 * Callback entry point
78
+	 */
79
+	protected function callback()
80
+	{
81
+		$oauthToken = WebRequest::getString('oauth_token');
82
+		$oauthVerifier = WebRequest::getString('oauth_verifier');
83
+
84
+		$this->doCallbackValidation($oauthToken, $oauthVerifier);
85
+
86
+		$user = User::getByRequestToken($oauthToken, $this->getDatabase());
87
+		if ($user === false) {
88
+			throw new ApplicationLogicException('Token not found in store, please try again');
89
+		}
90
+
91
+		$accessToken = $this->getOAuthHelper()->callbackCompleted(
92
+			$user->getOAuthRequestToken(),
93
+			$user->getOAuthRequestSecret(),
94
+			$oauthVerifier);
95
+
96
+		$user->setOAuthRequestSecret(null);
97
+		$user->setOAuthRequestToken(null);
98
+		$user->setOAuthAccessToken($accessToken->key);
99
+		$user->setOAuthAccessSecret($accessToken->secret);
100
+
101
+		// @todo we really should stop doing this kind of thing... it adds performance bottlenecks and breaks 3NF
102
+		$user->setOnWikiName('##OAUTH##');
103
+
104
+		$user->save();
105
+
106
+		// OK, we're the same session that just did a partial login that was redirected to OAuth. Let's upgrade the
107
+		// login to a full login
108
+		if (WebRequest::getPartialLogin() === $user->getId()) {
109
+			WebRequest::setLoggedInUser($user);
110
+		}
111
+
112
+		// My thinking is there are three cases here:
113
+		//   a) new user => redirect to prefs - it's the only thing they can access other than stats
114
+		//   b) existing user hit the connect button in prefs => redirect to prefs since it's where they were
115
+		//   c) existing user logging in => redirect to wherever they came from
116
+		$redirectDestination = WebRequest::clearPostLoginRedirect();
117
+		if ($redirectDestination !== null && !$user->isNewUser()) {
118
+			$this->redirectUrl($redirectDestination);
119
+		}
120
+		else {
121
+			$this->redirect('preferences', null, null, 'internal.php');
122
+		}
123
+	}
124
+
125
+	/**
126
+	 * Main function for this page, when no specific actions are called.
127
+	 * @return void
128
+	 */
129
+	protected function main()
130
+	{
131
+		$this->redirect('preferences');
132
+	}
133
+
134
+	/**
135
+	 * @param string $oauthToken
136
+	 * @param string $oauthVerifier
137
+	 *
138
+	 * @throws ApplicationLogicException
139
+	 */
140
+	protected function doCallbackValidation($oauthToken, $oauthVerifier)
141
+	{
142
+		if ($oauthToken === null) {
143
+			throw new ApplicationLogicException('No token provided');
144
+		}
145
+
146
+		if ($oauthVerifier === null) {
147
+			throw new ApplicationLogicException('No oauth verifier provided.');
148
+		}
149
+	}
150 150
 }
Please login to merge, or discard this patch.
includes/Pages/PageLogout.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -13,17 +13,17 @@
 block discarded – undo
13 13
 
14 14
 class PageLogout extends InternalPageBase
15 15
 {
16
-    /**
17
-     * Main function for this page, when no specific actions are called.
18
-     */
19
-    protected function main()
20
-    {
21
-        Session::destroy();
22
-        $this->redirect("login");
23
-    }
16
+	/**
17
+	 * Main function for this page, when no specific actions are called.
18
+	 */
19
+	protected function main()
20
+	{
21
+		Session::destroy();
22
+		$this->redirect("login");
23
+	}
24 24
 
25
-    protected function isProtectedPage()
26
-    {
27
-        return false;
28
-    }
25
+	protected function isProtectedPage()
26
+	{
27
+		return false;
28
+	}
29 29
 }
Please login to merge, or discard this patch.
includes/Pages/Registration/PageRegisterOption.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -12,17 +12,17 @@
 block discarded – undo
12 12
 
13 13
 class PageRegisterOption extends InternalPageBase
14 14
 {
15
-    /**
16
-     * Main function for this page, when no specific actions are called.
17
-     * @return void
18
-     */
19
-    protected function main()
20
-    {
21
-        $this->setTemplate('registration/option.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('registration/option.tpl');
22
+	}
23 23
 
24
-    protected function isProtectedPage()
25
-    {
26
-        return false;
27
-    }
24
+	protected function isProtectedPage()
25
+	{
26
+		return false;
27
+	}
28 28
 }
Please login to merge, or discard this patch.