From 483f85fcf84d7863b82815c6f700ca6039247e56 Mon Sep 17 00:00:00 2001 From: Victor Vasiliev Date: Sat, 8 Dec 2007 18:30:00 +0000 Subject: [PATCH] Introduce an "AbortMove" hook --- RELEASE-NOTES | 1 + docs/hooks.txt | 6 ++++++ includes/SpecialMovepage.php | 16 ++++++++++++++-- includes/Title.php | 6 ++++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 3f4ce410a5..61dd6ae2a4 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -93,6 +93,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 11810) Localize displayed semicolons * (bug 11657) Support for Thai solar calendar * (bug 943) RSS feed for Recentchangeslinked +* Introduced AbortMove hook === Bug fixes in 1.12 === diff --git a/docs/hooks.txt b/docs/hooks.txt index 65aa2db0be..feb14e92be 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -245,6 +245,12 @@ $password: the password being submitted, not yet checked for validity default is LoginForm::ABORTED. Note that the client may be using a machine API rather than the HTML user interface. +'AbortMove': allows to abort moving an article (title) +$old: old title +$nt: new title +$user: user who is doing the move +$err: error message + 'AbortNewAccount': Return false to cancel account creation. $user: the User object about to be created (read-only, incomplete) $message: out parameter: error message to display on abort diff --git a/includes/SpecialMovepage.php b/includes/SpecialMovepage.php index cfc434ae5f..148923f9cc 100644 --- a/includes/SpecialMovepage.php +++ b/includes/SpecialMovepage.php @@ -65,7 +65,7 @@ class MovePageForm { $this->watch = $wgRequest->getCheck( 'wpWatch' ); } - function showForm( $err ) { + function showForm( $err, $hookErr = '' ) { global $wgOut, $wgUser, $wgContLang; $start = $wgContLang->isRTL() ? 'right' : 'left'; @@ -135,7 +135,13 @@ class MovePageForm { if ( $err != '' ) { $wgOut->setSubtitle( wfMsg( 'formerror' ) ); - $wgOut->addWikiText( '

' . wfMsg($err) . "

\n" ); + $errMsg = ""; + if( $err == 'hookaborted' ) { + $errMsg = $hookErr; + } else { + $errMsg = '

' . wfMsgWikiHtml( $err ) . "

\n"; + } + $wgOut->addHTML( $errMsg ); } $moveTalkChecked = $this->moveTalk ? ' checked="checked"' : ''; @@ -216,6 +222,12 @@ class MovePageForm { return; } + $hookErr = null; + if( !wfRunHooks( 'AbortMove', array( $ot, $nt, $wgUser, &$hookErr ) ) ) { + $this->showForm( 'hookaborted', $hookErr ); + return; + } + $error = $ot->moveTo( $nt, true, $this->reason ); if ( $error !== true ) { $this->showForm( $error ); diff --git a/includes/Title.php b/includes/Title.php index 9e361e233f..cf8e295ad2 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -2182,6 +2182,12 @@ class Title { return 'protectedpage'; } + global $wgUser; + $err = null; + if( !wfRunHooks( 'AbortMove', array( $this, $nt, $wgUser, &$err ) ) ) { + return 'hookaborted'; + } + # The move is allowed only if (1) the target doesn't exist, or # (2) the target is a redirect to the source, and has no history # (so we can undo bad moves right after they're done). -- 2.20.1