From: X! Date: Thu, 29 Jan 2009 01:25:17 +0000 (+0000) Subject: Add "check" parameter to action=email X-Git-Tag: 1.31.0-rc.0~43147 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=a9b78e1db910c9a9ac9306795d224bf7ad0d115f;p=lhc%2Fweb%2Fwiklou.git Add "check" parameter to action=email --- diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index ea18c3246b..c12b1e79af 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -694,6 +694,7 @@ abstract class ApiBase { '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"), 'usermaildisabled' => array('code' => 'usermaildisabled', 'info' => "User email has been disabled"), + 'usermailenabled' => array('code' => 'usermailenabled', 'info' => "User email is enabled"), 'blockedemailuser' => array('code' => 'blockedfrommail', 'info' => "You have been blocked from sending e-mail"), 'notarget' => array('code' => 'notarget', 'info' => "You have not specified a valid target for this action"), 'noemail' => array('code' => 'noemail', 'info' => "The user has not specified a valid e-mail address, or has chosen not to receive e-mail from other users"), diff --git a/includes/api/ApiEmailUser.php b/includes/api/ApiEmailUser.php index 5548b18432..6cfbd7bd3e 100644 --- a/includes/api/ApiEmailUser.php +++ b/includes/api/ApiEmailUser.php @@ -57,9 +57,12 @@ class ApiEmailUser extends ApiBase { // Validate target $targetUser = EmailUserForm::validateEmailTarget( $params['target'] ); + if( isset( $params['check'] ) ) + ($targetUser instanceof User)? $this->dieUsageMsg( array( 'usermailenabled' ) ) : $this->dieUsageMsg( array( 'usermaildisabled' ) ); if ( !( $targetUser instanceof User ) ) $this->dieUsageMsg( array( $targetUser ) ); + // Check permissions $error = EmailUserForm::getPermissionsError( $wgUser, $params['token'] ); if ( $error ) @@ -77,7 +80,7 @@ class ApiEmailUser extends ApiBase { $this->getResult()->addValue( null, $this->getModuleName(), $result ); } - public function mustBePosted() { return true; } + //public function mustBePosted() { return true; } public function getAllowedParams() { return array ( @@ -86,6 +89,7 @@ class ApiEmailUser extends ApiBase { 'text' => null, 'token' => null, 'ccme' => false, + 'check' => null, ); } @@ -96,6 +100,7 @@ class ApiEmailUser extends ApiBase { 'text' => 'Mail body', 'token' => 'A token previously acquired via prop=info', 'ccme' => 'Send a copy of this mail to me', + 'check' => 'Check if the user has email enabled', ); } @@ -107,7 +112,8 @@ class ApiEmailUser extends ApiBase { protected function getExamples() { return array ( - 'api.php?action=emailuser&target=WikiSysop&text=Content' + 'api.php?action=emailuser&target=WikiSysop&text=Content', + 'api.php?action=emailuser&target=WikiSysop&check=yes', ); }