From: Roan Kattouw Date: Tue, 26 Aug 2008 21:34:47 +0000 (+0000) Subject: API: Improvements to action=emailuser: X-Git-Tag: 1.31.0-rc.0~45639 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=34a22d81f5982dee6f3bb3d908b3aafb1657287d;p=lhc%2Fweb%2Fwiklou.git API: Improvements to action=emailuser: * Add two messages from ApiEmailUser to ApiBase::$messageMap * Add email tokens to prop=info --- diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 86aae574b0..ea652fbc0b 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -632,6 +632,9 @@ abstract class ApiBase { 'ipb_already_blocked' => array('code' => 'alreadyblocked', 'info' => "The user you tried to block was already blocked"), 'ipb_blocked_as_range' => array('code' => 'blockedasrange', 'info' => "IP address ``\$1'' was blocked as part of range ``\$2''. You can't unblock the IP invidually, but you can unblock the range as a whole."), 'ipb_cant_unblock' => array('code' => 'cantunblock', 'info' => "The block you specified was not found. It may have been unblocked already"), + 'mailnologin' => array('code' => 'cantsend', 'info' => "You're not logged in or you don't have a confirmed e-mail address, so you can't send e-mail"), + 'blockedemailuser' => array('code' => 'blockedfrommail', 'info' => "You have been blocked from sending e-mail"), + // API-specific messages 'missingparam' => array('code' => 'no$1', 'info' => "The \$1 parameter must be set"), diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php index 5353fcf746..884473eac1 100644 --- a/includes/api/ApiQueryInfo.php +++ b/includes/api/ApiQueryInfo.php @@ -68,7 +68,8 @@ class ApiQueryInfo extends ApiQueryBase { 'protect' => array( 'ApiQueryInfo', 'getProtectToken' ), 'move' => array( 'ApiQueryInfo', 'getMoveToken' ), 'block' => array( 'ApiQueryInfo', 'getBlockToken' ), - 'unblock' => array( 'ApiQueryInfo', 'getUnblockToken' ) + 'unblock' => array( 'ApiQueryInfo', 'getUnblockToken' ), + 'email' => array( 'ApiQueryInfo', 'getEmailToken' ), ); wfRunHooks('APIQueryInfoTokens', array(&$this->tokenFunctions)); return $this->tokenFunctions; @@ -153,6 +154,20 @@ class ApiQueryInfo extends ApiQueryBase { return self::getBlockToken($pageid, $title); } + public static function getEmailToken($pageid, $title) + { + global $wgUser; + if(!$wgUser->canSendEmail() || $wgUser->isBlockedFromEmailUser()) + return false; + + static $cachedEmailToken = null; + if(!is_null($cachedEmailToken)) + return $cachedEmailToken; + + $cachedEmailToken = $wgUser->editToken(); + return $cachedEmailToken; + } + public function execute() { global $wgUser;