r46512 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46511‎ | r46512 | r46513 >
Date:01:25, 29 January 2009
Author:soxred93
Status:reverted (Comments)
Tags:
Comment:
Add "check" parameter to action=email
Modified paths:
  • /trunk/phase3/includes/api/ApiBase.php (modified) (history)
  • /trunk/phase3/includes/api/ApiEmailUser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiEmailUser.php
@@ -57,9 +57,12 @@
5858
5959 // Validate target
6060 $targetUser = EmailUserForm::validateEmailTarget( $params['target'] );
 61+ if( isset( $params['check'] ) )
 62+ ($targetUser instanceof User)? $this->dieUsageMsg( array( 'usermailenabled' ) ) : $this->dieUsageMsg( array( 'usermaildisabled' ) );
6163 if ( !( $targetUser instanceof User ) )
6264 $this->dieUsageMsg( array( $targetUser ) );
6365
 66+
6467 // Check permissions
6568 $error = EmailUserForm::getPermissionsError( $wgUser, $params['token'] );
6669 if ( $error )
@@ -77,7 +80,7 @@
7881 $this->getResult()->addValue( null, $this->getModuleName(), $result );
7982 }
8083
81 - public function mustBePosted() { return true; }
 84+ //public function mustBePosted() { return true; }
8285
8386 public function getAllowedParams() {
8487 return array (
@@ -86,6 +89,7 @@
8790 'text' => null,
8891 'token' => null,
8992 'ccme' => false,
 93+ 'check' => null,
9094 );
9195 }
9296
@@ -96,6 +100,7 @@
97101 'text' => 'Mail body',
98102 'token' => 'A token previously acquired via prop=info',
99103 'ccme' => 'Send a copy of this mail to me',
 104+ 'check' => 'Check if the user has email enabled',
100105 );
101106 }
102107
@@ -107,7 +112,8 @@
108113
109114 protected function getExamples() {
110115 return array (
111 - 'api.php?action=emailuser&target=WikiSysop&text=Content'
 116+ 'api.php?action=emailuser&target=WikiSysop&text=Content',
 117+ 'api.php?action=emailuser&target=WikiSysop&check=yes',
112118 );
113119 }
114120
Index: trunk/phase3/includes/api/ApiBase.php
@@ -694,6 +694,7 @@
695695 'ipb_cant_unblock' => array('code' => 'cantunblock', 'info' => "The block you specified was not found. It may have been unblocked already"),
696696 '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"),
697697 'usermaildisabled' => array('code' => 'usermaildisabled', 'info' => "User email has been disabled"),
 698+ 'usermailenabled' => array('code' => 'usermailenabled', 'info' => "User email is enabled"),
698699 'blockedemailuser' => array('code' => 'blockedfrommail', 'info' => "You have been blocked from sending e-mail"),
699700 'notarget' => array('code' => 'notarget', 'info' => "You have not specified a valid target for this action"),
700701 '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"),

Follow-up revisions

RevisionCommit summaryAuthorDate
r46642Revert r46512 (Add "check" parameter to action=email) and its followups r4651...catrope13:20, 31 January 2009

Comments

#Comment by Mr.Z-man (talk | contribs)   02:53, 29 January 2009

This doesn't work very well. It does the check after the check for param existence, so one has to provide something for the token and body text before the check is executed. Also, throwing an error as a positive result seems rather counter-intuitive. It wouldn't be unreasonable for a script to assume that an error really is an error, and not a result.

Also, you forgot to uncomment mustBePosted()

#Comment by Soxred93 (talk | contribs)   03:23, 29 January 2009

Fixed in r46515.

#Comment by Soxred93 (talk | contribs)   05:29, 31 January 2009

That has been fixed

#Comment by Aaron Schulz (talk | contribs)   08:49, 31 January 2009

OK, but why isn't this in userinfo? action=email seems to be intended for emailing someone, not checking email status.

#Comment by Catrope (talk | contribs)   13:21, 31 January 2009

Absolutely right. It's already present in list=users (not meta=userinfo, as that provides info about the current user only), and it belongs there. Reverted in r46642.

Status & tagging log