Added parameter to SavePreferences hook, contains old user preferences. See my next...
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sat, 12 Apr 2008 19:42:27 +0000 (19:42 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sat, 12 Apr 2008 19:42:27 +0000 (19:42 +0000)
docs/hooks.txt
includes/SpecialPreferences.php

index c8856bf..42ee77f 100644 (file)
@@ -912,7 +912,8 @@ $user: the User object to load preferences from
                    returning false prevents the preferences from being saved.
 $form: the PreferencesForm
 $user: the User object to save preferences to
-$message: change this to set an error message (ignored if the hook does notreturn fals)
+$message: change this to set an error message (ignored if the hook does not return false)
+$old: old preferences of the user
 
 'SearchUpdate': Prior to search update completion
 $id : Page id
index 57e973f..46c0eac 100644 (file)
@@ -236,6 +236,7 @@ class PreferencesForm {
                        }
                }
                $wgUser->setRealName( $this->mRealName );
+               $oldOptions = $wgUser->mOptions;
 
                if( $wgUser->getOption( 'language' ) !== $this->mUserLanguage ) {
                        $needRedirect = true;
@@ -336,13 +337,13 @@ class PreferencesForm {
                        }
                }
 
-               if (!$wgAuth->updateExternalDB($wgUser)) {
+               if( !$wgAuth->updateExternalDB( $wgUser ) ){
                        $this->mainPrefsForm( 'error', wfMsg( 'externaldberror' ) );
                        return;
                }
 
                $msg = '';
-               if ( !wfRunHooks( 'SavePreferences', array( $this, $wgUser, &$msg ) ) ) {
+               if ( !wfRunHooks( 'SavePreferences', array( $this, $wgUser, &$msg, $oldOptions ) ) ) {
                        $this->mainPrefsForm( 'error', $msg );
                        return;
                }
@@ -352,7 +353,7 @@ class PreferencesForm {
 
                if( $needRedirect && $error === false ) {
                        $title = SpecialPage::getTitleFor( 'Preferences' );
-                       $wgOut->redirect($title->getFullURL('success'));
+                       $wgOut->redirect( $title->getFullURL( 'success' ) );
                        return;
                }