Added parameter to SavePreferences hook, contains old user preferences. See my next commit for an implementation of it.

This commit is contained in:
Alexandre Emsenhuber 2008-04-12 19:42:27 +00:00
parent 5c44441dc8
commit c27b4b7b62
2 changed files with 6 additions and 4 deletions

View 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

View 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;
}