MediaWiki r24477 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r24476‎ | r24477 (on ViewVC)‎ | r24478 >
Date:22:52, 30 July 2007
Author:daniel
Status:old
Tags:
Comment:
adding generic hook points to SpecialPreferences
Modified paths:

Diff [purge]

Index: trunk/phase3/docs/hooks.txt
===================================================================
--- trunk/phase3/docs/hooks.txt	(revision 24476)
+++ trunk/phase3/docs/hooks.txt	(revision 24477)
@@ -482,6 +482,10 @@
 $imagePage: ImagePage object ($this)
 $output: $wgOut
 
+'InitPreferencesForm': called at the end of PreferencesForm's constructor
+$form: the PreferencesForm
+$request: the web request to initialized from
+
 'InternalParseBeforeLinks': during Parser's internalParse method before links but
 after noinclude/includeonly/onlyinclude and other processing.
 &$this: Parser object
@@ -574,6 +578,20 @@
 &$obj: RawPage object
 &$text: The text that's going to be the output
 
+'RenderPreferencesForm': called at the end of PreferencesForm::mainPrefsForm
+$form: the PreferencesForm
+$out: output page to render to, probably $wgOut
+
+'ResetPreferences': called at the end of PreferencesForm::resetPrefs
+$form: the PreferencesForm
+$user: the User object to load preferences from
+
+'SavePreferences': called at the end of PreferencesForm::savePreferences; 
+                   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)
+
 'SearchUpdate': Prior to search update completion
 $id : Page id
 $namespace : Page namespace
Index: trunk/phase3/includes/SpecialPreferences.php
===================================================================
--- trunk/phase3/includes/SpecialPreferences.php	(revision 24476)
+++ trunk/phase3/includes/SpecialPreferences.php	(revision 24477)
@@ -97,6 +97,8 @@
 		if ( !preg_match( '/^[a-z\-]*$/', $this->mUserLanguage ) ) {
 			$this->mUserLanguage = 'nolanguage';
 		}
+
+		wfRunHooks( "InitPreferencesForm", array( $this, $request ) );
 	}
 
 	function execute() {
@@ -298,9 +300,17 @@
 			$wgUser->setOption( $tname, $tvalue );
 		}
 		if (!$wgAuth->updateExternalDB($wgUser)) {
-			$this->mainPrefsForm( wfMsg( 'externaldberror' ) );
+			$this->mainPrefsForm( 'error', wfMsg( 'externaldberror' ) );
 			return;
 		}
+
+		$msg = '';
+		if ( !wfRunHooks( "SavePreferences", array( $this, $wgUser, &$msg ) ) ) {
+			print "(($msg))";
+			$this->mainPrefsForm( 'error', $msg ); 
+			return;
+		}
+
 		$wgUser->setCookies();
 		$wgUser->saveSettings();
 
@@ -395,6 +405,8 @@
 				$this->mSearchNs[$i] = $wgUser->getOption( 'searchNs'.$i );
 			}
 		}
+
+		wfRunHooks( "ResetPreferences", array( $this, $wgUser ) );
 	}
 
 	/**
@@ -994,6 +1006,8 @@
 		}
 		$wgOut->addHTML( '</fieldset>' );
 
+		wfRunHooks( "RenderPreferencesForm", array( $this, $wgOut ) );
+
 		$token = htmlspecialchars( $wgUser->editToken() );
 		$skin = $wgUser->getSkin();
 		$wgOut->addHTML( "

Follow-up revisions

Rev.Commit summaryAuthorDate
r24502Merged revisions 24415-24479 via svnmerge from...david22:31, 31 July 2007
r32152Fixed debugging code left in (since r24477)tstarling03:10, 19 March 2008

Status & tagging log

  • 15:20, 12 September 2011 Meno25 (Talk | contribs) changed the status of r24477 [removed: ok added: old]
Personal tools
Namespaces
Variants
Views
Actions
Site
Support
Download
Development
Communication
Toolbox