@@ -14,42 +14,42 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | class OAuthToken extends DataObject |
| 16 | 16 | { |
| 17 | - /** @var int */ |
|
| 18 | - private $user; |
|
| 19 | - /** @var string */ |
|
| 20 | - private $token; |
|
| 21 | - /** @var string */ |
|
| 22 | - private $secret; |
|
| 23 | - /** @var string */ |
|
| 24 | - private $type; |
|
| 25 | - /** @var string */ |
|
| 26 | - private $expiry; |
|
| 27 | - |
|
| 28 | - public function save() |
|
| 29 | - { |
|
| 30 | - if ($this->isNew()) { |
|
| 31 | - // insert |
|
| 32 | - $statement = $this->dbObject->prepare(<<<SQL |
|
| 17 | + /** @var int */ |
|
| 18 | + private $user; |
|
| 19 | + /** @var string */ |
|
| 20 | + private $token; |
|
| 21 | + /** @var string */ |
|
| 22 | + private $secret; |
|
| 23 | + /** @var string */ |
|
| 24 | + private $type; |
|
| 25 | + /** @var string */ |
|
| 26 | + private $expiry; |
|
| 27 | + |
|
| 28 | + public function save() |
|
| 29 | + { |
|
| 30 | + if ($this->isNew()) { |
|
| 31 | + // insert |
|
| 32 | + $statement = $this->dbObject->prepare(<<<SQL |
|
| 33 | 33 | INSERT INTO oauthtoken ( user, token, secret, type, expiry ) |
| 34 | 34 | VALUES ( :user, :token, :secret, :type, :expiry ); |
| 35 | 35 | SQL |
| 36 | - ); |
|
| 37 | - $statement->bindValue(":user", $this->user); |
|
| 38 | - $statement->bindValue(":token", $this->token); |
|
| 39 | - $statement->bindValue(":secret", $this->secret); |
|
| 40 | - $statement->bindValue(":type", $this->type); |
|
| 41 | - $statement->bindValue(":expiry", $this->expiry); |
|
| 42 | - |
|
| 43 | - if ($statement->execute()) { |
|
| 44 | - $this->id = (int)$this->dbObject->lastInsertId(); |
|
| 45 | - } |
|
| 46 | - else { |
|
| 47 | - throw new Exception($statement->errorInfo()); |
|
| 48 | - } |
|
| 49 | - } |
|
| 50 | - else { |
|
| 51 | - // update |
|
| 52 | - $statement = $this->dbObject->prepare(<<<SQL |
|
| 36 | + ); |
|
| 37 | + $statement->bindValue(":user", $this->user); |
|
| 38 | + $statement->bindValue(":token", $this->token); |
|
| 39 | + $statement->bindValue(":secret", $this->secret); |
|
| 40 | + $statement->bindValue(":type", $this->type); |
|
| 41 | + $statement->bindValue(":expiry", $this->expiry); |
|
| 42 | + |
|
| 43 | + if ($statement->execute()) { |
|
| 44 | + $this->id = (int)$this->dbObject->lastInsertId(); |
|
| 45 | + } |
|
| 46 | + else { |
|
| 47 | + throw new Exception($statement->errorInfo()); |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | + else { |
|
| 51 | + // update |
|
| 52 | + $statement = $this->dbObject->prepare(<<<SQL |
|
| 53 | 53 | UPDATE oauthtoken |
| 54 | 54 | SET token = :token |
| 55 | 55 | , secret = :secret |
@@ -58,109 +58,109 @@ discard block |
||
| 58 | 58 | , updateversion = updateversion + 1 |
| 59 | 59 | WHERE id = :id AND updateversion = :updateversion; |
| 60 | 60 | SQL |
| 61 | - ); |
|
| 62 | - |
|
| 63 | - $statement->bindValue(':id', $this->id); |
|
| 64 | - $statement->bindValue(':updateversion', $this->updateversion); |
|
| 65 | - |
|
| 66 | - $statement->bindValue(":token", $this->token); |
|
| 67 | - $statement->bindValue(":secret", $this->secret); |
|
| 68 | - $statement->bindValue(":type", $this->type); |
|
| 69 | - $statement->bindValue(":expiry", $this->expiry); |
|
| 70 | - |
|
| 71 | - if (!$statement->execute()) { |
|
| 72 | - throw new Exception($statement->errorInfo()); |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - if ($statement->rowCount() !== 1) { |
|
| 76 | - throw new OptimisticLockFailedException(); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - $this->updateversion++; |
|
| 80 | - } |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - #region properties |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * @return mixed |
|
| 87 | - */ |
|
| 88 | - public function getUserId() |
|
| 89 | - { |
|
| 90 | - return $this->user; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * @param mixed $user |
|
| 95 | - */ |
|
| 96 | - public function setUserId($user) |
|
| 97 | - { |
|
| 98 | - $this->user = $user; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - /** |
|
| 102 | - * @return mixed |
|
| 103 | - */ |
|
| 104 | - public function getToken() |
|
| 105 | - { |
|
| 106 | - return $this->token; |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * @param mixed $token |
|
| 111 | - */ |
|
| 112 | - public function setToken($token) |
|
| 113 | - { |
|
| 114 | - $this->token = $token; |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * @return mixed |
|
| 119 | - */ |
|
| 120 | - public function getSecret() |
|
| 121 | - { |
|
| 122 | - return $this->secret; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * @param mixed $secret |
|
| 127 | - */ |
|
| 128 | - public function setSecret($secret) |
|
| 129 | - { |
|
| 130 | - $this->secret = $secret; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * @return mixed |
|
| 135 | - */ |
|
| 136 | - public function getType() |
|
| 137 | - { |
|
| 138 | - return $this->type; |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * @param mixed $type |
|
| 143 | - */ |
|
| 144 | - public function setType($type) |
|
| 145 | - { |
|
| 146 | - $this->type = $type; |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * @return string |
|
| 151 | - */ |
|
| 152 | - public function getExpiry() |
|
| 153 | - { |
|
| 154 | - return $this->expiry; |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - /** |
|
| 158 | - * @param string $expiry |
|
| 159 | - */ |
|
| 160 | - public function setExpiry($expiry) |
|
| 161 | - { |
|
| 162 | - $this->expiry = $expiry; |
|
| 163 | - } |
|
| 164 | - #endregion |
|
| 61 | + ); |
|
| 62 | + |
|
| 63 | + $statement->bindValue(':id', $this->id); |
|
| 64 | + $statement->bindValue(':updateversion', $this->updateversion); |
|
| 65 | + |
|
| 66 | + $statement->bindValue(":token", $this->token); |
|
| 67 | + $statement->bindValue(":secret", $this->secret); |
|
| 68 | + $statement->bindValue(":type", $this->type); |
|
| 69 | + $statement->bindValue(":expiry", $this->expiry); |
|
| 70 | + |
|
| 71 | + if (!$statement->execute()) { |
|
| 72 | + throw new Exception($statement->errorInfo()); |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + if ($statement->rowCount() !== 1) { |
|
| 76 | + throw new OptimisticLockFailedException(); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + $this->updateversion++; |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + #region properties |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * @return mixed |
|
| 87 | + */ |
|
| 88 | + public function getUserId() |
|
| 89 | + { |
|
| 90 | + return $this->user; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * @param mixed $user |
|
| 95 | + */ |
|
| 96 | + public function setUserId($user) |
|
| 97 | + { |
|
| 98 | + $this->user = $user; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + /** |
|
| 102 | + * @return mixed |
|
| 103 | + */ |
|
| 104 | + public function getToken() |
|
| 105 | + { |
|
| 106 | + return $this->token; |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * @param mixed $token |
|
| 111 | + */ |
|
| 112 | + public function setToken($token) |
|
| 113 | + { |
|
| 114 | + $this->token = $token; |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * @return mixed |
|
| 119 | + */ |
|
| 120 | + public function getSecret() |
|
| 121 | + { |
|
| 122 | + return $this->secret; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * @param mixed $secret |
|
| 127 | + */ |
|
| 128 | + public function setSecret($secret) |
|
| 129 | + { |
|
| 130 | + $this->secret = $secret; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * @return mixed |
|
| 135 | + */ |
|
| 136 | + public function getType() |
|
| 137 | + { |
|
| 138 | + return $this->type; |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * @param mixed $type |
|
| 143 | + */ |
|
| 144 | + public function setType($type) |
|
| 145 | + { |
|
| 146 | + $this->type = $type; |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * @return string |
|
| 151 | + */ |
|
| 152 | + public function getExpiry() |
|
| 153 | + { |
|
| 154 | + return $this->expiry; |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + /** |
|
| 158 | + * @param string $expiry |
|
| 159 | + */ |
|
| 160 | + public function setExpiry($expiry) |
|
| 161 | + { |
|
| 162 | + $this->expiry = $expiry; |
|
| 163 | + } |
|
| 164 | + #endregion |
|
| 165 | 165 | |
| 166 | 166 | } |
| 167 | 167 | \ No newline at end of file |
@@ -14,14 +14,14 @@ |
||
| 14 | 14 | |
| 15 | 15 | class UserCreationTask extends CreationTaskBase |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * @return IMediaWikiClient |
|
| 19 | - */ |
|
| 20 | - protected function getMediaWikiClient() |
|
| 21 | - { |
|
| 22 | - $oauth = new OAuthUserHelper($this->getTriggerUser(), $this->getDatabase(), $this->getOauthProtocolHelper(), |
|
| 23 | - $this->getSiteConfiguration()); |
|
| 17 | + /** |
|
| 18 | + * @return IMediaWikiClient |
|
| 19 | + */ |
|
| 20 | + protected function getMediaWikiClient() |
|
| 21 | + { |
|
| 22 | + $oauth = new OAuthUserHelper($this->getTriggerUser(), $this->getDatabase(), $this->getOauthProtocolHelper(), |
|
| 23 | + $this->getSiteConfiguration()); |
|
| 24 | 24 | |
| 25 | - return $oauth; |
|
| 26 | - } |
|
| 25 | + return $oauth; |
|
| 26 | + } |
|
| 27 | 27 | } |
| 28 | 28 | \ No newline at end of file |
@@ -15,22 +15,22 @@ |
||
| 15 | 15 | |
| 16 | 16 | class PageDropRequest extends PageCloseRequest |
| 17 | 17 | { |
| 18 | - protected function getTemplate(PdoDatabase $database) |
|
| 19 | - { |
|
| 20 | - return EmailTemplate::getDroppedTemplate(); |
|
| 21 | - } |
|
| 18 | + protected function getTemplate(PdoDatabase $database) |
|
| 19 | + { |
|
| 20 | + return EmailTemplate::getDroppedTemplate(); |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - protected function confirmEmailAlreadySent(Request $request, EmailTemplate $template) |
|
| 24 | - { |
|
| 25 | - return false; |
|
| 26 | - } |
|
| 23 | + protected function confirmEmailAlreadySent(Request $request, EmailTemplate $template) |
|
| 24 | + { |
|
| 25 | + return false; |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - protected function confirmAccountCreated(Request $request, EmailTemplate $template) |
|
| 29 | - { |
|
| 30 | - return false; |
|
| 31 | - } |
|
| 28 | + protected function confirmAccountCreated(Request $request, EmailTemplate $template) |
|
| 29 | + { |
|
| 30 | + return false; |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - protected function sendMail(Request $request, $mailText, User $currentUser, $ccMailingList) |
|
| 34 | - { |
|
| 35 | - } |
|
| 33 | + protected function sendMail(Request $request, $mailText, User $currentUser, $ccMailingList) |
|
| 34 | + { |
|
| 35 | + } |
|
| 36 | 36 | } |
| 37 | 37 | \ No newline at end of file |
@@ -12,21 +12,21 @@ |
||
| 12 | 12 | |
| 13 | 13 | class Page404 extends InternalPageBase |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * Main function for this page, when no actions are called. |
|
| 17 | - */ |
|
| 18 | - protected function main() |
|
| 19 | - { |
|
| 20 | - if (!headers_sent()) { |
|
| 21 | - header("HTTP/1.1 404 Not Found"); |
|
| 22 | - } |
|
| 15 | + /** |
|
| 16 | + * Main function for this page, when no actions are called. |
|
| 17 | + */ |
|
| 18 | + protected function main() |
|
| 19 | + { |
|
| 20 | + if (!headers_sent()) { |
|
| 21 | + header("HTTP/1.1 404 Not Found"); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - $this->skipAlerts(); |
|
| 25 | - $this->setTemplate("404.tpl"); |
|
| 26 | - } |
|
| 24 | + $this->skipAlerts(); |
|
| 25 | + $this->setTemplate("404.tpl"); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - protected function isProtectedPage() |
|
| 29 | - { |
|
| 30 | - return false; |
|
| 31 | - } |
|
| 28 | + protected function isProtectedPage() |
|
| 29 | + { |
|
| 30 | + return false; |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -13,18 +13,18 @@ |
||
| 13 | 13 | |
| 14 | 14 | class PageOtpLogin extends LoginCredentialPageBase |
| 15 | 15 | { |
| 16 | - protected function providerSpecificSetup() |
|
| 17 | - { |
|
| 18 | - $this->setTemplate('login/otp.tpl'); |
|
| 19 | - } |
|
| 16 | + protected function providerSpecificSetup() |
|
| 17 | + { |
|
| 18 | + $this->setTemplate('login/otp.tpl'); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - protected function getProviderCredentials() |
|
| 22 | - { |
|
| 23 | - $otp = WebRequest::postString("otp"); |
|
| 24 | - if ($otp === null || $otp === "") { |
|
| 25 | - throw new ApplicationLogicException("No one-time code specified"); |
|
| 26 | - } |
|
| 21 | + protected function getProviderCredentials() |
|
| 22 | + { |
|
| 23 | + $otp = WebRequest::postString("otp"); |
|
| 24 | + if ($otp === null || $otp === "") { |
|
| 25 | + throw new ApplicationLogicException("No one-time code specified"); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - return $otp; |
|
| 29 | - } |
|
| 28 | + return $otp; |
|
| 29 | + } |
|
| 30 | 30 | } |
| 31 | 31 | \ No newline at end of file |
@@ -16,12 +16,12 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | interface IXmlApiAction extends IRoutedTask, IApiAction |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Method that runs API action |
|
| 21 | - * |
|
| 22 | - * @param DOMElement $apiDocument |
|
| 23 | - * |
|
| 24 | - * @return DOMElement The modified API document |
|
| 25 | - */ |
|
| 26 | - public function executeApiAction(DOMElement $apiDocument); |
|
| 19 | + /** |
|
| 20 | + * Method that runs API action |
|
| 21 | + * |
|
| 22 | + * @param DOMElement $apiDocument |
|
| 23 | + * |
|
| 24 | + * @return DOMElement The modified API document |
|
| 25 | + */ |
|
| 26 | + public function executeApiAction(DOMElement $apiDocument); |
|
| 27 | 27 | } |
@@ -15,10 +15,10 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | interface IJsonApiAction extends IRoutedTask, IApiAction |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * Method that runs API action |
|
| 20 | - * |
|
| 21 | - * @return object|array The modified API document |
|
| 22 | - */ |
|
| 23 | - public function executeApiAction(); |
|
| 18 | + /** |
|
| 19 | + * Method that runs API action |
|
| 20 | + * |
|
| 21 | + * @return object|array The modified API document |
|
| 22 | + */ |
|
| 23 | + public function executeApiAction(); |
|
| 24 | 24 | } |
@@ -16,15 +16,15 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class UnknownAction extends HelpAction implements IXmlApiAction |
| 18 | 18 | { |
| 19 | - public function executeApiAction(DOMElement $apiDocument) |
|
| 20 | - { |
|
| 21 | - $errorText = "Unknown API action specified."; |
|
| 22 | - $errorNode = $this->document->createElement("error", $errorText); |
|
| 23 | - $apiDocument->appendChild($errorNode); |
|
| 19 | + public function executeApiAction(DOMElement $apiDocument) |
|
| 20 | + { |
|
| 21 | + $errorText = "Unknown API action specified."; |
|
| 22 | + $errorNode = $this->document->createElement("error", $errorText); |
|
| 23 | + $apiDocument->appendChild($errorNode); |
|
| 24 | 24 | |
| 25 | - $helpElement = $this->getHelpElement(); |
|
| 26 | - $apiDocument->appendChild($helpElement); |
|
| 25 | + $helpElement = $this->getHelpElement(); |
|
| 26 | + $apiDocument->appendChild($helpElement); |
|
| 27 | 27 | |
| 28 | - return $apiDocument; |
|
| 29 | - } |
|
| 28 | + return $apiDocument; |
|
| 29 | + } |
|
| 30 | 30 | } |
@@ -18,34 +18,34 @@ |
||
| 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 | - { |
|
| 35 | - $helpInfo = "API help can be found at https://github.com/enwikipedia-acc/waca/wiki/API"; |
|
| 36 | - |
|
| 37 | - $help = $this->document->createElement("help"); |
|
| 38 | - $helptext = $this->document->createElement("info", $helpInfo); |
|
| 39 | - $helpactions = $this->document->createElement("actions"); |
|
| 40 | - |
|
| 41 | - foreach (ApiRequestRouter::getActionList() as $action) { |
|
| 42 | - $actionElement = $this->document->createElement("action", $action); |
|
| 43 | - $helpactions->appendChild($actionElement); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - $help->appendChild($helptext); |
|
| 47 | - $help->appendChild($helpactions); |
|
| 48 | - |
|
| 49 | - return $help; |
|
| 50 | - } |
|
| 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 | + $helpInfo = "API help can be found at https://github.com/enwikipedia-acc/waca/wiki/API"; |
|
| 36 | + |
|
| 37 | + $help = $this->document->createElement("help"); |
|
| 38 | + $helptext = $this->document->createElement("info", $helpInfo); |
|
| 39 | + $helpactions = $this->document->createElement("actions"); |
|
| 40 | + |
|
| 41 | + foreach (ApiRequestRouter::getActionList() as $action) { |
|
| 42 | + $actionElement = $this->document->createElement("action", $action); |
|
| 43 | + $helpactions->appendChild($actionElement); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + $help->appendChild($helptext); |
|
| 47 | + $help->appendChild($helpactions); |
|
| 48 | + |
|
| 49 | + return $help; |
|
| 50 | + } |
|
| 51 | 51 | } |