Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -483,7 +483,7 @@ |
484 | 484 | 'PopularPagesPage' => 'includes/specials/SpecialPopularpages.php', |
485 | 485 | 'PreferencesForm' => 'includes/specials/SpecialPreferences.php', |
486 | 486 | 'RandomPage' => 'includes/specials/SpecialRandompage.php', |
487 | | - 'RevisionDeleteForm' => 'includes/specials/SpecialRevisiondelete.php', |
| 487 | + 'SpecialRevisionDelete' => 'includes/specials/SpecialRevisiondelete.php', |
488 | 488 | 'RevisionDeleter' => 'includes/specials/SpecialRevisiondelete.php', |
489 | 489 | 'ShortPagesPage' => 'includes/specials/SpecialShortpages.php', |
490 | 490 | 'SpecialAllpages' => 'includes/specials/SpecialAllpages.php', |
Index: trunk/phase3/includes/specials/SpecialRevisiondelete.php |
— | — | @@ -7,93 +7,73 @@ |
8 | 8 | * @ingroup SpecialPage |
9 | 9 | */ |
10 | 10 | |
11 | | -function wfSpecialRevisiondelete( $par = null ) { |
12 | | - global $wgOut, $wgRequest, $wgUser; |
13 | | - |
14 | | - if ( wfReadOnly() ) { |
15 | | - $wgOut->readOnlyPage(); |
16 | | - return; |
| 11 | +class SpecialRevisionDelete extends SpecialPage { |
| 12 | + |
| 13 | + public function __construct() { |
| 14 | + parent::__construct( 'RevisionDelete', 'deleterevision' ); |
| 15 | + $this->includable( false ); |
17 | 16 | } |
18 | | - |
19 | | - # Handle our many different possible input types |
20 | | - $target = $wgRequest->getText( 'target' ); |
21 | | - $oldid = $wgRequest->getArray( 'oldid' ); |
22 | | - $artimestamp = $wgRequest->getArray( 'artimestamp' ); |
23 | | - $logid = $wgRequest->getArray( 'logid' ); |
24 | | - $img = $wgRequest->getArray( 'oldimage' ); |
25 | | - $fileid = $wgRequest->getArray( 'fileid' ); |
26 | | - # For reviewing deleted files... |
27 | | - $file = $wgRequest->getVal( 'file' ); |
28 | | - # If this is a revision, then we need a target page |
29 | | - $page = Title::newFromUrl( $target ); |
30 | | - if( is_null($page) ) { |
31 | | - $wgOut->addWikiMsg( 'undelete-header' ); |
32 | | - return; |
33 | | - } |
34 | | - # Only one target set at a time please! |
35 | | - $i = (bool)$file + (bool)$oldid + (bool)$logid + (bool)$artimestamp + (bool)$fileid + (bool)$img; |
36 | | - if( $i !== 1 ) { |
37 | | - $wgOut->showErrorPage( 'revdelete-toomanytargets-title', 'revdelete-toomanytargets-text' ); |
38 | | - return; |
39 | | - } |
40 | | - # Logs must have a type given |
41 | | - if( $logid && !strpos($page->getDBKey(),'/') ) { |
42 | | - $wgOut->showErrorPage( 'revdelete-nologtype-title', 'revdelete-nologtype-text' ); |
43 | | - return; |
44 | | - } |
45 | | - # Either submit or create our form |
46 | | - $form = new RevisionDeleteForm( $page, $oldid, $logid, $artimestamp, $fileid, $img, $file ); |
47 | | - if( $wgRequest->wasPosted() ) { |
48 | | - $form->submit( $wgRequest ); |
49 | | - } else if( $oldid || $artimestamp ) { |
50 | | - $form->showRevs(); |
51 | | - } else if( $fileid || $img ) { |
52 | | - $form->showImages(); |
53 | | - } else if( $logid ) { |
54 | | - $form->showLogItems(); |
55 | | - } |
56 | | - # Show relevant lines from the deletion log. This will show even if said ID |
57 | | - # does not exist...might be helpful |
58 | | - $wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'delete' ) ) . "</h2>\n" ); |
59 | | - LogEventsList::showLogExtract( $wgOut, 'delete', $page->getPrefixedText() ); |
60 | | - if( $wgUser->isAllowed( 'suppressionlog' ) ){ |
61 | | - $wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'suppress' ) ) . "</h2>\n" ); |
62 | | - LogEventsList::showLogExtract( $wgOut, 'suppress', $page->getPrefixedText() ); |
63 | | - } |
64 | | -} |
65 | 17 | |
66 | | -/** |
67 | | - * Implements the GUI for Revision Deletion. |
68 | | - * @ingroup SpecialPage |
69 | | - */ |
70 | | -class RevisionDeleteForm { |
71 | | - /** |
72 | | - * @param Title $page |
73 | | - * @param array $oldids |
74 | | - * @param array $logids |
75 | | - * @param array $artimestamps |
76 | | - * @param array $fileids |
77 | | - * @param array $img |
78 | | - * @param string $file |
79 | | - */ |
80 | | - function __construct( $page, $oldids, $logids, $artimestamps, $fileids, $img, $file ) { |
81 | | - global $wgUser, $wgOut; |
82 | | - |
83 | | - $this->page = $page; |
| 18 | + public function execute( $par ) { |
| 19 | + global $wgOut, $wgUser, $wgRequest; |
| 20 | + if( wfReadOnly() ) { |
| 21 | + $wgOut->readOnlyPage(); |
| 22 | + return; |
| 23 | + } |
| 24 | + if( !$wgUser->isAllowed( 'deleterevision' ) ) { |
| 25 | + $wgOut->permissionRequired( 'deleterevision' ); |
| 26 | + return; |
| 27 | + } |
| 28 | + $this->skin =& $wgUser->getSkin(); |
| 29 | + # Set title and such |
| 30 | + $this->setHeaders(); |
| 31 | + $this->outputHeader(); |
| 32 | + $this->wasPosted = $wgRequest->wasPosted(); |
| 33 | + # Handle our many different possible input types |
| 34 | + $this->target = $wgRequest->getText( 'target' ); |
| 35 | + $this->oldids = $wgRequest->getArray( 'oldid' ); |
| 36 | + $this->artimestamps = $wgRequest->getArray( 'artimestamp' ); |
| 37 | + $this->logids = $wgRequest->getArray( 'logid' ); |
| 38 | + $this->oldimgs = $wgRequest->getArray( 'oldimage' ); |
| 39 | + $this->fileids = $wgRequest->getArray( 'fileid' ); |
84 | 40 | # For reviewing deleted files... |
85 | | - if( $file ) { |
86 | | - $oimage = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( $page, $file ); |
| 41 | + $this->file = $wgRequest->getVal( 'file' ); |
| 42 | + # If this is a revision, then we need a target page |
| 43 | + $this->page = Title::newFromUrl( $this->target ); |
| 44 | + if( is_null($this->page) ) { |
| 45 | + $wgOut->addWikiMsg( 'undelete-header' ); |
| 46 | + return; |
| 47 | + } |
| 48 | + # Only one target set at a time please! |
| 49 | + $i = (bool)$this->file + (bool)$this->oldids + (bool)$this->logids |
| 50 | + + (bool)$this->artimestamps + (bool)$this->fileids + (bool)$this->oldimgs; |
| 51 | + if( $i !== 1 ) { |
| 52 | + $wgOut->showErrorPage( 'revdelete-toomanytargets-title', 'revdelete-toomanytargets-text' ); |
| 53 | + return; |
| 54 | + } |
| 55 | + # Logs must have a type given |
| 56 | + if( $this->logids && !strpos($this->page->getDBKey(),'/') ) { |
| 57 | + $wgOut->showErrorPage( 'revdelete-nologtype-title', 'revdelete-nologtype-text' ); |
| 58 | + return; |
| 59 | + } |
| 60 | + # Check edit token on submission |
| 61 | + if( $this->wasPosted && !$wgUser->matchEditToken( $wgRequest->getVal('wpEditToken') ) ) { |
| 62 | + $wgOut->addWikiMsg( 'sessionfailure' ); |
| 63 | + return; |
| 64 | + } |
| 65 | + # For reviewing deleted files...show it now if allowed |
| 66 | + if( $this->file ) { |
| 67 | + $oimage = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( $this->page, $this->file ); |
87 | 68 | $oimage->load(); |
88 | 69 | // Check if user is allowed to see this file |
89 | 70 | if( !$oimage->userCan(File::DELETED_FILE) ) { |
90 | 71 | $wgOut->permissionRequired( 'suppressrevision' ); |
91 | 72 | } else { |
92 | | - $this->showFile( $file ); |
| 73 | + $this->showFile( $this->file ); |
93 | 74 | } |
94 | 75 | return; |
95 | 76 | } |
96 | | - $this->skin = $wgUser->getSkin(); |
97 | | - # Give a link to the log for this page |
| 77 | + # Give a link to the logs/hist for this page |
98 | 78 | if( !is_null($this->page) && $this->page->getNamespace() > -1 ) { |
99 | 79 | $links = array(); |
100 | 80 | |
— | — | @@ -112,34 +92,60 @@ |
113 | 93 | # Logs themselves don't have histories or archived revisions |
114 | 94 | $wgOut->setSubtitle( '<p>'.implode($links,' / ').'</p>' ); |
115 | 95 | } |
| 96 | + # Lock the operation and the form context |
| 97 | + $this->secureOperation(); |
| 98 | + # Either submit or create our form |
| 99 | + if( $this->wasPosted ) { |
| 100 | + $this->submit( $wgRequest ); |
| 101 | + } else if( $this->deleteKey == 'oldid' || $this->deleteKey == 'artimestamp' ) { |
| 102 | + $this->showRevs(); |
| 103 | + } else if( $this->deleteKey == 'fileid' || $this->deleteKey == 'oldimage' ) { |
| 104 | + $this->showImages(); |
| 105 | + } else if( $this->deleteKey == 'logid' ) { |
| 106 | + $this->showLogItems(); |
| 107 | + } |
| 108 | + # Show relevant lines from the deletion log. This will show even if said ID |
| 109 | + # does not exist...might be helpful |
| 110 | + $wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'delete' ) ) . "</h2>\n" ); |
| 111 | + LogEventsList::showLogExtract( $wgOut, 'delete', $this->page->getPrefixedText() ); |
| 112 | + if( $wgUser->isAllowed( 'suppressionlog' ) ){ |
| 113 | + $wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'suppress' ) ) . "</h2>\n" ); |
| 114 | + LogEventsList::showLogExtract( $wgOut, 'suppress', $this->page->getPrefixedText() ); |
| 115 | + } |
| 116 | + } |
| 117 | + |
| 118 | + private function secureOperation() { |
| 119 | + global $wgUser; |
| 120 | + $this->deleteKey = ''; |
116 | 121 | // At this point, we should only have one of these |
117 | | - if( $oldids ) { |
118 | | - $this->revisions = $oldids; |
| 122 | + if( $this->oldids ) { |
| 123 | + $this->revisions = $this->oldids; |
119 | 124 | $hide_content_name = array( 'revdelete-hide-text', 'wpHideText', Revision::DELETED_TEXT ); |
120 | | - $this->deleteKey='oldid'; |
121 | | - } else if( $artimestamps ) { |
122 | | - $this->archrevs = $artimestamps; |
| 125 | + $this->deleteKey = 'oldid'; |
| 126 | + } else if( $this->artimestamps ) { |
| 127 | + $this->archrevs = $this->artimestamps; |
123 | 128 | $hide_content_name = array( 'revdelete-hide-text', 'wpHideText', Revision::DELETED_TEXT ); |
124 | | - $this->deleteKey='artimestamp'; |
125 | | - } else if( $img ) { |
126 | | - $this->ofiles = $img; |
| 129 | + $this->deleteKey = 'artimestamp'; |
| 130 | + } else if( $this->oldimgs ) { |
| 131 | + $this->ofiles = $this->oldimgs; |
127 | 132 | $hide_content_name = array( 'revdelete-hide-image', 'wpHideImage', File::DELETED_FILE ); |
128 | | - $this->deleteKey='oldimage'; |
129 | | - } else if( $fileids ) { |
130 | | - $this->afiles = $fileids; |
| 133 | + $this->deleteKey = 'oldimage'; |
| 134 | + } else if( $this->fileids ) { |
| 135 | + $this->afiles = $this->fileids; |
131 | 136 | $hide_content_name = array( 'revdelete-hide-image', 'wpHideImage', File::DELETED_FILE ); |
132 | | - $this->deleteKey='fileid'; |
133 | | - } else if( $logids ) { |
134 | | - $this->events = $logids; |
| 137 | + $this->deleteKey = 'fileid'; |
| 138 | + } else if( $this->logids ) { |
| 139 | + $this->events = $this->logids; |
135 | 140 | $hide_content_name = array( 'revdelete-hide-name', 'wpHideName', LogPage::DELETED_ACTION ); |
136 | | - $this->deleteKey='logid'; |
| 141 | + $this->deleteKey = 'logid'; |
137 | 142 | } |
138 | 143 | // Our checkbox messages depends one what we are doing, |
139 | 144 | // e.g. we don't hide "text" for logs or images |
140 | 145 | $this->checks = array( |
141 | 146 | $hide_content_name, |
142 | 147 | array( 'revdelete-hide-comment', 'wpHideComment', Revision::DELETED_COMMENT ), |
143 | | - array( 'revdelete-hide-user', 'wpHideUser', Revision::DELETED_USER ) ); |
| 148 | + array( 'revdelete-hide-user', 'wpHideUser', Revision::DELETED_USER ) |
| 149 | + ); |
144 | 150 | if( $wgUser->isAllowed('suppressrevision') ) { |
145 | 151 | $this->checks[] = array( 'revdelete-hide-restricted', 'wpHideRestricted', Revision::DELETED_RESTRICTED ); |
146 | 152 | } |
— | — | @@ -167,9 +173,8 @@ |
168 | 174 | /** |
169 | 175 | * This lets a user set restrictions for live and archived revisions |
170 | 176 | */ |
171 | | - function showRevs() { |
172 | | - global $wgOut, $wgUser, $action; |
173 | | - |
| 177 | + private function showRevs() { |
| 178 | + global $wgOut, $wgUser; |
174 | 179 | $UserAllowed = true; |
175 | 180 | |
176 | 181 | $count = ($this->deleteKey=='oldid') ? |
— | — | @@ -204,7 +209,7 @@ |
205 | 210 | continue; |
206 | 211 | } else if( !$revObjs[$revid]->userCan(Revision::DELETED_RESTRICTED) ) { |
207 | 212 | // If a rev is hidden from sysops |
208 | | - if( $action != 'submit') { |
| 213 | + if( !$this->wasPosted ) { |
209 | 214 | $wgOut->permissionRequired( 'suppressrevision' ); |
210 | 215 | return; |
211 | 216 | } |
— | — | @@ -246,7 +251,7 @@ |
247 | 252 | continue; |
248 | 253 | } else if( !$revObjs[$timestamp]->userCan(Revision::DELETED_RESTRICTED) ) { |
249 | 254 | // If a rev is hidden from sysops |
250 | | - if( $action != 'submit') { |
| 255 | + if( !$this->wasPosted ) { |
251 | 256 | $wgOut->permissionRequired( 'suppressrevision' ); |
252 | 257 | return; |
253 | 258 | } |
— | — | @@ -309,15 +314,12 @@ |
310 | 315 | /** |
311 | 316 | * This lets a user set restrictions for archived images |
312 | 317 | */ |
313 | | - function showImages() { |
314 | | - // What is $action doing here??? |
315 | | - global $wgOut, $wgUser, $action, $wgLang; |
316 | | - |
| 318 | + private function showImages() { |
| 319 | + global $wgOut, $wgUser, $wgLang; |
317 | 320 | $UserAllowed = true; |
318 | 321 | |
319 | 322 | $count = ($this->deleteKey=='oldimage') ? count($this->ofiles) : count($this->afiles); |
320 | | - $wgOut->addWikiMsg( 'revdelete-selected', |
321 | | - $this->page->getPrefixedText(), |
| 323 | + $wgOut->addWikiMsg( 'revdelete-selected', $this->page->getPrefixedText(), |
322 | 324 | $wgLang->formatNum($count) ); |
323 | 325 | |
324 | 326 | $bitfields = 0; |
— | — | @@ -349,7 +351,7 @@ |
350 | 352 | continue; |
351 | 353 | } else if( !$filesObjs[$archivename]->userCan(File::DELETED_RESTRICTED) ) { |
352 | 354 | // If a rev is hidden from sysops |
353 | | - if( $action != 'submit' ) { |
| 355 | + if( !$this->wasPosted ) { |
354 | 356 | $wgOut->permissionRequired( 'suppressrevision' ); |
355 | 357 | return; |
356 | 358 | } |
— | — | @@ -380,7 +382,7 @@ |
381 | 383 | continue; |
382 | 384 | } else if( !$filesObjs[$fileid]->userCan(File::DELETED_RESTRICTED) ) { |
383 | 385 | // If a rev is hidden from sysops |
384 | | - if( $action != 'submit' ) { |
| 386 | + if( !$this->wasPosted ) { |
385 | 387 | $wgOut->permissionRequired( 'suppressrevision' ); |
386 | 388 | return; |
387 | 389 | } |
— | — | @@ -443,10 +445,10 @@ |
444 | 446 | /** |
445 | 447 | * This lets a user set restrictions for log items |
446 | 448 | */ |
447 | | - function showLogItems() { |
448 | | - global $wgOut, $wgUser, $action, $wgMessageCache, $wgLang; |
| 449 | + private function showLogItems() { |
| 450 | + global $wgOut, $wgUser, $wgMessageCache, $wgLang; |
| 451 | + $UserAllowed = true; |
449 | 452 | |
450 | | - $UserAllowed = true; |
451 | 453 | $wgOut->addWikiMsg( 'logdelete-selected', $wgLang->formatNum( count($this->events) ) ); |
452 | 454 | |
453 | 455 | $bitfields = 0; |
— | — | @@ -475,7 +477,7 @@ |
476 | 478 | continue; |
477 | 479 | } else if( !LogEventsList::userCan( $logRows[$logid],Revision::DELETED_RESTRICTED) ) { |
478 | 480 | // If an event is hidden from sysops |
479 | | - if( $action != 'submit') { |
| 481 | + if( !$this->wasPosted ) { |
480 | 482 | $wgOut->permissionRequired( 'suppressrevision' ); |
481 | 483 | return; |
482 | 484 | } |
— | — | @@ -731,7 +733,7 @@ |
732 | 734 | /** |
733 | 735 | * @param WebRequest $request |
734 | 736 | */ |
735 | | - function submit( $request ) { |
| 737 | + private function submit( $request ) { |
736 | 738 | global $wgUser, $wgOut; |
737 | 739 | |
738 | 740 | $bitfield = $this->extractBitfield( $request ); |
Index: trunk/phase3/includes/SpecialPage.php |
— | — | @@ -183,7 +183,7 @@ |
184 | 184 | 'Mycontributions' => array( 'SpecialMycontributions' ), |
185 | 185 | 'Mypage' => array( 'SpecialMypage' ), |
186 | 186 | 'Mytalk' => array( 'SpecialMytalk' ), |
187 | | - 'Revisiondelete' => array( 'UnlistedSpecialPage', 'Revisiondelete', 'deleterevision' ), |
| 187 | + 'Revisiondelete' => 'SpecialRevisiondelete', |
188 | 188 | 'Specialpages' => array( 'UnlistedSpecialPage', 'Specialpages' ), |
189 | 189 | 'Userlogout' => array( 'UnlistedSpecialPage', 'Userlogout' ), |
190 | 190 | ); |