3 * Special page allowing users with the appropriate permissions to view
4 * and hide revisions. Log items can also be hidden.
10 function wfSpecialRevisiondelete( $par = null ) {
11 global $wgOut, $wgRequest, $wgUser;
14 $wgOut->readOnlyPage();
18 # Handle our many different possible input types
19 $target = $wgRequest->getText( 'target' );
20 $oldid = $wgRequest->getArray( 'oldid' );
21 $artimestamp = $wgRequest->getArray( 'artimestamp' );
22 $logid = $wgRequest->getArray( 'logid' );
23 $img = $wgRequest->getArray( 'oldimage' );
24 $fileid = $wgRequest->getArray( 'fileid' );
25 # For reviewing deleted files...
26 $file = $wgRequest->getVal( 'file' );
27 # If this is a revision, then we need a target page
28 $page = Title
::newFromUrl( $target );
29 if( is_null($page) ) {
30 $wgOut->addWikiMsg( 'undelete-header' );
33 # Only one target set at a time please!
34 $i = (bool)$file +
(bool)$oldid +
(bool)$logid +
(bool)$artimestamp +
(bool)$fileid +
(bool)$img;
36 $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
39 # Logs must have a type given
40 if( $logid && !strpos($page->getDBKey(),'/') ) {
41 $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
44 # Either submit or create our form
45 $form = new RevisionDeleteForm( $page, $oldid, $logid, $artimestamp, $fileid, $img, $file );
46 if( $wgRequest->wasPosted() ) {
47 $form->submit( $wgRequest );
48 } else if( $oldid ||
$artimestamp ) {
50 } else if( $fileid ||
$img ) {
53 $form->showLogItems();
55 # Show relevant lines from the deletion log. This will show even if said ID
56 # does not exist...might be helpful
57 $wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage
::logName( 'delete' ) ) . "</h2>\n" );
58 LogEventsList
::showLogExtract( $wgOut, 'delete', $page->getPrefixedText() );
59 if( $wgUser->isAllowed( 'suppressionlog' ) ){
60 $wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage
::logName( 'suppress' ) ) . "</h2>\n" );
61 LogEventsList
::showLogExtract( $wgOut, 'suppress', $page->getPrefixedText() );
66 * Implements the GUI for Revision Deletion.
67 * @ingroup SpecialPage
69 class RevisionDeleteForm
{
72 * @param array $oldids
73 * @param array $logids
74 * @param array $artimestamps
75 * @param array $fileids
79 function __construct( $page, $oldids, $logids, $artimestamps, $fileids, $img, $file ) {
80 global $wgUser, $wgOut;
83 # For reviewing deleted files...
85 $oimage = RepoGroup
::singleton()->getLocalRepo()->newFromArchiveName( $page, $file );
87 // Check if user is allowed to see this file
88 if( !$oimage->userCan(File
::DELETED_FILE
) ) {
89 $wgOut->permissionRequired( 'suppressrevision' );
91 $this->showFile( $file );
95 $this->skin
= $wgUser->getSkin();
96 # Give a link to the log for this page
97 if( !is_null($this->page
) && $this->page
->getNamespace() > -1 ) {
100 $logtitle = SpecialPage
::getTitleFor( 'Log' );
101 $links[] = $this->skin
->makeKnownLinkObj( $logtitle, wfMsgHtml( 'viewpagelogs' ),
102 wfArrayToCGI( array( 'page' => $this->page
->getPrefixedUrl() ) ) );
103 # Give a link to the page history
104 $links[] = $this->skin
->makeKnownLinkObj( $this->page
, wfMsgHtml( 'pagehist' ),
105 wfArrayToCGI( array( 'action' => 'history' ) ) );
106 # Link to deleted edits
107 if( $wgUser->isAllowed('undelete') ) {
108 $undelete = SpecialPage
::getTitleFor( 'Undelete' );
109 $links[] = $this->skin
->makeKnownLinkObj( $undelete, wfMsgHtml( 'deletedhist' ),
110 wfArrayToCGI( array( 'target' => $this->page
->getPrefixedUrl() ) ) );
112 # Logs themselves don't have histories or archived revisions
113 $wgOut->setSubtitle( '<p>'.implode($links,' / ').'</p>' );
115 // At this point, we should only have one of these
117 $this->revisions
= $oldids;
118 $hide_content_name = array( 'revdelete-hide-text', 'wpHideText', Revision
::DELETED_TEXT
);
119 $this->deleteKey
='oldid';
120 } else if( $artimestamps ) {
121 $this->archrevs
= $artimestamps;
122 $hide_content_name = array( 'revdelete-hide-text', 'wpHideText', Revision
::DELETED_TEXT
);
123 $this->deleteKey
='artimestamp';
125 $this->ofiles
= $img;
126 $hide_content_name = array( 'revdelete-hide-image', 'wpHideImage', File
::DELETED_FILE
);
127 $this->deleteKey
='oldimage';
128 } else if( $fileids ) {
129 $this->afiles
= $fileids;
130 $hide_content_name = array( 'revdelete-hide-image', 'wpHideImage', File
::DELETED_FILE
);
131 $this->deleteKey
='fileid';
132 } else if( $logids ) {
133 $this->events
= $logids;
134 $hide_content_name = array( 'revdelete-hide-name', 'wpHideName', LogPage
::DELETED_ACTION
);
135 $this->deleteKey
='logid';
137 // Our checkbox messages depends one what we are doing,
138 // e.g. we don't hide "text" for logs or images
139 $this->checks
= array(
141 array( 'revdelete-hide-comment', 'wpHideComment', Revision
::DELETED_COMMENT
),
142 array( 'revdelete-hide-user', 'wpHideUser', Revision
::DELETED_USER
) );
143 if( $wgUser->isAllowed('suppressrevision') ) {
144 $this->checks
[] = array( 'revdelete-hide-restricted', 'wpHideRestricted', Revision
::DELETED_RESTRICTED
);
149 * Show a deleted file version requested by the visitor.
151 private function showFile( $key ) {
152 global $wgOut, $wgRequest;
155 # We mustn't allow the output to be Squid cached, otherwise
156 # if an admin previews a deleted image, and it's cached, then
157 # a user without appropriate permissions can toddle off and
158 # nab the image, and Squid will serve it
159 $wgRequest->response()->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', 0 ) . ' GMT' );
160 $wgRequest->response()->header( 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' );
161 $wgRequest->response()->header( 'Pragma: no-cache' );
163 $store = FileStore
::get( 'deleted' );
164 $store->stream( $key );
168 * This lets a user set restrictions for live and archived revisions
170 function showRevs() {
171 global $wgOut, $wgUser, $action;
175 $count = ($this->deleteKey
=='oldid') ?
176 count($this->revisions
) : count($this->archrevs
);
177 $wgOut->addWikiMsg( 'revdelete-selected', $this->page
->getPrefixedText(), $count );
180 $wgOut->addHTML( "<ul>" );
182 $where = $revObjs = array();
183 $dbr = wfGetDB( DB_SLAVE
);
187 if( $this->deleteKey
=='oldid' ) {
188 // Run through and pull all our data in one query
189 foreach( $this->revisions
as $revid ) {
190 $where[] = intval($revid);
192 $whereClause = 'rev_id IN(' . implode(',',$where) . ')';
193 $result = $dbr->select( array('revision','page'), '*',
194 array( 'rev_page' => $this->page
->getArticleID(),
195 $whereClause, 'rev_page = page_id' ),
197 while( $row = $dbr->fetchObject( $result ) ) {
198 $revObjs[$row->rev_id
] = new Revision( $row );
200 foreach( $this->revisions
as $revid ) {
201 // Hiding top revisison is bad
202 if( !isset($revObjs[$revid]) ||
$revObjs[$revid]->isCurrent() ) {
204 } else if( !$revObjs[$revid]->userCan(Revision
::DELETED_RESTRICTED
) ) {
205 // If a rev is hidden from sysops
206 if( $action != 'submit') {
207 $wgOut->permissionRequired( 'suppressrevision' );
210 $UserAllowed = false;
213 $wgOut->addHTML( $this->historyLine( $revObjs[$revid] ) );
214 $bitfields |
= $revObjs[$revid]->mDeleted
;
218 // Run through and pull all our data in one query
219 foreach( $this->archrevs
as $timestamp ) {
220 $where[] = $dbr->addQuotes( $timestamp );
222 $whereClause = 'ar_timestamp IN(' . implode(',',$where) . ')';
223 $result = $dbr->select( 'archive', '*',
224 array( 'ar_namespace' => $this->page
->getNamespace(),
225 'ar_title' => $this->page
->getDBKey(),
228 while( $row = $dbr->fetchObject( $result ) ) {
229 $revObjs[$row->ar_timestamp
] = new Revision( array(
230 'page' => $this->page
->getArticleId(),
231 'id' => $row->ar_rev_id
,
232 'text' => $row->ar_text_id
,
233 'comment' => $row->ar_comment
,
234 'user' => $row->ar_user
,
235 'user_text' => $row->ar_user_text
,
236 'timestamp' => $row->ar_timestamp
,
237 'minor_edit' => $row->ar_minor_edit
,
238 'text_id' => $row->ar_text_id
,
239 'deleted' => $row->ar_deleted
,
240 'len' => $row->ar_len
) );
242 foreach( $this->archrevs
as $timestamp ) {
243 if( !isset($revObjs[$timestamp]) ) {
245 } else if( !$revObjs[$timestamp]->userCan(Revision
::DELETED_RESTRICTED
) ) {
246 // If a rev is hidden from sysops
247 if( $action != 'submit') {
248 $wgOut->permissionRequired( 'suppressrevision' );
251 $UserAllowed = false;
254 $wgOut->addHTML( $this->historyLine( $revObjs[$timestamp] ) );
255 $bitfields |
= $revObjs[$timestamp]->mDeleted
;
259 $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
263 $wgOut->addHTML( "</ul>" );
265 $wgOut->addWikiMsg( 'revdelete-text' );
267 // Normal sysops can always see what they did, but can't always change it
268 if( !$UserAllowed ) return;
271 Xml
::inputLabel( wfMsg( 'revdelete-log' ), 'wpReason', 'wpReason', 60 ),
272 Xml
::submitButton( wfMsg( 'revdelete-submit' ) )
275 Xml
::hidden( 'wpEditToken', $wgUser->editToken() ),
276 Xml
::hidden( 'target', $this->page
->getPrefixedText() ),
277 Xml
::hidden( 'type', $this->deleteKey
)
279 if( $this->deleteKey
=='oldid' ) {
280 foreach( $revObjs as $rev )
281 $hidden[] = Xml
::hidden( 'oldid[]', $rev->getId() );
283 foreach( $revObjs as $rev )
284 $hidden[] = Xml
::hidden( 'artimestamp[]', $rev->getTimestamp() );
286 $special = SpecialPage
::getTitleFor( 'Revisiondelete' );
288 Xml
::openElement( 'form', array( 'method' => 'post', 'action' => $special->getLocalUrl( 'action=submit' ),
289 'id' => 'mw-revdel-form-revisions' ) ) .
290 Xml
::openElement( 'fieldset' ) .
291 xml
::element( 'legend', null, wfMsg( 'revdelete-legend' ) )
293 // FIXME: all items checked for just one rev are checked, even if not set for the others
294 foreach( $this->checks
as $item ) {
295 list( $message, $name, $field ) = $item;
296 $wgOut->addHTML( Xml
::tags( 'div', null, Xml
::checkLabel( wfMsg( $message ), $name, $name, $bitfields & $field ) ) );
298 foreach( $items as $item ) {
299 $wgOut->addHTML( Xml
::tags( 'p', null, $item ) );
301 foreach( $hidden as $item ) {
302 $wgOut->addHTML( $item );
305 Xml
::closeElement( 'fieldset' ) .
306 Xml
::closeElement( 'form' ) . "\n"
312 * This lets a user set restrictions for archived images
314 function showImages() {
315 // What is $action doing here???
316 global $wgOut, $wgUser, $action, $wgLang;
320 $count = ($this->deleteKey
=='oldimage') ?
count($this->ofiles
) : count($this->afiles
);
321 $wgOut->addWikiMsg( 'revdelete-selected',
322 $this->page
->getPrefixedText(),
323 $wgLang->formatNum($count) );
326 $wgOut->addHTML( "<ul>" );
328 $where = $filesObjs = array();
329 $dbr = wfGetDB( DB_SLAVE
);
330 // Live old revisions...
332 if( $this->deleteKey
=='oldimage' ) {
333 // Run through and pull all our data in one query
334 foreach( $this->ofiles
as $timestamp ) {
335 $where[] = $dbr->addQuotes( $timestamp.'!'.$this->page
->getDBKey() );
337 $whereClause = 'oi_archive_name IN(' . implode(',',$where) . ')';
338 $result = $dbr->select( 'oldimage', '*',
339 array( 'oi_name' => $this->page
->getDBKey(),
342 while( $row = $dbr->fetchObject( $result ) ) {
343 $filesObjs[$row->oi_archive_name
] = RepoGroup
::singleton()->getLocalRepo()->newFileFromRow( $row );
344 $filesObjs[$row->oi_archive_name
]->user
= $row->oi_user
;
345 $filesObjs[$row->oi_archive_name
]->user_text
= $row->oi_user_text
;
347 // Check through our images
348 foreach( $this->ofiles
as $timestamp ) {
349 $archivename = $timestamp.'!'.$this->page
->getDBKey();
350 if( !isset($filesObjs[$archivename]) ) {
352 } else if( !$filesObjs[$archivename]->userCan(File
::DELETED_RESTRICTED
) ) {
353 // If a rev is hidden from sysops
354 if( $action != 'submit' ) {
355 $wgOut->permissionRequired( 'suppressrevision' );
358 $UserAllowed = false;
361 // Inject history info
362 $wgOut->addHTML( $this->fileLine( $filesObjs[$archivename] ) );
363 $bitfields |
= $filesObjs[$archivename]->deleted
;
367 // Run through and pull all our data in one query
368 foreach( $this->afiles
as $id ) {
369 $where[] = intval($id);
371 $whereClause = 'fa_id IN(' . implode(',',$where) . ')';
372 $result = $dbr->select( 'filearchive', '*',
373 array( 'fa_name' => $this->page
->getDBKey(),
376 while( $row = $dbr->fetchObject( $result ) ) {
377 $filesObjs[$row->fa_id
] = ArchivedFile
::newFromRow( $row );
380 foreach( $this->afiles
as $fileid ) {
381 if( !isset($filesObjs[$fileid]) ) {
383 } else if( !$filesObjs[$fileid]->userCan(File
::DELETED_RESTRICTED
) ) {
384 // If a rev is hidden from sysops
385 if( $action != 'submit' ) {
386 $wgOut->permissionRequired( 'suppressrevision' );
389 $UserAllowed = false;
392 // Inject history info
393 $wgOut->addHTML( $this->archivedfileLine( $filesObjs[$fileid] ) );
394 $bitfields |
= $filesObjs[$fileid]->deleted
;
398 $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
402 $wgOut->addHTML( "</ul>" );
404 $wgOut->addWikiMsg('revdelete-text' );
405 //Normal sysops can always see what they did, but can't always change it
406 if( !$UserAllowed ) return;
409 Xml
::inputLabel( wfMsg( 'revdelete-log' ), 'wpReason', 'wpReason', 60 ),
410 Xml
::submitButton( wfMsg( 'revdelete-submit' ) )
413 Xml
::hidden( 'wpEditToken', $wgUser->editToken() ),
414 Xml
::hidden( 'target', $this->page
->getPrefixedText() ),
415 Xml
::hidden( 'type', $this->deleteKey
)
417 if( $this->deleteKey
=='oldimage' ) {
418 foreach( $this->ofiles
as $filename )
419 $hidden[] = Xml
::hidden( 'oldimage[]', $filename );
421 foreach( $this->afiles
as $fileid )
422 $hidden[] = Xml
::hidden( 'fileid[]', $fileid );
424 $special = SpecialPage
::getTitleFor( 'Revisiondelete' );
426 Xml
::openElement( 'form', array( 'method' => 'post', 'action' => $special->getLocalUrl( 'action=submit' ),
427 'id' => 'mw-revdel-form-filerevisions' ) ) .
428 Xml
::fieldset( wfMsg( 'revdelete-legend' ) )
430 // FIXME: all items checked for just one file are checked, even if not set for the others
431 foreach( $this->checks
as $item ) {
432 list( $message, $name, $field ) = $item;
433 $wgOut->addHTML( Xml
::tags( 'div', null, Xml
::checkLabel( wfMsg( $message ), $name, $name, $bitfields & $field ) ) );
435 foreach( $items as $item ) {
436 $wgOut->addHTML( "<p>$item</p>" );
438 foreach( $hidden as $item ) {
439 $wgOut->addHTML( $item );
443 Xml
::closeElement( 'fieldset' ) .
444 Xml
::closeElement( 'form' ) . "\n"
449 * This lets a user set restrictions for log items
451 function showLogItems() {
452 global $wgOut, $wgUser, $action, $wgMessageCache, $wgLang;
455 $wgOut->addWikiMsg( 'logdelete-selected', $wgLang->formatNum( count($this->events
) ) );
458 $wgOut->addHTML( "<ul>" );
460 $where = $logRows = array();
461 $dbr = wfGetDB( DB_SLAVE
);
462 // Run through and pull all our data in one query
464 foreach( $this->events
as $logid ) {
465 $where[] = intval($logid);
467 list($log,$logtype) = explode( '/',$this->page
->getDBKey(), 2 );
468 $whereClause = "log_type = '$logtype' AND log_id IN(" . implode(',',$where) . ")";
469 $result = $dbr->select( 'logging', '*',
470 array( $whereClause ),
472 while( $row = $dbr->fetchObject( $result ) ) {
473 $logRows[$row->log_id
] = $row;
475 $wgMessageCache->loadAllMessages();
476 foreach( $this->events
as $logid ) {
477 // Don't hide from oversight log!!!
478 if( !isset( $logRows[$logid] ) ||
$logRows[$logid]->log_type
=='suppress' ) {
480 } else if( !LogEventsList
::userCan( $logRows[$logid],Revision
::DELETED_RESTRICTED
) ) {
481 // If an event is hidden from sysops
482 if( $action != 'submit') {
483 $wgOut->permissionRequired( 'suppressrevision' );
486 $UserAllowed = false;
489 $wgOut->addHTML( $this->logLine( $logRows[$logid] ) );
490 $bitfields |
= $logRows[$logid]->log_deleted
;
493 $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
497 $wgOut->addHTML( "</ul>" );
499 $wgOut->addWikiMsg( 'revdelete-text' );
500 // Normal sysops can always see what they did, but can't always change it
501 if( !$UserAllowed ) return;
504 Xml
::inputLabel( wfMsg( 'revdelete-log' ), 'wpReason', 'wpReason', 60 ),
505 Xml
::submitButton( wfMsg( 'revdelete-submit' ) ) );
507 Xml
::hidden( 'wpEditToken', $wgUser->editToken() ),
508 Xml
::hidden( 'target', $this->page
->getPrefixedText() ),
509 Xml
::hidden( 'type', $this->deleteKey
) );
510 foreach( $this->events
as $logid ) {
511 $hidden[] = Xml
::hidden( 'logid[]', $logid );
514 $special = SpecialPage
::getTitleFor( 'Revisiondelete' );
516 Xml
::openElement( 'form', array( 'method' => 'post', 'action' => $special->getLocalUrl( 'action=submit' ),
517 'id' => 'mw-revdel-form-logs' ) ) .
518 Xml
::fieldset( wfMsg( 'revdelete-legend' ) )
520 // FIXME: all items checked for just on event are checked, even if not set for the others
521 foreach( $this->checks
as $item ) {
522 list( $message, $name, $field ) = $item;
523 $wgOut->addHTML( Xml
::tags( 'div', null, Xml
::checkLabel( wfMsg( $message ), $name, $name, $bitfields & $field ) ) );
525 foreach( $items as $item ) {
526 $wgOut->addHTML( "<p>$item</p>" );
528 foreach( $hidden as $item ) {
529 $wgOut->addHTML( $item );
533 Xml
::closeElement( 'fieldset' ) .
534 Xml
::closeElement( 'form' ) . "\n"
539 * @param Revision $rev
542 private function historyLine( $rev ) {
545 $date = $wgLang->timeanddate( $rev->getTimestamp() );
546 $difflink = $del = '';
548 if( $this->deleteKey
=='oldid' ) {
549 $revlink = $this->skin
->makeLinkObj( $this->page
, $date, 'oldid=' . $rev->getId() );
550 $difflink = '(' . $this->skin
->makeKnownLinkObj( $this->page
, wfMsgHtml('diff'),
551 'diff=' . $rev->getId() . '&oldid=prev' ) . ')';
552 // Archived revisions
554 $undelete = SpecialPage
::getTitleFor( 'Undelete' );
555 $target = $this->page
->getPrefixedText();
556 $revlink = $this->skin
->makeLinkObj( $undelete, $date,
557 "target=$target×tamp=" . $rev->getTimestamp() );
558 $difflink = '(' . $this->skin
->makeKnownLinkObj( $undelete, wfMsgHtml('diff'),
559 "target=$target&diff=prev×tamp=" . $rev->getTimestamp() ) . ')';
562 if( $rev->isDeleted(Revision
::DELETED_TEXT
) ) {
563 $revlink = '<span class="history-deleted">'.$revlink.'</span>';
564 $del = ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
565 if( !$rev->userCan(Revision
::DELETED_TEXT
) ) {
566 $revlink = '<span class="history-deleted">'.$date.'</span>';
567 $difflink = '(' . wfMsgHtml('diff') . ')';
571 return "<li> $difflink $revlink ".$this->skin
->revUserLink( $rev )." ".$this->skin
->revComment( $rev )."$del</li>";
578 private function fileLine( $file ) {
579 global $wgLang, $wgTitle;
581 $target = $this->page
->getPrefixedText();
582 $date = $wgLang->timeanddate( $file->getTimestamp(), true );
586 if( $file->isDeleted(File
::DELETED_FILE
) ) {
587 $del = ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
588 if( !$file->userCan(File
::DELETED_FILE
) ) {
591 $pageLink = $this->skin
->makeKnownLinkObj( $wgTitle, $date,
592 "target=$target&file=$file->sha1.".$file->getExtension() );
594 $pageLink = '<span class="history-deleted">' . $pageLink . '</span>';
597 $url = $file->getUrlRel();
598 $pageLink = "<a href=\"{$url}\">{$date}</a>";
601 $data = wfMsg( 'widthheight',
602 $wgLang->formatNum( $file->getWidth() ),
603 $wgLang->formatNum( $file->getHeight() ) ) .
604 ' (' . wfMsgExt( 'nbytes', 'parsemag', $wgLang->formatNum( $file->getSize() ) ) . ')';
605 $data = htmlspecialchars( $data );
607 return "<li>$pageLink ".$this->fileUserTools( $file )." $data ".$this->fileComment( $file )."$del</li>";
611 * @param ArchivedFile $file
614 private function archivedfileLine( $file ) {
617 $target = $this->page
->getPrefixedText();
618 $date = $wgLang->timeanddate( $file->getTimestamp(), true );
620 $undelete = SpecialPage
::getTitleFor( 'Undelete' );
621 $pageLink = $this->skin
->makeKnownLinkObj( $undelete, $date, "target=$target&file={$file->getKey()}" );
624 if( $file->isDeleted(File
::DELETED_FILE
) ) {
625 $del = ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
628 $data = wfMsg( 'widthheight',
629 $wgLang->formatNum( $file->getWidth() ),
630 $wgLang->formatNum( $file->getHeight() ) ) .
631 ' (' . wfMsgExt( 'nbytes', 'parsemag', $wgLang->formatNum( $file->getSize() ) ) . ')';
632 $data = htmlspecialchars( $data );
634 return "<li> $pageLink ".$this->fileUserTools( $file )." $data ".$this->fileComment( $file )."$del</li>";
638 * @param Array $row row
641 private function logLine( $row ) {
644 $date = $wgLang->timeanddate( $row->log_timestamp
);
645 $paramArray = LogPage
::extractParams( $row->log_params
);
646 $title = Title
::makeTitle( $row->log_namespace
, $row->log_title
);
648 $logtitle = SpecialPage
::getTitleFor( 'Log' );
649 $loglink = $this->skin
->makeKnownLinkObj( $logtitle, wfMsgHtml( 'log' ),
650 wfArrayToCGI( array( 'page' => $title->getPrefixedUrl() ) ) );
652 if( !LogEventsList
::userCan($row,LogPage
::DELETED_ACTION
) ) {
653 $action = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
655 $action = LogPage
::actionText( $row->log_type
, $row->log_action
, $title,
656 $this->skin
, $paramArray, true, true );
657 if( $row->log_deleted
& LogPage
::DELETED_ACTION
)
658 $action = '<span class="history-deleted">' . $action . '</span>';
661 $userLink = $this->skin
->userLink( $row->log_user
, User
::WhoIs($row->log_user
) );
662 if( LogEventsList
::isDeleted($row,LogPage
::DELETED_USER
) ) {
663 $userLink = '<span class="history-deleted">' . $userLink . '</span>';
666 $comment = $wgLang->getDirMark() . $this->skin
->commentBlock( $row->log_comment
);
667 if( LogEventsList
::isDeleted($row,LogPage
::DELETED_COMMENT
) ) {
668 $comment = '<span class="history-deleted">' . $comment . '</span>';
670 return "<li>($loglink) $date $userLink $action $comment</li>";
674 * Generate a user tool link cluster if the current user is allowed to view it
675 * @param ArchivedFile $file
676 * @return string HTML
678 private function fileUserTools( $file ) {
679 if( $file->userCan( Revision
::DELETED_USER
) ) {
680 $link = $this->skin
->userLink( $file->user
, $file->user_text
) .
681 $this->skin
->userToolLinks( $file->user
, $file->user_text
);
683 $link = wfMsgHtml( 'rev-deleted-user' );
685 if( $file->isDeleted( Revision
::DELETED_USER
) ) {
686 return '<span class="history-deleted">' . $link . '</span>';
692 * Wrap and format the given file's comment block, if the current
693 * user is allowed to view it.
695 * @param ArchivedFile $file
696 * @return string HTML
698 private function fileComment( $file ) {
699 if( $file->userCan( File
::DELETED_COMMENT
) ) {
700 $block = $this->skin
->commentBlock( $file->description
);
702 $block = ' ' . wfMsgHtml( 'rev-deleted-comment' );
704 if( $file->isDeleted( File
::DELETED_COMMENT
) ) {
705 return "<span class=\"history-deleted\">$block</span>";
711 * @param WebRequest $request
713 function submit( $request ) {
714 global $wgUser, $wgOut;
716 $bitfield = $this->extractBitfield( $request );
717 $comment = $request->getText( 'wpReason' );
718 # Can the user set this field?
719 if( $bitfield & Revision
::DELETED_RESTRICTED
&& !$wgUser->isAllowed('suppressrevision') ) {
720 $wgOut->permissionRequired( 'suppressrevision' );
723 # If the save went through, go to success message. Otherwise
724 # bounce back to form...
725 if( $this->save( $bitfield, $comment, $this->page
) ) {
727 } else if( $request->getCheck( 'oldid' ) ||
$request->getCheck( 'artimestamp' ) ) {
728 return $this->showRevs();
729 } else if( $request->getCheck( 'logid' ) ) {
730 return $this->showLogs();
731 } else if( $request->getCheck( 'oldimage' ) ||
$request->getCheck( 'fileid' ) ) {
732 return $this->showImages();
736 private function success() {
739 $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
741 $wrap = '<span class="success">$1</span>';
743 if( $this->deleteKey
=='logid' ) {
744 $wgOut->wrapWikiMsg( $wrap, 'logdelete-success' );
745 $this->showLogItems();
746 } else if( $this->deleteKey
=='oldid' ||
$this->deleteKey
=='artimestamp' ) {
747 $wgOut->wrapWikiMsg( $wrap, 'revdelete-success' );
749 } else if( $this->deleteKey
=='fileid' ) {
750 $wgOut->wrapWikiMsg( $wrap, 'revdelete-success' );
752 } else if( $this->deleteKey
=='oldimage' ) {
753 $wgOut->wrapWikiMsg( $wrap, 'revdelete-success' );
759 * Put together a rev_deleted bitfield from the submitted checkboxes
760 * @param WebRequest $request
763 private function extractBitfield( $request ) {
765 foreach( $this->checks
as $item ) {
766 list( /* message */ , $name, $field ) = $item;
767 if( $request->getCheck( $name ) ) {
774 private function save( $bitfield, $reason, $title ) {
775 $dbw = wfGetDB( DB_MASTER
);
776 // Don't allow simply locking the interface for no reason
777 if( $bitfield == Revision
::DELETED_RESTRICTED
) {
780 $deleter = new RevisionDeleter( $dbw );
781 // By this point, only one of the below should be set
782 if( isset($this->revisions
) ) {
783 return $deleter->setRevVisibility( $title, $this->revisions
, $bitfield, $reason );
784 } else if( isset($this->archrevs
) ) {
785 return $deleter->setArchiveVisibility( $title, $this->archrevs
, $bitfield, $reason );
786 } else if( isset($this->ofiles
) ) {
787 return $deleter->setOldImgVisibility( $title, $this->ofiles
, $bitfield, $reason );
788 } else if( isset($this->afiles
) ) {
789 return $deleter->setArchFileVisibility( $title, $this->afiles
, $bitfield, $reason );
790 } else if( isset($this->events
) ) {
791 return $deleter->setEventVisibility( $title, $this->events
, $bitfield, $reason );
797 * Implements the actions for Revision Deletion.
798 * @ingroup SpecialPage
800 class RevisionDeleter
{
801 function __construct( $db ) {
806 * @param $title, the page these events apply to
807 * @param array $items list of revision ID numbers
808 * @param int $bitfield new rev_deleted value
809 * @param string $comment Comment for log records
811 function setRevVisibility( $title, $items, $bitfield, $comment ) {
814 $userAllowedAll = $success = true;
817 // Run through and pull all our data in one query
818 foreach( $items as $revid ) {
819 $where[] = intval($revid);
821 $whereClause = 'rev_id IN(' . implode(',',$where) . ')';
822 $result = $this->dbw
->select( 'revision', '*',
823 array( 'rev_page' => $title->getArticleID(),
826 while( $row = $this->dbw
->fetchObject( $result ) ) {
827 $revObjs[$row->rev_id
] = new Revision( $row );
830 foreach( $items as $revid ) {
831 if( !isset($revObjs[$revid]) ||
$revObjs[$revid]->isCurrent() ) {
833 continue; // Must exist
834 } else if( !$revObjs[$revid]->userCan(Revision
::DELETED_RESTRICTED
) ) {
835 $userAllowedAll=false;
838 // For logging, maintain a count of revisions
839 if( $revObjs[$revid]->mDeleted
!= $bitfield ) {
843 $this->updateRevision( $revObjs[$revid], $bitfield );
844 $this->updateRecentChangesEdits( $revObjs[$revid], $bitfield, false );
848 // Don't log or touch if nothing changed
849 if( $revCount > 0 ) {
850 $this->updateLog( $title, $revCount, $bitfield, $revObjs[$revid]->mDeleted
,
851 $comment, $title, 'oldid', $revIDs );
852 $this->updatePage( $title );
854 // Where all revs allowed to be set?
855 if( !$userAllowedAll ) {
856 //FIXME: still might be confusing???
857 $wgOut->permissionRequired( 'suppressrevision' );
865 * @param $title, the page these events apply to
866 * @param array $items list of revision ID numbers
867 * @param int $bitfield new rev_deleted value
868 * @param string $comment Comment for log records
870 function setArchiveVisibility( $title, $items, $bitfield, $comment ) {
873 $userAllowedAll = $success = true;
876 // Run through and pull all our data in one query
877 foreach( $items as $timestamp ) {
878 $where[] = $this->dbw
->addQuotes( $timestamp );
880 $whereClause = 'ar_timestamp IN(' . implode(',',$where) . ')';
881 $result = $this->dbw
->select( 'archive', '*',
882 array( 'ar_namespace' => $title->getNamespace(),
883 'ar_title' => $title->getDBKey(),
886 while( $row = $this->dbw
->fetchObject( $result ) ) {
887 $revObjs[$row->ar_timestamp
] = new Revision( array(
888 'page' => $title->getArticleId(),
889 'id' => $row->ar_rev_id
,
890 'text' => $row->ar_text_id
,
891 'comment' => $row->ar_comment
,
892 'user' => $row->ar_user
,
893 'user_text' => $row->ar_user_text
,
894 'timestamp' => $row->ar_timestamp
,
895 'minor_edit' => $row->ar_minor_edit
,
896 'text_id' => $row->ar_text_id
,
897 'deleted' => $row->ar_deleted
,
898 'len' => $row->ar_len
) );
901 foreach( $items as $timestamp ) {
902 // This will only select the first revision with this timestamp.
903 // Since they are all selected/deleted at once, we can just check the
904 // permissions of one. UPDATE is done via timestamp, so all revs are set.
905 if( !is_object($revObjs[$timestamp]) ) {
907 continue; // Must exist
908 } else if( !$revObjs[$timestamp]->userCan(Revision
::DELETED_RESTRICTED
) ) {
909 $userAllowedAll=false;
912 // Which revisions did we change anything about?
913 if( $revObjs[$timestamp]->mDeleted
!= $bitfield ) {
914 $Id_set[]=$timestamp;
917 $this->updateArchive( $revObjs[$timestamp], $title, $bitfield );
920 // For logging, maintain a count of revisions
922 $this->updateLog( $title, $count, $bitfield, $revObjs[$timestamp]->mDeleted
,
923 $comment, $title, 'artimestamp', $Id_set );
925 // Where all revs allowed to be set?
926 if( !$userAllowedAll ) {
927 $wgOut->permissionRequired( 'suppressrevision' );
935 * @param $title, the page these events apply to
936 * @param array $items list of revision ID numbers
937 * @param int $bitfield new rev_deleted value
938 * @param string $comment Comment for log records
940 function setOldImgVisibility( $title, $items, $bitfield, $comment ) {
943 $userAllowedAll = $success = true;
946 // Run through and pull all our data in one query
947 foreach( $items as $timestamp ) {
948 $where[] = $this->dbw
->addQuotes( $timestamp.'!'.$title->getDBKey() );
950 $whereClause = 'oi_archive_name IN(' . implode(',',$where) . ')';
951 $result = $this->dbw
->select( 'oldimage', '*',
952 array( 'oi_name' => $title->getDBKey(),
955 while( $row = $this->dbw
->fetchObject( $result ) ) {
956 $filesObjs[$row->oi_archive_name
] = RepoGroup
::singleton()->getLocalRepo()->newFileFromRow( $row );
957 $filesObjs[$row->oi_archive_name
]->user
= $row->oi_user
;
958 $filesObjs[$row->oi_archive_name
]->user_text
= $row->oi_user_text
;
961 foreach( $items as $timestamp ) {
962 $archivename = $timestamp.'!'.$title->getDBKey();
963 if( !isset($filesObjs[$archivename]) ) {
965 continue; // Must exist
966 } else if( !$filesObjs[$archivename]->userCan(File
::DELETED_RESTRICTED
) ) {
967 $userAllowedAll=false;
972 // Which revisions did we change anything about?
973 if( $filesObjs[$archivename]->deleted
!= $bitfield ) {
977 $this->updateOldFiles( $filesObjs[$archivename], $bitfield );
978 // If this image is currently hidden...
979 if( $filesObjs[$archivename]->deleted
& File
::DELETED_FILE
) {
980 if( $bitfield & File
::DELETED_FILE
) {
981 # Leave it alone if we are not changing this...
985 # We are moving this out
986 $transaction = $this->makeOldImagePublic( $filesObjs[$archivename] );
989 // Is it just now becoming hidden?
990 } else if( $bitfield & File
::DELETED_FILE
) {
991 $transaction = $this->makeOldImagePrivate( $filesObjs[$archivename] );
996 // If our file operations fail, then revert back the db
997 if( $transaction==false ) {
998 $this->dbw
->rollback();
1001 $this->dbw
->commit();
1005 // Log if something was changed
1007 $this->updateLog( $title, $count, $bitfield, $filesObjs[$archivename]->deleted
,
1008 $comment, $title, 'oldimage', $set );
1009 # Purge page/history
1010 $file = wfLocalFile( $title );
1011 $file->purgeCache();
1012 $file->purgeHistory();
1013 # Invalidate cache for all pages using this file
1014 $update = new HTMLCacheUpdate( $title, 'imagelinks' );
1015 $update->doUpdate();
1017 // Where all revs allowed to be set?
1018 if( !$userAllowedAll ) {
1019 $wgOut->permissionRequired( 'suppressrevision' );
1027 * @param $title, the page these events apply to
1028 * @param array $items list of revision ID numbers
1029 * @param int $bitfield new rev_deleted value
1030 * @param string $comment Comment for log records
1032 function setArchFileVisibility( $title, $items, $bitfield, $comment ) {
1035 $userAllowedAll = $success = true;
1039 // Run through and pull all our data in one query
1040 foreach( $items as $id ) {
1041 $where[] = intval($id);
1043 $whereClause = 'fa_id IN(' . implode(',',$where) . ')';
1044 $result = $this->dbw
->select( 'filearchive', '*',
1045 array( 'fa_name' => $title->getDBKey(),
1048 while( $row = $this->dbw
->fetchObject( $result ) ) {
1049 $filesObjs[$row->fa_id
] = ArchivedFile
::newFromRow( $row );
1052 foreach( $items as $fileid ) {
1053 if( !isset($filesObjs[$fileid]) ) {
1055 continue; // Must exist
1056 } else if( !$filesObjs[$fileid]->userCan(File
::DELETED_RESTRICTED
) ) {
1057 $userAllowedAll=false;
1060 // Which revisions did we change anything about?
1061 if( $filesObjs[$fileid]->deleted
!= $bitfield ) {
1065 $this->updateArchFiles( $filesObjs[$fileid], $bitfield );
1068 // Log if something was changed
1070 $this->updateLog( $title, $count, $bitfield, $comment,
1071 $filesObjs[$fileid]->deleted
, $title, 'fileid', $Id_set );
1073 // Where all revs allowed to be set?
1074 if( !$userAllowedAll ) {
1075 $wgOut->permissionRequired( 'suppressrevision' );
1083 * @param $title, the log page these events apply to
1084 * @param array $items list of log ID numbers
1085 * @param int $bitfield new log_deleted value
1086 * @param string $comment Comment for log records
1088 function setEventVisibility( $title, $items, $bitfield, $comment ) {
1091 $userAllowedAll = $success = true;
1095 // Run through and pull all our data in one query
1096 foreach( $items as $logid ) {
1097 $where[] = intval($logid);
1099 list($log,$logtype) = explode( '/',$title->getDBKey(), 2 );
1100 $whereClause = "log_type ='$logtype' AND log_id IN(" . implode(',',$where) . ")";
1101 $result = $this->dbw
->select( 'logging', '*',
1102 array( $whereClause ),
1104 while( $row = $this->dbw
->fetchObject( $result ) ) {
1105 $logRows[$row->log_id
] = $row;
1108 foreach( $items as $logid ) {
1109 if( !isset($logRows[$logid]) ) {
1111 continue; // Must exist
1112 } else if( !LogEventsList
::userCan($logRows[$logid], LogPage
::DELETED_RESTRICTED
)
1113 ||
$logRows[$logid]->log_type
== 'suppress' ) {
1114 // Don't hide from oversight log!!!
1115 $userAllowedAll=false;
1118 // Which logs did we change anything about?
1119 if( $logRows[$logid]->log_deleted
!= $bitfield ) {
1123 $this->updateLogs( $logRows[$logid], $bitfield );
1124 $this->updateRecentChangesLog( $logRows[$logid], $bitfield, true );
1127 // Don't log or touch if nothing changed
1129 $this->updateLog( $title, $count, $bitfield, $logRows[$logid]->log_deleted
,
1130 $comment, $title, 'logid', $log_Ids );
1132 // Were all revs allowed to be set?
1133 if( !$userAllowedAll ) {
1134 $wgOut->permissionRequired( 'suppressrevision' );
1142 * Moves an image to a safe private location
1143 * Caller is responsible for clearing caches
1144 * @param File $oimage
1145 * @returns mixed, timestamp string on success, false on failure
1147 function makeOldImagePrivate( $oimage ) {
1148 $transaction = new FSTransaction();
1149 if( !FileStore
::lock() ) {
1150 wfDebug( __METHOD__
.": failed to acquire file store lock, aborting\n" );
1153 $oldpath = $oimage->getArchivePath() . DIRECTORY_SEPARATOR
. $oimage->archive_name
;
1154 // Dupe the file into the file store
1155 if( file_exists( $oldpath ) ) {
1156 // Is our directory configured?
1157 if( $store = FileStore
::get( 'deleted' ) ) {
1158 if( !$oimage->sha1
) {
1159 $oimage->upgradeRow(); // sha1 may be missing
1161 $key = $oimage->sha1
. '.' . $oimage->getExtension();
1162 $transaction->add( $store->insert( $key, $oldpath, FileStore
::DELETE_ORIGINAL
) );
1166 $transaction = false; // Return an error and do nothing
1169 wfDebug( __METHOD__
." deleting already-missing '$oldpath'; moving on to database\n" );
1172 $transaction = new FSTransaction(); // empty
1175 if( $transaction === false ) {
1177 wfDebug( __METHOD__
.": import to file store failed, aborting\n" );
1178 throw new MWException( "Could not archive and delete file $oldpath" );
1182 wfDebug( __METHOD__
.": set db items, applying file transactions\n" );
1183 $transaction->commit();
1184 FileStore
::unlock();
1186 $m = explode('!',$oimage->archive_name
,2);
1193 * Moves an image from a safe private location
1194 * Caller is responsible for clearing caches
1195 * @param File $oimage
1196 * @returns mixed, string timestamp on success, false on failure
1198 function makeOldImagePublic( $oimage ) {
1199 $transaction = new FSTransaction();
1200 if( !FileStore
::lock() ) {
1201 wfDebug( __METHOD__
." could not acquire filestore lock\n" );
1205 $store = FileStore
::get( 'deleted' );
1207 wfDebug( __METHOD__
.": skipping row with no file.\n" );
1211 $key = $oimage->sha1
.'.'.$oimage->getExtension();
1212 $destDir = $oimage->getArchivePath();
1213 if( !is_dir( $destDir ) ) {
1214 wfMkdirParents( $destDir );
1216 $destPath = $destDir . DIRECTORY_SEPARATOR
. $oimage->archive_name
;
1217 // Check if any other stored revisions use this file;
1218 // if so, we shouldn't remove the file from the hidden
1219 // archives so they will still work. Check hidden files first.
1220 $useCount = $this->dbw
->selectField( 'oldimage', '1',
1221 array( 'oi_sha1' => $oimage->sha1
,
1222 'oi_deleted & '.File
::DELETED_FILE
=> File
::DELETED_FILE
),
1223 __METHOD__
, array( 'FOR UPDATE' ) );
1224 // Check the rest of the deleted archives too.
1225 // (these are the ones that don't show in the image history)
1227 $useCount = $this->dbw
->selectField( 'filearchive', '1',
1228 array( 'fa_storage_group' => 'deleted', 'fa_storage_key' => $key ),
1229 __METHOD__
, array( 'FOR UPDATE' ) );
1232 if( $useCount == 0 ) {
1233 wfDebug( __METHOD__
.": nothing else using {$oimage->sha1}, will deleting after\n" );
1234 $flags = FileStore
::DELETE_ORIGINAL
;
1238 $transaction->add( $store->export( $key, $destPath, $flags ) );
1240 wfDebug( __METHOD__
.": set db items, applying file transactions\n" );
1241 $transaction->commit();
1242 FileStore
::unlock();
1244 $m = explode('!',$oimage->archive_name
,2);
1251 * Update the revision's rev_deleted field
1252 * @param Revision $rev
1253 * @param int $bitfield new rev_deleted bitfield value
1255 function updateRevision( $rev, $bitfield ) {
1256 $this->dbw
->update( 'revision',
1257 array( 'rev_deleted' => $bitfield ),
1258 array( 'rev_id' => $rev->getId(),
1259 'rev_page' => $rev->getPage() ),
1264 * Update the revision's rev_deleted field
1265 * @param Revision $rev
1266 * @param Title $title
1267 * @param int $bitfield new rev_deleted bitfield value
1269 function updateArchive( $rev, $title, $bitfield ) {
1270 $this->dbw
->update( 'archive',
1271 array( 'ar_deleted' => $bitfield ),
1272 array( 'ar_namespace' => $title->getNamespace(),
1273 'ar_title' => $title->getDBKey(),
1274 'ar_timestamp' => $this->dbw
->timestamp( $rev->getTimestamp() ),
1275 'ar_rev_id' => $rev->getId() ),
1280 * Update the images's oi_deleted field
1282 * @param int $bitfield new rev_deleted bitfield value
1284 function updateOldFiles( $file, $bitfield ) {
1285 $this->dbw
->update( 'oldimage',
1286 array( 'oi_deleted' => $bitfield ),
1287 array( 'oi_name' => $file->getName(),
1288 'oi_timestamp' => $this->dbw
->timestamp( $file->getTimestamp() ) ),
1293 * Update the images's fa_deleted field
1294 * @param ArchivedFile $file
1295 * @param int $bitfield new rev_deleted bitfield value
1297 function updateArchFiles( $file, $bitfield ) {
1298 $this->dbw
->update( 'filearchive',
1299 array( 'fa_deleted' => $bitfield ),
1300 array( 'fa_id' => $file->getId() ),
1305 * Update the logging log_deleted field
1307 * @param int $bitfield new rev_deleted bitfield value
1309 function updateLogs( $row, $bitfield ) {
1310 $this->dbw
->update( 'logging',
1311 array( 'log_deleted' => $bitfield ),
1312 array( 'log_id' => $row->log_id
),
1317 * Update the revision's recentchanges record if fields have been hidden
1318 * @param Revision $rev
1319 * @param int $bitfield new rev_deleted bitfield value
1321 function updateRecentChangesEdits( $rev, $bitfield ) {
1322 $this->dbw
->update( 'recentchanges',
1323 array( 'rc_deleted' => $bitfield,
1324 'rc_patrolled' => 1 ),
1325 array( 'rc_this_oldid' => $rev->getId(),
1326 'rc_timestamp' => $this->dbw
->timestamp( $rev->getTimestamp() ) ),
1331 * Update the revision's recentchanges record if fields have been hidden
1333 * @param int $bitfield new rev_deleted bitfield value
1335 function updateRecentChangesLog( $row, $bitfield ) {
1336 $this->dbw
->update( 'recentchanges',
1337 array( 'rc_deleted' => $bitfield,
1338 'rc_patrolled' => 1 ),
1339 array( 'rc_logid' => $row->log_id
,
1340 'rc_timestamp' => $row->log_timestamp
),
1345 * Touch the page's cache invalidation timestamp; this forces cached
1346 * history views to refresh, so any newly hidden or shown fields will
1348 * @param Title $title
1350 function updatePage( $title ) {
1351 $title->invalidateCache();
1352 $title->purgeSquid();
1353 $title->touchLinks();
1354 // Extensions that require referencing previous revisions may need this
1355 wfRunHooks( 'ArticleRevisionVisiblitySet', array( &$title ) );
1359 * Checks for a change in the bitfield for a certain option and updates the
1360 * provided array accordingly.
1362 * @param String $desc Description to add to the array if the option was
1363 * enabled / disabled.
1364 * @param int $field The bitmask describing the single option.
1365 * @param int $diff The xor of the old and new bitfields.
1366 * @param array $arr The array to update.
1368 function checkItem ( $desc, $field, $diff, $new, &$arr ) {
1369 if ( $diff & $field ) {
1370 $arr [ ( $new & $field ) ?
0 : 1 ][] = $desc;
1375 * Gets an array describing the changes made to the visibilit of the revision.
1376 * If the resulting array is $arr, then $arr[0] will contain an array of strings
1377 * describing the items that were hidden, $arr[2] will contain an array of strings
1378 * describing the items that were unhidden, and $arr[3] will contain an array with
1379 * a single string, which can be one of "applied restrictions to sysops",
1380 * "removed restrictions from sysops", or null.
1382 * @param int $n The new bitfield.
1383 * @param int $o The old bitfield.
1384 * @return An array as described above.
1386 function getChanges ( $n, $o ) {
1388 $ret = array ( 0 => array(), 1 => array(), 2 => array() );
1390 $this->checkItem ( wfMsgForContent ( 'revdelete-content' ),
1391 Revision
::DELETED_TEXT
, $diff, $n, $ret );
1392 $this->checkItem ( wfMsgForContent ( 'revdelete-summary' ),
1393 Revision
::DELETED_COMMENT
, $diff, $n, $ret );
1394 $this->checkItem ( wfMsgForContent ( 'revdelete-uname' ),
1395 Revision
::DELETED_USER
, $diff, $n, $ret );
1397 // Restriction application to sysops
1398 if ( $diff & Revision
::DELETED_RESTRICTED
) {
1399 if ( $n & Revision
::DELETED_RESTRICTED
)
1400 $ret[2][] = wfMsgForContent ( 'revdelete-restricted' );
1402 $ret[2][] = wfMsgForContent ( 'revdelete-unrestricted' );
1409 * Gets a log message to describe the given revision visibility change. This
1410 * message will be of the form "[hid {content, edit summary, username}];
1411 * [unhid {...}][applied restrictions to sysops] for $count revisions: $comment".
1413 * @param int $count The number of effected revisions.
1414 * @param int $nbitfield The new bitfield for the revision.
1415 * @param int $obitfield The old bitfield for the revision.
1416 * @param string $comment The comment associated with the change.
1417 * @param bool $isForLog
1419 function getLogMessage ( $count, $nbitfield, $obitfield, $comment, $isForLog = false ) {
1423 $changes = $this->getChanges( $nbitfield, $obitfield );
1425 if ( count ( $changes[0] ) ) {
1426 $s .= wfMsgForContent ( 'revdelete-hid', implode ( ', ', $changes[0] ) );
1429 if ( count ( $changes[1] ) ) {
1432 $s .= wfMsgForContent ( 'revdelete-unhid', implode ( ', ', $changes[1] ) );
1435 if ( count ( $changes[2] )) {
1437 $s .= ' (' . $changes[2][0] . ')';
1439 $s = $changes[2][0];
1442 $msg = $isForLog ?
'logdelete-log-message' : 'revdelete-log-message';
1443 $ret = wfMsgExt ( $msg, array( 'parsemag', 'content' ),
1444 $s, $wgContLang->formatNum( $count ) );
1447 $ret .= ": $comment";
1454 * Record a log entry on the action
1455 * @param Title $title, page where item was removed from
1456 * @param int $count the number of revisions altered for this page
1457 * @param int $nbitfield the new _deleted value
1458 * @param int $obitfield the old _deleted value
1459 * @param string $comment
1460 * @param Title $target, the relevant page
1461 * @param string $param, URL param
1462 * @param Array $items
1464 function updateLog( $title, $count, $nbitfield, $obitfield, $comment, $target, $param, $items = array() ) {
1465 // Put things hidden from sysops in the oversight log
1466 $logtype = ( ($nbitfield |
$obitfield) & Revision
::DELETED_RESTRICTED
) ?
'suppress' : 'delete';
1467 $log = new LogPage( $logtype );
1469 $reason = $this->getLogMessage ( $count, $nbitfield, $obitfield, $comment, $param == 'logid' );
1471 if( $param == 'logid' ) {
1472 $params = array( implode( ',', $items) );
1473 $log->addEntry( 'event', $title, $reason, $params );
1475 // Add params for effected page and ids
1476 $params = array( $param, implode( ',', $items) );
1477 $log->addEntry( 'revision', $title, $reason, $params );