Index: trunk/phase3/includes/SpecialRevisiondelete.php |
— | — | @@ -40,259 +40,52 @@ |
41 | 41 | * @param Title $page |
42 | 42 | * @param int $oldid |
43 | 43 | */ |
44 | | - function __construct( $request, $oldid, $logid, $arid, $fileid ) { |
| 44 | + function __construct( $request ) { |
45 | 45 | global $wgUser; |
46 | 46 | |
47 | | - $target = $request->getText( 'target' ); |
48 | | - $this->page = Title::newFromUrl( $target, false ); |
| 47 | + $target = $request->getVal( 'target' ); |
| 48 | + $this->page = Title::newFromUrl( $target ); |
49 | 49 | |
50 | 50 | $this->revisions = $request->getIntArray( 'oldid', array() ); |
51 | | - $this->events = $request->getIntArray( 'logid', array() ); |
52 | | - $this->archrevs = $request->getIntArray( 'arid', array() ); |
53 | | - $this->files = $request->getIntArray( 'fileid', array() ); |
54 | 51 | |
55 | 52 | $this->skin = $wgUser->getSkin(); |
56 | | - |
57 | | - // log events don't have text to hide, but hiding the page name is useful |
58 | | - if ( $fileid ) { |
59 | | - $hide_text_name = array( 'revdelete-hide-image', 'wpHideImage', Image::DELETED_FILE ); |
60 | | - $this->deletetype='file'; |
61 | | - } else if ( $logid ) { |
62 | | - $hide_text_name = array( 'revdelete-hide-name', 'wpHideName', LogViewer::DELETED_ACTION ); |
63 | | - $this->deletetype='log'; |
64 | | - } else { |
65 | | - $hide_text_name = array( 'revdelete-hide-text', 'wpHideText', Revision::DELETED_TEXT ); |
66 | | - if ( $arid ) $this->deletetype='ar'; |
67 | | - else $this->deletetype='old'; |
68 | | - } |
69 | 53 | $this->checks = array( |
70 | | - $hide_text_name, |
| 54 | + array( 'revdelete-hide-text', 'wpHideText', Revision::DELETED_TEXT ), |
71 | 55 | array( 'revdelete-hide-comment', 'wpHideComment', Revision::DELETED_COMMENT ), |
72 | 56 | array( 'revdelete-hide-user', 'wpHideUser', Revision::DELETED_USER ), |
73 | 57 | array( 'revdelete-hide-restricted', 'wpHideRestricted', Revision::DELETED_RESTRICTED ) ); |
74 | 58 | } |
75 | 59 | |
76 | 60 | /** |
77 | | - * This sets any fields that are true to a bitfield to true on a given bitfield |
78 | | - * @param $bitfield, running bitfield |
79 | | - * @param $nbitfield, new bitfiled |
80 | | - */ |
81 | | - function setBitfield( $bitfield, $nbitfield ) { |
82 | | - if ( $nbitfield & Revision::DELETED_TEXT) $bitfield |= Revision::DELETED_TEXT; |
83 | | - if ( $nbitfield & LogViewer::DELETED_ACTION) $bitfield |= LogViewer::DELETED_ACTION; |
84 | | - if ( $nbitfield & Image::DELETED_FILE) $bitfield |= Image::DELETED_FILE; |
85 | | - if ( $nbitfield & Revision::DELETED_COMMENT) $bitfield |= Revision::DELETED_COMMENT; |
86 | | - if ( $nbitfield & Revision::DELETED_USER) $bitfield |= Revision::DELETED_USER; |
87 | | - if ( $nbitfield & Revision::DELETED_RESTRICTED) $bitfield |= Revision::DELETED_RESTRICTED; |
88 | | - return $bitfield; |
89 | | - } |
90 | | - |
91 | | - /** |
92 | | - * This lets a user set restrictions for live and archived revisions |
93 | 61 | * @param WebRequest $request |
94 | 62 | */ |
95 | | - function showRevs( $request ) { |
96 | | - global $wgOut, $wgUser, $action; |
| 63 | + function show( $request ) { |
| 64 | + global $wgOut, $wgUser; |
97 | 65 | |
98 | | - $UserAllowed = true; |
99 | | - $wgOut->addWikiText( wfMsgExt( 'revdelete-selected', 'parseinline', $this->page->getPrefixedText(), count( $this->revisions) ) ); |
100 | | - |
101 | | - $bitfields = 0; |
102 | | - $wgOut->addHtml( "<ul>" ); |
103 | | - if ( $this->deletetype=='old') { |
104 | | - foreach( $this->revisions as $revid ) { |
105 | | - $rev = Revision::newFromTitle( $this->page, $revid ); |
106 | | - // Hiding top revisison is bad |
107 | | - if( !isset( $rev ) || $rev->isCurrent() ) { |
108 | | - $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' ); |
109 | | - return; |
110 | | - } else if( !$rev->userCan(Revision::DELETED_RESTRICTED) ) { |
111 | | - // If a rev is hidden from sysops |
112 | | - if ( $action != 'submit') { |
113 | | - $wgOut->permissionRequired( 'hiderevision' ); return; |
114 | | - } |
115 | | - $UserAllowed=false; |
116 | | - } |
117 | | - $wgOut->addHtml( $this->historyLine( $rev ) ); |
118 | | - $bitfields = $this->setBitfield( $bitfields, $rev->mDeleted ); |
119 | | - } |
120 | | - } else if ( $this->deletetype=='ar') { |
121 | | - $archive = new PageArchive( $this->page ); |
122 | | - foreach( $this->archrevs as $revid ) { |
123 | | - $rev = $archive->getRevision('', $revid ); |
124 | | - if( !isset( $rev ) ) { |
125 | | - $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' ); |
126 | | - return; |
127 | | - } else if( !$rev->userCan(Revision::DELETED_RESTRICTED) ) { |
128 | | - //if a rev is hidden from sysops |
129 | | - if ( $action != 'submit') { |
130 | | - $wgOut->permissionRequired( 'hiderevision' ); return; |
131 | | - } |
132 | | - $UserAllowed=false; |
133 | | - } |
134 | | - $wgOut->addHtml( $this->historyLine( $rev ) ); |
135 | | - $bitfields = $this->setBitfield( $bitfields, $rev->mDeleted ); |
136 | | - } |
137 | | - } |
138 | | - $wgOut->addHtml( "</ul>" ); |
| 66 | + $wgOut->addWikiText( wfMsg( 'revdelete-selected', $this->page->getPrefixedText() ) ); |
139 | 67 | |
140 | | - $wgOut->addWikiText( wfMsgHtml( 'revdelete-text' ) ); |
141 | | - //Normal sysops can always see what they did, but can't always change it |
142 | | - if ( !$UserAllowed ) return; |
143 | | - |
144 | | - $items = array( |
145 | | - wfInputLabel( wfMsgHtml( 'revdelete-log' ), 'wpReason', 'wpReason', 60 ), |
146 | | - wfSubmitButton( wfMsgHtml( 'revdelete-submit' ) ) ); |
147 | | - $hidden = array( |
148 | | - wfHidden( 'wpEditToken', $wgUser->editToken() ), |
149 | | - wfHidden( 'target', $this->page->getPrefixedText() ), |
150 | | - wfHidden( 'type', $this->deletetype ) ); |
151 | | - if( $this->deletetype=='old' ) { |
152 | | - foreach( $this->revisions as $revid ) { |
153 | | - $hidden[] = wfHidden( 'oldid[]', $revid ); |
154 | | - } |
155 | | - } else if( $this->deletetype=='ar' ) { |
156 | | - foreach( $this->archrevs as $revid ) { |
157 | | - $hidden[] = wfHidden( 'arid[]', $revid ); |
158 | | - } |
159 | | - } |
160 | | - $special = SpecialPage::getTitleFor( 'Revisiondelete' ); |
161 | | - $wgOut->addHtml( wfElement( 'form', array( |
162 | | - 'method' => 'post', |
163 | | - 'action' => $special->getLocalUrl( 'action=submit' ) ), |
164 | | - null ) ); |
165 | | - |
166 | | - $wgOut->addHtml( '<fieldset><legend>' . wfMsgHtml( 'revdelete-legend' ) . '</legend>' ); |
167 | | - // FIXME: all items checked for just one rev are checked, even if not set for the others |
168 | | - foreach( $this->checks as $item ) { |
169 | | - list( $message, $name, $field ) = $item; |
170 | | - $wgOut->addHtml( '<div>' . |
171 | | - wfCheckLabel( wfMsgHtml( $message), $name, $name, $bitfields & $field ) . |
172 | | - '</div>' ); |
173 | | - } |
174 | | - $wgOut->addHtml( '</fieldset>' ); |
175 | | - foreach( $items as $item ) { |
176 | | - $wgOut->addHtml( '<p>' . $item . '</p>' ); |
177 | | - } |
178 | | - foreach( $hidden as $item ) { |
179 | | - $wgOut->addHtml( $item ); |
180 | | - } |
181 | | - |
182 | | - $wgOut->addHtml( '</form>' ); |
183 | | - } |
184 | | - |
185 | | - /** |
186 | | - * This lets a user set restrictions for archived images |
187 | | - * @param WebRequest $request |
188 | | - */ |
189 | | - function showImages( $request ) { |
190 | | - global $wgOut, $wgUser, $action; |
191 | | - |
192 | | - $UserAllowed = true; |
193 | | - $wgOut->addWikiText( wfMsgExt( 'revdelete-selected', 'parseline', $this->page->getPrefixedText(), count( $this->files ) ) ); |
194 | | - |
195 | | - $bitfields = 0; |
196 | 68 | $wgOut->addHtml( "<ul>" ); |
197 | | - foreach( $this->files as $fileid ) { |
198 | | - $file = new FSarchivedFile( $this->page, $fileid ); |
199 | | - if( !isset( $file->mId ) ) { |
200 | | - $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' ); |
201 | | - return; |
202 | | - } else if( !$file->userCan(Revision::DELETED_RESTRICTED) ) { |
203 | | - // If a rev is hidden from sysops |
204 | | - if ( $action != 'submit') { |
205 | | - $wgOut->permissionRequired( 'hiderevision' ); return; |
206 | | - } |
207 | | - $UserAllowed=false; |
208 | | - } |
209 | | - $wgOut->addHtml( $this->uploadLine( $file ) ); |
210 | | - $bitfields = $this->setBitfield( $bitfields, $file->mDeleted ); |
211 | | - } |
212 | | - $wgOut->addHtml( "</ul>" ); |
213 | | - |
214 | | - $wgOut->addWikiText( wfMsgHtml( 'revdelete-text' ) ); |
215 | | - //Normal sysops can always see what they did, but can't always change it |
216 | | - if ( !$UserAllowed ) return; |
217 | | - |
218 | | - $items = array( |
219 | | - wfInputLabel( wfMsgHtml( 'revdelete-log' ), 'wpReason', 'wpReason', 60 ), |
220 | | - wfSubmitButton( wfMsgHtml( 'revdelete-submit' ) ) ); |
221 | | - $hidden = array( |
222 | | - wfHidden( 'wpEditToken', $wgUser->editToken() ), |
223 | | - wfHidden( 'target', $this->page->getPrefixedText() ), |
224 | | - wfHidden( 'type', $this->deletetype ) ); |
225 | | - foreach( $this->files as $fileid ) { |
226 | | - $hidden[] = wfHidden( 'fileid[]', $fileid ); |
227 | | - } |
228 | | - $special = SpecialPage::getTitleFor( 'Revisiondelete' ); |
229 | | - $wgOut->addHtml( wfElement( 'form', array( |
230 | | - 'method' => 'post', |
231 | | - 'action' => $special->getLocalUrl( 'action=submit' ) ), |
232 | | - null ) ); |
233 | | - |
234 | | - $wgOut->addHtml( '<fieldset><legend>' . wfMsgHtml( 'revdelete-legend' ) . '</legend>' ); |
235 | | - // FIXME: all items checked for just one file are checked, even if not set for the others |
236 | | - foreach( $this->checks as $item ) { |
237 | | - list( $message, $name, $field ) = $item; |
238 | | - $wgOut->addHtml( '<div>' . |
239 | | - wfCheckLabel( wfMsgHtml( $message), $name, $name, $bitfields & $field ) . |
240 | | - '</div>' ); |
241 | | - } |
242 | | - $wgOut->addHtml( '</fieldset>' ); |
243 | | - foreach( $items as $item ) { |
244 | | - $wgOut->addHtml( '<p>' . $item . '</p>' ); |
245 | | - } |
246 | | - foreach( $hidden as $item ) { |
247 | | - $wgOut->addHtml( $item ); |
248 | | - } |
249 | | - |
250 | | - $wgOut->addHtml( '</form>' ); |
251 | | - } |
252 | | - |
253 | | - /** |
254 | | - * This lets a user set restrictions for log items |
255 | | - * @param WebRequest $request |
256 | | - */ |
257 | | - function showEvents( $request ) { |
258 | | - global $wgOut, $wgUser, $action; |
259 | | - |
260 | | - $UserAllowed = true; |
261 | | - $wgOut->addWikiText( wfMsgExt( 'logdelete-selected', 'parseinline', $this->page->getPrefixedText(), count( $this->events ) ) ); |
262 | | - |
263 | | - $bitfields = 0; |
264 | | - $wgOut->addHtml( "<ul>" ); |
265 | | - foreach( $this->events as $logid ) { |
266 | | - $log = new LogViewer( $wgRequest ); |
267 | | - $event = LogReader::newFromTitle( $this->page, $logid ); |
268 | | - // Don't hide from oversight log!!! |
269 | | - if( !isset( $event ) || $event->log_type == 'oversight' ) { |
| 69 | + foreach( $this->revisions as $revid ) { |
| 70 | + $rev = Revision::newFromTitle( $this->page, $revid ); |
| 71 | + if( !isset( $rev ) ) { |
270 | 72 | $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' ); |
271 | 73 | return; |
272 | | - } else if( !$log->userCan($event, Revision::DELETED_RESTRICTED) ) { |
273 | | - // If an event is hidden from sysops |
274 | | - if ( $action != 'submit') { |
275 | | - $wgOut->permissionRequired( 'hiderevision' ); return; |
276 | | - } |
277 | | - $UserAllowed=false; |
278 | 74 | } |
279 | | - $wgOut->addHtml( $this->logLine( $log, $event ) ); |
280 | | - $bitfields = $this->setBitfield( $bitfields, $event->log_deleted ); |
| 75 | + $wgOut->addHtml( $this->historyLine( $rev ) ); |
| 76 | + $bitfields[] = $rev->mDeleted; // FIXME |
281 | 77 | } |
282 | 78 | $wgOut->addHtml( "</ul>" ); |
283 | | - |
284 | | - $wgOut->addWikiText( wfMsgHtml( 'revdelete-text' ) ); |
285 | | - //Normal sysops can always see what they did, but can't always change it |
286 | | - if ( !$UserAllowed ) return; |
| 79 | + |
| 80 | + $wgOut->addWikiText( wfMsg( 'revdelete-text' ) ); |
287 | 81 | |
288 | 82 | $items = array( |
289 | | - wfInputLabel( wfMsgHtml( 'revdelete-log' ), 'wpReason', 'wpReason', 60 ), |
290 | | - wfSubmitButton( wfMsgHtml( 'revdelete-submit' ) ) ); |
| 83 | + wfInputLabel( wfMsg( 'revdelete-log' ), 'wpReason', 'wpReason', 60 ), |
| 84 | + wfSubmitButton( wfMsg( 'revdelete-submit' ) ) ); |
291 | 85 | $hidden = array( |
292 | 86 | wfHidden( 'wpEditToken', $wgUser->editToken() ), |
293 | | - wfHidden( 'target', $this->page->getPrefixedText() ), |
294 | | - wfHidden( 'type', $this->deletetype ) ); |
295 | | - foreach( $this->events as $logid ) { |
296 | | - $hidden[] = wfHidden( 'logid[]', $logid ); |
| 87 | + wfHidden( 'target', $this->page->getPrefixedText() ) ); |
| 88 | + foreach( $this->revisions as $revid ) { |
| 89 | + $hidden[] = wfHidden( 'oldid[]', $revid ); |
297 | 90 | } |
298 | 91 | |
299 | 92 | $special = SpecialPage::getTitleFor( 'Revisiondelete' ); |