36 if ( !( $targetUser instanceof
User ) ) {
37 switch ( $targetUser ) {
51 $this->
dieWithError( [
'apierror-unknownerror', $targetUser ] );
66 'Target' => $targetUser->getName(),
67 'Text' => $params[
'text'],
68 'Subject' => $params[
'subject'],
69 'CCMe' => $params[
'ccme'],
72 if ( !$retval instanceof
Status ) {
74 $retval = Status::newFatal(
'hookaborted' );
77 $result = array_filter( [
78 'result' => $retval->isGood() ?
'Success' : ( $retval->isOK() ?
'Warnings' :
'Failure' ),
97 ParamValidator::PARAM_TYPE =>
'string',
98 ParamValidator::PARAM_REQUIRED =>
true
101 ParamValidator::PARAM_TYPE =>
'string',
102 ParamValidator::PARAM_REQUIRED =>
true
105 ParamValidator::PARAM_TYPE =>
'text',
106 ParamValidator::PARAM_REQUIRED =>
true
118 'action=emailuser&target=WikiSysop&text=Content&token=123ABC'
119 =>
'apihelp-emailuser-example-email',
124 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Email';
This abstract class implements many basic API functions, and is the base of all API classes.
dieWithError( $msg, $code=null, $data=null, $httpCode=0)
Abort execution with an error.
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
getModuleName()
Get the name of the module being executed by this instance.
API Module to facilitate sending of emails to users.
needsToken()
Returns the token type this module requires in order to execute.
getHelpUrls()
Return links to more detailed help pages about the module.
isWriteMode()
Indicates whether this module requires write mode.
mustBePosted()
Indicates whether this module must be called with a POST request.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
getExamplesMessages()
Returns usage examples for this module.
getContext()
Get the base IContextSource object.
static getTarget( $target, User $sender)
Validate target User.
static getPermissionsError( $user, $editToken, Config $config=null)
Check whether a user is allowed to send email.
static submit(array $data, IContextSource $context)
Really send a mail.
Generic operation result class Has warning/error list, boolean status and arbitrary value.