private function getIdentityCache() { global $oauthConsumerToken, $oauthSecretToken, $oauthBaseUrl, $oauthBaseUrlInternal; try { $util = new OAuthUtility($oauthConsumerToken, $oauthSecretToken, $oauthBaseUrl, $oauthBaseUrlInternal); $this->identityCache = $util->getIdentity($this->oauthaccesstoken, $this->oauthaccesssecret); $this->oauthidentitycache = serialize($this->identityCache); $this->dbObject->prepare("UPDATE user SET oauthidentitycache = :identity WHERE id = :id;")->execute(array(":id" => $this->id, ":identity" => $this->oauthidentitycache)); } catch (UnexpectedValueException $ex) { $this->identityCache = null; $this->oauthidentitycache = null; $this->dbObject->prepare("UPDATE user SET oauthidentitycache = null WHERE id = :id;")->execute(array(":id" => $this->id)); SessionAlert::warning("OAuth error getting identity from MediaWiki: " . $ex->getMessage()); } }
if ($request->getStatus() == "Closed" && $logTime < $oneweek && !User::getCurrent($database)->isAdmin()) { throw new TransactionException("Only administrators and checkusers can reserve a request that has been closed for over a week.", "Error"); } if ($request->getReserved() != 0 && $request->getReserved() != User::getCurrent($database)->getId()) { throw new TransactionException("Request is already reserved by {$request->getReservedObject()->getUsername()}.", "Error"); } if ($request->getReserved() == 0) { // Check the number of requests a user has reserved already $doubleReserveCountQuery = $database->prepare("SELECT COUNT(*) FROM request WHERE reserved = :userid;"); $doubleReserveCountQuery->bindValue(":userid", User::getCurrent($database)->getId()); $doubleReserveCountQuery->execute(); $doubleReserveCount = $doubleReserveCountQuery->fetchColumn(); $doubleReserveCountQuery->closeCursor(); // User already has at least one reserved. if ($doubleReserveCount != 0) { SessionAlert::warning("You have multiple requests reserved!"); } // Is the request closed? if (!isset($_GET['confclosed'])) { if ($request->getStatus() == "Closed") { // FIXME: bootstrappify properly throw new TransactionException('This request is currently closed. Are you sure you wish to reserve it?<br /><ul><li><a href="' . $_SERVER["REQUEST_URI"] . '&confclosed=yes">Yes, reserve this closed request</a></li><li><a href="' . $baseurl . '/acc.php">No, return to main request interface</a></li></ul>', "Request closed", "alert-info"); } } $request->setReserved(User::getCurrent($database)->getId()); $request->save(); Logger::reserve($database, $request); Notification::requestReserved($request); SessionAlert::success("Reserved request {$request->getId()}."); } header("Location: {$baseurl}/acc.php?action=zoom&id={$request->getId()}");