r24477 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24476‎ | r24477 | r24478 >
Date:22:52, 30 July 2007
Author:daniel
Status:old
Tags:
Comment:
adding generic hook points to SpecialPreferences
Modified paths:
  • /trunk/phase3/docs/hooks.txt (modified) (history)
  • /trunk/phase3/includes/SpecialPreferences.php (modified) (history)

Diff [purge]

Index: trunk/phase3/docs/hooks.txt
@@ -482,6 +482,10 @@
483483 $imagePage: ImagePage object ($this)
484484 $output: $wgOut
485485
 486+'InitPreferencesForm': called at the end of PreferencesForm's constructor
 487+$form: the PreferencesForm
 488+$request: the web request to initialized from
 489+
486490 'InternalParseBeforeLinks': during Parser's internalParse method before links but
487491 after noinclude/includeonly/onlyinclude and other processing.
488492 &$this: Parser object
@@ -574,6 +578,20 @@
575579 &$obj: RawPage object
576580 &$text: The text that's going to be the output
577581
 582+'RenderPreferencesForm': called at the end of PreferencesForm::mainPrefsForm
 583+$form: the PreferencesForm
 584+$out: output page to render to, probably $wgOut
 585+
 586+'ResetPreferences': called at the end of PreferencesForm::resetPrefs
 587+$form: the PreferencesForm
 588+$user: the User object to load preferences from
 589+
 590+'SavePreferences': called at the end of PreferencesForm::savePreferences;
 591+ returning false prevents the preferences from being saved.
 592+$form: the PreferencesForm
 593+$user: the User object to save preferences to
 594+$message: change this to set an error message (ignored if the hook does notreturn fals)
 595+
578596 'SearchUpdate': Prior to search update completion
579597 $id : Page id
580598 $namespace : Page namespace
Index: trunk/phase3/includes/SpecialPreferences.php
@@ -97,6 +97,8 @@
9898 if ( !preg_match( '/^[a-z\-]*$/', $this->mUserLanguage ) ) {
9999 $this->mUserLanguage = 'nolanguage';
100100 }
 101+
 102+ wfRunHooks( "InitPreferencesForm", array( $this, $request ) );
101103 }
102104
103105 function execute() {
@@ -298,9 +300,17 @@
299301 $wgUser->setOption( $tname, $tvalue );
300302 }
301303 if (!$wgAuth->updateExternalDB($wgUser)) {
302 - $this->mainPrefsForm( wfMsg( 'externaldberror' ) );
 304+ $this->mainPrefsForm( 'error', wfMsg( 'externaldberror' ) );
303305 return;
304306 }
 307+
 308+ $msg = '';
 309+ if ( !wfRunHooks( "SavePreferences", array( $this, $wgUser, &$msg ) ) ) {
 310+ print "(($msg))";
 311+ $this->mainPrefsForm( 'error', $msg );
 312+ return;
 313+ }
 314+
305315 $wgUser->setCookies();
306316 $wgUser->saveSettings();
307317
@@ -395,6 +405,8 @@
396406 $this->mSearchNs[$i] = $wgUser->getOption( 'searchNs'.$i );
397407 }
398408 }
 409+
 410+ wfRunHooks( "ResetPreferences", array( $this, $wgUser ) );
399411 }
400412
401413 /**
@@ -994,6 +1006,8 @@
9951007 }
9961008 $wgOut->addHTML( '</fieldset>' );
9971009
 1010+ wfRunHooks( "RenderPreferencesForm", array( $this, $wgOut ) );
 1011+
9981012 $token = htmlspecialchars( $wgUser->editToken() );
9991013 $skin = $wgUser->getSkin();
10001014 $wgOut->addHTML( "

Follow-up revisions

RevisionCommit 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