43 private $userNameUtils;
46 private $userNamePrefixSearch;
49 private $userOptionsLookup;
61 parent::__construct(
'Emailuser' );
62 $this->userNameUtils = $userNameUtils;
63 $this->userNamePrefixSearch = $userNamePrefixSearch;
64 $this->userOptionsLookup = $userOptionsLookup;
73 if ( !$target instanceof
User ) {
74 return $this->
msg(
'emailuser-title-notarget' )->text();
77 return $this->
msg(
'emailuser-title-target', $target->getName() )->text();
87 'default' => $linkRenderer->makeLink(
91 'label-message' =>
'emailfrom',
92 'id' =>
'mw-emailuser-sender',
97 'default' => $linkRenderer->makeLink(
98 $this->mTargetObj->getUserPage(),
99 $this->mTargetObj->getName()
101 'label-message' =>
'emailto',
102 'id' =>
'mw-emailuser-recipient',
106 'default' => $this->mTargetObj->getName(),
110 'default' => $this->
msg(
'defemailsubject', $user->getName() )->inContentLanguage()->text(),
111 'label-message' =>
'emailsubject',
117 'type' =>
'textarea',
119 'label-message' =>
'emailmessage',
124 'label-message' =>
'emailccme',
125 'default' => $this->userOptionsLookup->getBoolOption( $user,
'ccmeonemails' ),
133 $out->addModuleStyles(
'mediawiki.special' );
135 $this->mTarget = $par ?? $request->getVal(
'wpTarget', $request->getVal(
'target',
'' ) );
155 case 'blockedemailuser':
158 case 'actionthrottledtext':
161 case 'usermaildisabled':
165 [
$title, $msg, $params ] = $error;
175 if ( !$this->mTargetObj instanceof
User ) {
191 return EmailUser::getTarget( $target, $sender );
203 return EmailUser::validateTarget( $target, $sender );
216 return EmailUser::getPermissionsError( $user, $editToken, $config );
225 $htmlForm = HTMLForm::factory(
'ooui', [
230 'label' => $this->
msg(
'emailusername' )->text(),
231 'id' =>
'emailusertarget',
239 ->setSubmitCallback( [ $this,
'sendEmailForm' ] )
240 ->setFormIdentifier(
'userForm' )
241 ->setId(
'askusername' )
242 ->setWrapperLegendMsg(
'emailtarget' )
243 ->setSubmitTextMsg(
'emailusernamesubmit' )
251 if ( !$ret instanceof
User ) {
252 if ( $this->mTarget !=
'' ) {
254 $ret = ( $ret ==
'notarget' ) ?
'emailnotarget' : ( $ret .
'text' );
255 return Status::newFatal( $ret );
264 ->addPreHtml( $this->
msg(
'emailpagetext', $this->mTarget )->parse() )
265 ->setSubmitTextMsg(
'emailsend' )
266 ->setSubmitCallback( [ __CLASS__,
'submit' ] )
267 ->setFormIdentifier(
'sendEmailForm' )
268 ->setWrapperLegendMsg(
'email-legend' )
271 if ( !$this->
getHookRunner()->onEmailUserForm( $htmlForm ) ) {
275 $result = $htmlForm->show();
277 if ( $result ===
true || ( $result instanceof
Status && $result->
isGood() ) ) {
278 $out->setPageTitle( $this->
msg(
'emailsent' ) );
279 $out->addWikiMsg(
'emailsenttext', $this->mTarget );
280 $out->returnToMain(
false, $ret->getUserPage() );
296 return EmailUser::submit( $data, $context );
308 $search = $this->userNameUtils->getCanonical( $search );
314 return $this->userNamePrefixSearch
315 ->search( UserNamePrefixSearch::AUDIENCE_PUBLIC, $search, $limit, $offset );
An error page which can definitely be safely rendered using the OutputPage.
Show an error when a user tries to do something they do not have the necessary permissions for.
A special page that allows users to send e-mails to other users.
static getTarget( $target, User $sender)
Validate target User.
userForm( $name)
Form to ask for target user name.
static getPermissionsError( $user, $editToken, Config $config=null)
Check whether a user is allowed to send email.
static validateTarget( $target, User $sender)
Validate target User.
static submit(array $data, IContextSource $context)
Really send a mail.
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
doesWrites()
Indicates whether this special page may perform database writes.
__construct(UserNameUtils $userNameUtils, UserNamePrefixSearch $userNamePrefixSearch, UserOptionsLookup $userOptionsLookup)
getDescription()
Returns the name that goes in the <h1> in the special page itself, and also the name that will be l...
execute( $par)
Default execute method Checks user permissions.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
getUser()
Shortcut to get the User executing this instance.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getConfig()
Shortcut to get main config object.
getRequest()
Get the WebRequest being used for this instance.
getPageTitle( $subpage=false)
Get a self-referential title object.
isGood()
Returns whether the operation completed and didn't have any error or warnings.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Show an error when the user hits a rate limit.
Shortcut to construct a special page which is unlisted by default.
Show an error when the user tries to do something whilst blocked.
Interface for configuration instances.
Interface for objects which can provide a MediaWiki context on request.