Index: trunk/phase3/includes/api/ApiMove.php |
— | — | @@ -71,7 +71,18 @@ |
72 | 72 | if(!$toTitle) |
73 | 73 | $this->dieUsageMsg(array('invalidtitle', $params['to'])); |
74 | 74 | $toTalk = $toTitle->getTalkPage(); |
75 | | - |
| 75 | + |
| 76 | + if ( $toTitle->getNamespace() == NS_FILE |
| 77 | + && !RepoGroup::singleton()->getLocalRepo()->findFile( $toTitle ) |
| 78 | + && wfFindFile( $toTitle ) ) |
| 79 | + { |
| 80 | + if ( !$params['ignorewarnings'] && $wgUser->isAllowed( 'reupload-shared' ) ) { |
| 81 | + $this->dieUsageMsg(array('sharedfile-exists')); |
| 82 | + } elseif ( !$wgUser->isAllowed( 'reupload-shared' ) ) { |
| 83 | + $this->dieUsageMsg(array('cantoverwrite-sharedfile')); |
| 84 | + } |
| 85 | + } |
| 86 | + |
76 | 87 | # Move the page |
77 | 88 | $hookErr = null; |
78 | 89 | $retval = $fromTitle->moveTo($toTitle, true, $params['reason'], !$params['noredirect']); |
— | — | @@ -171,7 +182,8 @@ |
172 | 183 | 'movesubpages' => false, |
173 | 184 | 'noredirect' => false, |
174 | 185 | 'watch' => false, |
175 | | - 'unwatch' => false |
| 186 | + 'unwatch' => false, |
| 187 | + 'ignorewarnings' => false |
176 | 188 | ); |
177 | 189 | } |
178 | 190 | |
— | — | @@ -186,7 +198,8 @@ |
187 | 199 | 'movesubpages' => 'Move subpages, if applicable', |
188 | 200 | 'noredirect' => 'Don\'t create a redirect', |
189 | 201 | 'watch' => 'Add the page and the redirect to your watchlist', |
190 | | - 'unwatch' => 'Remove the page and the redirect from your watchlist' |
| 202 | + 'unwatch' => 'Remove the page and the redirect from your watchlist', |
| 203 | + 'ignorewarnings' => 'Ignore any warnings' |
191 | 204 | ); |
192 | 205 | } |
193 | 206 | |
Index: trunk/phase3/includes/api/ApiBase.php |
— | — | @@ -846,6 +846,8 @@ |
847 | 847 | 'import-noarticle' => array('code' => 'badinterwiki', 'info' => 'Invalid interwiki title specified'), |
848 | 848 | 'importbadinterwiki' => array('code' => 'badinterwiki', 'info' => 'Invalid interwiki title specified'), |
849 | 849 | 'import-unknownerror' => array('code' => 'import-unknownerror', 'info' => "Unknown error on import: ``\$1''"), |
| 850 | + 'cantoverwrite-sharedfile' => array('code' => 'cantoverwrite-sharedfile', 'info' => 'The target file exists on a shared repository and you do not have permission to override it'), |
| 851 | + 'sharedfile-exists' => array('code' => 'fileexists-sharedrepo-perm', 'info' => 'The target file exists on a shared repository. Use the ignorewarnings parameter to override it.'), |
850 | 852 | |
851 | 853 | // ApiEditPage messages |
852 | 854 | 'noimageredirect-anon' => array('code' => 'noimageredirect-anon', 'info' => "Anonymous users can't create image redirects"), |
Index: trunk/phase3/includes/specials/SpecialMovepage.php |
— | — | @@ -58,7 +58,7 @@ |
59 | 59 | class MovePageForm { |
60 | 60 | var $oldTitle, $newTitle; # Objects |
61 | 61 | var $reason; # Text input |
62 | | - var $moveTalk, $deleteAndMove, $moveSubpages, $fixRedirects, $leaveRedirect; # Checks |
| 62 | + var $moveTalk, $deleteAndMove, $moveSubpages, $fixRedirects, $leaveRedirect, $moveOverShared; # Checks |
63 | 63 | |
64 | 64 | private $watch = false; |
65 | 65 | |
— | — | @@ -79,6 +79,7 @@ |
80 | 80 | } |
81 | 81 | $this->moveSubpages = $wgRequest->getBool( 'wpMovesubpages', false ); |
82 | 82 | $this->deleteAndMove = $wgRequest->getBool( 'wpDeleteAndMove' ) && $wgRequest->getBool( 'wpConfirm' ); |
| 83 | + $this->moveOverShared = $wgRequest->getBool( 'wpMoveOverSharedFile', false ); |
83 | 84 | $this->watch = $wgRequest->getCheck( 'wpWatch' ); |
84 | 85 | } |
85 | 86 | |
— | — | @@ -136,6 +137,12 @@ |
137 | 138 | $confirm = false; |
138 | 139 | } |
139 | 140 | |
| 141 | + if ( !empty($err) && $err[0] == 'file-exists-sharedrepo' && $wgUser->isAllowed( 'reupload-shared' ) ) { |
| 142 | + $wgOut->addWikiMsg( 'move-over-sharedrepo', $newTitle->getPrefixedText() ); |
| 143 | + $submitVar = 'wpMoveOverSharedFile'; |
| 144 | + $err = ''; |
| 145 | + } |
| 146 | + |
140 | 147 | $oldTalk = $this->oldTitle->getTalkPage(); |
141 | 148 | $considerTalk = ( !$this->oldTitle->isTalkPage() && $oldTalk->exists() ); |
142 | 149 | |
— | — | @@ -351,6 +358,17 @@ |
352 | 359 | return; |
353 | 360 | } |
354 | 361 | |
| 362 | + # Show a warning if the target file exists on a shared repo |
| 363 | + if ( $nt->getNamespace() == NS_FILE |
| 364 | + && !( $this->moveOverShared && $wgUser->isAllowed( 'reupload-shared' ) ) |
| 365 | + && !RepoGroup::singleton()->getLocalRepo()->findFile( $nt ) |
| 366 | + && wfFindFile( $nt ) ) |
| 367 | + { |
| 368 | + $this->showForm( array('file-exists-sharedrepo') ); |
| 369 | + return; |
| 370 | + |
| 371 | + } |
| 372 | + |
355 | 373 | if ( $wgUser->isAllowed( 'suppressredirect' ) ) { |
356 | 374 | $createRedirect = $this->leaveRedirect; |
357 | 375 | } else { |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -3109,6 +3109,10 @@ |
3110 | 3110 | 'move-leave-redirect' => 'Leave a redirect behind', |
3111 | 3111 | 'protectedpagemovewarning' => "'''Warning:''' This page has been locked so that only users with administrator privileges can move it.", |
3112 | 3112 | 'semiprotectedpagemovewarning' => "'''Note:''' This page has been locked so that only registered users can move it.", |
| 3113 | +'move-over-sharedrepo' => '==File exists== |
| 3114 | +[[:$1]] exists on a shared repository. Moving a file to this title will override the shared file.', |
| 3115 | +'file-exists-sharedrepo' => 'The file name chosen is already in use on a shared repository. |
| 3116 | +Please choose another name.', |
3113 | 3117 | |
3114 | 3118 | # Export |
3115 | 3119 | 'export' => 'Export pages', |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -591,6 +591,9 @@ |
592 | 592 | * (bug 21006) maintenance/updateArticleCount.php now works again on PostgreSQL |
593 | 593 | * (bug 19319) Add activeusers-intro message at top of SpecialActiveUsers page |
594 | 594 | * (bug 21255) Fixed hostname construction for DNSBL checking |
| 595 | +* (bug 18019) Users are now warned when moving a file to a name in use on a |
| 596 | + shared repository and only users with the 'reupload-shared' permission can |
| 597 | + complete the move. |
595 | 598 | |
596 | 599 | == API changes in 1.16 == |
597 | 600 | |