Go to the documentation of this file.
33 parent::__construct(
'Preferences' );
44 $out->disallowUserJs(); # Prevent hijacked user scripts from sniffing passwords etc.
49 if ( $par ==
'reset' ) {
55 $out->addModules(
'mediawiki.special.preferences.ooui' );
56 $out->addModuleStyles( [
57 'mediawiki.special.preferences.styles.ooui',
58 'mediawiki.widgets.TagMultiselectWidget.styles',
60 $out->addModuleStyles(
'oojs-ui-widgets.styles' );
63 if ( $session->get(
'specialPreferencesSaveSuccess' ) ) {
65 $session->remove(
'specialPreferencesSaveSuccess' );
66 $out->addModuleStyles(
'mediawiki.notification.convertmessagebox.styles' );
72 'class' =>
'mw-preferences-messagebox mw-notify-success successbox',
73 'id' =>
'mw-preferences-success',
74 'data-mw-autohide' =>
'false',
76 Html::element(
'p', [], $this->
msg(
'savedprefs' )->text() )
85 $user = $this->
getUser()->getInstanceForUpdate() ?: $this->
getUser();
91 $sectionTitles = $htmlForm->getPreferenceSections();
94 foreach ( $sectionTitles as $key ) {
97 'label' => $htmlForm->getLegend( $key ),
100 $out->addJsConfigVars(
'wgPreferencesTabs', $prefTabs );
112 $preferencesFactory = MediaWikiServices::getInstance()->getPreferencesFactory();
113 $form = $preferencesFactory->getForm( $user,
$context, PreferencesFormOOUI::class );
118 if ( !MediaWikiServices::getInstance()
120 ->userHasRight( $this->
getUser(),
'editmyoptions' )
125 $this->
getOutput()->addWikiMsg(
'prefs-reset-intro' );
131 $htmlForm->setSubmitTextMsg(
'restoreprefs' );
132 $htmlForm->setSubmitDestructive();
133 $htmlForm->setSubmitCallback( [ $this,
'submitReset' ] );
134 $htmlForm->suppressReset();
140 if ( !MediaWikiServices::getInstance()
142 ->userHasRight( $this->
getUser(),
'editmyoptions' )
147 $user = $this->
getUser()->getInstanceForUpdate();
148 $user->resetOptions(
'all', $this->
getContext() );
149 $user->saveSettings();
152 $this->
getRequest()->getSession()->set(
'specialPreferencesSaveSuccess', 1 );
getPageTitle( $subpage=false)
Get a self-referential title object.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
A special page that allows users to change their preferences.
execute( $par)
Default execute method Checks user permissions.
doesWrites()
Indicates whether this special page may perform database writes.
Show an error when a user tries to do something they do not have the necessary permissions for.
An IContextSource implementation which will inherit context from another source but allow individual ...
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getUser()
Shortcut to get the User executing this instance.
getContext()
Gets the context this SpecialPage is executed in.
requireLogin( $reasonMsg='exception-nologin-text', $titleMsg='exception-nologin')
If the user is not logged in, throws UserNotLoggedIn error.
Parent class for all special pages.
getRequest()
Get the WebRequest being used for this instance.
getFormObject( $user, IContextSource $context)
Get the preferences form to use.
Interface for objects which can provide a MediaWiki context on request.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...