summaryrefslogtreecommitdiff
path: root/includes/specials/SpecialPreferences.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/specials/SpecialPreferences.php')
-rw-r--r--includes/specials/SpecialPreferences.php30
1 files changed, 24 insertions, 6 deletions
diff --git a/includes/specials/SpecialPreferences.php b/includes/specials/SpecialPreferences.php
index c6b2bb6b..ecee0bb7 100644
--- a/includes/specials/SpecialPreferences.php
+++ b/includes/specials/SpecialPreferences.php
@@ -35,16 +35,21 @@ class SpecialPreferences extends SpecialPage {
$this->setHeaders();
$this->outputHeader();
$out = $this->getOutput();
- $out->disallowUserJs(); # Prevent hijacked user scripts from sniffing passwords etc.
+ $out->disallowUserJs(); # Prevent hijacked user scripts from sniffing passwords etc.
$user = $this->getUser();
if ( $user->isAnon() ) {
- throw new ErrorPageError( 'prefsnologin', 'prefsnologintext', array( $this->getTitle()->getPrefixedDBkey() ) );
+ throw new ErrorPageError(
+ 'prefsnologin',
+ 'prefsnologintext',
+ array( $this->getTitle()->getPrefixedDBkey() )
+ );
}
$this->checkReadOnly();
if ( $par == 'reset' ) {
$this->showResetForm();
+
return;
}
@@ -52,7 +57,7 @@ class SpecialPreferences extends SpecialPage {
if ( $this->getRequest()->getCheck( 'success' ) ) {
$out->wrapWikiMsg(
- "<div class=\"successbox\"><strong>\n$1\n</strong></div><div id=\"mw-pref-clear\"></div>",
+ "<div class=\"successbox\">\n$1\n</div>",
'savedprefs'
);
}
@@ -64,12 +69,17 @@ class SpecialPreferences extends SpecialPage {
}
private function showResetForm() {
+ if ( !$this->getUser()->isAllowed( 'editmyoptions' ) ) {
+ throw new PermissionsError( 'editmyoptions' );
+ }
+
$this->getOutput()->addWikiMsg( 'prefs-reset-intro' );
- $htmlForm = new HTMLForm( array(), $this->getContext(), 'prefs-restore' );
+ $context = new DerivativeContext( $this->getContext() );
+ $context->setTitle( $this->getTitle( 'reset' ) ); // Reset subpage
+ $htmlForm = new HTMLForm( array(), $context, 'prefs-restore' );
$htmlForm->setSubmitTextMsg( 'restoreprefs' );
- $htmlForm->setTitle( $this->getTitle( 'reset' ) );
$htmlForm->setSubmitCallback( array( $this, 'submitReset' ) );
$htmlForm->suppressReset();
@@ -77,8 +87,12 @@ class SpecialPreferences extends SpecialPage {
}
public function submitReset( $formData ) {
+ if ( !$this->getUser()->isAllowed( 'editmyoptions' ) ) {
+ throw new PermissionsError( 'editmyoptions' );
+ }
+
$user = $this->getUser();
- $user->resetOptions();
+ $user->resetOptions( 'all', $this->getContext() );
$user->saveSettings();
$url = $this->getTitle()->getFullURL( 'success' );
@@ -87,4 +101,8 @@ class SpecialPreferences extends SpecialPage {
return true;
}
+
+ protected function getGroupName() {
+ return 'users';
+ }
}