global $wgUser, $wgOut, $wgRequest, $action, $wgOnlySysopMayMove;
# check rights. We don't want newbies to move pages to prevents possible attack
- if ( 0 == $wgUser->getID() or $wgUser->isBlocked() or ($wgOnlySysopMayMove and $wgUser->isNewbie())) {
+ if ( $wgUser->isAnon() or $wgUser->isBlocked() or ($wgOnlySysopMayMove and $wgUser->isNewbie())) {
$wgOut->errorpage( "movenologin", "movenologintext" );
return;
}
$f = new MovePageForm();
- if ( 'success' == $action ) { $f->showSuccess(); }
- else if ( 'submit' == $action && $wgRequest->wasPosted() ) { $f->doSubmit(); }
- else { $f->showForm( '' ); }
+ if ( 'success' == $action ) {
+ $f->showSuccess();
+ } else if ( 'submit' == $action && $wgRequest->wasPosted()
+ && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
+ $f->doSubmit();
+ } else {
+ $f->showForm( '' );
+ }
}
/**
$wgOut->setPagetitle( wfMsg( 'movepage' ) );
- if ( $this->oldTitle == "" ) {
+ if ( $this->oldTitle == '' ) {
$wgOut->errorpage( 'notargettitle', 'notargettext' );
return;
}
+
+ $ot = Title::newFromURL( $this->oldTitle );
+ $ott = $ot->getPrefixedText();
$encOldTitle = htmlspecialchars( $this->oldTitle );
- if( $this->newTitle == "" ) {
+ if( $this->newTitle == '' ) {
# Show the current title as a default
# when the form is first opened.
- $encNewTitle = $encOldTitle;
+ $encNewTitle = $ott;
} else {
$encNewTitle = htmlspecialchars( $this->newTitle );
}
- $ot = Title::newFromURL( $this->oldTitle );
- $ott = $ot->getPrefixedText();
$wgOut->addWikiText( wfMsg( 'movepagetext' ) );
- if ( ! Namespace::isTalk( $ot->getNamespace() ) ) {
+ if ( !$ot->isTalkPage() ) {
$wgOut->addWikiText( wfMsg( 'movepagetalktext' ) );
}
$titleObj = Title::makeTitle( NS_SPECIAL, 'Movepage' );
$action = $titleObj->escapeLocalURL( 'action=submit' );
+ $token = htmlspecialchars( $wgUser->editToken() );
if ( $err != '' ) {
$wgOut->setSubtitle( wfMsg( 'formerror' ) );
</td>
</tr>" );
- if ( ! Namespace::isTalk( $ot->getNamespace() ) ) {
+ if ( ! $ot->isTalkPage() ) {
$wgOut->addHTML( "
<tr>
<td align='right'>
</td>
</tr>
</table>
+ <input type='hidden' name='wpEditToken' value=\"{$token}\" />
</form>\n" );
}
# Variables beginning with 'o' for old article 'n' for new article
# Attempt to move the article
-
$ot = Title::newFromText( $this->oldTitle );
$nt = Title::newFromText( $this->newTitle );
$this->showForm( wfMsg( $error ) );
return;
}
-
+
# Update counters if the article got moved into or out of NS_MAIN namespace
$ons = $ot->getNamespace();
$nns = $nt->getNamespace();
# (1) the checkbox says to,
# (2) the namespaces are not themselves talk namespaces, and of course
# (3) it exists.
-
if ( ( $wgRequest->getVal('wpMovetalk') == 1 ) &&
( ! Namespace::isTalk( $ons ) ) &&
( ! Namespace::isTalk( $nns ) ) ) {
}
# Give back result to user.
-
$titleObj = Title::makeTitle( NS_SPECIAL, 'Movepage' );
$success = $titleObj->getFullURL(
'action=success&oldtitle=' . wfUrlencode( $ot->getPrefixedText() ) .
}
function showSuccess() {
- global $wgOut, $wgUser, $wgRequest, $wgRawHtml;
+ global $wgOut, $wgRequest, $wgRawHtml;
$wgOut->setPagetitle( wfMsg( 'movepage' ) );
$wgOut->setSubtitle( wfMsg( 'pagemovedsub' ) );
$wgOut->addHTML( "\n<p><strong>" . wfMsg( 'talkexists' ) . "</strong></p>\n" );
} else {
$ot = Title::newFromURL( $oldtitle );
- if ( ! Namespace::isTalk( $ot->getNamespace() ) ) {
+ if ( ! $ot->isTalkPage() ) {
$wgOut->addHTML( "\n<p>" . wfMsg( 'talkpagenotmoved', wfMsg( $talkmoved ) ) . "</p>\n" );
}
}
}
}
-?>
+?>
\ No newline at end of file