Pass Context to User::resetOptions
[lhc/web/wiklou.git] / includes / specials / SpecialPreferences.php
index 5fcf9ae..cc7b8fa 100644 (file)
@@ -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\">\n$1\n</div>",
+                               "<div class=\"successbox mw-sp-pref-successbox\">\n$1\n</div>",
                                'savedprefs'
                        );
                }
@@ -64,6 +69,10 @@ 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' );
@@ -77,8 +86,12 @@ class SpecialPreferences extends SpecialPage {
        }
 
        public function submitReset( $formData ) {
+               if ( !$this->getUser()->isAllowed( 'editmyoptions' ) ) {
+                       throw new PermissionsError( 'editmyoptions' );
+               }
+
                $user = $this->getUser();
-               $user->resetOptions( 'all' );
+               $user->resetOptions( 'all', $this->getContext() );
                $user->saveSettings();
 
                $url = $this->getTitle()->getFullURL( 'success' );