Introduce an "AbortMove" hook
authorVictor Vasiliev <vasilievvv@users.mediawiki.org>
Sat, 8 Dec 2007 18:30:00 +0000 (18:30 +0000)
committerVictor Vasiliev <vasilievvv@users.mediawiki.org>
Sat, 8 Dec 2007 18:30:00 +0000 (18:30 +0000)
RELEASE-NOTES
docs/hooks.txt
includes/SpecialMovepage.php
includes/Title.php

index 3f4ce41..61dd6ae 100644 (file)
@@ -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 ===
 
index 65aa2db..feb14e9 100644 (file)
@@ -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
index cfc434a..148923f 100644 (file)
@@ -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( '<p class="error">' . wfMsg($err) . "</p>\n" );
+                       $errMsg = "";
+                       if( $err == 'hookaborted' ) {
+                               $errMsg = $hookErr;
+                       } else {
+                               $errMsg = '<p class="error">' . wfMsgWikiHtml( $err ) . "</p>\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 );
index 9e361e2..cf8e295 100644 (file)
@@ -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).