From c27b4b7b627b265f34d7d9de4e60b3cb0198a2f0 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Sat, 12 Apr 2008 19:42:27 +0000 Subject: [PATCH] Added parameter to SavePreferences hook, contains old user preferences. See my next commit for an implementation of it. --- docs/hooks.txt | 3 ++- includes/SpecialPreferences.php | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index c8856bf632..42ee77f83c 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -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 diff --git a/includes/SpecialPreferences.php b/includes/SpecialPreferences.php index 57e973f8b5..46c0eac09c 100644 --- a/includes/SpecialPreferences.php +++ b/includes/SpecialPreferences.php @@ -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; } -- 2.20.1