<?php
-
/**
- * Created on June 1, 2008
* API for MediaWiki 1.8+
*
+ * Created on June 1, 2008
+ *
* Copyright © 2008 Bryan Tong Minh <Bryan.TongMinh@Gmail.com>
*
* This program is free software; you can redistribute it and/or modify
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
*/
if ( !defined( 'MEDIAWIKI' ) ) {
}
/**
+ * API Module to facilitate sending of emails to users
* @ingroup API
*/
class ApiEmailUser extends ApiBase {
global $wgUser;
$params = $this->extractRequestParams();
- // Check required parameters
- if ( !isset( $params['target'] ) ) {
- $this->dieUsageMsg( array( 'missingparam', 'target' ) );
- }
- if ( !isset( $params['text'] ) ) {
- $this->dieUsageMsg( array( 'missingparam', 'text' ) );
- }
// Validate target
- $targetUser = SpecialEmailuser::getTarget( $params['target'] );
+ $targetUser = SpecialEmailUser::getTarget( $params['target'] );
if ( !( $targetUser instanceof User ) ) {
$this->dieUsageMsg( array( $targetUser ) );
}
// Check permissions and errors
- $error = SpecialEmailuser::getPermissionsError( $wgUser, $params['token'] );
+ $error = SpecialEmailUser::getPermissionsError( $wgUser, $params['token'] );
if ( $error ) {
$this->dieUsageMsg( array( $error ) );
}
'Subject' => $params['subject'],
'CCMe' => $params['ccme'],
);
- $retval = SpecialEmailuser::submit( $data );
+ $retval = SpecialEmailUser::submit( $data );
if ( $retval === true ) {
$result = array( 'result' => 'Success' );
} else {
public function getAllowedParams() {
return array(
- 'target' => null,
+ 'target' => array(
+ ApiBase::PARAM_TYPE => 'string',
+ ApiBase::PARAM_REQUIRED => true
+ ),
'subject' => null,
- 'text' => null,
+ 'text' => array(
+ ApiBase::PARAM_TYPE => 'string',
+ ApiBase::PARAM_REQUIRED => true
+ ),
'token' => null,
'ccme' => false,
);
}
public function getDescription() {
- return array(
- 'Email a user.'
- );
+ return 'Email a user.';
}
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(), array(
array( 'usermaildisabled' ),
- array( 'missingparam', 'target' ),
- array( 'missingparam', 'text' ),
) );
}