Index: trunk/phase3/includes/SpecialMovepage.php |
— | — | @@ -10,25 +10,37 @@ |
11 | 11 | function wfSpecialMovepage( $par = null ) { |
12 | 12 | global $wgUser, $wgOut, $wgRequest, $action; |
13 | 13 | |
14 | | - # Check rights |
15 | | - if ( !$wgUser->isAllowed( 'move' ) ) { |
16 | | - $wgOut->showPermissionsErrorPage( array( $wgUser->isAnon() ? 'movenologintext' : 'movenotallowed' ) ); |
| 14 | + # Check for database lock |
| 15 | + if ( wfReadOnly() ) { |
| 16 | + $wgOut->readOnlyPage(); |
17 | 17 | return; |
18 | 18 | } |
19 | 19 | |
20 | | - # Don't allow blocked users to move pages |
21 | | - if ( $wgUser->isBlocked() ) { |
22 | | - $wgOut->blockedPage(); |
| 20 | + $target = isset( $par ) ? $par : $wgRequest->getVal( 'target' ); |
| 21 | + $oldTitle = $wgRequest->getText( 'wpOldTitle', $target ); |
| 22 | + $newTitle = $wgRequest->getText( 'wpNewTitle' ); |
| 23 | + |
| 24 | + # Variables beginning with 'o' for old article 'n' for new article |
| 25 | + $ot = Title::newFromText( $oldTitle ); |
| 26 | + $nt = Title::newFromText( $newTitle ); |
| 27 | + |
| 28 | + if( is_null( $ot ) ) { |
| 29 | + $wgOut->showErrorPage( 'notargettitle', 'notargettext' ); |
23 | 30 | return; |
24 | 31 | } |
| 32 | + if( !$ot->exists() ) { |
| 33 | + $wgOut->showErrorPage( 'nopagetitle', 'nopagetext' ); |
| 34 | + return; |
| 35 | + } |
25 | 36 | |
26 | | - # Check for database lock |
27 | | - if ( wfReadOnly() ) { |
28 | | - $wgOut->readOnlyPage(); |
| 37 | + # Check rights |
| 38 | + $permErrors = $ot->getUserPermissionsErrors( 'move', $wgUser ); |
| 39 | + if( !empty( $permErrors ) ) { |
| 40 | + $wgOut->showPermissionsErrorPage( $permErrors ); |
29 | 41 | return; |
30 | 42 | } |
31 | 43 | |
32 | | - $f = new MovePageForm( $par ); |
| 44 | + $f = new MovePageForm( $ot, $nt ); |
33 | 45 | |
34 | 46 | if ( 'submit' == $action && $wgRequest->wasPosted() |
35 | 47 | && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { |
— | — | @@ -48,11 +60,11 @@ |
49 | 61 | |
50 | 62 | private $watch = false; |
51 | 63 | |
52 | | - function MovePageForm( $par ) { |
| 64 | + function MovePageForm( $oldTitle, $newTitle ) { |
53 | 65 | global $wgRequest; |
54 | 66 | $target = isset($par) ? $par : $wgRequest->getVal( 'target' ); |
55 | | - $this->oldTitle = $wgRequest->getText( 'wpOldTitle', $target ); |
56 | | - $this->newTitle = $wgRequest->getText( 'wpNewTitle' ); |
| 67 | + $this->oldTitle = $oldTitle; |
| 68 | + $this->newTitle = $newTitle; |
57 | 69 | $this->reason = $wgRequest->getText( 'wpReason' ); |
58 | 70 | if ( $wgRequest->wasPosted() ) { |
59 | 71 | $this->moveTalk = $wgRequest->getBool( 'wpMovetalk', false ); |
— | — | @@ -67,16 +79,7 @@ |
68 | 80 | function showForm( $err, $hookErr = '' ) { |
69 | 81 | global $wgOut, $wgUser; |
70 | 82 | |
71 | | - $ot = Title::newFromURL( $this->oldTitle ); |
72 | | - if( is_null( $ot ) ) { |
73 | | - $wgOut->showErrorPage( 'notargettitle', 'notargettext' ); |
74 | | - return; |
75 | | - } |
76 | | - if( !$ot->exists() ) { |
77 | | - $wgOut->showErrorPage( 'nopagetitle', 'nopagetext' ); |
78 | | - return; |
79 | | - } |
80 | | - |
| 83 | + $ot = $this->oldTitle; |
81 | 84 | $sk = $wgUser->getSkin(); |
82 | 85 | |
83 | 86 | $oldTitleLink = $sk->makeLinkObj( $ot ); |
— | — | @@ -244,11 +247,9 @@ |
245 | 248 | return; |
246 | 249 | } |
247 | 250 | |
248 | | - # Variables beginning with 'o' for old article 'n' for new article |
| 251 | + $ot = $this->oldTitle; |
| 252 | + $nt = $this->newTitle; |
249 | 253 | |
250 | | - $ot = Title::newFromText( $this->oldTitle ); |
251 | | - $nt = Title::newFromText( $this->newTitle ); |
252 | | - |
253 | 254 | # Delete to make way if requested |
254 | 255 | if ( $wgUser->isAllowed( 'delete' ) && $this->deleteAndMove ) { |
255 | 256 | $article = new Article( $nt ); |