Failed Conditions
Pull Request — newinternal (#527)
by Simon
17:20 queued 07:22
created
includes/Tasks/PageBase.php 1 patch
Indentation   +349 added lines, -349 removed lines patch added patch discarded remove patch
@@ -21,353 +21,353 @@
 block discarded – undo
21 21
 
22 22
 abstract class PageBase extends TaskBase implements IRoutedTask
23 23
 {
24
-    use TemplateOutput;
25
-    /** @var string Smarty template to display */
26
-    protected $template = "base.tpl";
27
-    /** @var string HTML title. Currently unused. */
28
-    protected $htmlTitle;
29
-    /** @var bool Determines if the page is a redirect or not */
30
-    protected $isRedirecting = false;
31
-    /** @var array Queue of headers to be sent on successful completion */
32
-    protected $headerQueue = array();
33
-    /** @var string The name of the route to use, as determined by the request router. */
34
-    private $routeName = null;
35
-    /** @var TokenManager */
36
-    protected $tokenManager;
37
-    /** @var string[] Extra CSS files to include */
38
-    private $extraCss = array();
39
-    /** @var string[] Extra JS files to include */
40
-    private $extraJs = array();
41
-
42
-    /**
43
-     * Sets the route the request will take. Only should be called from the request router or barrier test.
44
-     *
45
-     * @param string $routeName        The name of the route
46
-     * @param bool   $skipCallableTest Don't use this unless you know what you're doing, and what the implications are.
47
-     *
48
-     * @throws Exception
49
-     * @category Security-Critical
50
-     */
51
-    final public function setRoute($routeName, $skipCallableTest = false)
52
-    {
53
-        // Test the new route is callable before adopting it.
54
-        if (!$skipCallableTest && !is_callable(array($this, $routeName))) {
55
-            throw new Exception("Proposed route '$routeName' is not callable.");
56
-        }
57
-
58
-        // Adopt the new route
59
-        $this->routeName = $routeName;
60
-    }
61
-
62
-    /**
63
-     * Gets the name of the route that has been passed from the request router.
64
-     * @return string
65
-     */
66
-    final public function getRouteName()
67
-    {
68
-        return $this->routeName;
69
-    }
70
-
71
-    /**
72
-     * Performs generic page setup actions
73
-     */
74
-    final protected function setupPage()
75
-    {
76
-        $this->setUpSmarty();
77
-
78
-        $siteNoticeText = SiteNotice::get($this->getDatabase());
79
-
80
-        $this->assign('siteNoticeText', $siteNoticeText);
81
-
82
-        $currentUser = User::getCurrent($this->getDatabase());
83
-        $this->assign('currentUser', $currentUser);
84
-        $this->assign('loggedIn', (!$currentUser->isCommunityUser()));
85
-    }
86
-
87
-    /**
88
-     * Runs the page logic as routed by the RequestRouter
89
-     *
90
-     * Only should be called after a security barrier! That means only from execute().
91
-     */
92
-    final protected function runPage()
93
-    {
94
-        $database = $this->getDatabase();
95
-
96
-        // initialise a database transaction
97
-        if (!$database->beginTransaction()) {
98
-            throw new Exception('Failed to start transaction on primary database.');
99
-        }
100
-
101
-        try {
102
-            // run the page code
103
-            $this->{$this->getRouteName()}();
104
-
105
-            $database->commit();
106
-        }
107
-        catch (ApplicationLogicException $ex) {
108
-            // it's an application logic exception, so nothing went seriously wrong with the site. We can use the
109
-            // standard templating system for this.
110
-
111
-            // Firstly, let's undo anything that happened to the database.
112
-            $database->rollBack();
113
-
114
-            // Reset smarty
115
-            $this->setUpSmarty();
116
-
117
-            // Set the template
118
-            $this->setTemplate('exception/application-logic.tpl');
119
-            $this->assign('message', $ex->getMessage());
120
-
121
-            // Force this back to false
122
-            $this->isRedirecting = false;
123
-            $this->headerQueue = array();
124
-        }
125
-        catch (OptimisticLockFailedException $ex) {
126
-            // it's an optimistic lock failure exception, so nothing went seriously wrong with the site. We can use the
127
-            // standard templating system for this.
128
-
129
-            // Firstly, let's undo anything that happened to the database.
130
-            $database->rollBack();
131
-
132
-            // Reset smarty
133
-            $this->setUpSmarty();
134
-
135
-            // Set the template
136
-            $this->setTemplate('exception/optimistic-lock-failure.tpl');
137
-            $this->assign('message', $ex->getMessage());
138
-
139
-            $this->assign('debugTrace', false);
140
-
141
-            if ($this->getSiteConfiguration()->getDebuggingTraceEnabled()) {
142
-                ob_start();
143
-                var_dump(ExceptionHandler::getExceptionData($ex));
144
-                $textErrorData = ob_get_contents();
145
-                ob_end_clean();
146
-
147
-                $this->assign('exceptionData', $textErrorData);
148
-                $this->assign('debugTrace', true);
149
-            }
150
-
151
-            // Force this back to false
152
-            $this->isRedirecting = false;
153
-            $this->headerQueue = array();
154
-        }
155
-        finally {
156
-            // Catch any hanging on transactions
157
-            if ($database->hasActiveTransaction()) {
158
-                $database->rollBack();
159
-            }
160
-        }
161
-
162
-        // run any finalisation code needed before we send the output to the browser.
163
-        $this->finalisePage();
164
-
165
-        // Send the headers
166
-        $this->sendResponseHeaders();
167
-
168
-        // Check we have a template to use!
169
-        if ($this->template !== null) {
170
-            $content = $this->fetchTemplate($this->template);
171
-            ob_clean();
172
-            print($content);
173
-            ob_flush();
174
-
175
-            return;
176
-        }
177
-    }
178
-
179
-    /**
180
-     * Performs final tasks needed before rendering the page.
181
-     */
182
-    protected function finalisePage()
183
-    {
184
-        if ($this->isRedirecting) {
185
-            $this->template = null;
186
-
187
-            return;
188
-        }
189
-
190
-        $this->assign('extraCss', $this->extraCss);
191
-        $this->assign('extraJs', $this->extraJs);
192
-
193
-        // If we're actually displaying content, we want to add the session alerts here!
194
-        $this->assign('alerts', SessionAlert::getAlerts());
195
-        SessionAlert::clearAlerts();
196
-
197
-        $this->assign('htmlTitle', $this->htmlTitle);
198
-    }
199
-
200
-    /**
201
-     * @return TokenManager
202
-     */
203
-    public function getTokenManager()
204
-    {
205
-        return $this->tokenManager;
206
-    }
207
-
208
-    /**
209
-     * @param TokenManager $tokenManager
210
-     */
211
-    public function setTokenManager($tokenManager)
212
-    {
213
-        $this->tokenManager = $tokenManager;
214
-    }
215
-
216
-    /**
217
-     * Sends the redirect headers to perform a GET at the destination page.
218
-     *
219
-     * Also nullifies the set template so Smarty does not render it.
220
-     *
221
-     * @param string      $page   The page to redirect requests to (as used in the UR)
222
-     * @param null|string $action The action to use on the page.
223
-     * @param null|array  $parameters
224
-     * @param null|string $script The script (relative to index.php) to redirect to
225
-     */
226
-    final protected function redirect($page = '', $action = null, $parameters = null, $script = null)
227
-    {
228
-        $currentScriptName = WebRequest::scriptName();
229
-
230
-        // Are we changing script?
231
-        if ($script === null || substr($currentScriptName, -1 * count($script)) === $script) {
232
-            $targetScriptName = $currentScriptName;
233
-        }
234
-        else {
235
-            $targetScriptName = $this->getSiteConfiguration()->getBaseUrl() . '/' . $script;
236
-        }
237
-
238
-        $pathInfo = array($targetScriptName);
239
-
240
-        $pathInfo[1] = $page;
241
-
242
-        if ($action !== null) {
243
-            $pathInfo[2] = $action;
244
-        }
245
-
246
-        $url = implode('/', $pathInfo);
247
-
248
-        if (is_array($parameters) && count($parameters) > 0) {
249
-            $url .= '?' . http_build_query($parameters);
250
-        }
251
-
252
-        $this->redirectUrl($url);
253
-    }
254
-
255
-    /**
256
-     * Sends the redirect headers to perform a GET at the new address.
257
-     *
258
-     * Also nullifies the set template so Smarty does not render it.
259
-     *
260
-     * @param string $path URL to redirect to
261
-     */
262
-    final protected function redirectUrl($path)
263
-    {
264
-        // 303 See Other = re-request at new address with a GET.
265
-        $this->headerQueue[] = 'HTTP/1.1 303 See Other';
266
-        $this->headerQueue[] = "Location: $path";
267
-
268
-        $this->setTemplate(null);
269
-        $this->isRedirecting = true;
270
-    }
271
-
272
-    /**
273
-     * Sets the name of the template this page should display.
274
-     *
275
-     * @param string $name
276
-     *
277
-     * @throws Exception
278
-     */
279
-    final protected function setTemplate($name)
280
-    {
281
-        if ($this->isRedirecting) {
282
-            throw new Exception('This page has been set as a redirect, no template can be displayed!');
283
-        }
284
-
285
-        $this->template = $name;
286
-    }
287
-
288
-    /**
289
-     * Adds an extra CSS file to to the page
290
-     *
291
-     * @param string $path The path (relative to the application root) of the file
292
-     */
293
-    final protected function addCss($path) {
294
-        if(in_array($path, $this->extraCss)){
295
-            // nothing to do
296
-            return;
297
-        }
298
-
299
-        $this->extraCss[] = $path;
300
-    }
301
-
302
-    /**
303
-     * Adds an extra JS file to to the page
304
-     *
305
-     * @param string $path The path (relative to the application root) of the file
306
-     */
307
-    final protected function addJs($path){
308
-        if(in_array($path, $this->extraJs)){
309
-            // nothing to do
310
-            return;
311
-        }
312
-
313
-        $this->extraJs[] = $path;
314
-    }
315
-
316
-    /**
317
-     * Main function for this page, when no specific actions are called.
318
-     * @return void
319
-     */
320
-    abstract protected function main();
321
-
322
-    /**
323
-     * @param string $title
324
-     */
325
-    final protected function setHtmlTitle($title)
326
-    {
327
-        $this->htmlTitle = $title;
328
-    }
329
-
330
-    public function execute()
331
-    {
332
-        if ($this->getRouteName() === null) {
333
-            throw new Exception('Request is unrouted.');
334
-        }
335
-
336
-        if ($this->getSiteConfiguration() === null) {
337
-            throw new Exception('Page has no configuration!');
338
-        }
339
-
340
-        $this->setupPage();
341
-
342
-        $this->runPage();
343
-    }
344
-
345
-    public function assignCSRFToken()
346
-    {
347
-        $token = $this->tokenManager->getNewToken();
348
-        $this->assign('csrfTokenData', $token->getTokenData());
349
-    }
350
-
351
-    public function validateCSRFToken()
352
-    {
353
-        if (!$this->tokenManager->validateToken(WebRequest::postString('csrfTokenData'))) {
354
-            throw new ApplicationLogicException('Form token is not valid, please reload and try again');
355
-        }
356
-    }
357
-
358
-    protected function sendResponseHeaders()
359
-    {
360
-        if (headers_sent()) {
361
-            throw new ApplicationLogicException          ('Headers have already been sent! This is likely a bug in the application.');
362
-        }
363
-
364
-        foreach ($this->headerQueue as $item) {
365
-            if (mb_strpos($item, "\r") !== false || mb_strpos($item, "\n") !== false) {
366
-                // Oops. We're not allowed to do this.
367
-                throw new Exception('Unable to split header');
368
-            }
369
-
370
-            header($item);
371
-        }
372
-    }
24
+	use TemplateOutput;
25
+	/** @var string Smarty template to display */
26
+	protected $template = "base.tpl";
27
+	/** @var string HTML title. Currently unused. */
28
+	protected $htmlTitle;
29
+	/** @var bool Determines if the page is a redirect or not */
30
+	protected $isRedirecting = false;
31
+	/** @var array Queue of headers to be sent on successful completion */
32
+	protected $headerQueue = array();
33
+	/** @var string The name of the route to use, as determined by the request router. */
34
+	private $routeName = null;
35
+	/** @var TokenManager */
36
+	protected $tokenManager;
37
+	/** @var string[] Extra CSS files to include */
38
+	private $extraCss = array();
39
+	/** @var string[] Extra JS files to include */
40
+	private $extraJs = array();
41
+
42
+	/**
43
+	 * Sets the route the request will take. Only should be called from the request router or barrier test.
44
+	 *
45
+	 * @param string $routeName        The name of the route
46
+	 * @param bool   $skipCallableTest Don't use this unless you know what you're doing, and what the implications are.
47
+	 *
48
+	 * @throws Exception
49
+	 * @category Security-Critical
50
+	 */
51
+	final public function setRoute($routeName, $skipCallableTest = false)
52
+	{
53
+		// Test the new route is callable before adopting it.
54
+		if (!$skipCallableTest && !is_callable(array($this, $routeName))) {
55
+			throw new Exception("Proposed route '$routeName' is not callable.");
56
+		}
57
+
58
+		// Adopt the new route
59
+		$this->routeName = $routeName;
60
+	}
61
+
62
+	/**
63
+	 * Gets the name of the route that has been passed from the request router.
64
+	 * @return string
65
+	 */
66
+	final public function getRouteName()
67
+	{
68
+		return $this->routeName;
69
+	}
70
+
71
+	/**
72
+	 * Performs generic page setup actions
73
+	 */
74
+	final protected function setupPage()
75
+	{
76
+		$this->setUpSmarty();
77
+
78
+		$siteNoticeText = SiteNotice::get($this->getDatabase());
79
+
80
+		$this->assign('siteNoticeText', $siteNoticeText);
81
+
82
+		$currentUser = User::getCurrent($this->getDatabase());
83
+		$this->assign('currentUser', $currentUser);
84
+		$this->assign('loggedIn', (!$currentUser->isCommunityUser()));
85
+	}
86
+
87
+	/**
88
+	 * Runs the page logic as routed by the RequestRouter
89
+	 *
90
+	 * Only should be called after a security barrier! That means only from execute().
91
+	 */
92
+	final protected function runPage()
93
+	{
94
+		$database = $this->getDatabase();
95
+
96
+		// initialise a database transaction
97
+		if (!$database->beginTransaction()) {
98
+			throw new Exception('Failed to start transaction on primary database.');
99
+		}
100
+
101
+		try {
102
+			// run the page code
103
+			$this->{$this->getRouteName()}();
104
+
105
+			$database->commit();
106
+		}
107
+		catch (ApplicationLogicException $ex) {
108
+			// it's an application logic exception, so nothing went seriously wrong with the site. We can use the
109
+			// standard templating system for this.
110
+
111
+			// Firstly, let's undo anything that happened to the database.
112
+			$database->rollBack();
113
+
114
+			// Reset smarty
115
+			$this->setUpSmarty();
116
+
117
+			// Set the template
118
+			$this->setTemplate('exception/application-logic.tpl');
119
+			$this->assign('message', $ex->getMessage());
120
+
121
+			// Force this back to false
122
+			$this->isRedirecting = false;
123
+			$this->headerQueue = array();
124
+		}
125
+		catch (OptimisticLockFailedException $ex) {
126
+			// it's an optimistic lock failure exception, so nothing went seriously wrong with the site. We can use the
127
+			// standard templating system for this.
128
+
129
+			// Firstly, let's undo anything that happened to the database.
130
+			$database->rollBack();
131
+
132
+			// Reset smarty
133
+			$this->setUpSmarty();
134
+
135
+			// Set the template
136
+			$this->setTemplate('exception/optimistic-lock-failure.tpl');
137
+			$this->assign('message', $ex->getMessage());
138
+
139
+			$this->assign('debugTrace', false);
140
+
141
+			if ($this->getSiteConfiguration()->getDebuggingTraceEnabled()) {
142
+				ob_start();
143
+				var_dump(ExceptionHandler::getExceptionData($ex));
144
+				$textErrorData = ob_get_contents();
145
+				ob_end_clean();
146
+
147
+				$this->assign('exceptionData', $textErrorData);
148
+				$this->assign('debugTrace', true);
149
+			}
150
+
151
+			// Force this back to false
152
+			$this->isRedirecting = false;
153
+			$this->headerQueue = array();
154
+		}
155
+		finally {
156
+			// Catch any hanging on transactions
157
+			if ($database->hasActiveTransaction()) {
158
+				$database->rollBack();
159
+			}
160
+		}
161
+
162
+		// run any finalisation code needed before we send the output to the browser.
163
+		$this->finalisePage();
164
+
165
+		// Send the headers
166
+		$this->sendResponseHeaders();
167
+
168
+		// Check we have a template to use!
169
+		if ($this->template !== null) {
170
+			$content = $this->fetchTemplate($this->template);
171
+			ob_clean();
172
+			print($content);
173
+			ob_flush();
174
+
175
+			return;
176
+		}
177
+	}
178
+
179
+	/**
180
+	 * Performs final tasks needed before rendering the page.
181
+	 */
182
+	protected function finalisePage()
183
+	{
184
+		if ($this->isRedirecting) {
185
+			$this->template = null;
186
+
187
+			return;
188
+		}
189
+
190
+		$this->assign('extraCss', $this->extraCss);
191
+		$this->assign('extraJs', $this->extraJs);
192
+
193
+		// If we're actually displaying content, we want to add the session alerts here!
194
+		$this->assign('alerts', SessionAlert::getAlerts());
195
+		SessionAlert::clearAlerts();
196
+
197
+		$this->assign('htmlTitle', $this->htmlTitle);
198
+	}
199
+
200
+	/**
201
+	 * @return TokenManager
202
+	 */
203
+	public function getTokenManager()
204
+	{
205
+		return $this->tokenManager;
206
+	}
207
+
208
+	/**
209
+	 * @param TokenManager $tokenManager
210
+	 */
211
+	public function setTokenManager($tokenManager)
212
+	{
213
+		$this->tokenManager = $tokenManager;
214
+	}
215
+
216
+	/**
217
+	 * Sends the redirect headers to perform a GET at the destination page.
218
+	 *
219
+	 * Also nullifies the set template so Smarty does not render it.
220
+	 *
221
+	 * @param string      $page   The page to redirect requests to (as used in the UR)
222
+	 * @param null|string $action The action to use on the page.
223
+	 * @param null|array  $parameters
224
+	 * @param null|string $script The script (relative to index.php) to redirect to
225
+	 */
226
+	final protected function redirect($page = '', $action = null, $parameters = null, $script = null)
227
+	{
228
+		$currentScriptName = WebRequest::scriptName();
229
+
230
+		// Are we changing script?
231
+		if ($script === null || substr($currentScriptName, -1 * count($script)) === $script) {
232
+			$targetScriptName = $currentScriptName;
233
+		}
234
+		else {
235
+			$targetScriptName = $this->getSiteConfiguration()->getBaseUrl() . '/' . $script;
236
+		}
237
+
238
+		$pathInfo = array($targetScriptName);
239
+
240
+		$pathInfo[1] = $page;
241
+
242
+		if ($action !== null) {
243
+			$pathInfo[2] = $action;
244
+		}
245
+
246
+		$url = implode('/', $pathInfo);
247
+
248
+		if (is_array($parameters) && count($parameters) > 0) {
249
+			$url .= '?' . http_build_query($parameters);
250
+		}
251
+
252
+		$this->redirectUrl($url);
253
+	}
254
+
255
+	/**
256
+	 * Sends the redirect headers to perform a GET at the new address.
257
+	 *
258
+	 * Also nullifies the set template so Smarty does not render it.
259
+	 *
260
+	 * @param string $path URL to redirect to
261
+	 */
262
+	final protected function redirectUrl($path)
263
+	{
264
+		// 303 See Other = re-request at new address with a GET.
265
+		$this->headerQueue[] = 'HTTP/1.1 303 See Other';
266
+		$this->headerQueue[] = "Location: $path";
267
+
268
+		$this->setTemplate(null);
269
+		$this->isRedirecting = true;
270
+	}
271
+
272
+	/**
273
+	 * Sets the name of the template this page should display.
274
+	 *
275
+	 * @param string $name
276
+	 *
277
+	 * @throws Exception
278
+	 */
279
+	final protected function setTemplate($name)
280
+	{
281
+		if ($this->isRedirecting) {
282
+			throw new Exception('This page has been set as a redirect, no template can be displayed!');
283
+		}
284
+
285
+		$this->template = $name;
286
+	}
287
+
288
+	/**
289
+	 * Adds an extra CSS file to to the page
290
+	 *
291
+	 * @param string $path The path (relative to the application root) of the file
292
+	 */
293
+	final protected function addCss($path) {
294
+		if(in_array($path, $this->extraCss)){
295
+			// nothing to do
296
+			return;
297
+		}
298
+
299
+		$this->extraCss[] = $path;
300
+	}
301
+
302
+	/**
303
+	 * Adds an extra JS file to to the page
304
+	 *
305
+	 * @param string $path The path (relative to the application root) of the file
306
+	 */
307
+	final protected function addJs($path){
308
+		if(in_array($path, $this->extraJs)){
309
+			// nothing to do
310
+			return;
311
+		}
312
+
313
+		$this->extraJs[] = $path;
314
+	}
315
+
316
+	/**
317
+	 * Main function for this page, when no specific actions are called.
318
+	 * @return void
319
+	 */
320
+	abstract protected function main();
321
+
322
+	/**
323
+	 * @param string $title
324
+	 */
325
+	final protected function setHtmlTitle($title)
326
+	{
327
+		$this->htmlTitle = $title;
328
+	}
329
+
330
+	public function execute()
331
+	{
332
+		if ($this->getRouteName() === null) {
333
+			throw new Exception('Request is unrouted.');
334
+		}
335
+
336
+		if ($this->getSiteConfiguration() === null) {
337
+			throw new Exception('Page has no configuration!');
338
+		}
339
+
340
+		$this->setupPage();
341
+
342
+		$this->runPage();
343
+	}
344
+
345
+	public function assignCSRFToken()
346
+	{
347
+		$token = $this->tokenManager->getNewToken();
348
+		$this->assign('csrfTokenData', $token->getTokenData());
349
+	}
350
+
351
+	public function validateCSRFToken()
352
+	{
353
+		if (!$this->tokenManager->validateToken(WebRequest::postString('csrfTokenData'))) {
354
+			throw new ApplicationLogicException('Form token is not valid, please reload and try again');
355
+		}
356
+	}
357
+
358
+	protected function sendResponseHeaders()
359
+	{
360
+		if (headers_sent()) {
361
+			throw new ApplicationLogicException          ('Headers have already been sent! This is likely a bug in the application.');
362
+		}
363
+
364
+		foreach ($this->headerQueue as $item) {
365
+			if (mb_strpos($item, "\r") !== false || mb_strpos($item, "\n") !== false) {
366
+				// Oops. We're not allowed to do this.
367
+				throw new Exception('Unable to split header');
368
+			}
369
+
370
+			header($item);
371
+		}
372
+	}
373 373
 }
Please login to merge, or discard this patch.
includes/Tasks/TaskBase.php 1 patch
Indentation   +225 added lines, -225 removed lines patch added patch discarded remove patch
@@ -23,229 +23,229 @@
 block discarded – undo
23 23
 
24 24
 abstract class TaskBase implements ITask
25 25
 {
26
-    /** @var SiteConfiguration */
27
-    private $siteConfiguration;
28
-    /** @var IEmailHelper */
29
-    private $emailHelper;
30
-    /** @var HttpHelper */
31
-    private $httpHelper;
32
-    /** @var WikiTextHelper */
33
-    private $wikiTextHelper;
34
-    /** @var ILocationProvider */
35
-    private $locationProvider;
36
-    /** @var IXffTrustProvider */
37
-    private $xffTrustProvider;
38
-    /** @var IRDnsProvider */
39
-    private $rdnsProvider;
40
-    /** @var IAntiSpoofProvider */
41
-    private $antiSpoofProvider;
42
-    /** @var IOAuthProtocolHelper */
43
-    private $oauthHelper;
44
-    /** @var PdoDatabase */
45
-    private $database;
46
-    /** @var IrcNotificationHelper */
47
-    private $notificationHelper;
48
-    /** @var TorExitProvider */
49
-    private $torExitProvider;
50
-
51
-    /**
52
-     * @return IEmailHelper
53
-     */
54
-    final public function getEmailHelper()
55
-    {
56
-        return $this->emailHelper;
57
-    }
58
-
59
-    /**
60
-     * @param IEmailHelper $emailHelper
61
-     */
62
-    final public function setEmailHelper($emailHelper)
63
-    {
64
-        $this->emailHelper = $emailHelper;
65
-    }
66
-
67
-    /**
68
-     * @return HttpHelper
69
-     */
70
-    final public function getHttpHelper()
71
-    {
72
-        return $this->httpHelper;
73
-    }
74
-
75
-    /**
76
-     * @param HttpHelper $httpHelper
77
-     */
78
-    final public function setHttpHelper($httpHelper)
79
-    {
80
-        $this->httpHelper = $httpHelper;
81
-    }
82
-
83
-    /**
84
-     * @return WikiTextHelper
85
-     */
86
-    final public function getWikiTextHelper()
87
-    {
88
-        return $this->wikiTextHelper;
89
-    }
90
-
91
-    /**
92
-     * @param WikiTextHelper $wikiTextHelper
93
-     */
94
-    final public function setWikiTextHelper($wikiTextHelper)
95
-    {
96
-        $this->wikiTextHelper = $wikiTextHelper;
97
-    }
98
-
99
-    /**
100
-     * @return ILocationProvider
101
-     */
102
-    final public function getLocationProvider()
103
-    {
104
-        return $this->locationProvider;
105
-    }
106
-
107
-    /**
108
-     * @param ILocationProvider $locationProvider
109
-     */
110
-    final public function setLocationProvider(ILocationProvider $locationProvider)
111
-    {
112
-        $this->locationProvider = $locationProvider;
113
-    }
114
-
115
-    /**
116
-     * @return IXffTrustProvider
117
-     */
118
-    final public function getXffTrustProvider()
119
-    {
120
-        return $this->xffTrustProvider;
121
-    }
122
-
123
-    /**
124
-     * @param IXffTrustProvider $xffTrustProvider
125
-     */
126
-    final public function setXffTrustProvider(IXffTrustProvider $xffTrustProvider)
127
-    {
128
-        $this->xffTrustProvider = $xffTrustProvider;
129
-    }
130
-
131
-    /**
132
-     * @return IRDnsProvider
133
-     */
134
-    final public function getRdnsProvider()
135
-    {
136
-        return $this->rdnsProvider;
137
-    }
138
-
139
-    /**
140
-     * @param IRDnsProvider $rdnsProvider
141
-     */
142
-    public function setRdnsProvider($rdnsProvider)
143
-    {
144
-        $this->rdnsProvider = $rdnsProvider;
145
-    }
146
-
147
-    /**
148
-     * @return IAntiSpoofProvider
149
-     */
150
-    public function getAntiSpoofProvider()
151
-    {
152
-        return $this->antiSpoofProvider;
153
-    }
154
-
155
-    /**
156
-     * @param IAntiSpoofProvider $antiSpoofProvider
157
-     */
158
-    public function setAntiSpoofProvider($antiSpoofProvider)
159
-    {
160
-        $this->antiSpoofProvider = $antiSpoofProvider;
161
-    }
162
-
163
-    /**
164
-     * @return PdoDatabase
165
-     */
166
-    final public function getDatabase()
167
-    {
168
-        return $this->database;
169
-    }
170
-
171
-    /**
172
-     * @param PdoDatabase $database
173
-     */
174
-    final public function setDatabase($database)
175
-    {
176
-        $this->database = $database;
177
-    }
178
-
179
-    /**
180
-     * @return IOAuthProtocolHelper
181
-     */
182
-    public function getOAuthProtocolHelper()
183
-    {
184
-        return $this->oauthHelper;
185
-    }
186
-
187
-    /**
188
-     * @param IOAuthProtocolHelper $oauthProtocolHelper
189
-     */
190
-    public function setOAuthProtocolHelper($oauthProtocolHelper)
191
-    {
192
-        $this->oauthHelper = $oauthProtocolHelper;
193
-    }
194
-
195
-    /**
196
-     * @return void
197
-     */
198
-    abstract public function execute();
199
-
200
-    /**
201
-     * @return IrcNotificationHelper
202
-     */
203
-    public function getNotificationHelper()
204
-    {
205
-        return $this->notificationHelper;
206
-    }
207
-
208
-    /**
209
-     * @param IrcNotificationHelper $notificationHelper
210
-     */
211
-    public function setNotificationHelper($notificationHelper)
212
-    {
213
-        $this->notificationHelper = $notificationHelper;
214
-    }
215
-
216
-    /**
217
-     * @return TorExitProvider
218
-     */
219
-    public function getTorExitProvider()
220
-    {
221
-        return $this->torExitProvider;
222
-    }
223
-
224
-    /**
225
-     * @param TorExitProvider $torExitProvider
226
-     */
227
-    public function setTorExitProvider($torExitProvider)
228
-    {
229
-        $this->torExitProvider = $torExitProvider;
230
-    }
231
-
232
-    /**
233
-     * Gets the site configuration object
234
-     *
235
-     * @return SiteConfiguration
236
-     */
237
-    final protected function getSiteConfiguration()
238
-    {
239
-        return $this->siteConfiguration;
240
-    }
241
-
242
-    /**
243
-     * Sets the site configuration object for this page
244
-     *
245
-     * @param SiteConfiguration $configuration
246
-     */
247
-    final public function setSiteConfiguration($configuration)
248
-    {
249
-        $this->siteConfiguration = $configuration;
250
-    }
26
+	/** @var SiteConfiguration */
27
+	private $siteConfiguration;
28
+	/** @var IEmailHelper */
29
+	private $emailHelper;
30
+	/** @var HttpHelper */
31
+	private $httpHelper;
32
+	/** @var WikiTextHelper */
33
+	private $wikiTextHelper;
34
+	/** @var ILocationProvider */
35
+	private $locationProvider;
36
+	/** @var IXffTrustProvider */
37
+	private $xffTrustProvider;
38
+	/** @var IRDnsProvider */
39
+	private $rdnsProvider;
40
+	/** @var IAntiSpoofProvider */
41
+	private $antiSpoofProvider;
42
+	/** @var IOAuthProtocolHelper */
43
+	private $oauthHelper;
44
+	/** @var PdoDatabase */
45
+	private $database;
46
+	/** @var IrcNotificationHelper */
47
+	private $notificationHelper;
48
+	/** @var TorExitProvider */
49
+	private $torExitProvider;
50
+
51
+	/**
52
+	 * @return IEmailHelper
53
+	 */
54
+	final public function getEmailHelper()
55
+	{
56
+		return $this->emailHelper;
57
+	}
58
+
59
+	/**
60
+	 * @param IEmailHelper $emailHelper
61
+	 */
62
+	final public function setEmailHelper($emailHelper)
63
+	{
64
+		$this->emailHelper = $emailHelper;
65
+	}
66
+
67
+	/**
68
+	 * @return HttpHelper
69
+	 */
70
+	final public function getHttpHelper()
71
+	{
72
+		return $this->httpHelper;
73
+	}
74
+
75
+	/**
76
+	 * @param HttpHelper $httpHelper
77
+	 */
78
+	final public function setHttpHelper($httpHelper)
79
+	{
80
+		$this->httpHelper = $httpHelper;
81
+	}
82
+
83
+	/**
84
+	 * @return WikiTextHelper
85
+	 */
86
+	final public function getWikiTextHelper()
87
+	{
88
+		return $this->wikiTextHelper;
89
+	}
90
+
91
+	/**
92
+	 * @param WikiTextHelper $wikiTextHelper
93
+	 */
94
+	final public function setWikiTextHelper($wikiTextHelper)
95
+	{
96
+		$this->wikiTextHelper = $wikiTextHelper;
97
+	}
98
+
99
+	/**
100
+	 * @return ILocationProvider
101
+	 */
102
+	final public function getLocationProvider()
103
+	{
104
+		return $this->locationProvider;
105
+	}
106
+
107
+	/**
108
+	 * @param ILocationProvider $locationProvider
109
+	 */
110
+	final public function setLocationProvider(ILocationProvider $locationProvider)
111
+	{
112
+		$this->locationProvider = $locationProvider;
113
+	}
114
+
115
+	/**
116
+	 * @return IXffTrustProvider
117
+	 */
118
+	final public function getXffTrustProvider()
119
+	{
120
+		return $this->xffTrustProvider;
121
+	}
122
+
123
+	/**
124
+	 * @param IXffTrustProvider $xffTrustProvider
125
+	 */
126
+	final public function setXffTrustProvider(IXffTrustProvider $xffTrustProvider)
127
+	{
128
+		$this->xffTrustProvider = $xffTrustProvider;
129
+	}
130
+
131
+	/**
132
+	 * @return IRDnsProvider
133
+	 */
134
+	final public function getRdnsProvider()
135
+	{
136
+		return $this->rdnsProvider;
137
+	}
138
+
139
+	/**
140
+	 * @param IRDnsProvider $rdnsProvider
141
+	 */
142
+	public function setRdnsProvider($rdnsProvider)
143
+	{
144
+		$this->rdnsProvider = $rdnsProvider;
145
+	}
146
+
147
+	/**
148
+	 * @return IAntiSpoofProvider
149
+	 */
150
+	public function getAntiSpoofProvider()
151
+	{
152
+		return $this->antiSpoofProvider;
153
+	}
154
+
155
+	/**
156
+	 * @param IAntiSpoofProvider $antiSpoofProvider
157
+	 */
158
+	public function setAntiSpoofProvider($antiSpoofProvider)
159
+	{
160
+		$this->antiSpoofProvider = $antiSpoofProvider;
161
+	}
162
+
163
+	/**
164
+	 * @return PdoDatabase
165
+	 */
166
+	final public function getDatabase()
167
+	{
168
+		return $this->database;
169
+	}
170
+
171
+	/**
172
+	 * @param PdoDatabase $database
173
+	 */
174
+	final public function setDatabase($database)
175
+	{
176
+		$this->database = $database;
177
+	}
178
+
179
+	/**
180
+	 * @return IOAuthProtocolHelper
181
+	 */
182
+	public function getOAuthProtocolHelper()
183
+	{
184
+		return $this->oauthHelper;
185
+	}
186
+
187
+	/**
188
+	 * @param IOAuthProtocolHelper $oauthProtocolHelper
189
+	 */
190
+	public function setOAuthProtocolHelper($oauthProtocolHelper)
191
+	{
192
+		$this->oauthHelper = $oauthProtocolHelper;
193
+	}
194
+
195
+	/**
196
+	 * @return void
197
+	 */
198
+	abstract public function execute();
199
+
200
+	/**
201
+	 * @return IrcNotificationHelper
202
+	 */
203
+	public function getNotificationHelper()
204
+	{
205
+		return $this->notificationHelper;
206
+	}
207
+
208
+	/**
209
+	 * @param IrcNotificationHelper $notificationHelper
210
+	 */
211
+	public function setNotificationHelper($notificationHelper)
212
+	{
213
+		$this->notificationHelper = $notificationHelper;
214
+	}
215
+
216
+	/**
217
+	 * @return TorExitProvider
218
+	 */
219
+	public function getTorExitProvider()
220
+	{
221
+		return $this->torExitProvider;
222
+	}
223
+
224
+	/**
225
+	 * @param TorExitProvider $torExitProvider
226
+	 */
227
+	public function setTorExitProvider($torExitProvider)
228
+	{
229
+		$this->torExitProvider = $torExitProvider;
230
+	}
231
+
232
+	/**
233
+	 * Gets the site configuration object
234
+	 *
235
+	 * @return SiteConfiguration
236
+	 */
237
+	final protected function getSiteConfiguration()
238
+	{
239
+		return $this->siteConfiguration;
240
+	}
241
+
242
+	/**
243
+	 * Sets the site configuration object for this page
244
+	 *
245
+	 * @param SiteConfiguration $configuration
246
+	 */
247
+	final public function setSiteConfiguration($configuration)
248
+	{
249
+		$this->siteConfiguration = $configuration;
250
+	}
251 251
 }
252 252
\ No newline at end of file
Please login to merge, or discard this patch.
includes/DataObjects/User.php 2 patches
Indentation   +542 added lines, -542 removed lines patch added patch discarded remove patch
@@ -21,159 +21,159 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class User extends DataObject
23 23
 {
24
-    const STATUS_ACTIVE = 'Active';
25
-    const STATUS_SUSPENDED = 'Suspended';
26
-    const STATUS_DECLINED = 'Declined';
27
-    const STATUS_NEW = 'New';
28
-    const CREATION_MANUAL = 0;
29
-    const CREATION_OAUTH = 1;
30
-    const CREATION_BOT = 2;
31
-    private $username;
32
-    private $email;
33
-    private $status = self::STATUS_NEW;
34
-    private $onwikiname;
35
-    private $welcome_sig = "";
36
-    private $lastactive = "0000-00-00 00:00:00";
37
-    private $forcelogout = 0;
38
-    private $forceidentified = null;
39
-    private $welcome_template = 0;
40
-    private $abortpref = 0;
41
-    private $confirmationdiff = 0;
42
-    private $emailsig = "";
43
-    private $creationmode = 0;
44
-    /** @var User Cache variable of the current user - it's never going to change in the middle of a request. */
45
-    private static $currentUser;
46
-    #region Object load methods
47
-
48
-    /**
49
-     * Gets the currently logged in user
50
-     *
51
-     * @param PdoDatabase $database
52
-     *
53
-     * @return User|CommunityUser
54
-     */
55
-    public static function getCurrent(PdoDatabase $database)
56
-    {
57
-        if (self::$currentUser === null) {
58
-            $sessionId = WebRequest::getSessionUserId();
59
-
60
-            if ($sessionId !== null) {
61
-                /** @var User $user */
62
-                $user = self::getById($sessionId, $database);
63
-
64
-                if ($user === false) {
65
-                    self::$currentUser = new CommunityUser();
66
-                }
67
-                else {
68
-                    self::$currentUser = $user;
69
-                }
70
-            }
71
-            else {
72
-                $anonymousCoward = new CommunityUser();
73
-
74
-                self::$currentUser = $anonymousCoward;
75
-            }
76
-        }
77
-
78
-        return self::$currentUser;
79
-    }
80
-
81
-    /**
82
-     * Gets a user by their user ID
83
-     *
84
-     * Pass -1 to get the community user.
85
-     *
86
-     * @param int|null    $id
87
-     * @param PdoDatabase $database
88
-     *
89
-     * @return User|false
90
-     */
91
-    public static function getById($id, PdoDatabase $database)
92
-    {
93
-        if ($id === null || $id == -1) {
94
-            return new CommunityUser();
95
-        }
96
-
97
-        /** @var User|false $user */
98
-        $user = parent::getById($id, $database);
99
-
100
-        return $user;
101
-    }
102
-
103
-    /**
104
-     * @return CommunityUser
105
-     */
106
-    public static function getCommunity()
107
-    {
108
-        return new CommunityUser();
109
-    }
110
-
111
-    /**
112
-     * Gets a user by their username
113
-     *
114
-     * @param  string      $username
115
-     * @param  PdoDatabase $database
116
-     *
117
-     * @return CommunityUser|User|false
118
-     */
119
-    public static function getByUsername($username, PdoDatabase $database)
120
-    {
121
-        global $communityUsername;
122
-        if ($username == $communityUsername) {
123
-            return new CommunityUser();
124
-        }
125
-
126
-        $statement = $database->prepare("SELECT * FROM user WHERE username = :id LIMIT 1;");
127
-        $statement->bindValue(":id", $username);
128
-
129
-        $statement->execute();
130
-
131
-        $resultObject = $statement->fetchObject(get_called_class());
132
-
133
-        if ($resultObject != false) {
134
-            $resultObject->setDatabase($database);
135
-        }
136
-
137
-        return $resultObject;
138
-    }
139
-
140
-    /**
141
-     * Gets a user by their on-wiki username.
142
-     *
143
-     * @param string      $username
144
-     * @param PdoDatabase $database
145
-     *
146
-     * @return User|false
147
-     */
148
-    public static function getByOnWikiUsername($username, PdoDatabase $database)
149
-    {
150
-        $statement = $database->prepare("SELECT * FROM user WHERE onwikiname = :id LIMIT 1;");
151
-        $statement->bindValue(":id", $username);
152
-        $statement->execute();
153
-
154
-        $resultObject = $statement->fetchObject(get_called_class());
155
-
156
-        if ($resultObject != false) {
157
-            $resultObject->setDatabase($database);
158
-
159
-            return $resultObject;
160
-        }
161
-
162
-        return false;
163
-    }
164
-
165
-    #endregion
166
-
167
-    /**
168
-     * Saves the current object
169
-     *
170
-     * @throws Exception
171
-     */
172
-    public function save()
173
-    {
174
-        if ($this->isNew()) {
175
-            // insert
176
-            $statement = $this->dbObject->prepare(<<<SQL
24
+	const STATUS_ACTIVE = 'Active';
25
+	const STATUS_SUSPENDED = 'Suspended';
26
+	const STATUS_DECLINED = 'Declined';
27
+	const STATUS_NEW = 'New';
28
+	const CREATION_MANUAL = 0;
29
+	const CREATION_OAUTH = 1;
30
+	const CREATION_BOT = 2;
31
+	private $username;
32
+	private $email;
33
+	private $status = self::STATUS_NEW;
34
+	private $onwikiname;
35
+	private $welcome_sig = "";
36
+	private $lastactive = "0000-00-00 00:00:00";
37
+	private $forcelogout = 0;
38
+	private $forceidentified = null;
39
+	private $welcome_template = 0;
40
+	private $abortpref = 0;
41
+	private $confirmationdiff = 0;
42
+	private $emailsig = "";
43
+	private $creationmode = 0;
44
+	/** @var User Cache variable of the current user - it's never going to change in the middle of a request. */
45
+	private static $currentUser;
46
+	#region Object load methods
47
+
48
+	/**
49
+	 * Gets the currently logged in user
50
+	 *
51
+	 * @param PdoDatabase $database
52
+	 *
53
+	 * @return User|CommunityUser
54
+	 */
55
+	public static function getCurrent(PdoDatabase $database)
56
+	{
57
+		if (self::$currentUser === null) {
58
+			$sessionId = WebRequest::getSessionUserId();
59
+
60
+			if ($sessionId !== null) {
61
+				/** @var User $user */
62
+				$user = self::getById($sessionId, $database);
63
+
64
+				if ($user === false) {
65
+					self::$currentUser = new CommunityUser();
66
+				}
67
+				else {
68
+					self::$currentUser = $user;
69
+				}
70
+			}
71
+			else {
72
+				$anonymousCoward = new CommunityUser();
73
+
74
+				self::$currentUser = $anonymousCoward;
75
+			}
76
+		}
77
+
78
+		return self::$currentUser;
79
+	}
80
+
81
+	/**
82
+	 * Gets a user by their user ID
83
+	 *
84
+	 * Pass -1 to get the community user.
85
+	 *
86
+	 * @param int|null    $id
87
+	 * @param PdoDatabase $database
88
+	 *
89
+	 * @return User|false
90
+	 */
91
+	public static function getById($id, PdoDatabase $database)
92
+	{
93
+		if ($id === null || $id == -1) {
94
+			return new CommunityUser();
95
+		}
96
+
97
+		/** @var User|false $user */
98
+		$user = parent::getById($id, $database);
99
+
100
+		return $user;
101
+	}
102
+
103
+	/**
104
+	 * @return CommunityUser
105
+	 */
106
+	public static function getCommunity()
107
+	{
108
+		return new CommunityUser();
109
+	}
110
+
111
+	/**
112
+	 * Gets a user by their username
113
+	 *
114
+	 * @param  string      $username
115
+	 * @param  PdoDatabase $database
116
+	 *
117
+	 * @return CommunityUser|User|false
118
+	 */
119
+	public static function getByUsername($username, PdoDatabase $database)
120
+	{
121
+		global $communityUsername;
122
+		if ($username == $communityUsername) {
123
+			return new CommunityUser();
124
+		}
125
+
126
+		$statement = $database->prepare("SELECT * FROM user WHERE username = :id LIMIT 1;");
127
+		$statement->bindValue(":id", $username);
128
+
129
+		$statement->execute();
130
+
131
+		$resultObject = $statement->fetchObject(get_called_class());
132
+
133
+		if ($resultObject != false) {
134
+			$resultObject->setDatabase($database);
135
+		}
136
+
137
+		return $resultObject;
138
+	}
139
+
140
+	/**
141
+	 * Gets a user by their on-wiki username.
142
+	 *
143
+	 * @param string      $username
144
+	 * @param PdoDatabase $database
145
+	 *
146
+	 * @return User|false
147
+	 */
148
+	public static function getByOnWikiUsername($username, PdoDatabase $database)
149
+	{
150
+		$statement = $database->prepare("SELECT * FROM user WHERE onwikiname = :id LIMIT 1;");
151
+		$statement->bindValue(":id", $username);
152
+		$statement->execute();
153
+
154
+		$resultObject = $statement->fetchObject(get_called_class());
155
+
156
+		if ($resultObject != false) {
157
+			$resultObject->setDatabase($database);
158
+
159
+			return $resultObject;
160
+		}
161
+
162
+		return false;
163
+	}
164
+
165
+	#endregion
166
+
167
+	/**
168
+	 * Saves the current object
169
+	 *
170
+	 * @throws Exception
171
+	 */
172
+	public function save()
173
+	{
174
+		if ($this->isNew()) {
175
+			// insert
176
+			$statement = $this->dbObject->prepare(<<<SQL
177 177
 				INSERT INTO `user` ( 
178 178
 					username, email, status, onwikiname, welcome_sig, 
179 179
 					lastactive, forcelogout, forceidentified,
@@ -184,31 +184,31 @@  discard block
 block discarded – undo
184 184
 					:welcome_template, :abortpref, :confirmationdiff, :emailsig, :creationmode
185 185
 				);
186 186
 SQL
187
-            );
188
-            $statement->bindValue(":username", $this->username);
189
-            $statement->bindValue(":email", $this->email);
190
-            $statement->bindValue(":status", $this->status);
191
-            $statement->bindValue(":onwikiname", $this->onwikiname);
192
-            $statement->bindValue(":welcome_sig", $this->welcome_sig);
193
-            $statement->bindValue(":lastactive", $this->lastactive);
194
-            $statement->bindValue(":forcelogout", $this->forcelogout);
195
-            $statement->bindValue(":forceidentified", $this->forceidentified);
196
-            $statement->bindValue(":welcome_template", $this->welcome_template);
197
-            $statement->bindValue(":abortpref", $this->abortpref);
198
-            $statement->bindValue(":confirmationdiff", $this->confirmationdiff);
199
-            $statement->bindValue(":emailsig", $this->emailsig);
200
-            $statement->bindValue(":creationmode", $this->creationmode);
201
-
202
-            if ($statement->execute()) {
203
-                $this->id = (int)$this->dbObject->lastInsertId();
204
-            }
205
-            else {
206
-                throw new Exception($statement->errorInfo());
207
-            }
208
-        }
209
-        else {
210
-            // update
211
-            $statement = $this->dbObject->prepare(<<<SQL
187
+			);
188
+			$statement->bindValue(":username", $this->username);
189
+			$statement->bindValue(":email", $this->email);
190
+			$statement->bindValue(":status", $this->status);
191
+			$statement->bindValue(":onwikiname", $this->onwikiname);
192
+			$statement->bindValue(":welcome_sig", $this->welcome_sig);
193
+			$statement->bindValue(":lastactive", $this->lastactive);
194
+			$statement->bindValue(":forcelogout", $this->forcelogout);
195
+			$statement->bindValue(":forceidentified", $this->forceidentified);
196
+			$statement->bindValue(":welcome_template", $this->welcome_template);
197
+			$statement->bindValue(":abortpref", $this->abortpref);
198
+			$statement->bindValue(":confirmationdiff", $this->confirmationdiff);
199
+			$statement->bindValue(":emailsig", $this->emailsig);
200
+			$statement->bindValue(":creationmode", $this->creationmode);
201
+
202
+			if ($statement->execute()) {
203
+				$this->id = (int)$this->dbObject->lastInsertId();
204
+			}
205
+			else {
206
+				throw new Exception($statement->errorInfo());
207
+			}
208
+		}
209
+		else {
210
+			// update
211
+			$statement = $this->dbObject->prepare(<<<SQL
212 212
 				UPDATE `user` SET 
213 213
 					username = :username, email = :email, 
214 214
 					status = :status,
@@ -221,364 +221,364 @@  discard block
 block discarded – undo
221 221
 				WHERE id = :id AND updateversion = :updateversion
222 222
 				LIMIT 1;
223 223
 SQL
224
-            );
225
-            $statement->bindValue(":forceidentified", $this->forceidentified);
226
-
227
-            $statement->bindValue(':id', $this->id);
228
-            $statement->bindValue(':updateversion', $this->updateversion);
229
-
230
-            $statement->bindValue(':username', $this->username);
231
-            $statement->bindValue(':email', $this->email);
232
-            $statement->bindValue(':status', $this->status);
233
-            $statement->bindValue(':onwikiname', $this->onwikiname);
234
-            $statement->bindValue(':welcome_sig', $this->welcome_sig);
235
-            $statement->bindValue(':lastactive', $this->lastactive);
236
-            $statement->bindValue(':forcelogout', $this->forcelogout);
237
-            $statement->bindValue(':forceidentified', $this->forceidentified);
238
-            $statement->bindValue(':welcome_template', $this->welcome_template);
239
-            $statement->bindValue(':abortpref', $this->abortpref);
240
-            $statement->bindValue(':confirmationdiff', $this->confirmationdiff);
241
-            $statement->bindValue(':emailsig', $this->emailsig);
242
-            $statement->bindValue(':creationmode', $this->creationmode);
243
-
244
-            if (!$statement->execute()) {
245
-                throw new Exception($statement->errorInfo());
246
-            }
247
-
248
-            if ($statement->rowCount() !== 1) {
249
-                throw new OptimisticLockFailedException();
250
-            }
251
-
252
-            $this->updateversion++;
253
-        }
254
-    }
255
-
256
-    #region properties
257
-
258
-    /**
259
-     * Gets the tool username
260
-     * @return string
261
-     */
262
-    public function getUsername()
263
-    {
264
-        return $this->username;
265
-    }
266
-
267
-    /**
268
-     * Sets the tool username
269
-     *
270
-     * @param string $username
271
-     */
272
-    public function setUsername($username)
273
-    {
274
-        $this->username = $username;
275
-
276
-        // If this isn't a brand new user, then it's a rename, force the logout
277
-        if (!$this->isNew()) {
278
-            $this->forcelogout = 1;
279
-        }
280
-    }
281
-
282
-    /**
283
-     * Gets the user's email address
284
-     * @return string
285
-     */
286
-    public function getEmail()
287
-    {
288
-        return $this->email;
289
-    }
290
-
291
-    /**
292
-     * Sets the user's email address
293
-     *
294
-     * @param string $email
295
-     */
296
-    public function setEmail($email)
297
-    {
298
-        $this->email = $email;
299
-    }
300
-
301
-    /**
302
-     * Gets the status (User, Admin, Suspended, etc - excludes checkuser) of the user.
303
-     * @return string
304
-     */
305
-    public function getStatus()
306
-    {
307
-        return $this->status;
308
-    }
309
-
310
-    /**
311
-     * @param string $status
312
-     */
313
-    public function setStatus($status)
314
-    {
315
-        $this->status = $status;
316
-    }
317
-
318
-    /**
319
-     * Gets the user's on-wiki name
320
-     * @return string
321
-     */
322
-    public function getOnWikiName()
323
-    {
324
-        return $this->onwikiname;
325
-    }
326
-
327
-    /**
328
-     * Sets the user's on-wiki name
329
-     *
330
-     * This can have interesting side-effects with OAuth.
331
-     *
332
-     * @param string $onWikiName
333
-     */
334
-    public function setOnWikiName($onWikiName)
335
-    {
336
-        $this->onwikiname = $onWikiName;
337
-    }
338
-
339
-    /**
340
-     * Gets the welcome signature
341
-     * @return string
342
-     */
343
-    public function getWelcomeSig()
344
-    {
345
-        return $this->welcome_sig;
346
-    }
347
-
348
-    /**
349
-     * Sets the welcome signature
350
-     *
351
-     * @param string $welcomeSig
352
-     */
353
-    public function setWelcomeSig($welcomeSig)
354
-    {
355
-        $this->welcome_sig = $welcomeSig;
356
-    }
357
-
358
-    /**
359
-     * Gets the last activity date for the user
360
-     *
361
-     * @return string
362
-     * @todo This should probably return an instance of DateTime
363
-     */
364
-    public function getLastActive()
365
-    {
366
-        return $this->lastactive;
367
-    }
368
-
369
-    /**
370
-     * Gets the user's forced logout status
371
-     *
372
-     * @return bool
373
-     */
374
-    public function getForceLogout()
375
-    {
376
-        return $this->forcelogout == 1;
377
-    }
378
-
379
-    /**
380
-     * Sets the user's forced logout status
381
-     *
382
-     * @param bool $forceLogout
383
-     */
384
-    public function setForceLogout($forceLogout)
385
-    {
386
-        $this->forcelogout = $forceLogout ? 1 : 0;
387
-    }
388
-
389
-    /**
390
-     * Returns the ID of the welcome template used.
391
-     * @return int
392
-     */
393
-    public function getWelcomeTemplate()
394
-    {
395
-        return $this->welcome_template;
396
-    }
397
-
398
-    /**
399
-     * Sets the ID of the welcome template used.
400
-     *
401
-     * @param int $welcomeTemplate
402
-     */
403
-    public function setWelcomeTemplate($welcomeTemplate)
404
-    {
405
-        $this->welcome_template = $welcomeTemplate;
406
-    }
407
-
408
-    /**
409
-     * Gets the user's abort preference
410
-     * @todo this is badly named too! Also a bool that's actually an int.
411
-     * @return int
412
-     */
413
-    public function getAbortPref()
414
-    {
415
-        return $this->abortpref;
416
-    }
417
-
418
-    /**
419
-     * Sets the user's abort preference
420
-     * @todo rename, retype, and re-comment.
421
-     *
422
-     * @param int $abortPreference
423
-     */
424
-    public function setAbortPref($abortPreference)
425
-    {
426
-        $this->abortpref = $abortPreference;
427
-    }
428
-
429
-    /**
430
-     * Gets the user's confirmation diff. Unused if OAuth is in use.
431
-     * @return int the diff ID
432
-     */
433
-    public function getConfirmationDiff()
434
-    {
435
-        return $this->confirmationdiff;
436
-    }
437
-
438
-    /**
439
-     * Sets the user's confirmation diff.
440
-     *
441
-     * @param int $confirmationDiff
442
-     */
443
-    public function setConfirmationDiff($confirmationDiff)
444
-    {
445
-        $this->confirmationdiff = $confirmationDiff;
446
-    }
447
-
448
-    /**
449
-     * Gets the users' email signature used on outbound mail.
450
-     * @todo rename me!
451
-     * @return string
452
-     */
453
-    public function getEmailSig()
454
-    {
455
-        return $this->emailsig;
456
-    }
457
-
458
-    /**
459
-     * Sets the user's email signature for outbound mail.
460
-     *
461
-     * @param string $emailSignature
462
-     */
463
-    public function setEmailSig($emailSignature)
464
-    {
465
-        $this->emailsig = $emailSignature;
466
-    }
467
-
468
-    /**
469
-     * @return int
470
-     */
471
-    public function getCreationMode()
472
-    {
473
-        return $this->creationmode;
474
-    }
475
-
476
-    /**
477
-     * @param $creationMode int
478
-     */
479
-    public function setCreationMode($creationMode)
480
-    {
481
-        $this->creationmode = $creationMode;
482
-    }
483
-
484
-    #endregion
485
-
486
-    #region user access checks
487
-
488
-    public function isActive()
489
-    {
490
-        return $this->status == self::STATUS_ACTIVE;
491
-    }
492
-
493
-    /**
494
-     * Tests if the user is identified
495
-     *
496
-     * @param IdentificationVerifier $iv
497
-     *
498
-     * @return bool
499
-     * @todo     Figure out what on earth is going on with PDO's typecasting here.  Apparently, it returns string("0") for
500
-     *       the force-unidentified case, and int(1) for the identified case?!  This is quite ugly, but probably needed
501
-     *       to play it safe for now.
502
-     * @category Security-Critical
503
-     */
504
-    public function isIdentified(IdentificationVerifier $iv)
505
-    {
506
-        if ($this->forceidentified === 0 || $this->forceidentified === "0") {
507
-            // User forced to unidentified in the database.
508
-            return false;
509
-        }
510
-        elseif ($this->forceidentified === 1 || $this->forceidentified === "1") {
511
-            // User forced to identified in the database.
512
-            return true;
513
-        }
514
-        else {
515
-            // User not forced to any particular identified status; consult IdentificationVerifier
516
-            return $iv->isUserIdentified($this->getOnWikiName());
517
-        }
518
-    }
519
-
520
-    /**
521
-     * Tests if the user is suspended
522
-     * @return bool
523
-     * @category Security-Critical
524
-     */
525
-    public function isSuspended()
526
-    {
527
-        return $this->status == self::STATUS_SUSPENDED;
528
-    }
529
-
530
-    /**
531
-     * Tests if the user is new
532
-     * @return bool
533
-     * @category Security-Critical
534
-     */
535
-    public function isNewUser()
536
-    {
537
-        return $this->status == self::STATUS_NEW;
538
-    }
539
-
540
-    /**
541
-     * Tests if the user has been declined access to the tool
542
-     * @return bool
543
-     * @category Security-Critical
544
-     */
545
-    public function isDeclined()
546
-    {
547
-        return $this->status == self::STATUS_DECLINED;
548
-    }
549
-
550
-    /**
551
-     * Tests if the user is the community user
552
-     *
553
-     * @todo     decide if this means logged out. I think it usually does.
554
-     * @return bool
555
-     * @category Security-Critical
556
-     */
557
-    public function isCommunityUser()
558
-    {
559
-        return false;
560
-    }
561
-
562
-    #endregion 
563
-
564
-    /**
565
-     * Gets a hash of data for the user to reset their password with.
566
-     * @category Security-Critical
567
-     * @return string
568
-     */
569
-    public function getForgottenPasswordHash()
570
-    {
571
-        // FIXME
572
-        return md5($this->username . $this->email . $this->welcome_template . $this->id);
573
-    }
574
-
575
-    /**
576
-     * Gets the approval date of the user
577
-     * @return DateTime|false
578
-     */
579
-    public function getApprovalDate()
580
-    {
581
-        $query = $this->dbObject->prepare(<<<SQL
224
+			);
225
+			$statement->bindValue(":forceidentified", $this->forceidentified);
226
+
227
+			$statement->bindValue(':id', $this->id);
228
+			$statement->bindValue(':updateversion', $this->updateversion);
229
+
230
+			$statement->bindValue(':username', $this->username);
231
+			$statement->bindValue(':email', $this->email);
232
+			$statement->bindValue(':status', $this->status);
233
+			$statement->bindValue(':onwikiname', $this->onwikiname);
234
+			$statement->bindValue(':welcome_sig', $this->welcome_sig);
235
+			$statement->bindValue(':lastactive', $this->lastactive);
236
+			$statement->bindValue(':forcelogout', $this->forcelogout);
237
+			$statement->bindValue(':forceidentified', $this->forceidentified);
238
+			$statement->bindValue(':welcome_template', $this->welcome_template);
239
+			$statement->bindValue(':abortpref', $this->abortpref);
240
+			$statement->bindValue(':confirmationdiff', $this->confirmationdiff);
241
+			$statement->bindValue(':emailsig', $this->emailsig);
242
+			$statement->bindValue(':creationmode', $this->creationmode);
243
+
244
+			if (!$statement->execute()) {
245
+				throw new Exception($statement->errorInfo());
246
+			}
247
+
248
+			if ($statement->rowCount() !== 1) {
249
+				throw new OptimisticLockFailedException();
250
+			}
251
+
252
+			$this->updateversion++;
253
+		}
254
+	}
255
+
256
+	#region properties
257
+
258
+	/**
259
+	 * Gets the tool username
260
+	 * @return string
261
+	 */
262
+	public function getUsername()
263
+	{
264
+		return $this->username;
265
+	}
266
+
267
+	/**
268
+	 * Sets the tool username
269
+	 *
270
+	 * @param string $username
271
+	 */
272
+	public function setUsername($username)
273
+	{
274
+		$this->username = $username;
275
+
276
+		// If this isn't a brand new user, then it's a rename, force the logout
277
+		if (!$this->isNew()) {
278
+			$this->forcelogout = 1;
279
+		}
280
+	}
281
+
282
+	/**
283
+	 * Gets the user's email address
284
+	 * @return string
285
+	 */
286
+	public function getEmail()
287
+	{
288
+		return $this->email;
289
+	}
290
+
291
+	/**
292
+	 * Sets the user's email address
293
+	 *
294
+	 * @param string $email
295
+	 */
296
+	public function setEmail($email)
297
+	{
298
+		$this->email = $email;
299
+	}
300
+
301
+	/**
302
+	 * Gets the status (User, Admin, Suspended, etc - excludes checkuser) of the user.
303
+	 * @return string
304
+	 */
305
+	public function getStatus()
306
+	{
307
+		return $this->status;
308
+	}
309
+
310
+	/**
311
+	 * @param string $status
312
+	 */
313
+	public function setStatus($status)
314
+	{
315
+		$this->status = $status;
316
+	}
317
+
318
+	/**
319
+	 * Gets the user's on-wiki name
320
+	 * @return string
321
+	 */
322
+	public function getOnWikiName()
323
+	{
324
+		return $this->onwikiname;
325
+	}
326
+
327
+	/**
328
+	 * Sets the user's on-wiki name
329
+	 *
330
+	 * This can have interesting side-effects with OAuth.
331
+	 *
332
+	 * @param string $onWikiName
333
+	 */
334
+	public function setOnWikiName($onWikiName)
335
+	{
336
+		$this->onwikiname = $onWikiName;
337
+	}
338
+
339
+	/**
340
+	 * Gets the welcome signature
341
+	 * @return string
342
+	 */
343
+	public function getWelcomeSig()
344
+	{
345
+		return $this->welcome_sig;
346
+	}
347
+
348
+	/**
349
+	 * Sets the welcome signature
350
+	 *
351
+	 * @param string $welcomeSig
352
+	 */
353
+	public function setWelcomeSig($welcomeSig)
354
+	{
355
+		$this->welcome_sig = $welcomeSig;
356
+	}
357
+
358
+	/**
359
+	 * Gets the last activity date for the user
360
+	 *
361
+	 * @return string
362
+	 * @todo This should probably return an instance of DateTime
363
+	 */
364
+	public function getLastActive()
365
+	{
366
+		return $this->lastactive;
367
+	}
368
+
369
+	/**
370
+	 * Gets the user's forced logout status
371
+	 *
372
+	 * @return bool
373
+	 */
374
+	public function getForceLogout()
375
+	{
376
+		return $this->forcelogout == 1;
377
+	}
378
+
379
+	/**
380
+	 * Sets the user's forced logout status
381
+	 *
382
+	 * @param bool $forceLogout
383
+	 */
384
+	public function setForceLogout($forceLogout)
385
+	{
386
+		$this->forcelogout = $forceLogout ? 1 : 0;
387
+	}
388
+
389
+	/**
390
+	 * Returns the ID of the welcome template used.
391
+	 * @return int
392
+	 */
393
+	public function getWelcomeTemplate()
394
+	{
395
+		return $this->welcome_template;
396
+	}
397
+
398
+	/**
399
+	 * Sets the ID of the welcome template used.
400
+	 *
401
+	 * @param int $welcomeTemplate
402
+	 */
403
+	public function setWelcomeTemplate($welcomeTemplate)
404
+	{
405
+		$this->welcome_template = $welcomeTemplate;
406
+	}
407
+
408
+	/**
409
+	 * Gets the user's abort preference
410
+	 * @todo this is badly named too! Also a bool that's actually an int.
411
+	 * @return int
412
+	 */
413
+	public function getAbortPref()
414
+	{
415
+		return $this->abortpref;
416
+	}
417
+
418
+	/**
419
+	 * Sets the user's abort preference
420
+	 * @todo rename, retype, and re-comment.
421
+	 *
422
+	 * @param int $abortPreference
423
+	 */
424
+	public function setAbortPref($abortPreference)
425
+	{
426
+		$this->abortpref = $abortPreference;
427
+	}
428
+
429
+	/**
430
+	 * Gets the user's confirmation diff. Unused if OAuth is in use.
431
+	 * @return int the diff ID
432
+	 */
433
+	public function getConfirmationDiff()
434
+	{
435
+		return $this->confirmationdiff;
436
+	}
437
+
438
+	/**
439
+	 * Sets the user's confirmation diff.
440
+	 *
441
+	 * @param int $confirmationDiff
442
+	 */
443
+	public function setConfirmationDiff($confirmationDiff)
444
+	{
445
+		$this->confirmationdiff = $confirmationDiff;
446
+	}
447
+
448
+	/**
449
+	 * Gets the users' email signature used on outbound mail.
450
+	 * @todo rename me!
451
+	 * @return string
452
+	 */
453
+	public function getEmailSig()
454
+	{
455
+		return $this->emailsig;
456
+	}
457
+
458
+	/**
459
+	 * Sets the user's email signature for outbound mail.
460
+	 *
461
+	 * @param string $emailSignature
462
+	 */
463
+	public function setEmailSig($emailSignature)
464
+	{
465
+		$this->emailsig = $emailSignature;
466
+	}
467
+
468
+	/**
469
+	 * @return int
470
+	 */
471
+	public function getCreationMode()
472
+	{
473
+		return $this->creationmode;
474
+	}
475
+
476
+	/**
477
+	 * @param $creationMode int
478
+	 */
479
+	public function setCreationMode($creationMode)
480
+	{
481
+		$this->creationmode = $creationMode;
482
+	}
483
+
484
+	#endregion
485
+
486
+	#region user access checks
487
+
488
+	public function isActive()
489
+	{
490
+		return $this->status == self::STATUS_ACTIVE;
491
+	}
492
+
493
+	/**
494
+	 * Tests if the user is identified
495
+	 *
496
+	 * @param IdentificationVerifier $iv
497
+	 *
498
+	 * @return bool
499
+	 * @todo     Figure out what on earth is going on with PDO's typecasting here.  Apparently, it returns string("0") for
500
+	 *       the force-unidentified case, and int(1) for the identified case?!  This is quite ugly, but probably needed
501
+	 *       to play it safe for now.
502
+	 * @category Security-Critical
503
+	 */
504
+	public function isIdentified(IdentificationVerifier $iv)
505
+	{
506
+		if ($this->forceidentified === 0 || $this->forceidentified === "0") {
507
+			// User forced to unidentified in the database.
508
+			return false;
509
+		}
510
+		elseif ($this->forceidentified === 1 || $this->forceidentified === "1") {
511
+			// User forced to identified in the database.
512
+			return true;
513
+		}
514
+		else {
515
+			// User not forced to any particular identified status; consult IdentificationVerifier
516
+			return $iv->isUserIdentified($this->getOnWikiName());
517
+		}
518
+	}
519
+
520
+	/**
521
+	 * Tests if the user is suspended
522
+	 * @return bool
523
+	 * @category Security-Critical
524
+	 */
525
+	public function isSuspended()
526
+	{
527
+		return $this->status == self::STATUS_SUSPENDED;
528
+	}
529
+
530
+	/**
531
+	 * Tests if the user is new
532
+	 * @return bool
533
+	 * @category Security-Critical
534
+	 */
535
+	public function isNewUser()
536
+	{
537
+		return $this->status == self::STATUS_NEW;
538
+	}
539
+
540
+	/**
541
+	 * Tests if the user has been declined access to the tool
542
+	 * @return bool
543
+	 * @category Security-Critical
544
+	 */
545
+	public function isDeclined()
546
+	{
547
+		return $this->status == self::STATUS_DECLINED;
548
+	}
549
+
550
+	/**
551
+	 * Tests if the user is the community user
552
+	 *
553
+	 * @todo     decide if this means logged out. I think it usually does.
554
+	 * @return bool
555
+	 * @category Security-Critical
556
+	 */
557
+	public function isCommunityUser()
558
+	{
559
+		return false;
560
+	}
561
+
562
+	#endregion 
563
+
564
+	/**
565
+	 * Gets a hash of data for the user to reset their password with.
566
+	 * @category Security-Critical
567
+	 * @return string
568
+	 */
569
+	public function getForgottenPasswordHash()
570
+	{
571
+		// FIXME
572
+		return md5($this->username . $this->email . $this->welcome_template . $this->id);
573
+	}
574
+
575
+	/**
576
+	 * Gets the approval date of the user
577
+	 * @return DateTime|false
578
+	 */
579
+	public function getApprovalDate()
580
+	{
581
+		$query = $this->dbObject->prepare(<<<SQL
582 582
 			SELECT timestamp 
583 583
 			FROM log 
584 584
 			WHERE objectid = :userid
@@ -587,12 +587,12 @@  discard block
 block discarded – undo
587 587
 			ORDER BY id DESC 
588 588
 			LIMIT 1;
589 589
 SQL
590
-        );
591
-        $query->execute(array(":userid" => $this->id));
590
+		);
591
+		$query->execute(array(":userid" => $this->id));
592 592
 
593
-        $data = DateTime::createFromFormat("Y-m-d H:i:s", $query->fetchColumn());
594
-        $query->closeCursor();
593
+		$data = DateTime::createFromFormat("Y-m-d H:i:s", $query->fetchColumn());
594
+		$query->closeCursor();
595 595
 
596
-        return $data;
597
-    }
596
+		return $data;
597
+	}
598 598
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -569,7 +569,7 @@
 block discarded – undo
569 569
     public function getForgottenPasswordHash()
570 570
     {
571 571
         // FIXME
572
-        return md5($this->username . $this->email . $this->welcome_template . $this->id);
572
+        return md5($this->username.$this->email.$this->welcome_template.$this->id);
573 573
     }
574 574
 
575 575
     /**
Please login to merge, or discard this patch.
includes/DataObjects/Credential.php 1 patch
Indentation   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -14,122 +14,122 @@  discard block
 block discarded – undo
14 14
 
15 15
 class Credential extends DataObject
16 16
 {
17
-    /** @var int */
18
-    private $user;
19
-    /** @var int */
20
-    private $factor;
21
-    /** @var string */
22
-    private $type;
23
-    /** @var string */
24
-    private $data;
25
-    /** @var int */
26
-    private $version;
27
-
28
-    /**
29
-     * @return int
30
-     */
31
-    public function getUserId()
32
-    {
33
-        return $this->user;
34
-    }
35
-
36
-    /**
37
-     * @param int $user
38
-     */
39
-    public function setUserId($user)
40
-    {
41
-        $this->user = $user;
42
-    }
43
-
44
-    /**
45
-     * @return int
46
-     */
47
-    public function getFactor()
48
-    {
49
-        return $this->factor;
50
-    }
51
-
52
-    /**
53
-     * @param int $factor
54
-     */
55
-    public function setFactor($factor)
56
-    {
57
-        $this->factor = $factor;
58
-    }
59
-
60
-    /**
61
-     * @return string
62
-     */
63
-    public function getType()
64
-    {
65
-        return $this->type;
66
-    }
67
-
68
-    /**
69
-     * @param string $type
70
-     */
71
-    public function setType($type)
72
-    {
73
-        $this->type = $type;
74
-    }
75
-
76
-    /**
77
-     * @return string
78
-     */
79
-    public function getData()
80
-    {
81
-        return $this->data;
82
-    }
83
-
84
-    /**
85
-     * @param string $data
86
-     */
87
-    public function setData($data)
88
-    {
89
-        $this->data = $data;
90
-    }
91
-
92
-    /**
93
-     * @return int
94
-     */
95
-    public function getVersion()
96
-    {
97
-        return $this->version;
98
-    }
99
-
100
-    /**
101
-     * @param int $version
102
-     */
103
-    public function setVersion($version)
104
-    {
105
-        $this->version = $version;
106
-    }
107
-
108
-    public function save()
109
-    {
110
-        if ($this->isNew()) {
111
-            // insert
112
-            $statement = $this->dbObject->prepare(<<<SQL
17
+	/** @var int */
18
+	private $user;
19
+	/** @var int */
20
+	private $factor;
21
+	/** @var string */
22
+	private $type;
23
+	/** @var string */
24
+	private $data;
25
+	/** @var int */
26
+	private $version;
27
+
28
+	/**
29
+	 * @return int
30
+	 */
31
+	public function getUserId()
32
+	{
33
+		return $this->user;
34
+	}
35
+
36
+	/**
37
+	 * @param int $user
38
+	 */
39
+	public function setUserId($user)
40
+	{
41
+		$this->user = $user;
42
+	}
43
+
44
+	/**
45
+	 * @return int
46
+	 */
47
+	public function getFactor()
48
+	{
49
+		return $this->factor;
50
+	}
51
+
52
+	/**
53
+	 * @param int $factor
54
+	 */
55
+	public function setFactor($factor)
56
+	{
57
+		$this->factor = $factor;
58
+	}
59
+
60
+	/**
61
+	 * @return string
62
+	 */
63
+	public function getType()
64
+	{
65
+		return $this->type;
66
+	}
67
+
68
+	/**
69
+	 * @param string $type
70
+	 */
71
+	public function setType($type)
72
+	{
73
+		$this->type = $type;
74
+	}
75
+
76
+	/**
77
+	 * @return string
78
+	 */
79
+	public function getData()
80
+	{
81
+		return $this->data;
82
+	}
83
+
84
+	/**
85
+	 * @param string $data
86
+	 */
87
+	public function setData($data)
88
+	{
89
+		$this->data = $data;
90
+	}
91
+
92
+	/**
93
+	 * @return int
94
+	 */
95
+	public function getVersion()
96
+	{
97
+		return $this->version;
98
+	}
99
+
100
+	/**
101
+	 * @param int $version
102
+	 */
103
+	public function setVersion($version)
104
+	{
105
+		$this->version = $version;
106
+	}
107
+
108
+	public function save()
109
+	{
110
+		if ($this->isNew()) {
111
+			// insert
112
+			$statement = $this->dbObject->prepare(<<<SQL
113 113
 INSERT INTO credential ( updateversion, user, factor, type, data, version )
114 114
 VALUES ( 0, :user, :factor, :type, :data, :version );
115 115
 SQL
116
-            );
117
-            $statement->bindValue(":user", $this->user);
118
-            $statement->bindValue(":factor", $this->factor);
119
-            $statement->bindValue(":type", $this->type);
120
-            $statement->bindValue(":data", $this->data);
121
-            $statement->bindValue(":version", $this->version);
122
-
123
-            if ($statement->execute()) {
124
-                $this->id = (int)$this->dbObject->lastInsertId();
125
-            }
126
-            else {
127
-                throw new Exception($statement->errorInfo());
128
-            }
129
-        }
130
-        else {
131
-            // update
132
-            $statement = $this->dbObject->prepare(<<<SQL
116
+			);
117
+			$statement->bindValue(":user", $this->user);
118
+			$statement->bindValue(":factor", $this->factor);
119
+			$statement->bindValue(":type", $this->type);
120
+			$statement->bindValue(":data", $this->data);
121
+			$statement->bindValue(":version", $this->version);
122
+
123
+			if ($statement->execute()) {
124
+				$this->id = (int)$this->dbObject->lastInsertId();
125
+			}
126
+			else {
127
+				throw new Exception($statement->errorInfo());
128
+			}
129
+		}
130
+		else {
131
+			// update
132
+			$statement = $this->dbObject->prepare(<<<SQL
133 133
                 UPDATE credential
134 134
                 SET   factor = :factor
135 135
                     , data = :data
@@ -137,24 +137,24 @@  discard block
 block discarded – undo
137 137
                     , updateversion = updateversion + 1
138 138
                 WHERE id = :id AND updateversion = :updateversion;
139 139
 SQL
140
-            );
140
+			);
141 141
 
142
-            $statement->bindValue(':id', $this->id);
143
-            $statement->bindValue(':updateversion', $this->updateversion);
142
+			$statement->bindValue(':id', $this->id);
143
+			$statement->bindValue(':updateversion', $this->updateversion);
144 144
 
145
-            $statement->bindValue(":factor", $this->factor);
146
-            $statement->bindValue(":data", $this->data);
147
-            $statement->bindValue(":version", $this->version);
145
+			$statement->bindValue(":factor", $this->factor);
146
+			$statement->bindValue(":data", $this->data);
147
+			$statement->bindValue(":version", $this->version);
148 148
 
149
-            if (!$statement->execute()) {
150
-                throw new Exception($statement->errorInfo());
151
-            }
149
+			if (!$statement->execute()) {
150
+				throw new Exception($statement->errorInfo());
151
+			}
152 152
 
153
-            if ($statement->rowCount() !== 1) {
154
-                throw new OptimisticLockFailedException();
155
-            }
153
+			if ($statement->rowCount() !== 1) {
154
+				throw new OptimisticLockFailedException();
155
+			}
156 156
 
157
-            $this->updateversion++;
158
-        }
159
-    }
157
+			$this->updateversion++;
158
+		}
159
+	}
160 160
 }
161 161
\ No newline at end of file
Please login to merge, or discard this patch.
includes/DataObjects/CommunityUser.php 1 patch
Indentation   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -16,163 +16,163 @@
 block discarded – undo
16 16
  */
17 17
 class CommunityUser extends User
18 18
 {
19
-    public function getId()
20
-    {
21
-        return -1;
22
-    }
23
-
24
-    public function save()
25
-    {
26
-        // Do nothing
27
-    }
28
-
29
-    #region properties
30
-
31
-    /**
32
-     * @return string
33
-     */
34
-    public function getUsername()
35
-    {
36
-        global $communityUsername;
37
-
38
-        return $communityUsername;
39
-    }
40
-
41
-    public function setUsername($username)
42
-    {
43
-    }
44
-
45
-    /**
46
-     * @return string
47
-     */
48
-    public function getEmail()
49
-    {
50
-        global $cDataClearEmail;
51
-
52
-        return $cDataClearEmail;
53
-    }
54
-
55
-    public function setEmail($email)
56
-    {
57
-    }
58
-
59
-    public function getStatus()
60
-    {
61
-        return "Community";
62
-    }
63
-
64
-    public function getOnWikiName()
65
-    {
66
-        return "127.0.0.1";
67
-    }
68
-
69
-    public function setOnWikiName($onWikiName)
70
-    {
71
-    }
72
-
73
-    public function getWelcomeSig()
74
-    {
75
-        return null;
76
-    }
77
-
78
-    public function setWelcomeSig($welcomeSig)
79
-    {
80
-    }
81
-
82
-    public function getLastActive()
83
-    {
84
-        $now = new DateTime();
85
-
86
-        return $now->format("Y-m-d H:i:s");
87
-    }
88
-
89
-    public function getForceLogout()
90
-    {
91
-        return true;
92
-    }
93
-
94
-    public function setForceLogout($forceLogout)
95
-    {
96
-    }
97
-
98
-    /**
99
-     * @param string $status
100
-     */
101
-    public function setStatus($status)
102
-    {
103
-    }
104
-
105
-    public function getWelcomeTemplate()
106
-    {
107
-        return 0;
108
-    }
109
-
110
-    public function setWelcomeTemplate($welcomeTemplate)
111
-    {
112
-    }
113
-
114
-    public function getAbortPref()
115
-    {
116
-        return 0;
117
-    }
118
-
119
-    public function setAbortPref($abortPreference)
120
-    {
121
-    }
122
-
123
-    public function getConfirmationDiff()
124
-    {
125
-        return null;
126
-    }
127
-
128
-    public function setConfirmationDiff($confirmationDiff)
129
-    {
130
-    }
131
-
132
-    public function getEmailSig()
133
-    {
134
-        return null;
135
-    }
136
-
137
-    public function setEmailSig($emailSignature)
138
-    {
139
-    }
140
-
141
-    #endregion
142
-
143
-    #region user access checks
144
-
145
-    public function isIdentified(IdentificationVerifier $iv)
146
-    {
147
-        return false;
148
-    }
149
-
150
-    public function isSuspended()
151
-    {
152
-        return false;
153
-    }
154
-
155
-    public function isNewUser()
156
-    {
157
-        return false;
158
-    }
159
-
160
-    public function isDeclined()
161
-    {
162
-        return false;
163
-    }
164
-
165
-    public function isCommunityUser()
166
-    {
167
-        return true;
168
-    }
169
-
170
-    #endregion
171
-
172
-    public function getApprovalDate()
173
-    {
174
-        $data = DateTime::createFromFormat("Y-m-d H:i:s", "1970-01-01 00:00:00");
175
-
176
-        return $data;
177
-    }
19
+	public function getId()
20
+	{
21
+		return -1;
22
+	}
23
+
24
+	public function save()
25
+	{
26
+		// Do nothing
27
+	}
28
+
29
+	#region properties
30
+
31
+	/**
32
+	 * @return string
33
+	 */
34
+	public function getUsername()
35
+	{
36
+		global $communityUsername;
37
+
38
+		return $communityUsername;
39
+	}
40
+
41
+	public function setUsername($username)
42
+	{
43
+	}
44
+
45
+	/**
46
+	 * @return string
47
+	 */
48
+	public function getEmail()
49
+	{
50
+		global $cDataClearEmail;
51
+
52
+		return $cDataClearEmail;
53
+	}
54
+
55
+	public function setEmail($email)
56
+	{
57
+	}
58
+
59
+	public function getStatus()
60
+	{
61
+		return "Community";
62
+	}
63
+
64
+	public function getOnWikiName()
65
+	{
66
+		return "127.0.0.1";
67
+	}
68
+
69
+	public function setOnWikiName($onWikiName)
70
+	{
71
+	}
72
+
73
+	public function getWelcomeSig()
74
+	{
75
+		return null;
76
+	}
77
+
78
+	public function setWelcomeSig($welcomeSig)
79
+	{
80
+	}
81
+
82
+	public function getLastActive()
83
+	{
84
+		$now = new DateTime();
85
+
86
+		return $now->format("Y-m-d H:i:s");
87
+	}
88
+
89
+	public function getForceLogout()
90
+	{
91
+		return true;
92
+	}
93
+
94
+	public function setForceLogout($forceLogout)
95
+	{
96
+	}
97
+
98
+	/**
99
+	 * @param string $status
100
+	 */
101
+	public function setStatus($status)
102
+	{
103
+	}
104
+
105
+	public function getWelcomeTemplate()
106
+	{
107
+		return 0;
108
+	}
109
+
110
+	public function setWelcomeTemplate($welcomeTemplate)
111
+	{
112
+	}
113
+
114
+	public function getAbortPref()
115
+	{
116
+		return 0;
117
+	}
118
+
119
+	public function setAbortPref($abortPreference)
120
+	{
121
+	}
122
+
123
+	public function getConfirmationDiff()
124
+	{
125
+		return null;
126
+	}
127
+
128
+	public function setConfirmationDiff($confirmationDiff)
129
+	{
130
+	}
131
+
132
+	public function getEmailSig()
133
+	{
134
+		return null;
135
+	}
136
+
137
+	public function setEmailSig($emailSignature)
138
+	{
139
+	}
140
+
141
+	#endregion
142
+
143
+	#region user access checks
144
+
145
+	public function isIdentified(IdentificationVerifier $iv)
146
+	{
147
+		return false;
148
+	}
149
+
150
+	public function isSuspended()
151
+	{
152
+		return false;
153
+	}
154
+
155
+	public function isNewUser()
156
+	{
157
+		return false;
158
+	}
159
+
160
+	public function isDeclined()
161
+	{
162
+		return false;
163
+	}
164
+
165
+	public function isCommunityUser()
166
+	{
167
+		return true;
168
+	}
169
+
170
+	#endregion
171
+
172
+	public function getApprovalDate()
173
+	{
174
+		$data = DateTime::createFromFormat("Y-m-d H:i:s", "1970-01-01 00:00:00");
175
+
176
+		return $data;
177
+	}
178 178
 }
Please login to merge, or discard this patch.
includes/ApplicationBase.php 1 patch
Indentation   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -25,155 +25,155 @@
 block discarded – undo
25 25
 
26 26
 abstract class ApplicationBase
27 27
 {
28
-    private $configuration;
29
-
30
-    public function __construct(SiteConfiguration $configuration)
31
-    {
32
-        $this->configuration = $configuration;
33
-    }
34
-
35
-    /**
36
-     * Application entry point.
37
-     *
38
-     * Sets up the environment and runs the application, performing any global cleanup operations when done.
39
-     */
40
-    public function run()
41
-    {
42
-        try {
43
-            if ($this->setupEnvironment()) {
44
-                $this->main();
45
-            }
46
-        }
47
-        catch (Exception $ex) {
48
-            print $ex->getMessage();
49
-        }
50
-        finally {
51
-            $this->cleanupEnvironment();
52
-        }
53
-    }
54
-
55
-    /**
56
-     * Environment setup
57
-     *
58
-     * This method initialises the tool environment. If the tool cannot be initialised correctly, it will return false
59
-     * and shut down prematurely.
60
-     *
61
-     * @return bool
62
-     * @throws EnvironmentException
63
-     */
64
-    protected function setupEnvironment()
65
-    {
66
-        $this->setupDatabase();
67
-
68
-        return true;
69
-    }
70
-
71
-    /**
72
-     * @return PdoDatabase
73
-     * @throws EnvironmentException
74
-     * @throws Exception
75
-     */
76
-    protected function setupDatabase()
77
-    {
78
-        // check the schema version
79
-        $database = PdoDatabase::getDatabaseConnection('acc');
80
-
81
-        /** @var int $actualVersion */
82
-        $actualVersion = (int)$database->query('SELECT version FROM schemaversion')->fetchColumn();
83
-        if ($actualVersion !== $this->getConfiguration()->getSchemaVersion()) {
84
-            throw new EnvironmentException('Database schema is wrong version! Please either update configuration or database.');
85
-        }
86
-
87
-        return $database;
88
-    }
89
-
90
-    /**
91
-     * @return SiteConfiguration
92
-     */
93
-    public function getConfiguration()
94
-    {
95
-        return $this->configuration;
96
-    }
97
-
98
-    /**
99
-     * Main application logic
100
-     * @return void
101
-     */
102
-    abstract protected function main();
103
-
104
-    /**
105
-     * Any cleanup tasks should go here
106
-     *
107
-     * Note that we need to be very careful here, as exceptions may have been thrown and handled.
108
-     * This should *only* be for cleaning up, no logic should go here.
109
-     *
110
-     * @return void
111
-     */
112
-    abstract protected function cleanupEnvironment();
113
-
114
-    /**
115
-     * @param ITask             $page
116
-     * @param SiteConfiguration $siteConfiguration
117
-     * @param PdoDatabase       $database
118
-     * @param PdoDatabase       $notificationsDatabase
119
-     *
120
-     * @return void
121
-     */
122
-    protected function setupHelpers(
123
-        ITask $page,
124
-        SiteConfiguration $siteConfiguration,
125
-        PdoDatabase $database,
126
-        PdoDatabase $notificationsDatabase = null
127
-    ) {
128
-        $page->setSiteConfiguration($siteConfiguration);
129
-
130
-        // setup the global database object
131
-        $page->setDatabase($database);
132
-
133
-        // set up helpers and inject them into the page.
134
-        $httpHelper = new HttpHelper(
135
-            $siteConfiguration->getUserAgent(),
136
-            $siteConfiguration->getCurlDisableVerifyPeer()
137
-        );
138
-
139
-        $page->setEmailHelper(new EmailHelper());
140
-        $page->setHttpHelper($httpHelper);
141
-        $page->setWikiTextHelper(new WikiTextHelper($siteConfiguration, $page->getHttpHelper()));
142
-
143
-        if ($siteConfiguration->getLocationProviderApiKey() === null) {
144
-            $page->setLocationProvider(new FakeLocationProvider());
145
-        }
146
-        else {
147
-            $page->setLocationProvider(
148
-                new IpLocationProvider(
149
-                    $database,
150
-                    $siteConfiguration->getLocationProviderApiKey(),
151
-                    $httpHelper
152
-                ));
153
-        }
154
-
155
-        $page->setXffTrustProvider(new XffTrustProvider($siteConfiguration->getSquidList(), $database));
156
-
157
-        $page->setRdnsProvider(new CachedRDnsLookupProvider($database));
158
-
159
-        $page->setAntiSpoofProvider(new CachedApiAntispoofProvider(
160
-            $database,
161
-            $this->getConfiguration()->getMediawikiWebServiceEndpoint(),
162
-            $httpHelper));
163
-
164
-        $page->setOAuthProtocolHelper(new OAuthProtocolHelper(
165
-            $siteConfiguration->getOAuthBaseUrl(),
166
-            $siteConfiguration->getOAuthConsumerToken(),
167
-            $siteConfiguration->getOAuthConsumerSecret(),
168
-            $httpHelper,
169
-            $siteConfiguration->getMediawikiWebServiceEndpoint()
170
-        ));
171
-
172
-        $page->setNotificationHelper(new IrcNotificationHelper(
173
-            $siteConfiguration,
174
-            $database,
175
-            $notificationsDatabase));
176
-
177
-        $page->setTorExitProvider(new TorExitProvider($database));
178
-    }
28
+	private $configuration;
29
+
30
+	public function __construct(SiteConfiguration $configuration)
31
+	{
32
+		$this->configuration = $configuration;
33
+	}
34
+
35
+	/**
36
+	 * Application entry point.
37
+	 *
38
+	 * Sets up the environment and runs the application, performing any global cleanup operations when done.
39
+	 */
40
+	public function run()
41
+	{
42
+		try {
43
+			if ($this->setupEnvironment()) {
44
+				$this->main();
45
+			}
46
+		}
47
+		catch (Exception $ex) {
48
+			print $ex->getMessage();
49
+		}
50
+		finally {
51
+			$this->cleanupEnvironment();
52
+		}
53
+	}
54
+
55
+	/**
56
+	 * Environment setup
57
+	 *
58
+	 * This method initialises the tool environment. If the tool cannot be initialised correctly, it will return false
59
+	 * and shut down prematurely.
60
+	 *
61
+	 * @return bool
62
+	 * @throws EnvironmentException
63
+	 */
64
+	protected function setupEnvironment()
65
+	{
66
+		$this->setupDatabase();
67
+
68
+		return true;
69
+	}
70
+
71
+	/**
72
+	 * @return PdoDatabase
73
+	 * @throws EnvironmentException
74
+	 * @throws Exception
75
+	 */
76
+	protected function setupDatabase()
77
+	{
78
+		// check the schema version
79
+		$database = PdoDatabase::getDatabaseConnection('acc');
80
+
81
+		/** @var int $actualVersion */
82
+		$actualVersion = (int)$database->query('SELECT version FROM schemaversion')->fetchColumn();
83
+		if ($actualVersion !== $this->getConfiguration()->getSchemaVersion()) {
84
+			throw new EnvironmentException('Database schema is wrong version! Please either update configuration or database.');
85
+		}
86
+
87
+		return $database;
88
+	}
89
+
90
+	/**
91
+	 * @return SiteConfiguration
92
+	 */
93
+	public function getConfiguration()
94
+	{
95
+		return $this->configuration;
96
+	}
97
+
98
+	/**
99
+	 * Main application logic
100
+	 * @return void
101
+	 */
102
+	abstract protected function main();
103
+
104
+	/**
105
+	 * Any cleanup tasks should go here
106
+	 *
107
+	 * Note that we need to be very careful here, as exceptions may have been thrown and handled.
108
+	 * This should *only* be for cleaning up, no logic should go here.
109
+	 *
110
+	 * @return void
111
+	 */
112
+	abstract protected function cleanupEnvironment();
113
+
114
+	/**
115
+	 * @param ITask             $page
116
+	 * @param SiteConfiguration $siteConfiguration
117
+	 * @param PdoDatabase       $database
118
+	 * @param PdoDatabase       $notificationsDatabase
119
+	 *
120
+	 * @return void
121
+	 */
122
+	protected function setupHelpers(
123
+		ITask $page,
124
+		SiteConfiguration $siteConfiguration,
125
+		PdoDatabase $database,
126
+		PdoDatabase $notificationsDatabase = null
127
+	) {
128
+		$page->setSiteConfiguration($siteConfiguration);
129
+
130
+		// setup the global database object
131
+		$page->setDatabase($database);
132
+
133
+		// set up helpers and inject them into the page.
134
+		$httpHelper = new HttpHelper(
135
+			$siteConfiguration->getUserAgent(),
136
+			$siteConfiguration->getCurlDisableVerifyPeer()
137
+		);
138
+
139
+		$page->setEmailHelper(new EmailHelper());
140
+		$page->setHttpHelper($httpHelper);
141
+		$page->setWikiTextHelper(new WikiTextHelper($siteConfiguration, $page->getHttpHelper()));
142
+
143
+		if ($siteConfiguration->getLocationProviderApiKey() === null) {
144
+			$page->setLocationProvider(new FakeLocationProvider());
145
+		}
146
+		else {
147
+			$page->setLocationProvider(
148
+				new IpLocationProvider(
149
+					$database,
150
+					$siteConfiguration->getLocationProviderApiKey(),
151
+					$httpHelper
152
+				));
153
+		}
154
+
155
+		$page->setXffTrustProvider(new XffTrustProvider($siteConfiguration->getSquidList(), $database));
156
+
157
+		$page->setRdnsProvider(new CachedRDnsLookupProvider($database));
158
+
159
+		$page->setAntiSpoofProvider(new CachedApiAntispoofProvider(
160
+			$database,
161
+			$this->getConfiguration()->getMediawikiWebServiceEndpoint(),
162
+			$httpHelper));
163
+
164
+		$page->setOAuthProtocolHelper(new OAuthProtocolHelper(
165
+			$siteConfiguration->getOAuthBaseUrl(),
166
+			$siteConfiguration->getOAuthConsumerToken(),
167
+			$siteConfiguration->getOAuthConsumerSecret(),
168
+			$httpHelper,
169
+			$siteConfiguration->getMediawikiWebServiceEndpoint()
170
+		));
171
+
172
+		$page->setNotificationHelper(new IrcNotificationHelper(
173
+			$siteConfiguration,
174
+			$database,
175
+			$notificationsDatabase));
176
+
177
+		$page->setTorExitProvider(new TorExitProvider($database));
178
+	}
179 179
 }
180 180
\ No newline at end of file
Please login to merge, or discard this patch.
includes/ConsoleStart.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -15,74 +15,74 @@
 block discarded – undo
15 15
 
16 16
 class ConsoleStart extends ApplicationBase
17 17
 {
18
-    /**
19
-     * @var ConsoleTaskBase
20
-     */
21
-    private $consoleTask;
18
+	/**
19
+	 * @var ConsoleTaskBase
20
+	 */
21
+	private $consoleTask;
22 22
 
23
-    /**
24
-     * ConsoleStart constructor.
25
-     *
26
-     * @param SiteConfiguration $configuration
27
-     * @param ConsoleTaskBase   $consoleTask
28
-     */
29
-    public function __construct(SiteConfiguration $configuration, ConsoleTaskBase $consoleTask)
30
-    {
31
-        parent::__construct($configuration);
32
-        $this->consoleTask = $consoleTask;
33
-    }
23
+	/**
24
+	 * ConsoleStart constructor.
25
+	 *
26
+	 * @param SiteConfiguration $configuration
27
+	 * @param ConsoleTaskBase   $consoleTask
28
+	 */
29
+	public function __construct(SiteConfiguration $configuration, ConsoleTaskBase $consoleTask)
30
+	{
31
+		parent::__construct($configuration);
32
+		$this->consoleTask = $consoleTask;
33
+	}
34 34
 
35
-    protected function setupEnvironment()
36
-    {
37
-        // initialise super-global providers
38
-        WebRequest::setGlobalStateProvider(new FakeGlobalStateProvider());
35
+	protected function setupEnvironment()
36
+	{
37
+		// initialise super-global providers
38
+		WebRequest::setGlobalStateProvider(new FakeGlobalStateProvider());
39 39
 
40
-        if (WebRequest::method() !== null) {
41
-            throw new EnvironmentException('This is a console task, which cannot be executed via the web.');
42
-        }
40
+		if (WebRequest::method() !== null) {
41
+			throw new EnvironmentException('This is a console task, which cannot be executed via the web.');
42
+		}
43 43
 
44
-        return parent::setupEnvironment();
45
-    }
44
+		return parent::setupEnvironment();
45
+	}
46 46
 
47
-    protected function cleanupEnvironment()
48
-    {
49
-    }
47
+	protected function cleanupEnvironment()
48
+	{
49
+	}
50 50
 
51
-    /**
52
-     * Main application logic
53
-     */
54
-    protected function main()
55
-    {
56
-        $database = PdoDatabase::getDatabaseConnection('acc');
51
+	/**
52
+	 * Main application logic
53
+	 */
54
+	protected function main()
55
+	{
56
+		$database = PdoDatabase::getDatabaseConnection('acc');
57 57
 
58
-        if ($this->getConfiguration()->getIrcNotificationsEnabled()) {
59
-            $notificationsDatabase = PdoDatabase::getDatabaseConnection('notifications');
60
-        }
61
-        else {
62
-            // pass through null
63
-            $notificationsDatabase = null;
64
-        }
58
+		if ($this->getConfiguration()->getIrcNotificationsEnabled()) {
59
+			$notificationsDatabase = PdoDatabase::getDatabaseConnection('notifications');
60
+		}
61
+		else {
62
+			// pass through null
63
+			$notificationsDatabase = null;
64
+		}
65 65
 
66
-        $this->setupHelpers($this->consoleTask, $this->getConfiguration(), $database, $notificationsDatabase);
66
+		$this->setupHelpers($this->consoleTask, $this->getConfiguration(), $database, $notificationsDatabase);
67 67
 
68
-        // initialise a database transaction
69
-        if (!$database->beginTransaction()) {
70
-            throw new Exception('Failed to start transaction on primary database.');
71
-        }
68
+		// initialise a database transaction
69
+		if (!$database->beginTransaction()) {
70
+			throw new Exception('Failed to start transaction on primary database.');
71
+		}
72 72
 
73
-        try {
74
-            // run the task
75
-            $this->consoleTask->execute();
73
+		try {
74
+			// run the task
75
+			$this->consoleTask->execute();
76 76
 
77
-            if ($database->hasActiveTransaction()) {
78
-                $database->commit();
79
-            }
80
-        }
81
-        finally {
82
-            // Catch any hanging on transactions
83
-            if ($database->hasActiveTransaction()) {
84
-                $database->rollBack();
85
-            }
86
-        }
87
-    }
77
+			if ($database->hasActiveTransaction()) {
78
+				$database->commit();
79
+			}
80
+		}
81
+		finally {
82
+			// Catch any hanging on transactions
83
+			if ($database->hasActiveTransaction()) {
84
+				$database->rollBack();
85
+			}
86
+		}
87
+	}
88 88
 }
89 89
\ No newline at end of file
Please login to merge, or discard this patch.
includes/ConsoleTasks/RefreshOAuthDataTask.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -17,35 +17,35 @@
 block discarded – undo
17 17
 
18 18
 class RefreshOAuthDataTask extends ConsoleTaskBase
19 19
 {
20
-    public function execute()
21
-    {
22
-        $database = $this->getDatabase();
23
-
24
-        $idList = $database
25
-            ->query('SELECT user FROM oauthtoken WHERE type = \'access\' AND expiry IS NULL')
26
-            ->fetchAll(PDO::FETCH_COLUMN);
27
-
28
-        if (count($idList) > 0) {
29
-            /** @var User[] $users */
30
-            $users = UserSearchHelper::get($database)->inIds($idList)->fetch();
31
-
32
-            $expiredStatement = $database
33
-                ->prepare('UPDATE oauthtoken SET expiry = CURRENT_TIMESTAMP() WHERE user = :u AND type = \'access\'');
34
-
35
-            foreach ($users as $u) {
36
-                $oauth = new OAuthUserHelper($u, $database, $this->getOAuthProtocolHelper(),
37
-                    $this->getSiteConfiguration());
38
-
39
-                try {
40
-                    $oauth->refreshIdentity();
41
-                }
42
-                catch (OAuthException $ex) {
43
-                    $expiredStatement->execute(array(':u' => $u->getId()));
44
-                }
45
-            }
46
-        }
47
-
48
-        $this->getDatabase()
49
-            ->exec('DELETE FROM oauthtoken WHERE expiry IS NOT NULL AND expiry < NOW() AND type = \'request\'');
50
-    }
20
+	public function execute()
21
+	{
22
+		$database = $this->getDatabase();
23
+
24
+		$idList = $database
25
+			->query('SELECT user FROM oauthtoken WHERE type = \'access\' AND expiry IS NULL')
26
+			->fetchAll(PDO::FETCH_COLUMN);
27
+
28
+		if (count($idList) > 0) {
29
+			/** @var User[] $users */
30
+			$users = UserSearchHelper::get($database)->inIds($idList)->fetch();
31
+
32
+			$expiredStatement = $database
33
+				->prepare('UPDATE oauthtoken SET expiry = CURRENT_TIMESTAMP() WHERE user = :u AND type = \'access\'');
34
+
35
+			foreach ($users as $u) {
36
+				$oauth = new OAuthUserHelper($u, $database, $this->getOAuthProtocolHelper(),
37
+					$this->getSiteConfiguration());
38
+
39
+				try {
40
+					$oauth->refreshIdentity();
41
+				}
42
+				catch (OAuthException $ex) {
43
+					$expiredStatement->execute(array(':u' => $u->getId()));
44
+				}
45
+			}
46
+		}
47
+
48
+		$this->getDatabase()
49
+			->exec('DELETE FROM oauthtoken WHERE expiry IS NOT NULL AND expiry < NOW() AND type = \'request\'');
50
+	}
51 51
 }
52 52
\ No newline at end of file
Please login to merge, or discard this patch.
includes/ConsoleTasks/ClearOAuthDataTask.php 3 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -14,19 +14,19 @@
 block discarded – undo
14 14
 
15 15
 class ClearOAuthDataTask extends ConsoleTaskBase
16 16
 {
17
-    public function execute()
18
-    {
19
-        $database = $this->getDatabase();
17
+	public function execute()
18
+	{
19
+		$database = $this->getDatabase();
20 20
 
21
-        $users = UserSearchHelper::get($database)->inIds(
22
-            $database->query('SELECT user FROM oauthtoken WHERE type = \'access\'')->fetchColumn());
21
+		$users = UserSearchHelper::get($database)->inIds(
22
+			$database->query('SELECT user FROM oauthtoken WHERE type = \'access\'')->fetchColumn());
23 23
 
24
-        foreach ($users as $u){
25
-            $oauth = new OAuthUserHelper($u, $database, $this->getOAuthProtocolHelper(), $this->getSiteConfiguration());
26
-            $oauth->detach();
27
-        }
24
+		foreach ($users as $u){
25
+			$oauth = new OAuthUserHelper($u, $database, $this->getOAuthProtocolHelper(), $this->getSiteConfiguration());
26
+			$oauth->detach();
27
+		}
28 28
 
29
-        $database->exec('DELETE FROM oauthtoken');
30
-        $database->exec('DELETE FROM oauthidentity');
31
-    }
29
+		$database->exec('DELETE FROM oauthtoken');
30
+		$database->exec('DELETE FROM oauthidentity');
31
+	}
32 32
 }
33 33
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
         $users = UserSearchHelper::get($database)->inIds(
22 22
             $database->query('SELECT user FROM oauthtoken WHERE type = \'access\'')->fetchColumn());
23 23
 
24
-        foreach ($users as $u){
24
+        foreach ($users as $u) {
25 25
             $oauth = new OAuthUserHelper($u, $database, $this->getOAuthProtocolHelper(), $this->getSiteConfiguration());
26 26
             $oauth->detach();
27 27
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
         $users = UserSearchHelper::get($database)->inIds(
22 22
             $database->query('SELECT user FROM oauthtoken WHERE type = \'access\'')->fetchColumn());
23 23
 
24
-        foreach ($users as $u){
24
+        foreach ($users as $u) {
25 25
             $oauth = new OAuthUserHelper($u, $database, $this->getOAuthProtocolHelper(), $this->getSiteConfiguration());
26 26
             $oauth->detach();
27 27
         }
Please login to merge, or discard this patch.