Test Failed
Push — dependabot/composer/newinterna... ( de8420 )
by
unknown
13:57 queued 08:25
created
includes/Pages/Request/PageEmailConfirmationRequired.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@
 block discarded – undo
12 12
 
13 13
 class PageEmailConfirmationRequired extends PublicInterfacePageBase
14 14
 {
15
-    /**
16
-     * Main function for this page, when no specific actions are called.
17
-     * @return void
18
-     */
19
-    protected function main()
20
-    {
21
-        $this->setTemplate('request/email-confirmation.tpl');
22
-    }
15
+	/**
16
+	 * Main function for this page, when no specific actions are called.
17
+	 * @return void
18
+	 */
19
+	protected function main()
20
+	{
21
+		$this->setTemplate('request/email-confirmation.tpl');
22
+	}
23 23
 }
24 24
\ No newline at end of file
Please login to merge, or discard this patch.
includes/Pages/Request/PageRequestAccount.php 2 patches
Indentation   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -19,150 +19,150 @@
 block discarded – undo
19 19
 
20 20
 class PageRequestAccount extends PublicInterfacePageBase
21 21
 {
22
-    /**
23
-     * Main function for this page, when no specific actions are called.
24
-     * @return void
25
-     */
26
-    protected function main()
27
-    {
28
-        // dual mode page
29
-        if (WebRequest::wasPosted()) {
30
-            $request = $this->createNewRequest();
31
-
32
-            $validationErrors = $this->validateRequest($request);
33
-
34
-            if (count($validationErrors) > 0) {
35
-                foreach ($validationErrors as $validationError) {
36
-                    SessionAlert::error($validationError->getErrorMessage());
37
-                }
38
-
39
-                // Preserve the data after an error
40
-                WebRequest::setSessionContext('accountReq',
41
-                    array(
42
-                        'username' => WebRequest::postString('name'),
43
-                        'email'    => WebRequest::postEmail('email'),
44
-                        'comments' => WebRequest::postString('comments'),
45
-                    )
46
-                );
47
-
48
-                // Validation error, bomb out early.
49
-                $this->redirect();
50
-
51
-                return;
52
-            }
53
-
54
-            // actually save the request to the database
55
-            if ($this->getSiteConfiguration()->getEmailConfirmationEnabled()) {
56
-                $this->saveAsEmailConfirmation($request);
57
-            }
58
-            else {
59
-                $this->saveWithoutEmailConfirmation($request);
60
-            }
61
-        }
62
-        else {
63
-            // set the form values from the session context
64
-            $context = WebRequest::getSessionContext('accountReq');
65
-            if ($context !== null && is_array($context)) {
66
-                $this->assign('username', $context['username']);
67
-                $this->assign('email', $context['email']);
68
-                $this->assign('comments', $context['comments']);
69
-            }
70
-
71
-            // Clear it for a refresh
72
-            WebRequest::setSessionContext('accountReq', null);
73
-
74
-            $this->setTemplate('request/request-form.tpl');
75
-        }
76
-    }
77
-
78
-    /**
79
-     * @return Request
80
-     */
81
-    protected function createNewRequest()
82
-    {
83
-        $request = new Request();
84
-        $request->setDatabase($this->getDatabase());
85
-
86
-        $request->setName(WebRequest::postString('name'));
87
-        $request->setEmail(WebRequest::postEmail('email'));
88
-        $request->setComment(WebRequest::postString('comments'));
89
-
90
-        $request->setIp(WebRequest::remoteAddress());
91
-        $request->setForwardedIp(WebRequest::forwardedAddress());
92
-
93
-        $request->setUserAgent(WebRequest::userAgent());
94
-
95
-        return $request;
96
-    }
97
-
98
-    /**
99
-     * @param Request $request
100
-     *
101
-     * @return ValidationError[]
102
-     */
103
-    protected function validateRequest($request)
104
-    {
105
-        $validationHelper = new RequestValidationHelper(
106
-            new BanHelper($this->getDatabase()),
107
-            $request,
108
-            WebRequest::postEmail('emailconfirm'),
109
-            $this->getDatabase(),
110
-            $this->getAntiSpoofProvider(),
111
-            $this->getXffTrustProvider(),
112
-            $this->getHttpHelper(),
113
-            $this->getSiteConfiguration()->getMediawikiWebServiceEndpoint(),
114
-            $this->getSiteConfiguration()->getTitleBlacklistEnabled(),
115
-            $this->getTorExitProvider());
116
-
117
-        // These are arrays of ValidationError.
118
-        $nameValidation = $validationHelper->validateName();
119
-        $emailValidation = $validationHelper->validateEmail();
120
-        $otherValidation = $validationHelper->validateOther();
121
-
122
-        $validationErrors = array_merge($nameValidation, $emailValidation, $otherValidation);
123
-
124
-        return $validationErrors;
125
-    }
126
-
127
-    /**
128
-     * @param Request $request
129
-     *
130
-     * @throws Exception
131
-     */
132
-    protected function saveAsEmailConfirmation(Request $request)
133
-    {
134
-        $request->generateEmailConfirmationHash();
135
-        $request->save();
136
-
137
-        $trustedIp = $this->getXffTrustProvider()->getTrustedClientIp(
138
-            $request->getIp(),
139
-            $request->getForwardedIp());
140
-
141
-        $this->assign("ip", $trustedIp);
142
-        $this->assign("id", $request->getId());
143
-        $this->assign("hash", $request->getEmailConfirm());
144
-
145
-        // Sends the confirmation email to the user.
146
-        $this->getEmailHelper()->sendMail(
147
-            $request->getEmail(),
148
-            "[ACC #{$request->getId()}] English Wikipedia Account Request",
149
-            $this->fetchTemplate('request/confirmation-mail.tpl'));
150
-
151
-        $this->redirect('emailConfirmationRequired');
152
-    }
153
-
154
-    /**
155
-     * @param Request $request
156
-     *
157
-     * @throws Exception
158
-     */
159
-    protected function saveWithoutEmailConfirmation(Request $request)
160
-    {
161
-        $request->setEmailConfirm(0); // fixme Since it can't be null
162
-        $request->save();
163
-
164
-        $this->getNotificationHelper()->requestReceived($request);
165
-
166
-        $this->redirect('requestSubmitted');
167
-    }
22
+	/**
23
+	 * Main function for this page, when no specific actions are called.
24
+	 * @return void
25
+	 */
26
+	protected function main()
27
+	{
28
+		// dual mode page
29
+		if (WebRequest::wasPosted()) {
30
+			$request = $this->createNewRequest();
31
+
32
+			$validationErrors = $this->validateRequest($request);
33
+
34
+			if (count($validationErrors) > 0) {
35
+				foreach ($validationErrors as $validationError) {
36
+					SessionAlert::error($validationError->getErrorMessage());
37
+				}
38
+
39
+				// Preserve the data after an error
40
+				WebRequest::setSessionContext('accountReq',
41
+					array(
42
+						'username' => WebRequest::postString('name'),
43
+						'email'    => WebRequest::postEmail('email'),
44
+						'comments' => WebRequest::postString('comments'),
45
+					)
46
+				);
47
+
48
+				// Validation error, bomb out early.
49
+				$this->redirect();
50
+
51
+				return;
52
+			}
53
+
54
+			// actually save the request to the database
55
+			if ($this->getSiteConfiguration()->getEmailConfirmationEnabled()) {
56
+				$this->saveAsEmailConfirmation($request);
57
+			}
58
+			else {
59
+				$this->saveWithoutEmailConfirmation($request);
60
+			}
61
+		}
62
+		else {
63
+			// set the form values from the session context
64
+			$context = WebRequest::getSessionContext('accountReq');
65
+			if ($context !== null && is_array($context)) {
66
+				$this->assign('username', $context['username']);
67
+				$this->assign('email', $context['email']);
68
+				$this->assign('comments', $context['comments']);
69
+			}
70
+
71
+			// Clear it for a refresh
72
+			WebRequest::setSessionContext('accountReq', null);
73
+
74
+			$this->setTemplate('request/request-form.tpl');
75
+		}
76
+	}
77
+
78
+	/**
79
+	 * @return Request
80
+	 */
81
+	protected function createNewRequest()
82
+	{
83
+		$request = new Request();
84
+		$request->setDatabase($this->getDatabase());
85
+
86
+		$request->setName(WebRequest::postString('name'));
87
+		$request->setEmail(WebRequest::postEmail('email'));
88
+		$request->setComment(WebRequest::postString('comments'));
89
+
90
+		$request->setIp(WebRequest::remoteAddress());
91
+		$request->setForwardedIp(WebRequest::forwardedAddress());
92
+
93
+		$request->setUserAgent(WebRequest::userAgent());
94
+
95
+		return $request;
96
+	}
97
+
98
+	/**
99
+	 * @param Request $request
100
+	 *
101
+	 * @return ValidationError[]
102
+	 */
103
+	protected function validateRequest($request)
104
+	{
105
+		$validationHelper = new RequestValidationHelper(
106
+			new BanHelper($this->getDatabase()),
107
+			$request,
108
+			WebRequest::postEmail('emailconfirm'),
109
+			$this->getDatabase(),
110
+			$this->getAntiSpoofProvider(),
111
+			$this->getXffTrustProvider(),
112
+			$this->getHttpHelper(),
113
+			$this->getSiteConfiguration()->getMediawikiWebServiceEndpoint(),
114
+			$this->getSiteConfiguration()->getTitleBlacklistEnabled(),
115
+			$this->getTorExitProvider());
116
+
117
+		// These are arrays of ValidationError.
118
+		$nameValidation = $validationHelper->validateName();
119
+		$emailValidation = $validationHelper->validateEmail();
120
+		$otherValidation = $validationHelper->validateOther();
121
+
122
+		$validationErrors = array_merge($nameValidation, $emailValidation, $otherValidation);
123
+
124
+		return $validationErrors;
125
+	}
126
+
127
+	/**
128
+	 * @param Request $request
129
+	 *
130
+	 * @throws Exception
131
+	 */
132
+	protected function saveAsEmailConfirmation(Request $request)
133
+	{
134
+		$request->generateEmailConfirmationHash();
135
+		$request->save();
136
+
137
+		$trustedIp = $this->getXffTrustProvider()->getTrustedClientIp(
138
+			$request->getIp(),
139
+			$request->getForwardedIp());
140
+
141
+		$this->assign("ip", $trustedIp);
142
+		$this->assign("id", $request->getId());
143
+		$this->assign("hash", $request->getEmailConfirm());
144
+
145
+		// Sends the confirmation email to the user.
146
+		$this->getEmailHelper()->sendMail(
147
+			$request->getEmail(),
148
+			"[ACC #{$request->getId()}] English Wikipedia Account Request",
149
+			$this->fetchTemplate('request/confirmation-mail.tpl'));
150
+
151
+		$this->redirect('emailConfirmationRequired');
152
+	}
153
+
154
+	/**
155
+	 * @param Request $request
156
+	 *
157
+	 * @throws Exception
158
+	 */
159
+	protected function saveWithoutEmailConfirmation(Request $request)
160
+	{
161
+		$request->setEmailConfirm(0); // fixme Since it can't be null
162
+		$request->save();
163
+
164
+		$this->getNotificationHelper()->requestReceived($request);
165
+
166
+		$this->redirect('requestSubmitted');
167
+	}
168 168
 }
169 169
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -54,12 +54,10 @@
 block discarded – undo
54 54
             // actually save the request to the database
55 55
             if ($this->getSiteConfiguration()->getEmailConfirmationEnabled()) {
56 56
                 $this->saveAsEmailConfirmation($request);
57
-            }
58
-            else {
57
+            } else {
59 58
                 $this->saveWithoutEmailConfirmation($request);
60 59
             }
61
-        }
62
-        else {
60
+        } else {
63 61
             // set the form values from the session context
64 62
             $context = WebRequest::getSessionContext('accountReq');
65 63
             if ($context !== null && is_array($context)) {
Please login to merge, or discard this patch.
includes/Pages/Request/PageConfirmEmail.php 2 patches
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -18,67 +18,67 @@
 block discarded – undo
18 18
 
19 19
 class PageConfirmEmail extends PublicInterfacePageBase
20 20
 {
21
-    /**
22
-     * Main function for this page, when no specific actions are called.
23
-     * @throws ApplicationLogicException
24
-     * @throws Exception
25
-     */
26
-    protected function main()
27
-    {
28
-        $id = WebRequest::getInt('id');
29
-        $si = WebRequest::getString('si');
30
-
31
-        if ($id === null || $si === null) {
32
-            throw new ApplicationLogicException('Link incomplete - please double check the link you received.');
33
-        }
34
-
35
-        /** @var Request|false $request */
36
-        $request = Request::getById($id, $this->getDatabase());
37
-
38
-        if ($request === false) {
39
-            throw new ApplicationLogicException('Request not found');
40
-        }
41
-
42
-        if ($request->getEmailConfirm() === 'Confirmed') {
43
-            // request has already been confirmed. Bomb out silently.
44
-            $this->redirect('requestSubmitted');
45
-
46
-            return;
47
-        }
48
-
49
-        if ($request->getEmailConfirm() === $si) {
50
-            $request->setEmailConfirm('Confirmed');
51
-        }
52
-        else {
53
-            throw new ApplicationLogicException('The confirmation value does not appear to match the expected value');
54
-        }
55
-
56
-        try {
57
-            $request->save();
58
-        }
59
-        catch (OptimisticLockFailedException $ex) {
60
-            // Okay. Someone's edited this in the time between us loading this page and doing the checks, and us getting
61
-            // to saving the page. We *do not* want to show an optimistic lock failure, the most likely problem is they
62
-            // double-loaded this page (see #255). Let's confirm this, and bomb out with a success message if it's the
63
-            // case.
64
-
65
-            $request = Request::getById($id, $this->getDatabase());
66
-            if ($request->getEmailConfirm() === 'Confirmed') {
67
-                // we've already done the sanity checks above
68
-
69
-                $this->redirect('requestSubmitted');
70
-
71
-                // skip the log and notification
72
-                return;
73
-            }
74
-
75
-            // something really weird happened. Another race condition?
76
-            throw $ex;
77
-        }
78
-
79
-        Logger::emailConfirmed($this->getDatabase(), $request);
80
-        $this->getNotificationHelper()->requestReceived($request);
81
-
82
-        $this->redirect('requestSubmitted');
83
-    }
21
+	/**
22
+	 * Main function for this page, when no specific actions are called.
23
+	 * @throws ApplicationLogicException
24
+	 * @throws Exception
25
+	 */
26
+	protected function main()
27
+	{
28
+		$id = WebRequest::getInt('id');
29
+		$si = WebRequest::getString('si');
30
+
31
+		if ($id === null || $si === null) {
32
+			throw new ApplicationLogicException('Link incomplete - please double check the link you received.');
33
+		}
34
+
35
+		/** @var Request|false $request */
36
+		$request = Request::getById($id, $this->getDatabase());
37
+
38
+		if ($request === false) {
39
+			throw new ApplicationLogicException('Request not found');
40
+		}
41
+
42
+		if ($request->getEmailConfirm() === 'Confirmed') {
43
+			// request has already been confirmed. Bomb out silently.
44
+			$this->redirect('requestSubmitted');
45
+
46
+			return;
47
+		}
48
+
49
+		if ($request->getEmailConfirm() === $si) {
50
+			$request->setEmailConfirm('Confirmed');
51
+		}
52
+		else {
53
+			throw new ApplicationLogicException('The confirmation value does not appear to match the expected value');
54
+		}
55
+
56
+		try {
57
+			$request->save();
58
+		}
59
+		catch (OptimisticLockFailedException $ex) {
60
+			// Okay. Someone's edited this in the time between us loading this page and doing the checks, and us getting
61
+			// to saving the page. We *do not* want to show an optimistic lock failure, the most likely problem is they
62
+			// double-loaded this page (see #255). Let's confirm this, and bomb out with a success message if it's the
63
+			// case.
64
+
65
+			$request = Request::getById($id, $this->getDatabase());
66
+			if ($request->getEmailConfirm() === 'Confirmed') {
67
+				// we've already done the sanity checks above
68
+
69
+				$this->redirect('requestSubmitted');
70
+
71
+				// skip the log and notification
72
+				return;
73
+			}
74
+
75
+			// something really weird happened. Another race condition?
76
+			throw $ex;
77
+		}
78
+
79
+		Logger::emailConfirmed($this->getDatabase(), $request);
80
+		$this->getNotificationHelper()->requestReceived($request);
81
+
82
+		$this->redirect('requestSubmitted');
83
+	}
84 84
 }
85 85
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,8 +48,7 @@
 block discarded – undo
48 48
 
49 49
         if ($request->getEmailConfirm() === $si) {
50 50
             $request->setEmailConfirm('Confirmed');
51
-        }
52
-        else {
51
+        } else {
53 52
             throw new ApplicationLogicException('The confirmation value does not appear to match the expected value');
54 53
         }
55 54
 
Please login to merge, or discard this patch.
includes/Pages/Request/PageRequestSubmitted.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@
 block discarded – undo
12 12
 
13 13
 class PageRequestSubmitted extends PublicInterfacePageBase
14 14
 {
15
-    /**
16
-     * Main function for this page, when no specific actions are called.
17
-     * @return void
18
-     */
19
-    protected function main()
20
-    {
21
-        $this->setTemplate('request/email-confirmed.tpl');
22
-    }
15
+	/**
16
+	 * Main function for this page, when no specific actions are called.
17
+	 * @return void
18
+	 */
19
+	protected function main()
20
+	{
21
+		$this->setTemplate('request/email-confirmed.tpl');
22
+	}
23 23
 }
24 24
\ No newline at end of file
Please login to merge, or discard this patch.
includes/Pages/PageTeam.php 2 patches
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -12,31 +12,31 @@
 block discarded – undo
12 12
 
13 13
 class PageTeam 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
-        $path = $this->getSiteConfiguration()->getFilePath() . '/team.json';
22
-        $json = file_get_contents($path);
15
+	/**
16
+	 * Main function for this page, when no specific actions are called.
17
+	 * @return void
18
+	 */
19
+	protected function main()
20
+	{
21
+		$path = $this->getSiteConfiguration()->getFilePath() . '/team.json';
22
+		$json = file_get_contents($path);
23 23
 
24
-        $teamData = json_decode($json, true);
24
+		$teamData = json_decode($json, true);
25 25
 
26
-        $active = array();
27
-        $inactive = array();
26
+		$active = array();
27
+		$inactive = array();
28 28
 
29
-        foreach ($teamData as $name => $item) {
30
-            if (count($item['Role']) == 0) {
31
-                $inactive[$name] = $item;
32
-            }
33
-            else {
34
-                $active[$name] = $item;
35
-            }
36
-        }
29
+		foreach ($teamData as $name => $item) {
30
+			if (count($item['Role']) == 0) {
31
+				$inactive[$name] = $item;
32
+			}
33
+			else {
34
+				$active[$name] = $item;
35
+			}
36
+		}
37 37
 
38
-        $this->assign('developer', $active);
39
-        $this->assign('inactiveDeveloper', $inactive);
40
-        $this->setTemplate('team/team.tpl');
41
-    }
38
+		$this->assign('developer', $active);
39
+		$this->assign('inactiveDeveloper', $inactive);
40
+		$this->setTemplate('team/team.tpl');
41
+	}
42 42
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,8 +29,7 @@
 block discarded – undo
29 29
         foreach ($teamData as $name => $item) {
30 30
             if (count($item['Role']) == 0) {
31 31
                 $inactive[$name] = $item;
32
-            }
33
-            else {
32
+            } else {
34 33
                 $active[$name] = $item;
35 34
             }
36 35
         }
Please login to merge, or discard this patch.
includes/Pages/RequestAction/PageCustomClose.php 2 patches
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -42,8 +42,7 @@  discard block
 block discarded – undo
42 42
             $this->doCustomClose($currentUser, $request, $database);
43 43
 
44 44
             $this->redirect();
45
-        }
46
-        else {
45
+        } else {
47 46
             $this->assignCSRFToken();
48 47
             $this->showCustomCloseForm($database, $request);
49 48
         }
@@ -185,16 +184,14 @@  discard block
 block discarded – undo
185 184
 
186 185
             // Send the mail after the save, since save can be rolled back
187 186
             $this->sendMail($request, $messageBody, $currentUser, $ccMailingList);
188
-        }
189
-        else {
187
+        } else {
190 188
             if (array_key_exists($action, $availableRequestStates)) {
191 189
                 // Defer to other state
192 190
                 $this->deferRequest($request, $database, $action, $availableRequestStates, $messageBody);
193 191
 
194 192
                 // Send the mail after the save, since save can be rolled back
195 193
                 $this->sendMail($request, $messageBody, $currentUser, $ccMailingList);
196
-            }
197
-            else {
194
+            } else {
198 195
                 $request->setReserved(null);
199 196
                 $request->setUpdateVersion(WebRequest::postInt('updateversion'));
200 197
                 $request->save();
@@ -236,8 +233,7 @@  discard block
 block discarded – undo
236 233
         if ($action == EmailTemplate::CREATED) {
237 234
             $logCloseType = 'custom-y';
238 235
             $notificationCloseType = "Custom, Created";
239
-        }
240
-        else {
236
+        } else {
241 237
             $logCloseType = 'custom-n';
242 238
             $notificationCloseType = "Custom, Not Created";
243 239
         }
Please login to merge, or discard this patch.
Indentation   +274 added lines, -274 removed lines patch added patch discarded remove patch
@@ -24,278 +24,278 @@
 block discarded – undo
24 24
 
25 25
 class PageCustomClose extends PageCloseRequest
26 26
 {
27
-    use RequestData;
28
-
29
-    protected function main()
30
-    {
31
-        $database = $this->getDatabase();
32
-
33
-        $request = $this->getRequest($database);
34
-        $currentUser = User::getCurrent($this->getDatabase());
35
-
36
-        if ($request->getStatus() === 'Closed') {
37
-            throw new ApplicationLogicException('Request is already closed');
38
-        }
39
-
40
-        // Dual-mode page
41
-        if (WebRequest::wasPosted()) {
42
-            $this->validateCSRFToken();
43
-            $this->doCustomClose($currentUser, $request, $database);
44
-
45
-            $this->redirect();
46
-        }
47
-        else {
48
-            $this->assignCSRFToken();
49
-            $this->showCustomCloseForm($database, $request);
50
-        }
51
-    }
52
-
53
-    /**
54
-     * @param $database
55
-     *
56
-     * @return Request
57
-     * @throws ApplicationLogicException
58
-     */
59
-    protected function getRequest(PdoDatabase $database)
60
-    {
61
-        $requestId = WebRequest::getInt('request');
62
-        if ($requestId === null) {
63
-            throw new ApplicationLogicException('Request ID not found');
64
-        }
65
-
66
-        /** @var Request $request */
67
-        $request = Request::getById($requestId, $database);
68
-
69
-        if ($request === false) {
70
-            throw new ApplicationLogicException('Request not found');
71
-        }
72
-
73
-        return $request;
74
-    }
75
-
76
-    /**
77
-     * @param PdoDatabase $database
78
-     *
79
-     * @return EmailTemplate|null
80
-     */
81
-    protected function getTemplate(PdoDatabase $database)
82
-    {
83
-        $templateId = WebRequest::getInt('template');
84
-        if ($templateId === null) {
85
-            return null;
86
-        }
87
-
88
-        /** @var EmailTemplate $template */
89
-        $template = EmailTemplate::getById($templateId, $database);
90
-        if ($template === false || !$template->getActive()) {
91
-            return null;
92
-        }
93
-
94
-        return $template;
95
-    }
96
-
97
-    /**
98
-     * @param $database
99
-     * @param $request
100
-     *
101
-     * @throws Exception
102
-     */
103
-    protected function showCustomCloseForm(PdoDatabase $database, Request $request)
104
-    {
105
-        $currentUser = User::getCurrent($database);
106
-        $config = $this->getSiteConfiguration();
107
-
108
-        $allowedPrivateData = $this->isAllowedPrivateData($request, $currentUser);
109
-        if (!$allowedPrivateData) {
110
-            // we probably shouldn't be showing the user this form if they're not allowed to access private data...
111
-            throw new AccessDeniedException($this->getSecurityManager());
112
-        }
113
-
114
-        $template = $this->getTemplate($database);
115
-
116
-        // Preload data
117
-        $this->assign('defaultAction', '');
118
-        $this->assign('preloadText', '');
119
-        $this->assign('preloadTitle', '');
120
-
121
-        if ($template !== null) {
122
-            $this->assign('defaultAction', $template->getDefaultAction());
123
-            $this->assign('preloadText', $template->getText());
124
-            $this->assign('preloadTitle', $template->getName());
125
-        }
126
-
127
-        // Static data
128
-        $this->assign('requeststates', $config->getRequestStates());
129
-
130
-        // request data
131
-        $this->assign('requestId', $request->getIp());
132
-        $this->assign('updateVersion', $request->getUpdateVersion());
133
-        $this->setupBasicData($request, $config);
134
-        $this->setupReservationDetails($request->getReserved(), $database, $currentUser);
135
-        $this->setupPrivateData($request, $currentUser, $this->getSiteConfiguration(), $database);
136
-
137
-        // IP location
138
-        $trustedIp = $this->getXffTrustProvider()->getTrustedClientIp($request->getIp(), $request->getForwardedIp());
139
-        $this->assign('iplocation', $this->getLocationProvider()->getIpLocation($trustedIp));
140
-
141
-        // Confirmations
142
-        $this->assign('confirmEmailAlreadySent', $this->checkEmailAlreadySent($request));
143
-
144
-        $this->assign('canSkipCcMailingList', $this->barrierTest('skipCcMailingList', $currentUser));
145
-
146
-        $this->assign('allowWelcomeSkip', false);
147
-        $this->assign('forceWelcomeSkip', false);
148
-
149
-        $oauth = new OAuthUserHelper($currentUser, $this->getDatabase(), $this->getOAuthProtocolHelper(), $config);
150
-
151
-        if ($currentUser->getWelcomeTemplate() != 0) {
152
-            $this->assign('allowWelcomeSkip', true);
153
-
154
-            if (!$oauth->canWelcome()) {
155
-                $this->assign('forceWelcomeSkip', true);
156
-            }
157
-        }
158
-
159
-
160
-        // template
161
-        $this->setTemplate('custom-close.tpl');
162
-    }
163
-
164
-    /**
165
-     * @param User        $currentUser
166
-     * @param Request     $request
167
-     * @param PdoDatabase $database
168
-     *
169
-     * @throws ApplicationLogicException
170
-     */
171
-    protected function doCustomClose(User $currentUser, Request $request, PdoDatabase $database)
172
-    {
173
-        $messageBody = WebRequest::postString('msgbody');
174
-        if ($messageBody === null || trim($messageBody) === '') {
175
-            throw new ApplicationLogicException('Message body cannot be blank');
176
-        }
177
-
178
-        $ccMailingList = true;
179
-        if ($this->barrierTest('skipCcMailingList', $currentUser)) {
180
-            $ccMailingList = WebRequest::postBoolean('ccMailingList');
181
-        }
182
-
183
-        if ($request->getStatus() === 'Closed') {
184
-            throw new ApplicationLogicException('Request is already closed');
185
-        }
186
-
187
-        if (!(WebRequest::postBoolean('confirmEmailAlreadySent'))
188
-        ) {
189
-            throw new ApplicationLogicException('Not all confirmations checked');
190
-        }
191
-
192
-        $action = WebRequest::postString('action');
193
-        $availableRequestStates = $this->getSiteConfiguration()->getRequestStates();
194
-
195
-        if ($action === EmailTemplate::CREATED || $action === EmailTemplate::NOT_CREATED) {
196
-            // Close request
197
-            $this->closeRequest($request, $database, $action, $messageBody);
198
-
199
-            $this->processWelcome($action);
200
-
201
-            // Send the mail after the save, since save can be rolled back
202
-            $this->sendMail($request, $messageBody, $currentUser, $ccMailingList);
203
-        }
204
-        else {
205
-            if (array_key_exists($action, $availableRequestStates)) {
206
-                // Defer to other state
207
-                $this->deferRequest($request, $database, $action, $availableRequestStates, $messageBody);
208
-
209
-                // Send the mail after the save, since save can be rolled back
210
-                $this->sendMail($request, $messageBody, $currentUser, $ccMailingList);
211
-            }
212
-            else {
213
-                $request->setReserved(null);
214
-                $request->setUpdateVersion(WebRequest::postInt('updateversion'));
215
-                $request->save();
216
-
217
-                // Perform the notifications and stuff *after* we've successfully saved, since the save can throw an OLE
218
-                // and be rolled back.
219
-
220
-                // Send mail
221
-                $this->sendMail($request, $messageBody, $currentUser, $ccMailingList);
222
-
223
-                Logger::sentMail($database, $request, $messageBody);
224
-                Logger::unreserve($database, $request);
225
-
226
-                $this->getNotificationHelper()->sentMail($request);
227
-                SessionAlert::success("Sent mail to Request {$request->getId()}");
228
-            }
229
-        }
230
-    }
231
-
232
-    /**
233
-     * @param Request     $request
234
-     * @param PdoDatabase $database
235
-     * @param string      $action
236
-     * @param string      $messageBody
237
-     *
238
-     * @throws Exception
239
-     * @throws OptimisticLockFailedException
240
-     */
241
-    protected function closeRequest(Request $request, PdoDatabase $database, $action, $messageBody)
242
-    {
243
-        $request->setStatus('Closed');
244
-        $request->setReserved(null);
245
-        $request->setUpdateVersion(WebRequest::postInt('updateversion'));
246
-        $request->save();
247
-
248
-        // Perform the notifications and stuff *after* we've successfully saved, since the save can throw an OLE and
249
-        // be rolled back.
250
-
251
-        if ($action == EmailTemplate::CREATED) {
252
-            $logCloseType = 'custom-y';
253
-            $notificationCloseType = "Custom, Created";
254
-        }
255
-        else {
256
-            $logCloseType = 'custom-n';
257
-            $notificationCloseType = "Custom, Not Created";
258
-        }
259
-
260
-        Logger::closeRequest($database, $request, $logCloseType, $messageBody);
261
-        $this->getNotificationHelper()->requestClosed($request, $notificationCloseType);
262
-
263
-        $requestName = htmlentities($request->getName(), ENT_COMPAT, 'UTF-8');
264
-        SessionAlert::success("Request {$request->getId()} ({$requestName}) closed as {$notificationCloseType}.");
265
-    }
266
-
267
-    /**
268
-     * @param Request     $request
269
-     * @param PdoDatabase $database
270
-     * @param string      $action
271
-     * @param             $availableRequestStates
272
-     * @param string      $messageBody
273
-     *
274
-     * @throws Exception
275
-     * @throws OptimisticLockFailedException
276
-     */
277
-    protected function deferRequest(
278
-        Request $request,
279
-        PdoDatabase $database,
280
-        $action,
281
-        $availableRequestStates,
282
-        $messageBody
283
-    ) {
284
-        $request->setStatus($action);
285
-        $request->setReserved(null);
286
-        $request->setUpdateVersion(WebRequest::postInt('updateversion'));
287
-        $request->save();
288
-
289
-        // Perform the notifications and stuff *after* we've successfully saved, since the save can throw an OLE
290
-        // and be rolled back.
291
-
292
-        $deferToLog = $availableRequestStates[$action]['defertolog'];
293
-        Logger::sentMail($database, $request, $messageBody);
294
-        Logger::deferRequest($database, $request, $deferToLog);
295
-
296
-        $this->getNotificationHelper()->requestDeferredWithMail($request);
297
-
298
-        $deferTo = $availableRequestStates[$action]['deferto'];
299
-        SessionAlert::success("Request {$request->getId()} deferred to $deferTo, sending an email.");
300
-    }
27
+	use RequestData;
28
+
29
+	protected function main()
30
+	{
31
+		$database = $this->getDatabase();
32
+
33
+		$request = $this->getRequest($database);
34
+		$currentUser = User::getCurrent($this->getDatabase());
35
+
36
+		if ($request->getStatus() === 'Closed') {
37
+			throw new ApplicationLogicException('Request is already closed');
38
+		}
39
+
40
+		// Dual-mode page
41
+		if (WebRequest::wasPosted()) {
42
+			$this->validateCSRFToken();
43
+			$this->doCustomClose($currentUser, $request, $database);
44
+
45
+			$this->redirect();
46
+		}
47
+		else {
48
+			$this->assignCSRFToken();
49
+			$this->showCustomCloseForm($database, $request);
50
+		}
51
+	}
52
+
53
+	/**
54
+	 * @param $database
55
+	 *
56
+	 * @return Request
57
+	 * @throws ApplicationLogicException
58
+	 */
59
+	protected function getRequest(PdoDatabase $database)
60
+	{
61
+		$requestId = WebRequest::getInt('request');
62
+		if ($requestId === null) {
63
+			throw new ApplicationLogicException('Request ID not found');
64
+		}
65
+
66
+		/** @var Request $request */
67
+		$request = Request::getById($requestId, $database);
68
+
69
+		if ($request === false) {
70
+			throw new ApplicationLogicException('Request not found');
71
+		}
72
+
73
+		return $request;
74
+	}
75
+
76
+	/**
77
+	 * @param PdoDatabase $database
78
+	 *
79
+	 * @return EmailTemplate|null
80
+	 */
81
+	protected function getTemplate(PdoDatabase $database)
82
+	{
83
+		$templateId = WebRequest::getInt('template');
84
+		if ($templateId === null) {
85
+			return null;
86
+		}
87
+
88
+		/** @var EmailTemplate $template */
89
+		$template = EmailTemplate::getById($templateId, $database);
90
+		if ($template === false || !$template->getActive()) {
91
+			return null;
92
+		}
93
+
94
+		return $template;
95
+	}
96
+
97
+	/**
98
+	 * @param $database
99
+	 * @param $request
100
+	 *
101
+	 * @throws Exception
102
+	 */
103
+	protected function showCustomCloseForm(PdoDatabase $database, Request $request)
104
+	{
105
+		$currentUser = User::getCurrent($database);
106
+		$config = $this->getSiteConfiguration();
107
+
108
+		$allowedPrivateData = $this->isAllowedPrivateData($request, $currentUser);
109
+		if (!$allowedPrivateData) {
110
+			// we probably shouldn't be showing the user this form if they're not allowed to access private data...
111
+			throw new AccessDeniedException($this->getSecurityManager());
112
+		}
113
+
114
+		$template = $this->getTemplate($database);
115
+
116
+		// Preload data
117
+		$this->assign('defaultAction', '');
118
+		$this->assign('preloadText', '');
119
+		$this->assign('preloadTitle', '');
120
+
121
+		if ($template !== null) {
122
+			$this->assign('defaultAction', $template->getDefaultAction());
123
+			$this->assign('preloadText', $template->getText());
124
+			$this->assign('preloadTitle', $template->getName());
125
+		}
126
+
127
+		// Static data
128
+		$this->assign('requeststates', $config->getRequestStates());
129
+
130
+		// request data
131
+		$this->assign('requestId', $request->getIp());
132
+		$this->assign('updateVersion', $request->getUpdateVersion());
133
+		$this->setupBasicData($request, $config);
134
+		$this->setupReservationDetails($request->getReserved(), $database, $currentUser);
135
+		$this->setupPrivateData($request, $currentUser, $this->getSiteConfiguration(), $database);
136
+
137
+		// IP location
138
+		$trustedIp = $this->getXffTrustProvider()->getTrustedClientIp($request->getIp(), $request->getForwardedIp());
139
+		$this->assign('iplocation', $this->getLocationProvider()->getIpLocation($trustedIp));
140
+
141
+		// Confirmations
142
+		$this->assign('confirmEmailAlreadySent', $this->checkEmailAlreadySent($request));
143
+
144
+		$this->assign('canSkipCcMailingList', $this->barrierTest('skipCcMailingList', $currentUser));
145
+
146
+		$this->assign('allowWelcomeSkip', false);
147
+		$this->assign('forceWelcomeSkip', false);
148
+
149
+		$oauth = new OAuthUserHelper($currentUser, $this->getDatabase(), $this->getOAuthProtocolHelper(), $config);
150
+
151
+		if ($currentUser->getWelcomeTemplate() != 0) {
152
+			$this->assign('allowWelcomeSkip', true);
153
+
154
+			if (!$oauth->canWelcome()) {
155
+				$this->assign('forceWelcomeSkip', true);
156
+			}
157
+		}
158
+
159
+
160
+		// template
161
+		$this->setTemplate('custom-close.tpl');
162
+	}
163
+
164
+	/**
165
+	 * @param User        $currentUser
166
+	 * @param Request     $request
167
+	 * @param PdoDatabase $database
168
+	 *
169
+	 * @throws ApplicationLogicException
170
+	 */
171
+	protected function doCustomClose(User $currentUser, Request $request, PdoDatabase $database)
172
+	{
173
+		$messageBody = WebRequest::postString('msgbody');
174
+		if ($messageBody === null || trim($messageBody) === '') {
175
+			throw new ApplicationLogicException('Message body cannot be blank');
176
+		}
177
+
178
+		$ccMailingList = true;
179
+		if ($this->barrierTest('skipCcMailingList', $currentUser)) {
180
+			$ccMailingList = WebRequest::postBoolean('ccMailingList');
181
+		}
182
+
183
+		if ($request->getStatus() === 'Closed') {
184
+			throw new ApplicationLogicException('Request is already closed');
185
+		}
186
+
187
+		if (!(WebRequest::postBoolean('confirmEmailAlreadySent'))
188
+		) {
189
+			throw new ApplicationLogicException('Not all confirmations checked');
190
+		}
191
+
192
+		$action = WebRequest::postString('action');
193
+		$availableRequestStates = $this->getSiteConfiguration()->getRequestStates();
194
+
195
+		if ($action === EmailTemplate::CREATED || $action === EmailTemplate::NOT_CREATED) {
196
+			// Close request
197
+			$this->closeRequest($request, $database, $action, $messageBody);
198
+
199
+			$this->processWelcome($action);
200
+
201
+			// Send the mail after the save, since save can be rolled back
202
+			$this->sendMail($request, $messageBody, $currentUser, $ccMailingList);
203
+		}
204
+		else {
205
+			if (array_key_exists($action, $availableRequestStates)) {
206
+				// Defer to other state
207
+				$this->deferRequest($request, $database, $action, $availableRequestStates, $messageBody);
208
+
209
+				// Send the mail after the save, since save can be rolled back
210
+				$this->sendMail($request, $messageBody, $currentUser, $ccMailingList);
211
+			}
212
+			else {
213
+				$request->setReserved(null);
214
+				$request->setUpdateVersion(WebRequest::postInt('updateversion'));
215
+				$request->save();
216
+
217
+				// Perform the notifications and stuff *after* we've successfully saved, since the save can throw an OLE
218
+				// and be rolled back.
219
+
220
+				// Send mail
221
+				$this->sendMail($request, $messageBody, $currentUser, $ccMailingList);
222
+
223
+				Logger::sentMail($database, $request, $messageBody);
224
+				Logger::unreserve($database, $request);
225
+
226
+				$this->getNotificationHelper()->sentMail($request);
227
+				SessionAlert::success("Sent mail to Request {$request->getId()}");
228
+			}
229
+		}
230
+	}
231
+
232
+	/**
233
+	 * @param Request     $request
234
+	 * @param PdoDatabase $database
235
+	 * @param string      $action
236
+	 * @param string      $messageBody
237
+	 *
238
+	 * @throws Exception
239
+	 * @throws OptimisticLockFailedException
240
+	 */
241
+	protected function closeRequest(Request $request, PdoDatabase $database, $action, $messageBody)
242
+	{
243
+		$request->setStatus('Closed');
244
+		$request->setReserved(null);
245
+		$request->setUpdateVersion(WebRequest::postInt('updateversion'));
246
+		$request->save();
247
+
248
+		// Perform the notifications and stuff *after* we've successfully saved, since the save can throw an OLE and
249
+		// be rolled back.
250
+
251
+		if ($action == EmailTemplate::CREATED) {
252
+			$logCloseType = 'custom-y';
253
+			$notificationCloseType = "Custom, Created";
254
+		}
255
+		else {
256
+			$logCloseType = 'custom-n';
257
+			$notificationCloseType = "Custom, Not Created";
258
+		}
259
+
260
+		Logger::closeRequest($database, $request, $logCloseType, $messageBody);
261
+		$this->getNotificationHelper()->requestClosed($request, $notificationCloseType);
262
+
263
+		$requestName = htmlentities($request->getName(), ENT_COMPAT, 'UTF-8');
264
+		SessionAlert::success("Request {$request->getId()} ({$requestName}) closed as {$notificationCloseType}.");
265
+	}
266
+
267
+	/**
268
+	 * @param Request     $request
269
+	 * @param PdoDatabase $database
270
+	 * @param string      $action
271
+	 * @param             $availableRequestStates
272
+	 * @param string      $messageBody
273
+	 *
274
+	 * @throws Exception
275
+	 * @throws OptimisticLockFailedException
276
+	 */
277
+	protected function deferRequest(
278
+		Request $request,
279
+		PdoDatabase $database,
280
+		$action,
281
+		$availableRequestStates,
282
+		$messageBody
283
+	) {
284
+		$request->setStatus($action);
285
+		$request->setReserved(null);
286
+		$request->setUpdateVersion(WebRequest::postInt('updateversion'));
287
+		$request->save();
288
+
289
+		// Perform the notifications and stuff *after* we've successfully saved, since the save can throw an OLE
290
+		// and be rolled back.
291
+
292
+		$deferToLog = $availableRequestStates[$action]['defertolog'];
293
+		Logger::sentMail($database, $request, $messageBody);
294
+		Logger::deferRequest($database, $request, $deferToLog);
295
+
296
+		$this->getNotificationHelper()->requestDeferredWithMail($request);
297
+
298
+		$deferTo = $availableRequestStates[$action]['deferto'];
299
+		SessionAlert::success("Request {$request->getId()} deferred to $deferTo, sending an email.");
300
+	}
301 301
 }
Please login to merge, or discard this patch.
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/RequestAction/PageReservation.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -17,58 +17,58 @@
 block discarded – undo
17 17
 
18 18
 class PageReservation extends RequestActionBase
19 19
 {
20
-    /**
21
-     * Main function for this page, when no specific actions are called.
22
-     * @throws ApplicationLogicException
23
-     */
24
-    protected function main()
25
-    {
26
-        $this->checkPosted();
27
-        $database = $this->getDatabase();
28
-        $request = $this->getRequest($database);
20
+	/**
21
+	 * Main function for this page, when no specific actions are called.
22
+	 * @throws ApplicationLogicException
23
+	 */
24
+	protected function main()
25
+	{
26
+		$this->checkPosted();
27
+		$database = $this->getDatabase();
28
+		$request = $this->getRequest($database);
29 29
 
30
-        $closureDate = $request->getClosureDate();
30
+		$closureDate = $request->getClosureDate();
31 31
 
32
-        $date = new DateTime();
33
-        $date->modify("-7 days");
34
-        $oneweek = $date->format("Y-m-d H:i:s");
32
+		$date = new DateTime();
33
+		$date->modify("-7 days");
34
+		$oneweek = $date->format("Y-m-d H:i:s");
35 35
 
36
-        $currentUser = User::getCurrent($database);
37
-        if ($request->getStatus() == "Closed" && $closureDate < $oneweek) {
38
-            if (!$this->barrierTest('reopenOldRequest', $currentUser, 'RequestData')) {
39
-                throw new ApplicationLogicException(
40
-                    "You are not allowed to reserve a request that has been closed for over a week.");
41
-            }
42
-        }
36
+		$currentUser = User::getCurrent($database);
37
+		if ($request->getStatus() == "Closed" && $closureDate < $oneweek) {
38
+			if (!$this->barrierTest('reopenOldRequest', $currentUser, 'RequestData')) {
39
+				throw new ApplicationLogicException(
40
+					"You are not allowed to reserve a request that has been closed for over a week.");
41
+			}
42
+		}
43 43
 
44
-        if ($request->getReserved() !== null && $request->getReserved() != $currentUser->getId()) {
45
-            throw new ApplicationLogicException("Request is already reserved!");
46
-        }
44
+		if ($request->getReserved() !== null && $request->getReserved() != $currentUser->getId()) {
45
+			throw new ApplicationLogicException("Request is already reserved!");
46
+		}
47 47
 
48
-        if ($request->getReserved() === null) {
49
-            // Check the number of requests a user has reserved already
50
-            $doubleReserveCountQuery = $database->prepare("SELECT COUNT(*) FROM request WHERE reserved = :userid;");
51
-            $doubleReserveCountQuery->bindValue(":userid", $currentUser->getId());
52
-            $doubleReserveCountQuery->execute();
53
-            $doubleReserveCount = $doubleReserveCountQuery->fetchColumn();
54
-            $doubleReserveCountQuery->closeCursor();
48
+		if ($request->getReserved() === null) {
49
+			// Check the number of requests a user has reserved already
50
+			$doubleReserveCountQuery = $database->prepare("SELECT COUNT(*) FROM request WHERE reserved = :userid;");
51
+			$doubleReserveCountQuery->bindValue(":userid", $currentUser->getId());
52
+			$doubleReserveCountQuery->execute();
53
+			$doubleReserveCount = $doubleReserveCountQuery->fetchColumn();
54
+			$doubleReserveCountQuery->closeCursor();
55 55
 
56
-            // User already has at least one reserved.
57
-            if ($doubleReserveCount != 0) {
58
-                SessionAlert::warning("You have multiple requests reserved!");
59
-            }
56
+			// User already has at least one reserved.
57
+			if ($doubleReserveCount != 0) {
58
+				SessionAlert::warning("You have multiple requests reserved!");
59
+			}
60 60
 
61
-            $request->setReserved($currentUser->getId());
62
-            $request->setUpdateVersion(WebRequest::postInt('updateversion'));
63
-            $request->save();
61
+			$request->setReserved($currentUser->getId());
62
+			$request->setUpdateVersion(WebRequest::postInt('updateversion'));
63
+			$request->save();
64 64
 
65
-            Logger::reserve($database, $request);
65
+			Logger::reserve($database, $request);
66 66
 
67
-            $this->getNotificationHelper()->requestReserved($request);
67
+			$this->getNotificationHelper()->requestReserved($request);
68 68
 
69
-            SessionAlert::success("Reserved request {$request->getId()}.");
70
-        }
69
+			SessionAlert::success("Reserved request {$request->getId()}.");
70
+		}
71 71
 
72
-        $this->redirect('viewRequest', null, array('id' => $request->getId()));
73
-    }
72
+		$this->redirect('viewRequest', null, array('id' => $request->getId()));
73
+	}
74 74
 }
Please login to merge, or discard this patch.
includes/Offline.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,8 +48,7 @@
 block discarded – undo
48 48
 
49 49
         if ($external) {
50 50
             return $smarty->fetch("offline/external.tpl");
51
-        }
52
-        else {
51
+        } else {
53 52
             $hideCulprit = true;
54 53
 
55 54
             // Use the provided message if possible
Please login to merge, or discard this patch.
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -17,16 +17,16 @@  discard block
 block discarded – undo
17 17
  */
18 18
 class Offline
19 19
 {
20
-    /**
21
-     * Determines if the tool is offline
22
-     * @return bool
23
-     */
24
-    public static function isOffline()
25
-    {
26
-        global $dontUseDb;
20
+	/**
21
+	 * Determines if the tool is offline
22
+	 * @return bool
23
+	 */
24
+	public static function isOffline()
25
+	{
26
+		global $dontUseDb;
27 27
 
28
-        return (bool)$dontUseDb;
29
-    }
28
+		return (bool)$dontUseDb;
29
+	}
30 30
 
31 31
 	/**
32 32
 	 * Gets the offline message
@@ -37,38 +37,38 @@  discard block
 block discarded – undo
37 37
 	 * @return string
38 38
 	 * @throws SmartyException
39 39
 	 */
40
-    public static function getOfflineMessage($external, $message = null)
41
-    {
42
-        global $dontUseDbCulprit, $dontUseDbReason, $baseurl;
40
+	public static function getOfflineMessage($external, $message = null)
41
+	{
42
+		global $dontUseDbCulprit, $dontUseDbReason, $baseurl;
43 43
 
44
-        $smarty = new Smarty();
45
-        $smarty->assign("baseurl", $baseurl);
46
-        $smarty->assign("alerts", []);
47
-        $smarty->assign("toolversion", Environment::getToolVersion());
44
+		$smarty = new Smarty();
45
+		$smarty->assign("baseurl", $baseurl);
46
+		$smarty->assign("alerts", []);
47
+		$smarty->assign("toolversion", Environment::getToolVersion());
48 48
 
49
-        if (!headers_sent()) {
50
-            header("HTTP/1.1 503 Service Unavailable");
51
-        }
49
+		if (!headers_sent()) {
50
+			header("HTTP/1.1 503 Service Unavailable");
51
+		}
52 52
 
53
-        if ($external) {
54
-            return $smarty->fetch("offline/external.tpl");
55
-        }
56
-        else {
57
-            $hideCulprit = true;
53
+		if ($external) {
54
+			return $smarty->fetch("offline/external.tpl");
55
+		}
56
+		else {
57
+			$hideCulprit = true;
58 58
 
59
-            // Use the provided message if possible
60
-            if ($message === null) {
61
-                $hideCulprit = false;
62
-                $message = $dontUseDbReason;
63
-            }
59
+			// Use the provided message if possible
60
+			if ($message === null) {
61
+				$hideCulprit = false;
62
+				$message = $dontUseDbReason;
63
+			}
64 64
 
65
-            $smarty->assign("hideCulprit", $hideCulprit);
66
-            $smarty->assign("dontUseDbCulprit", $dontUseDbCulprit);
67
-            $smarty->assign("dontUseDbReason", $message);
68
-            $smarty->assign("alerts", array());
69
-            $smarty->assign('currentUser', User::getCommunity());
65
+			$smarty->assign("hideCulprit", $hideCulprit);
66
+			$smarty->assign("dontUseDbCulprit", $dontUseDbCulprit);
67
+			$smarty->assign("dontUseDbReason", $message);
68
+			$smarty->assign("alerts", array());
69
+			$smarty->assign('currentUser', User::getCommunity());
70 70
 
71
-            return $smarty->fetch("offline/internal.tpl");
72
-        }
73
-    }
71
+			return $smarty->fetch("offline/internal.tpl");
72
+		}
73
+	}
74 74
 }
Please login to merge, or discard this patch.