Completed
Push — newinternal-releasecandidate ( 06bb07...1c5b59 )
by Simon
06:04
created
includes/API/Actions/StatusAction.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -17,67 +17,67 @@
 block discarded – undo
17 17
  */
18 18
 class StatusAction extends XmlApiPageBase implements IXmlApiAction
19 19
 {
20
-    public function executeApiAction(DOMElement $apiDocument)
21
-    {
22
-        $statusElement = $this->document->createElement("status");
23
-        $apiDocument->appendChild($statusElement);
20
+	public function executeApiAction(DOMElement $apiDocument)
21
+	{
22
+		$statusElement = $this->document->createElement("status");
23
+		$apiDocument->appendChild($statusElement);
24 24
 
25
-        $query = $this->getDatabase()->prepare(<<<SQL
25
+		$query = $this->getDatabase()->prepare(<<<SQL
26 26
             SELECT /* Api/StatusAction */ COUNT(*) AS count
27 27
             FROM request
28 28
             WHERE
29 29
                 status = :pstatus
30 30
                 AND emailconfirm = 'Confirmed';
31 31
 SQL
32
-        );
32
+		);
33 33
 
34
-        $availableRequestStates = $this->getSiteConfiguration()->getRequestStates();
34
+		$availableRequestStates = $this->getSiteConfiguration()->getRequestStates();
35 35
 
36
-        foreach ($availableRequestStates as $key => $value) {
37
-            $query->bindValue(":pstatus", $key);
38
-            $query->execute();
39
-            $sus = $query->fetchColumn();
40
-            $statusElement->setAttribute($value['api'], $sus);
41
-            $query->closeCursor();
42
-        }
36
+		foreach ($availableRequestStates as $key => $value) {
37
+			$query->bindValue(":pstatus", $key);
38
+			$query->execute();
39
+			$sus = $query->fetchColumn();
40
+			$statusElement->setAttribute($value['api'], $sus);
41
+			$query->closeCursor();
42
+		}
43 43
 
44
-        $query = $this->getDatabase()->prepare(<<<SQL
44
+		$query = $this->getDatabase()->prepare(<<<SQL
45 45
             SELECT /* Api/StatusAction */ COUNT(*) AS count
46 46
             FROM ban
47 47
             WHERE
48 48
                 (duration > UNIX_TIMESTAMP() OR duration = -1)
49 49
                 AND active = 1;
50 50
 SQL
51
-        );
51
+		);
52 52
 
53
-        $query->execute();
54
-        $sus = $query->fetchColumn();
55
-        $statusElement->setAttribute("bans", $sus);
56
-        $query->closeCursor();
53
+		$query->execute();
54
+		$sus = $query->fetchColumn();
55
+		$statusElement->setAttribute("bans", $sus);
56
+		$query->closeCursor();
57 57
 
58
-        $query = $this->getDatabase()->prepare(<<<SQL
58
+		$query = $this->getDatabase()->prepare(<<<SQL
59 59
 SELECT /* Api/StatusAction */ COUNT(*) AS count
60 60
 FROM user WHERE status = :ulevel;
61 61
 SQL
62
-        );
63
-        $query->bindValue(":ulevel", "Admin");
64
-        $query->execute();
65
-        $sus = $query->fetchColumn();
66
-        $statusElement->setAttribute("useradmin", $sus);
67
-        $query->closeCursor();
62
+		);
63
+		$query->bindValue(":ulevel", "Admin");
64
+		$query->execute();
65
+		$sus = $query->fetchColumn();
66
+		$statusElement->setAttribute("useradmin", $sus);
67
+		$query->closeCursor();
68 68
 
69
-        $query->bindValue(":ulevel", "User");
70
-        $query->execute();
71
-        $sus = $query->fetchColumn();
72
-        $statusElement->setAttribute("user", $sus);
73
-        $query->closeCursor();
69
+		$query->bindValue(":ulevel", "User");
70
+		$query->execute();
71
+		$sus = $query->fetchColumn();
72
+		$statusElement->setAttribute("user", $sus);
73
+		$query->closeCursor();
74 74
 
75
-        $query->bindValue(":ulevel", "New");
76
-        $query->execute();
77
-        $sus = $query->fetchColumn();
78
-        $statusElement->setAttribute("usernew", $sus);
79
-        $query->closeCursor();
75
+		$query->bindValue(":ulevel", "New");
76
+		$query->execute();
77
+		$sus = $query->fetchColumn();
78
+		$statusElement->setAttribute("usernew", $sus);
79
+		$query->closeCursor();
80 80
 
81
-        return $apiDocument;
82
-    }
81
+		return $apiDocument;
82
+	}
83 83
 }
Please login to merge, or discard this patch.
includes/API/IApiAction.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@
 block discarded – undo
15 15
  */
16 16
 interface IApiAction extends IRoutedTask
17 17
 {
18
-    /**
19
-     * @return string the XML, or false if an error occurred.
20
-     */
21
-    public function runApiPage();
18
+	/**
19
+	 * @return string the XML, or false if an error occurred.
20
+	 */
21
+	public function runApiPage();
22 22
 }
Please login to merge, or discard this patch.
includes/Helpers/TypeAheadHelper.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -12,21 +12,21 @@  discard block
 block discarded – undo
12 12
 
13 13
 class TypeAheadHelper implements ITypeAheadHelper
14 14
 {
15
-    private $definedClasses = array();
15
+	private $definedClasses = array();
16 16
 
17
-    /**
18
-     * @param string   $class     CSS class to apply this typeahead to.
19
-     * @param callable $generator Generator function taking no arguments to return an array of strings.
20
-     */
21
-    public function defineTypeAheadSource($class, callable $generator)
22
-    {
23
-        $dataList = '';
24
-        foreach ($generator() as $dataItem) {
25
-            $dataList .= '"' . htmlentities($dataItem) . '", ';
26
-        }
27
-        $dataList = "[" . rtrim($dataList, ", ") . "]";
17
+	/**
18
+	 * @param string   $class     CSS class to apply this typeahead to.
19
+	 * @param callable $generator Generator function taking no arguments to return an array of strings.
20
+	 */
21
+	public function defineTypeAheadSource($class, callable $generator)
22
+	{
23
+		$dataList = '';
24
+		foreach ($generator() as $dataItem) {
25
+			$dataList .= '"' . htmlentities($dataItem) . '", ';
26
+		}
27
+		$dataList = "[" . rtrim($dataList, ", ") . "]";
28 28
 
29
-        $script = <<<JS
29
+		$script = <<<JS
30 30
 
31 31
 $('.{$class}').typeahead({
32 32
         hint: true,
@@ -39,32 +39,32 @@  discard block
 block discarded – undo
39 39
 })
40 40
 ;
41 41
 JS;
42
-        $this->definedClasses[$class] = $script;
43
-    }
42
+		$this->definedClasses[$class] = $script;
43
+	}
44 44
 
45
-    /**
46
-     * @return string HTML fragment containing a JS block for typeaheads.
47
-     */
48
-    public function getTypeAheadScriptBlock()
49
-    {
50
-        $jsBlocks = '';
45
+	/**
46
+	 * @return string HTML fragment containing a JS block for typeaheads.
47
+	 */
48
+	public function getTypeAheadScriptBlock()
49
+	{
50
+		$jsBlocks = '';
51 51
 
52
-        if (count($this->definedClasses) === 0) {
53
-            return '';
54
-        }
52
+		if (count($this->definedClasses) === 0) {
53
+			return '';
54
+		}
55 55
 
56
-        foreach ($this->definedClasses as $class => $js) {
57
-            $jsBlocks = $js . "\r\n\r\n";
58
-        }
56
+		foreach ($this->definedClasses as $class => $js) {
57
+			$jsBlocks = $js . "\r\n\r\n";
58
+		}
59 59
 
60
-        $data = <<<HTML
60
+		$data = <<<HTML
61 61
 <script type="text/javascript">
62 62
 	{$jsBlocks}
63 63
 </script>
64 64
 HTML;
65 65
 
66
-        $this->definedClasses = array();
66
+		$this->definedClasses = array();
67 67
 
68
-        return $data;
69
-    }
68
+		return $data;
69
+	}
70 70
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
     {
23 23
         $dataList = '';
24 24
         foreach ($generator() as $dataItem) {
25
-            $dataList .= '"' . htmlentities($dataItem) . '", ';
25
+            $dataList .= '"'.htmlentities($dataItem).'", ';
26 26
         }
27
-        $dataList = "[" . rtrim($dataList, ", ") . "]";
27
+        $dataList = "[".rtrim($dataList, ", ")."]";
28 28
 
29 29
         $script = <<<JS
30 30
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         }
55 55
 
56 56
         foreach ($this->definedClasses as $class => $js) {
57
-            $jsBlocks = $js . "\r\n\r\n";
57
+            $jsBlocks = $js."\r\n\r\n";
58 58
         }
59 59
 
60 60
         $data = <<<HTML
Please login to merge, or discard this patch.
includes/Tasks/ApiPageBase.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -12,24 +12,24 @@
 block discarded – undo
12 12
 
13 13
 abstract class ApiPageBase extends TaskBase implements IRoutedTask, IApiAction
14 14
 {
15
-    final public function execute()
16
-    {
17
-        $this->main();
18
-    }
15
+	final public function execute()
16
+	{
17
+		$this->main();
18
+	}
19 19
 
20
-    /**
21
-     * @param string $routeName
22
-     */
23
-    public function setRoute($routeName)
24
-    {
25
-        // no-op
26
-    }
20
+	/**
21
+	 * @param string $routeName
22
+	 */
23
+	public function setRoute($routeName)
24
+	{
25
+		// no-op
26
+	}
27 27
 
28
-    /**
29
-     * @return string
30
-     */
31
-    public function getRouteName()
32
-    {
33
-        return 'main';
34
-    }
28
+	/**
29
+	 * @return string
30
+	 */
31
+	public function getRouteName()
32
+	{
33
+		return 'main';
34
+	}
35 35
 }
Please login to merge, or discard this patch.
includes/Tasks/XmlApiPageBase.php 2 patches
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -17,76 +17,76 @@
 block discarded – undo
17 17
 
18 18
 abstract class XmlApiPageBase extends ApiPageBase implements IXmlApiAction
19 19
 {
20
-    /**
21
-     * API result document
22
-     * @var DOMDocument
23
-     */
24
-    protected $document;
25
-
26
-    public function __construct()
27
-    {
28
-        $this->document = new DOMDocument('1.0');
29
-    }
30
-
31
-    /**
32
-     * Main function for this page, when no specific actions are called.
33
-     *
34
-     * @throws ApiException
35
-     * @return void
36
-     */
37
-    final protected function main()
38
-    {
39
-        if (headers_sent()) {
40
-            throw new ApiException('Headers have already been sent - this indicates a bug in the application!');
41
-        }
42
-
43
-        header("Content-Type: text/xml");
44
-
45
-        // javascript access control
46
-        $httpOrigin = WebRequest::origin();
47
-
48
-        if ($httpOrigin !== null) {
49
-            $CORSallowed = $this->getSiteConfiguration()->getCrossOriginResourceSharingHosts();
50
-
51
-            if (in_array($httpOrigin, $CORSallowed)) {
52
-                header("Access-Control-Allow-Origin: " . $httpOrigin);
53
-            }
54
-        }
55
-
56
-        $responseData = $this->runApiPage();
57
-
58
-        ob_end_clean();
59
-        print($responseData);
60
-        ob_start();
61
-    }
62
-
63
-    /**
64
-     * Method that runs API action
65
-     *
66
-     * @param DOMElement $apiDocument
67
-     *
68
-     * @return DOMElement
69
-     */
70
-    abstract public function executeApiAction(DOMElement $apiDocument);
71
-
72
-    /**
73
-     * @return string
74
-     */
75
-    final public function runApiPage()
76
-    {
77
-        $apiDocument = $this->document->createElement("api");
78
-
79
-        try {
80
-            $apiDocument = $this->executeApiAction($apiDocument);
81
-        }
82
-        catch (ApiException $ex) {
83
-            $exception = $this->document->createElement("error");
84
-            $exception->setAttribute("message", $ex->getMessage());
85
-            $apiDocument->appendChild($exception);
86
-        }
87
-
88
-        $this->document->appendChild($apiDocument);
89
-
90
-        return $this->document->saveXML();
91
-    }
20
+	/**
21
+	 * API result document
22
+	 * @var DOMDocument
23
+	 */
24
+	protected $document;
25
+
26
+	public function __construct()
27
+	{
28
+		$this->document = new DOMDocument('1.0');
29
+	}
30
+
31
+	/**
32
+	 * Main function for this page, when no specific actions are called.
33
+	 *
34
+	 * @throws ApiException
35
+	 * @return void
36
+	 */
37
+	final protected function main()
38
+	{
39
+		if (headers_sent()) {
40
+			throw new ApiException('Headers have already been sent - this indicates a bug in the application!');
41
+		}
42
+
43
+		header("Content-Type: text/xml");
44
+
45
+		// javascript access control
46
+		$httpOrigin = WebRequest::origin();
47
+
48
+		if ($httpOrigin !== null) {
49
+			$CORSallowed = $this->getSiteConfiguration()->getCrossOriginResourceSharingHosts();
50
+
51
+			if (in_array($httpOrigin, $CORSallowed)) {
52
+				header("Access-Control-Allow-Origin: " . $httpOrigin);
53
+			}
54
+		}
55
+
56
+		$responseData = $this->runApiPage();
57
+
58
+		ob_end_clean();
59
+		print($responseData);
60
+		ob_start();
61
+	}
62
+
63
+	/**
64
+	 * Method that runs API action
65
+	 *
66
+	 * @param DOMElement $apiDocument
67
+	 *
68
+	 * @return DOMElement
69
+	 */
70
+	abstract public function executeApiAction(DOMElement $apiDocument);
71
+
72
+	/**
73
+	 * @return string
74
+	 */
75
+	final public function runApiPage()
76
+	{
77
+		$apiDocument = $this->document->createElement("api");
78
+
79
+		try {
80
+			$apiDocument = $this->executeApiAction($apiDocument);
81
+		}
82
+		catch (ApiException $ex) {
83
+			$exception = $this->document->createElement("error");
84
+			$exception->setAttribute("message", $ex->getMessage());
85
+			$apiDocument->appendChild($exception);
86
+		}
87
+
88
+		$this->document->appendChild($apiDocument);
89
+
90
+		return $this->document->saveXML();
91
+	}
92 92
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@
 block discarded – undo
69 69
             $CORSallowed = $this->getSiteConfiguration()->getCrossOriginResourceSharingHosts();
70 70
 
71 71
             if (in_array($httpOrigin, $CORSallowed)) {
72
-                header("Access-Control-Allow-Origin: " . $httpOrigin);
72
+                header("Access-Control-Allow-Origin: ".$httpOrigin);
73 73
             }
74 74
         }
75 75
 
Please login to merge, or discard this patch.
includes/API/Actions/HelpAction.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -18,34 +18,34 @@
 block discarded – undo
18 18
  */
19 19
 class HelpAction extends XmlApiPageBase implements IXmlApiAction
20 20
 {
21
-    public function executeApiAction(DOMElement $apiDocument)
22
-    {
23
-        $helpElement = $this->getHelpElement();
24
-        $apiDocument->appendChild($helpElement);
25
-
26
-        return $apiDocument;
27
-    }
28
-
29
-    /**
30
-     * Gets the help information
31
-     * @return DOMElement
32
-     */
33
-    protected function getHelpElement()
34
-    {
21
+	public function executeApiAction(DOMElement $apiDocument)
22
+	{
23
+		$helpElement = $this->getHelpElement();
24
+		$apiDocument->appendChild($helpElement);
25
+
26
+		return $apiDocument;
27
+	}
28
+
29
+	/**
30
+	 * Gets the help information
31
+	 * @return DOMElement
32
+	 */
33
+	protected function getHelpElement()
34
+	{
35 35
 		$helpInfo = "API help can be found at https://github.com/enwikipedia-acc/waca/wiki/API";
36 36
 
37
-        $help = $this->document->createElement("help");
38
-        $helptext = $this->document->createElement("info", $helpInfo);
39
-        $helpactions = $this->document->createElement("actions");
37
+		$help = $this->document->createElement("help");
38
+		$helptext = $this->document->createElement("info", $helpInfo);
39
+		$helpactions = $this->document->createElement("actions");
40 40
 
41
-        foreach (ApiRequestRouter::getActionList() as $action) {
42
-            $actionElement = $this->document->createElement("action", $action);
43
-            $helpactions->appendChild($actionElement);
44
-        }
41
+		foreach (ApiRequestRouter::getActionList() as $action) {
42
+			$actionElement = $this->document->createElement("action", $action);
43
+			$helpactions->appendChild($actionElement);
44
+		}
45 45
 
46
-        $help->appendChild($helptext);
47
-        $help->appendChild($helpactions);
46
+		$help->appendChild($helptext);
47
+		$help->appendChild($helpactions);
48 48
 
49
-        return $help;
50
-    }
49
+		return $help;
50
+	}
51 51
 }
Please login to merge, or discard this patch.
includes/API/Actions/StatsAction.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -22,58 +22,58 @@
 block discarded – undo
22 22
  */
23 23
 class StatsAction extends XmlApiPageBase implements IXmlApiAction
24 24
 {
25
-    /**
26
-     * The target user
27
-     * @var User $user
28
-     */
29
-    private $user;
25
+	/**
26
+	 * The target user
27
+	 * @var User $user
28
+	 */
29
+	private $user;
30 30
 
31
-    /**
32
-     * Summary of execute
33
-     *
34
-     * @param DOMElement $apiDocument
35
-     *
36
-     * @return DOMElement
37
-     * @throws ApiException
38
-     * @throws Exception
39
-     */
40
-    public function executeApiAction(DOMElement $apiDocument)
41
-    {
42
-        $username = WebRequest::getString('user');
43
-        $wikiusername = WebRequest::getString('wikiuser');
31
+	/**
32
+	 * Summary of execute
33
+	 *
34
+	 * @param DOMElement $apiDocument
35
+	 *
36
+	 * @return DOMElement
37
+	 * @throws ApiException
38
+	 * @throws Exception
39
+	 */
40
+	public function executeApiAction(DOMElement $apiDocument)
41
+	{
42
+		$username = WebRequest::getString('user');
43
+		$wikiusername = WebRequest::getString('wikiuser');
44 44
 
45
-        if ($username === null && $wikiusername === null) {
46
-            throw new ApiException("Please specify a username using either user or wikiuser parameters.");
47
-        }
45
+		if ($username === null && $wikiusername === null) {
46
+			throw new ApiException("Please specify a username using either user or wikiuser parameters.");
47
+		}
48 48
 
49
-        $userElement = $this->document->createElement("user");
50
-        $apiDocument->appendChild($userElement);
49
+		$userElement = $this->document->createElement("user");
50
+		$apiDocument->appendChild($userElement);
51 51
 
52
-        if ($username !== null) {
53
-            $user = User::getByUsername($username, $this->getDatabase());
54
-        }
55
-        else {
56
-            $user = User::getByOnWikiUsername($wikiusername, $this->getDatabase());
57
-        }
52
+		if ($username !== null) {
53
+			$user = User::getByUsername($username, $this->getDatabase());
54
+		}
55
+		else {
56
+			$user = User::getByOnWikiUsername($wikiusername, $this->getDatabase());
57
+		}
58 58
 
59
-        if ($user === false) {
60
-            $userElement->setAttribute("missing", "true");
59
+		if ($user === false) {
60
+			$userElement->setAttribute("missing", "true");
61 61
 
62
-            return $apiDocument;
63
-        }
62
+			return $apiDocument;
63
+		}
64 64
 
65
-        $this->user = $user;
65
+		$this->user = $user;
66 66
 
67
-        $oauth = new OAuthUserHelper($user, $this->getDatabase(), $this->getOAuthProtocolHelper(),
68
-            $this->getSiteConfiguration());
67
+		$oauth = new OAuthUserHelper($user, $this->getDatabase(), $this->getOAuthProtocolHelper(),
68
+			$this->getSiteConfiguration());
69 69
 
70
-        $userElement->setAttribute("username", $this->user->getUsername());
71
-        $userElement->setAttribute("status", $this->user->getStatus());
72
-        $userElement->setAttribute("lastactive", $this->user->getLastActive());
73
-        $userElement->setAttribute("welcome_template", $this->user->getWelcomeTemplate());
74
-        $userElement->setAttribute("onwikiname", $this->user->getOnWikiName());
75
-        $userElement->setAttribute("oauth", $oauth->isFullyLinked() ? "true" : "false");
70
+		$userElement->setAttribute("username", $this->user->getUsername());
71
+		$userElement->setAttribute("status", $this->user->getStatus());
72
+		$userElement->setAttribute("lastactive", $this->user->getLastActive());
73
+		$userElement->setAttribute("welcome_template", $this->user->getWelcomeTemplate());
74
+		$userElement->setAttribute("onwikiname", $this->user->getOnWikiName());
75
+		$userElement->setAttribute("oauth", $oauth->isFullyLinked() ? "true" : "false");
76 76
 
77
-        return $apiDocument;
78
-    }
77
+		return $apiDocument;
78
+	}
79 79
 }
Please login to merge, or discard this patch.
includes/DataObjects/OAuthIdentity.php 1 patch
Indentation   +284 added lines, -284 removed lines patch added patch discarded remove patch
@@ -16,51 +16,51 @@  discard block
 block discarded – undo
16 16
 
17 17
 class OAuthIdentity extends DataObject
18 18
 {
19
-    #region Fields
20
-    /** @var int */
21
-    private $user;
22
-    /** @var string */
23
-    private $iss;
24
-    /** @var int */
25
-    private $sub;
26
-    /** @var string */
27
-    private $aud;
28
-    /** @var int */
29
-    private $exp;
30
-    /** @var int */
31
-    private $iat;
32
-    /** @var string */
33
-    private $username;
34
-    /** @var int */
35
-    private $editcount;
36
-    /** @var int */
37
-    private $confirmed_email;
38
-    /** @var int */
39
-    private $blocked;
40
-    /** @var string */
41
-    private $registered;
42
-    /** @var int */
43
-    private $checkuser;
44
-    /** @var int */
45
-    private $grantbasic;
46
-    /** @var int */
47
-    private $grantcreateaccount;
48
-    /** @var int */
49
-    private $granthighvolume;
50
-    /** @var int */
51
-    private $grantcreateeditmovepage;
52
-    #endregion
53
-
54
-    /**
55
-     * Saves a data object to the database, either updating or inserting a record.
56
-     * @return void
57
-     * @throws Exception
58
-     * @throws OptimisticLockFailedException
59
-     */
60
-    public function save()
61
-    {
62
-        if ($this->isNew()) {
63
-            $statement = $this->dbObject->prepare(<<<SQL
19
+	#region Fields
20
+	/** @var int */
21
+	private $user;
22
+	/** @var string */
23
+	private $iss;
24
+	/** @var int */
25
+	private $sub;
26
+	/** @var string */
27
+	private $aud;
28
+	/** @var int */
29
+	private $exp;
30
+	/** @var int */
31
+	private $iat;
32
+	/** @var string */
33
+	private $username;
34
+	/** @var int */
35
+	private $editcount;
36
+	/** @var int */
37
+	private $confirmed_email;
38
+	/** @var int */
39
+	private $blocked;
40
+	/** @var string */
41
+	private $registered;
42
+	/** @var int */
43
+	private $checkuser;
44
+	/** @var int */
45
+	private $grantbasic;
46
+	/** @var int */
47
+	private $grantcreateaccount;
48
+	/** @var int */
49
+	private $granthighvolume;
50
+	/** @var int */
51
+	private $grantcreateeditmovepage;
52
+	#endregion
53
+
54
+	/**
55
+	 * Saves a data object to the database, either updating or inserting a record.
56
+	 * @return void
57
+	 * @throws Exception
58
+	 * @throws OptimisticLockFailedException
59
+	 */
60
+	public function save()
61
+	{
62
+		if ($this->isNew()) {
63
+			$statement = $this->dbObject->prepare(<<<SQL
64 64
                 INSERT INTO oauthidentity (
65 65
                     user, iss, sub, aud, exp, iat, username, editcount, confirmed_email, blocked, registered, checkuser, 
66 66
                     grantbasic, grantcreateaccount, granthighvolume, grantcreateeditmovepage
@@ -69,34 +69,34 @@  discard block
 block discarded – undo
69 69
                     :checkuser, :grantbasic, :grantcreateaccount, :granthighvolume, :grantcreateeditmovepage
70 70
                 )
71 71
 SQL
72
-            );
73
-
74
-            $statement->bindValue(':user', $this->user);
75
-            $statement->bindValue(':iss', $this->iss);
76
-            $statement->bindValue(':sub', $this->sub);
77
-            $statement->bindValue(':aud', $this->aud);
78
-            $statement->bindValue(':exp', $this->exp);
79
-            $statement->bindValue(':iat', $this->iat);
80
-            $statement->bindValue(':username', $this->username);
81
-            $statement->bindValue(':editcount', $this->editcount);
82
-            $statement->bindValue(':confirmed_email', $this->confirmed_email);
83
-            $statement->bindValue(':blocked', $this->blocked);
84
-            $statement->bindValue(':registered', $this->registered);
85
-            $statement->bindValue(':checkuser', $this->checkuser);
86
-            $statement->bindValue(':grantbasic', $this->grantbasic);
87
-            $statement->bindValue(':grantcreateaccount', $this->grantcreateaccount);
88
-            $statement->bindValue(':granthighvolume', $this->granthighvolume);
89
-            $statement->bindValue(':grantcreateeditmovepage', $this->grantcreateeditmovepage);
90
-
91
-            if ($statement->execute()) {
92
-                $this->id = (int)$this->dbObject->lastInsertId();
93
-            }
94
-            else {
95
-                throw new Exception($statement->errorInfo());
96
-            }
97
-        }
98
-        else {
99
-            $statement = $this->dbObject->prepare(<<<SQL
72
+			);
73
+
74
+			$statement->bindValue(':user', $this->user);
75
+			$statement->bindValue(':iss', $this->iss);
76
+			$statement->bindValue(':sub', $this->sub);
77
+			$statement->bindValue(':aud', $this->aud);
78
+			$statement->bindValue(':exp', $this->exp);
79
+			$statement->bindValue(':iat', $this->iat);
80
+			$statement->bindValue(':username', $this->username);
81
+			$statement->bindValue(':editcount', $this->editcount);
82
+			$statement->bindValue(':confirmed_email', $this->confirmed_email);
83
+			$statement->bindValue(':blocked', $this->blocked);
84
+			$statement->bindValue(':registered', $this->registered);
85
+			$statement->bindValue(':checkuser', $this->checkuser);
86
+			$statement->bindValue(':grantbasic', $this->grantbasic);
87
+			$statement->bindValue(':grantcreateaccount', $this->grantcreateaccount);
88
+			$statement->bindValue(':granthighvolume', $this->granthighvolume);
89
+			$statement->bindValue(':grantcreateeditmovepage', $this->grantcreateeditmovepage);
90
+
91
+			if ($statement->execute()) {
92
+				$this->id = (int)$this->dbObject->lastInsertId();
93
+			}
94
+			else {
95
+				throw new Exception($statement->errorInfo());
96
+			}
97
+		}
98
+		else {
99
+			$statement = $this->dbObject->prepare(<<<SQL
100 100
                 UPDATE oauthidentity SET
101 101
                       iss                     = :iss
102 102
                     , sub                     = :sub
@@ -116,211 +116,211 @@  discard block
 block discarded – undo
116 116
                     , updateversion           = updateversion + 1
117 117
                 WHERE  id = :id AND updateversion = :updateversion
118 118
 SQL
119
-            );
120
-
121
-            $statement->bindValue(':iss', $this->iss);
122
-            $statement->bindValue(':sub', $this->sub);
123
-            $statement->bindValue(':aud', $this->aud);
124
-            $statement->bindValue(':exp', $this->exp);
125
-            $statement->bindValue(':iat', $this->iat);
126
-            $statement->bindValue(':username', $this->username);
127
-            $statement->bindValue(':editcount', $this->editcount);
128
-            $statement->bindValue(':confirmed_email', $this->confirmed_email);
129
-            $statement->bindValue(':blocked', $this->blocked);
130
-            $statement->bindValue(':registered', $this->registered);
131
-            $statement->bindValue(':checkuser', $this->checkuser);
132
-            $statement->bindValue(':grantbasic', $this->grantbasic);
133
-            $statement->bindValue(':grantcreateaccount', $this->grantcreateaccount);
134
-            $statement->bindValue(':granthighvolume', $this->granthighvolume);
135
-            $statement->bindValue(':grantcreateeditmovepage', $this->grantcreateeditmovepage);
136
-
137
-            $statement->bindValue(':id', $this->id);
138
-            $statement->bindValue(':updateversion', $this->updateversion);
139
-
140
-            if (!$statement->execute()) {
141
-                throw new Exception($statement->errorInfo());
142
-            }
143
-
144
-            if ($statement->rowCount() !== 1) {
145
-                throw new OptimisticLockFailedException();
146
-            }
147
-
148
-            $this->updateversion++;
149
-        }
150
-    }
151
-
152
-    #region Properties
153
-
154
-    /**
155
-     * @return int
156
-     */
157
-    public function getUserId()
158
-    {
159
-        return $this->user;
160
-    }
161
-
162
-    /**
163
-     * @param int $user
164
-     */
165
-    public function setUserId($user)
166
-    {
167
-        $this->user = $user;
168
-    }
169
-
170
-    /**
171
-     * @return string
172
-     */
173
-    public function getIssuer()
174
-    {
175
-        return $this->iss;
176
-    }
177
-
178
-    /**
179
-     * @return int
180
-     */
181
-    public function getSubject()
182
-    {
183
-        return $this->sub;
184
-    }
185
-
186
-    /**
187
-     * @return string
188
-     */
189
-    public function getAudience()
190
-    {
191
-        return $this->aud;
192
-    }
193
-
194
-    /**
195
-     * @return int
196
-     */
197
-    public function getExpirationTime()
198
-    {
199
-        return $this->exp;
200
-    }
201
-
202
-    /**
203
-     * @return int
204
-     */
205
-    public function getIssuedAtTime()
206
-    {
207
-        return $this->iat;
208
-    }
209
-
210
-    /**
211
-     * @return string
212
-     */
213
-    public function getUsername()
214
-    {
215
-        return $this->username;
216
-    }
217
-
218
-    /**
219
-     * @return int
220
-     */
221
-    public function getEditCount()
222
-    {
223
-        return $this->editcount;
224
-    }
225
-
226
-    /**
227
-     * @return bool
228
-     */
229
-    public function getConfirmedEmail()
230
-    {
231
-        return $this->confirmed_email == 1;
232
-    }
233
-
234
-    /**
235
-     * @return bool
236
-     */
237
-    public function getBlocked()
238
-    {
239
-        return $this->blocked == 1;
240
-    }
241
-
242
-    /**
243
-     * @return string
244
-     */
245
-    public function getRegistered()
246
-    {
247
-        return $this->registered;
248
-    }
249
-
250
-    public function getRegistrationDate()
251
-    {
252
-        return DateTimeImmutable::createFromFormat('YmdHis', $this->registered)->format('r');
253
-    }
254
-
255
-    public function getAccountAge()
256
-    {
257
-        $regDate = DateTimeImmutable::createFromFormat('YmdHis', $this->registered);
258
-        $interval = $regDate->diff(new DateTimeImmutable(), true);
259
-
260
-        return $interval->days;
261
-    }
262
-
263
-    /**
264
-     * @return bool
265
-     */
266
-    public function getCheckuser()
267
-    {
268
-        return $this->checkuser == 1;
269
-    }
270
-
271
-    /**
272
-     * @return bool
273
-     */
274
-    public function getGrantBasic()
275
-    {
276
-        return $this->grantbasic == 1;
277
-    }
278
-
279
-    /**
280
-     * @return bool
281
-     */
282
-    public function getGrantCreateAccount()
283
-    {
284
-        return $this->grantcreateaccount == 1;
285
-    }
286
-
287
-    /**
288
-     * @return bool
289
-     */
290
-    public function getGrantHighVolume()
291
-    {
292
-        return $this->granthighvolume == 1;
293
-    }
294
-
295
-    /**
296
-     * @return bool
297
-     */
298
-    public function getGrantCreateEditMovePage()
299
-    {
300
-        return $this->grantcreateeditmovepage == 1;
301
-    }
302
-
303
-    #endregion Properties
304
-
305
-    /**
306
-     * Populates the fields of this instance from a provided JSON Web Token
307
-     *
308
-     * @param stdClass $jwt
309
-     */
310
-    public function populate($jwt)
311
-    {
312
-        $this->iss = $jwt->iss;
313
-        $this->sub = $jwt->sub;
314
-        $this->aud = $jwt->aud;
315
-        $this->exp = $jwt->exp;
316
-        $this->iat = $jwt->iat;
317
-        $this->username = $jwt->username;
318
-        $this->editcount = $jwt->editcount;
319
-        $this->confirmed_email = $jwt->confirmed_email ? 1 : 0;
320
-        $this->blocked = $jwt->blocked ? 1 : 0;
321
-        $this->registered = $jwt->registered;
322
-
323
-        /*
119
+			);
120
+
121
+			$statement->bindValue(':iss', $this->iss);
122
+			$statement->bindValue(':sub', $this->sub);
123
+			$statement->bindValue(':aud', $this->aud);
124
+			$statement->bindValue(':exp', $this->exp);
125
+			$statement->bindValue(':iat', $this->iat);
126
+			$statement->bindValue(':username', $this->username);
127
+			$statement->bindValue(':editcount', $this->editcount);
128
+			$statement->bindValue(':confirmed_email', $this->confirmed_email);
129
+			$statement->bindValue(':blocked', $this->blocked);
130
+			$statement->bindValue(':registered', $this->registered);
131
+			$statement->bindValue(':checkuser', $this->checkuser);
132
+			$statement->bindValue(':grantbasic', $this->grantbasic);
133
+			$statement->bindValue(':grantcreateaccount', $this->grantcreateaccount);
134
+			$statement->bindValue(':granthighvolume', $this->granthighvolume);
135
+			$statement->bindValue(':grantcreateeditmovepage', $this->grantcreateeditmovepage);
136
+
137
+			$statement->bindValue(':id', $this->id);
138
+			$statement->bindValue(':updateversion', $this->updateversion);
139
+
140
+			if (!$statement->execute()) {
141
+				throw new Exception($statement->errorInfo());
142
+			}
143
+
144
+			if ($statement->rowCount() !== 1) {
145
+				throw new OptimisticLockFailedException();
146
+			}
147
+
148
+			$this->updateversion++;
149
+		}
150
+	}
151
+
152
+	#region Properties
153
+
154
+	/**
155
+	 * @return int
156
+	 */
157
+	public function getUserId()
158
+	{
159
+		return $this->user;
160
+	}
161
+
162
+	/**
163
+	 * @param int $user
164
+	 */
165
+	public function setUserId($user)
166
+	{
167
+		$this->user = $user;
168
+	}
169
+
170
+	/**
171
+	 * @return string
172
+	 */
173
+	public function getIssuer()
174
+	{
175
+		return $this->iss;
176
+	}
177
+
178
+	/**
179
+	 * @return int
180
+	 */
181
+	public function getSubject()
182
+	{
183
+		return $this->sub;
184
+	}
185
+
186
+	/**
187
+	 * @return string
188
+	 */
189
+	public function getAudience()
190
+	{
191
+		return $this->aud;
192
+	}
193
+
194
+	/**
195
+	 * @return int
196
+	 */
197
+	public function getExpirationTime()
198
+	{
199
+		return $this->exp;
200
+	}
201
+
202
+	/**
203
+	 * @return int
204
+	 */
205
+	public function getIssuedAtTime()
206
+	{
207
+		return $this->iat;
208
+	}
209
+
210
+	/**
211
+	 * @return string
212
+	 */
213
+	public function getUsername()
214
+	{
215
+		return $this->username;
216
+	}
217
+
218
+	/**
219
+	 * @return int
220
+	 */
221
+	public function getEditCount()
222
+	{
223
+		return $this->editcount;
224
+	}
225
+
226
+	/**
227
+	 * @return bool
228
+	 */
229
+	public function getConfirmedEmail()
230
+	{
231
+		return $this->confirmed_email == 1;
232
+	}
233
+
234
+	/**
235
+	 * @return bool
236
+	 */
237
+	public function getBlocked()
238
+	{
239
+		return $this->blocked == 1;
240
+	}
241
+
242
+	/**
243
+	 * @return string
244
+	 */
245
+	public function getRegistered()
246
+	{
247
+		return $this->registered;
248
+	}
249
+
250
+	public function getRegistrationDate()
251
+	{
252
+		return DateTimeImmutable::createFromFormat('YmdHis', $this->registered)->format('r');
253
+	}
254
+
255
+	public function getAccountAge()
256
+	{
257
+		$regDate = DateTimeImmutable::createFromFormat('YmdHis', $this->registered);
258
+		$interval = $regDate->diff(new DateTimeImmutable(), true);
259
+
260
+		return $interval->days;
261
+	}
262
+
263
+	/**
264
+	 * @return bool
265
+	 */
266
+	public function getCheckuser()
267
+	{
268
+		return $this->checkuser == 1;
269
+	}
270
+
271
+	/**
272
+	 * @return bool
273
+	 */
274
+	public function getGrantBasic()
275
+	{
276
+		return $this->grantbasic == 1;
277
+	}
278
+
279
+	/**
280
+	 * @return bool
281
+	 */
282
+	public function getGrantCreateAccount()
283
+	{
284
+		return $this->grantcreateaccount == 1;
285
+	}
286
+
287
+	/**
288
+	 * @return bool
289
+	 */
290
+	public function getGrantHighVolume()
291
+	{
292
+		return $this->granthighvolume == 1;
293
+	}
294
+
295
+	/**
296
+	 * @return bool
297
+	 */
298
+	public function getGrantCreateEditMovePage()
299
+	{
300
+		return $this->grantcreateeditmovepage == 1;
301
+	}
302
+
303
+	#endregion Properties
304
+
305
+	/**
306
+	 * Populates the fields of this instance from a provided JSON Web Token
307
+	 *
308
+	 * @param stdClass $jwt
309
+	 */
310
+	public function populate($jwt)
311
+	{
312
+		$this->iss = $jwt->iss;
313
+		$this->sub = $jwt->sub;
314
+		$this->aud = $jwt->aud;
315
+		$this->exp = $jwt->exp;
316
+		$this->iat = $jwt->iat;
317
+		$this->username = $jwt->username;
318
+		$this->editcount = $jwt->editcount;
319
+		$this->confirmed_email = $jwt->confirmed_email ? 1 : 0;
320
+		$this->blocked = $jwt->blocked ? 1 : 0;
321
+		$this->registered = $jwt->registered;
322
+
323
+		/*
324 324
          * Rights we need:
325 325
          *  Account creation
326 326
          *      createaccount      => createaccount
@@ -342,11 +342,11 @@  discard block
 block discarded – undo
342 342
          * Any antispoof conflicts will still have to be resolved manually using the normal creation form.
343 343
          */
344 344
 
345
-        $this->grantbasic = in_array('basic', $jwt->grants) ? 1 : 0;
346
-        $this->grantcreateaccount = in_array('createaccount', $jwt->grants) ? 1 : 0;
347
-        $this->grantcreateeditmovepage = in_array('createeditmovepage', $jwt->grants) ? 1 : 0;
348
-        $this->granthighvolume = in_array('highvolume', $jwt->grants) ? 1 : 0;
345
+		$this->grantbasic = in_array('basic', $jwt->grants) ? 1 : 0;
346
+		$this->grantcreateaccount = in_array('createaccount', $jwt->grants) ? 1 : 0;
347
+		$this->grantcreateeditmovepage = in_array('createeditmovepage', $jwt->grants) ? 1 : 0;
348
+		$this->granthighvolume = in_array('highvolume', $jwt->grants) ? 1 : 0;
349 349
 
350
-        $this->checkuser = in_array('checkuser-log', $jwt->rights) ? 1 : 0;
351
-    }
350
+		$this->checkuser = in_array('checkuser-log', $jwt->rights) ? 1 : 0;
351
+	}
352 352
 }
Please login to merge, or discard this patch.
includes/Pages/PageJobQueue.php 1 patch
Indentation   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -26,241 +26,241 @@
 block discarded – undo
26 26
 
27 27
 class PageJobQueue extends PagedInternalPageBase
28 28
 {
29
-    /**
30
-     * Main function for this page, when no specific actions are called.
31
-     * @return void
32
-     */
33
-    protected function main()
34
-    {
35
-        $this->setHtmlTitle('Job Queue Management');
29
+	/**
30
+	 * Main function for this page, when no specific actions are called.
31
+	 * @return void
32
+	 */
33
+	protected function main()
34
+	{
35
+		$this->setHtmlTitle('Job Queue Management');
36 36
 
37
-        $this->prepareMaps();
37
+		$this->prepareMaps();
38 38
 
39
-        $database = $this->getDatabase();
39
+		$database = $this->getDatabase();
40 40
 
41
-        /** @var JobQueue[] $jobList */
42
-        $jobList = JobQueueSearchHelper::get($database)
43
-            ->statusIn(array('ready', 'waiting', 'running', 'failed'))
44
-            ->notAcknowledged()
45
-            ->fetch();
41
+		/** @var JobQueue[] $jobList */
42
+		$jobList = JobQueueSearchHelper::get($database)
43
+			->statusIn(array('ready', 'waiting', 'running', 'failed'))
44
+			->notAcknowledged()
45
+			->fetch();
46 46
 
47
-        $userIds = array();
48
-        $requestIds = array();
47
+		$userIds = array();
48
+		$requestIds = array();
49 49
 
50
-        foreach ($jobList as $job) {
51
-            $userIds[] = $job->getTriggerUserId();
52
-            $requestIds[] = $job->getRequest();
50
+		foreach ($jobList as $job) {
51
+			$userIds[] = $job->getTriggerUserId();
52
+			$requestIds[] = $job->getRequest();
53 53
 
54
-            $job->setDatabase($database);
55
-        }
54
+			$job->setDatabase($database);
55
+		}
56 56
 
57
-        $this->assign('canSeeAll', $this->barrierTest('all', User::getCurrent($database)));
57
+		$this->assign('canSeeAll', $this->barrierTest('all', User::getCurrent($database)));
58 58
 
59
-        $this->assign('users', UserSearchHelper::get($database)->inIds($userIds)->fetchMap('username'));
60
-        $this->assign('requests', RequestSearchHelper::get($database)->inIds($requestIds)->fetchMap('name'));
59
+		$this->assign('users', UserSearchHelper::get($database)->inIds($userIds)->fetchMap('username'));
60
+		$this->assign('requests', RequestSearchHelper::get($database)->inIds($requestIds)->fetchMap('name'));
61 61
 
62
-        $this->assign('joblist', $jobList);
63
-        $this->setTemplate('jobqueue/main.tpl');
64
-    }
62
+		$this->assign('joblist', $jobList);
63
+		$this->setTemplate('jobqueue/main.tpl');
64
+	}
65 65
 
66
-    protected function all()
67
-    {
68
-        $this->setHtmlTitle('All Jobs');
66
+	protected function all()
67
+	{
68
+		$this->setHtmlTitle('All Jobs');
69 69
 
70
-        $this->prepareMaps();
70
+		$this->prepareMaps();
71 71
 
72
-        $database = $this->getDatabase();
72
+		$database = $this->getDatabase();
73 73
 
74
-        $searchHelper = JobQueueSearchHelper::get($database);
75
-        $this->setSearchHelper($searchHelper);
76
-        $this->setupLimits();
74
+		$searchHelper = JobQueueSearchHelper::get($database);
75
+		$this->setSearchHelper($searchHelper);
76
+		$this->setupLimits();
77 77
 
78
-        $filterUser = WebRequest::getString('filterUser');
79
-        $filterTask = WebRequest::getString('filterTask');
80
-        $filterStatus = WebRequest::getString('filterStatus');
81
-        $filterRequest = WebRequest::getString('filterRequest');
78
+		$filterUser = WebRequest::getString('filterUser');
79
+		$filterTask = WebRequest::getString('filterTask');
80
+		$filterStatus = WebRequest::getString('filterStatus');
81
+		$filterRequest = WebRequest::getString('filterRequest');
82 82
 
83
-        if ($filterUser !== null) {
84
-            $searchHelper->byUser(User::getByUsername($filterUser, $database)->getId());
85
-        }
83
+		if ($filterUser !== null) {
84
+			$searchHelper->byUser(User::getByUsername($filterUser, $database)->getId());
85
+		}
86 86
 
87
-        if ($filterTask !== null) {
88
-            $searchHelper->byTask($filterTask);
89
-        }
87
+		if ($filterTask !== null) {
88
+			$searchHelper->byTask($filterTask);
89
+		}
90 90
 
91
-        if ($filterStatus !== null) {
92
-            $searchHelper->byStatus($filterStatus);
93
-        }
91
+		if ($filterStatus !== null) {
92
+			$searchHelper->byStatus($filterStatus);
93
+		}
94 94
 
95
-        if ($filterRequest !== null) {
96
-            $searchHelper->byRequest($filterRequest);
97
-        }
95
+		if ($filterRequest !== null) {
96
+			$searchHelper->byRequest($filterRequest);
97
+		}
98 98
 
99
-        /** @var JobQueue[] $jobList */
100
-        $jobList = $searchHelper->getRecordCount($count)->fetch();
99
+		/** @var JobQueue[] $jobList */
100
+		$jobList = $searchHelper->getRecordCount($count)->fetch();
101 101
 
102
-        $this->setupPageData($count, array(
103
-            'filterUser' => $filterUser,
104
-            'filterTask' => $filterTask,
105
-            'filterStatus' => $filterStatus,
106
-            'filterRequest' => $filterRequest,
107
-        ));
102
+		$this->setupPageData($count, array(
103
+			'filterUser' => $filterUser,
104
+			'filterTask' => $filterTask,
105
+			'filterStatus' => $filterStatus,
106
+			'filterRequest' => $filterRequest,
107
+		));
108 108
 
109
-        $userIds = array();
110
-        $requestIds = array();
109
+		$userIds = array();
110
+		$requestIds = array();
111 111
 
112
-        foreach ($jobList as $job) {
113
-            $userIds[] = $job->getTriggerUserId();
114
-            $requestIds[] = $job->getRequest();
112
+		foreach ($jobList as $job) {
113
+			$userIds[] = $job->getTriggerUserId();
114
+			$requestIds[] = $job->getRequest();
115 115
 
116
-            $job->setDatabase($database);
117
-        }
116
+			$job->setDatabase($database);
117
+		}
118 118
 
119
-        $this->getTypeAheadHelper()->defineTypeAheadSource('username-typeahead', function() use ($database) {
120
-            return UserSearchHelper::get($database)->fetchColumn('username');
121
-        });
119
+		$this->getTypeAheadHelper()->defineTypeAheadSource('username-typeahead', function() use ($database) {
120
+			return UserSearchHelper::get($database)->fetchColumn('username');
121
+		});
122 122
 
123
-        $this->assign('users', UserSearchHelper::get($database)->inIds($userIds)->fetchMap('username'));
124
-        $this->assign('requests', RequestSearchHelper::get($database)->inIds($requestIds)->fetchMap('name'));
123
+		$this->assign('users', UserSearchHelper::get($database)->inIds($userIds)->fetchMap('username'));
124
+		$this->assign('requests', RequestSearchHelper::get($database)->inIds($requestIds)->fetchMap('name'));
125 125
 
126
-        $this->assign('joblist', $jobList);
126
+		$this->assign('joblist', $jobList);
127 127
 
128
-        $this->addJs("/api.php?action=users&all=true&targetVariable=typeaheaddata");
128
+		$this->addJs("/api.php?action=users&all=true&targetVariable=typeaheaddata");
129 129
 
130
-        $this->setTemplate('jobqueue/all.tpl');
131
-    }
130
+		$this->setTemplate('jobqueue/all.tpl');
131
+	}
132 132
 
133
-    protected function view()
134
-    {
135
-        $jobId = WebRequest::getInt('id');
136
-        $database = $this->getDatabase();
133
+	protected function view()
134
+	{
135
+		$jobId = WebRequest::getInt('id');
136
+		$database = $this->getDatabase();
137 137
 
138
-        if ($jobId === null) {
139
-            throw new ApplicationLogicException('No job specified');
140
-        }
138
+		if ($jobId === null) {
139
+			throw new ApplicationLogicException('No job specified');
140
+		}
141 141
 
142
-        /** @var JobQueue $job */
143
-        $job = JobQueue::getById($jobId, $database);
142
+		/** @var JobQueue $job */
143
+		$job = JobQueue::getById($jobId, $database);
144 144
 
145
-        if ($job === false) {
146
-            throw new ApplicationLogicException('Could not find requested job');
147
-        }
145
+		if ($job === false) {
146
+			throw new ApplicationLogicException('Could not find requested job');
147
+		}
148 148
 
149
-        $this->prepareMaps();
149
+		$this->prepareMaps();
150 150
 
151
-        $this->assign('user', User::getById($job->getTriggerUserId(), $database));
152
-        $this->assign('request', Request::getById($job->getRequest(), $database));
153
-        $this->assign('emailTemplate', EmailTemplate::getById($job->getEmailTemplate(), $database));
154
-        $this->assign('parent', JobQueue::getById($job->getParent(), $database));
151
+		$this->assign('user', User::getById($job->getTriggerUserId(), $database));
152
+		$this->assign('request', Request::getById($job->getRequest(), $database));
153
+		$this->assign('emailTemplate', EmailTemplate::getById($job->getEmailTemplate(), $database));
154
+		$this->assign('parent', JobQueue::getById($job->getParent(), $database));
155 155
 
156
-        /** @var Log[] $logs */
157
-        $logs = LogSearchHelper::get($database)->byObjectType('JobQueue')
158
-            ->byObjectId($job->getId())->getRecordCount($logCount)->fetch();
159
-        if ($logCount === 0) {
160
-            $this->assign('log', array());
161
-        }
162
-        else {
163
-            list($users, $logData) = LogHelper::prepareLogsForTemplate($logs, $database, $this->getSiteConfiguration());
156
+		/** @var Log[] $logs */
157
+		$logs = LogSearchHelper::get($database)->byObjectType('JobQueue')
158
+			->byObjectId($job->getId())->getRecordCount($logCount)->fetch();
159
+		if ($logCount === 0) {
160
+			$this->assign('log', array());
161
+		}
162
+		else {
163
+			list($users, $logData) = LogHelper::prepareLogsForTemplate($logs, $database, $this->getSiteConfiguration());
164 164
 
165
-            $this->assign("log", $logData);
166
-            $this->assign("users", $users);
167
-        }
165
+			$this->assign("log", $logData);
166
+			$this->assign("users", $users);
167
+		}
168 168
 
169
-        $this->assignCSRFToken();
169
+		$this->assignCSRFToken();
170 170
 
171
-        $this->assign('job', $job);
171
+		$this->assign('job', $job);
172 172
 
173
-        $this->assign('canAcknowledge', $this->barrierTest('acknowledge', User::getCurrent($database)));
174
-        $this->assign('canRequeue', $this->barrierTest('requeue', User::getCurrent($database)));
173
+		$this->assign('canAcknowledge', $this->barrierTest('acknowledge', User::getCurrent($database)));
174
+		$this->assign('canRequeue', $this->barrierTest('requeue', User::getCurrent($database)));
175 175
 
176
-        $this->setHtmlTitle('Job #{$job->getId()|escape}');
177
-        $this->setTemplate('jobqueue/view.tpl');
178
-    }
176
+		$this->setHtmlTitle('Job #{$job->getId()|escape}');
177
+		$this->setTemplate('jobqueue/view.tpl');
178
+	}
179 179
 
180
-    protected function acknowledge()
181
-    {
182
-        if (!WebRequest::wasPosted()) {
183
-            throw new ApplicationLogicException('This page does not support GET methods.');
184
-        }
180
+	protected function acknowledge()
181
+	{
182
+		if (!WebRequest::wasPosted()) {
183
+			throw new ApplicationLogicException('This page does not support GET methods.');
184
+		}
185 185
 
186
-        $this->validateCSRFToken();
186
+		$this->validateCSRFToken();
187 187
 
188
-        $jobId = WebRequest::postInt('job');
189
-        $database = $this->getDatabase();
188
+		$jobId = WebRequest::postInt('job');
189
+		$database = $this->getDatabase();
190 190
 
191
-        if ($jobId === null) {
192
-            throw new ApplicationLogicException('No job specified');
193
-        }
191
+		if ($jobId === null) {
192
+			throw new ApplicationLogicException('No job specified');
193
+		}
194 194
 
195
-        /** @var JobQueue $job */
196
-        $job = JobQueue::getById($jobId, $database);
195
+		/** @var JobQueue $job */
196
+		$job = JobQueue::getById($jobId, $database);
197 197
 
198
-        if ($job === false) {
199
-            throw new ApplicationLogicException('Could not find requested job');
200
-        }
198
+		if ($job === false) {
199
+			throw new ApplicationLogicException('Could not find requested job');
200
+		}
201 201
 
202
-        $job->setUpdateVersion(WebRequest::postInt('updateVersion'));
203
-        $job->setAcknowledged(true);
204
-        $job->save();
202
+		$job->setUpdateVersion(WebRequest::postInt('updateVersion'));
203
+		$job->setAcknowledged(true);
204
+		$job->save();
205 205
 
206
-        Logger::backgroundJobAcknowledged($database, $job);
206
+		Logger::backgroundJobAcknowledged($database, $job);
207 207
 
208
-        $this->redirect('jobQueue', 'view', array('id' => $jobId));
209
-    }
208
+		$this->redirect('jobQueue', 'view', array('id' => $jobId));
209
+	}
210 210
 
211
-    protected function requeue()
212
-    {
213
-        if (!WebRequest::wasPosted()) {
214
-            throw new ApplicationLogicException('This page does not support GET methods.');
215
-        }
211
+	protected function requeue()
212
+	{
213
+		if (!WebRequest::wasPosted()) {
214
+			throw new ApplicationLogicException('This page does not support GET methods.');
215
+		}
216 216
 
217
-        $this->validateCSRFToken();
217
+		$this->validateCSRFToken();
218 218
 
219
-        $jobId = WebRequest::postInt('job');
220
-        $database = $this->getDatabase();
219
+		$jobId = WebRequest::postInt('job');
220
+		$database = $this->getDatabase();
221 221
 
222
-        if ($jobId === null) {
223
-            throw new ApplicationLogicException('No job specified');
224
-        }
222
+		if ($jobId === null) {
223
+			throw new ApplicationLogicException('No job specified');
224
+		}
225 225
 
226
-        /** @var JobQueue $job */
227
-        $job = JobQueue::getById($jobId, $database);
226
+		/** @var JobQueue $job */
227
+		$job = JobQueue::getById($jobId, $database);
228 228
 
229
-        if ($job === false) {
230
-            throw new ApplicationLogicException('Could not find requested job');
231
-        }
229
+		if ($job === false) {
230
+			throw new ApplicationLogicException('Could not find requested job');
231
+		}
232 232
 
233
-        $job->setStatus(JobQueue::STATUS_READY);
234
-        $job->setUpdateVersion(WebRequest::postInt('updateVersion'));
235
-        $job->setAcknowledged(null);
236
-        $job->setError(null);
237
-        $job->save();
238
-
239
-        /** @var Request $request */
240
-        $request = Request::getById($job->getRequest(), $database);
241
-        $request->setStatus(RequestStatus::JOBQUEUE);
242
-        $request->save();
233
+		$job->setStatus(JobQueue::STATUS_READY);
234
+		$job->setUpdateVersion(WebRequest::postInt('updateVersion'));
235
+		$job->setAcknowledged(null);
236
+		$job->setError(null);
237
+		$job->save();
238
+
239
+		/** @var Request $request */
240
+		$request = Request::getById($job->getRequest(), $database);
241
+		$request->setStatus(RequestStatus::JOBQUEUE);
242
+		$request->save();
243 243
 
244
-        Logger::enqueuedJobQueue($database, $request);
245
-        Logger::backgroundJobRequeued($database, $job);
246
-
247
-        $this->redirect('jobQueue', 'view', array('id' => $jobId));
248
-    }
249
-
250
-    protected function prepareMaps()
251
-    {
252
-        $taskNameMap = JobQueue::getTaskDescriptions();
253
-
254
-        $statusDecriptionMap = array(
255
-            JobQueue::STATUS_CANCELLED => 'The job was cancelled',
256
-            JobQueue::STATUS_COMPLETE  => 'The job completed successfully',
257
-            JobQueue::STATUS_FAILED    => 'The job encountered an error',
258
-            JobQueue::STATUS_READY     => 'The job is ready to be picked up by the next job runner execution',
259
-            JobQueue::STATUS_RUNNING   => 'The job is being run right now by the job runner',
260
-            JobQueue::STATUS_WAITING   => 'The job has been picked up by a job runner',
261
-            JobQueue::STATUS_HELD      => 'The job has manually held from processing',
262
-        );
263
-        $this->assign('taskNameMap', $taskNameMap);
264
-        $this->assign('statusDescriptionMap', $statusDecriptionMap);
265
-    }
244
+		Logger::enqueuedJobQueue($database, $request);
245
+		Logger::backgroundJobRequeued($database, $job);
246
+
247
+		$this->redirect('jobQueue', 'view', array('id' => $jobId));
248
+	}
249
+
250
+	protected function prepareMaps()
251
+	{
252
+		$taskNameMap = JobQueue::getTaskDescriptions();
253
+
254
+		$statusDecriptionMap = array(
255
+			JobQueue::STATUS_CANCELLED => 'The job was cancelled',
256
+			JobQueue::STATUS_COMPLETE  => 'The job completed successfully',
257
+			JobQueue::STATUS_FAILED    => 'The job encountered an error',
258
+			JobQueue::STATUS_READY     => 'The job is ready to be picked up by the next job runner execution',
259
+			JobQueue::STATUS_RUNNING   => 'The job is being run right now by the job runner',
260
+			JobQueue::STATUS_WAITING   => 'The job has been picked up by a job runner',
261
+			JobQueue::STATUS_HELD      => 'The job has manually held from processing',
262
+		);
263
+		$this->assign('taskNameMap', $taskNameMap);
264
+		$this->assign('statusDescriptionMap', $statusDecriptionMap);
265
+	}
266 266
 }
Please login to merge, or discard this patch.