50 $config = RequestContext::getMain()->getConfig();
51 $this->enableUserEmailBlacklist = $config->get(
'EnableUserEmailBlacklist' );
52 $this->enableUserEmail = $config->get(
'EnableUserEmail' );
54 $this->centralIdLookup = CentralIdLookup::factory();
56 parent::__construct( self::PAGE_NAME,
'',
false );
68 parent::execute(
$par );
71 $out->addModules(
'mediawiki.misc-authed-ooui' );
93 $out->addWikiMsg(
'specialmute-success' );
103 foreach ( $data as $userOption => $value ) {
110 $hookData[$userOption][
'after'] = (bool)$value;
114 Hooks::run(
'SpecialMuteSubmit', [ $hookData ] );
123 return $this->
msg(
'specialmute' )->text();
134 $key = array_search( $this->targetCentralId, $blacklist );
135 if ( $key !==
false ) {
136 unset( $blacklist[$key] );
137 $blacklist = implode(
"\n", $blacklist );
140 $user->setOption( $userOption, $blacklist );
141 $user->saveSettings();
155 $blacklist = implode(
"\n", $blacklist );
158 $user->setOption( $userOption, $blacklist );
159 $user->saveSettings();
167 $form = parent::getForm();
168 $form->setId(
'mw-specialmute-form' );
169 $form->setHeaderText( $this->
msg(
'specialmute-header', $this->target )->parse() );
170 $form->setSubmitTextMsg(
'specialmute-submit' );
171 $form->setSubmitID(
'save' );
182 $this->enableUserEmailBlacklist &&
183 $this->enableUserEmail &&
184 $this->
getUser()->getEmailAuthenticationTimestamp()
186 $fields[
'email-blacklist'] = [
188 'label-message' =>
'specialmute-label-mute-email',
193 Hooks::run(
'SpecialMuteModifyFormFields', [ $this, &$fields ] );
195 if ( count( $fields ) == 0 ) {
196 throw new ErrorPageError(
'specialmute',
'specialmute-error-no-options' );
208 throw new ErrorPageError(
'specialmute',
'specialmute-error-invalid-user' );
211 $this->targetCentralId = $this->centralIdLookup->centralIdFromLocalUser(
$target );
221 return in_array( $this->targetCentralId, $blacklist,
true );
229 $blacklist = $this->
getUser()->getOption( $userOption );
234 return MultiUsernameFilter::splitIds( $blacklist );
The CentralIdLookup service allows for connecting local users with cluster-wide IDs.
An error page which can definitely be safely rendered using the OutputPage.
Special page which uses an HTMLForm to handle processing.
string null $par
The sub-page of the special page.
A special page that allows users to modify their notification preferences.
muteTarget( $userOption)
Mute target.
onSuccess()
Do something exciting on successful processing of the form, most likely to show a confirmation messag...
bool $enableUserEmailBlacklist
unmuteTarget( $userOption)
Un-mute target.
getDisplayFormat()
Get display format for the form.See HTMLForm documentation for available values.1....
execute( $par)
Entry point for special pages.
requiresUnblock()
Whether this action cannot be executed by a blocked user.bool
isTargetBlacklisted( $userOption)
getBlacklist( $userOption)
getDescription()
Returns the name that goes in the <h1> in the special page itself, and also the name that will be l...
getFormFields()
Get an HTMLForm descriptor array.array
onSubmit(array $data, HTMLForm $form=null)
CentralIdLookup $centralIdLookup
getForm()
Get the HTMLForm to control behavior.HTMLForm|null
getOutput()
Get the OutputPage being used for this instance.
requireLogin( $reasonMsg='exception-nologin-text', $titleMsg='exception-nologin')
If the user is not logged in, throws UserNotLoggedIn error.
getUser()
Shortcut to get the User executing this instance.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
getId()
Get the user's ID.