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-toomanytargets-title', 'revdelete-toomanytargets-text' );
39 # Logs must have a type given
40 if( $logid && !strpos($page->getDBKey(),'/') ) {
41 $wgOut->showErrorPage( 'revdelete-nologtype-title', 'revdelete-nologtype-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
->getPrefixedDBkey() ) ) );
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 $result = $dbr->select( array('revision','page'), '*',
194 'rev_page' => $this->page
->getArticleID(),
196 'rev_page = page_id' ),
198 while( $row = $dbr->fetchObject( $result ) ) {
199 $revObjs[$row->rev_id
] = new Revision( $row );
201 foreach( $this->revisions
as $revid ) {
202 // Hiding top revisison is bad
203 if( !isset($revObjs[$revid]) ||
$revObjs[$revid]->isCurrent() ) {
205 } else if( !$revObjs[$revid]->userCan(Revision
::DELETED_RESTRICTED
) ) {
206 // If a rev is hidden from sysops
207 if( $action != 'submit') {
208 $wgOut->permissionRequired( 'suppressrevision' );
211 $UserAllowed = false;
214 $wgOut->addHTML( $this->historyLine( $revObjs[$revid] ) );
215 $bitfields |
= $revObjs[$revid]->mDeleted
;
219 // Run through and pull all our data in one query
220 foreach( $this->archrevs
as $timestamp ) {
221 $where[] = $dbr->addQuotes( $timestamp );
223 $result = $dbr->select( 'archive', '*',
225 'ar_namespace' => $this->page
->getNamespace(),
226 'ar_title' => $this->page
->getDBKey(),
227 'ar_timestamp' => $where ),
229 while( $row = $dbr->fetchObject( $result ) ) {
230 $revObjs[$row->ar_timestamp
] = new Revision( array(
231 'page' => $this->page
->getArticleId(),
232 'id' => $row->ar_rev_id
,
233 'text' => $row->ar_text_id
,
234 'comment' => $row->ar_comment
,
235 'user' => $row->ar_user
,
236 'user_text' => $row->ar_user_text
,
237 'timestamp' => $row->ar_timestamp
,
238 'minor_edit' => $row->ar_minor_edit
,
239 'text_id' => $row->ar_text_id
,
240 'deleted' => $row->ar_deleted
,
241 'len' => $row->ar_len
) );
243 foreach( $this->archrevs
as $timestamp ) {
244 if( !isset($revObjs[$timestamp]) ) {
246 } else if( !$revObjs[$timestamp]->userCan(Revision
::DELETED_RESTRICTED
) ) {
247 // If a rev is hidden from sysops
248 if( $action != 'submit') {
249 $wgOut->permissionRequired( 'suppressrevision' );
252 $UserAllowed = false;
255 $wgOut->addHTML( $this->historyLine( $revObjs[$timestamp] ) );
256 $bitfields |
= $revObjs[$timestamp]->mDeleted
;
260 $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
264 $wgOut->addHTML( "</ul>" );
266 $wgOut->addWikiMsg( 'revdelete-text' );
268 // Normal sysops can always see what they did, but can't always change it
269 if( !$UserAllowed ) return;
272 Xml
::inputLabel( wfMsg( 'revdelete-log' ), 'wpReason', 'wpReason', 60 ),
273 Xml
::submitButton( wfMsg( 'revdelete-submit' ) )
276 Xml
::hidden( 'wpEditToken', $wgUser->editToken() ),
277 Xml
::hidden( 'target', $this->page
->getPrefixedText() ),
278 Xml
::hidden( 'type', $this->deleteKey
)
280 if( $this->deleteKey
=='oldid' ) {
281 foreach( $revObjs as $rev )
282 $hidden[] = Xml
::hidden( 'oldid[]', $rev->getId() );
284 foreach( $revObjs as $rev )
285 $hidden[] = Xml
::hidden( 'artimestamp[]', $rev->getTimestamp() );
287 $special = SpecialPage
::getTitleFor( 'Revisiondelete' );
289 Xml
::openElement( 'form', array( 'method' => 'post', 'action' => $special->getLocalUrl( 'action=submit' ),
290 'id' => 'mw-revdel-form-revisions' ) ) .
291 Xml
::openElement( 'fieldset' ) .
292 xml
::element( 'legend', null, wfMsg( 'revdelete-legend' ) )
294 // FIXME: all items checked for just one rev are checked, even if not set for the others
295 foreach( $this->checks
as $item ) {
296 list( $message, $name, $field ) = $item;
297 $wgOut->addHTML( Xml
::tags( 'div', null, Xml
::checkLabel( wfMsg( $message ), $name, $name, $bitfields & $field ) ) );
299 foreach( $items as $item ) {
300 $wgOut->addHTML( Xml
::tags( 'p', null, $item ) );
302 foreach( $hidden as $item ) {
303 $wgOut->addHTML( $item );
306 Xml
::closeElement( 'fieldset' ) .
307 Xml
::closeElement( 'form' ) . "\n"
313 * This lets a user set restrictions for archived images
315 function showImages() {
316 // What is $action doing here???
317 global $wgOut, $wgUser, $action, $wgLang;
321 $count = ($this->deleteKey
=='oldimage') ?
count($this->ofiles
) : count($this->afiles
);
322 $wgOut->addWikiMsg( 'revdelete-selected',
323 $this->page
->getPrefixedText(),
324 $wgLang->formatNum($count) );
327 $wgOut->addHTML( "<ul>" );
329 $where = $filesObjs = array();
330 $dbr = wfGetDB( DB_SLAVE
);
331 // Live old revisions...
333 if( $this->deleteKey
=='oldimage' ) {
334 // Run through and pull all our data in one query
335 foreach( $this->ofiles
as $timestamp ) {
336 $where[] = $dbr->addQuotes( $timestamp.'!'.$this->page
->getDBKey() );
338 $result = $dbr->select( 'oldimage', '*',
340 'oi_name' => $this->page
->getDBKey(),
341 'oi_archive_name' => $where ),
343 while( $row = $dbr->fetchObject( $result ) ) {
344 $filesObjs[$row->oi_archive_name
] = RepoGroup
::singleton()->getLocalRepo()->newFileFromRow( $row );
345 $filesObjs[$row->oi_archive_name
]->user
= $row->oi_user
;
346 $filesObjs[$row->oi_archive_name
]->user_text
= $row->oi_user_text
;
348 // Check through our images
349 foreach( $this->ofiles
as $timestamp ) {
350 $archivename = $timestamp.'!'.$this->page
->getDBKey();
351 if( !isset($filesObjs[$archivename]) ) {
353 } else if( !$filesObjs[$archivename]->userCan(File
::DELETED_RESTRICTED
) ) {
354 // If a rev is hidden from sysops
355 if( $action != 'submit' ) {
356 $wgOut->permissionRequired( 'suppressrevision' );
359 $UserAllowed = false;
362 // Inject history info
363 $wgOut->addHTML( $this->fileLine( $filesObjs[$archivename] ) );
364 $bitfields |
= $filesObjs[$archivename]->deleted
;
368 // Run through and pull all our data in one query
369 foreach( $this->afiles
as $id ) {
370 $where[] = intval($id);
372 $result = $dbr->select( 'filearchive', '*',
374 'fa_name' => $this->page
->getDBKey(),
377 while( $row = $dbr->fetchObject( $result ) ) {
378 $filesObjs[$row->fa_id
] = ArchivedFile
::newFromRow( $row );
381 foreach( $this->afiles
as $fileid ) {
382 if( !isset($filesObjs[$fileid]) ) {
384 } else if( !$filesObjs[$fileid]->userCan(File
::DELETED_RESTRICTED
) ) {
385 // If a rev is hidden from sysops
386 if( $action != 'submit' ) {
387 $wgOut->permissionRequired( 'suppressrevision' );
390 $UserAllowed = false;
393 // Inject history info
394 $wgOut->addHTML( $this->archivedfileLine( $filesObjs[$fileid] ) );
395 $bitfields |
= $filesObjs[$fileid]->deleted
;
399 $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
403 $wgOut->addHTML( "</ul>" );
405 $wgOut->addWikiMsg('revdelete-text' );
406 //Normal sysops can always see what they did, but can't always change it
407 if( !$UserAllowed ) return;
410 Xml
::inputLabel( wfMsg( 'revdelete-log' ), 'wpReason', 'wpReason', 60 ),
411 Xml
::submitButton( wfMsg( 'revdelete-submit' ) )
414 Xml
::hidden( 'wpEditToken', $wgUser->editToken() ),
415 Xml
::hidden( 'target', $this->page
->getPrefixedText() ),
416 Xml
::hidden( 'type', $this->deleteKey
)
418 if( $this->deleteKey
=='oldimage' ) {
419 foreach( $this->ofiles
as $filename )
420 $hidden[] = Xml
::hidden( 'oldimage[]', $filename );
422 foreach( $this->afiles
as $fileid )
423 $hidden[] = Xml
::hidden( 'fileid[]', $fileid );
425 $special = SpecialPage
::getTitleFor( 'Revisiondelete' );
427 Xml
::openElement( 'form', array( 'method' => 'post', 'action' => $special->getLocalUrl( 'action=submit' ),
428 'id' => 'mw-revdel-form-filerevisions' ) ) .
429 Xml
::fieldset( wfMsg( 'revdelete-legend' ) )
431 // FIXME: all items checked for just one file are checked, even if not set for the others
432 foreach( $this->checks
as $item ) {
433 list( $message, $name, $field ) = $item;
434 $wgOut->addHTML( Xml
::tags( 'div', null, Xml
::checkLabel( wfMsg( $message ), $name, $name, $bitfields & $field ) ) );
436 foreach( $items as $item ) {
437 $wgOut->addHTML( "<p>$item</p>" );
439 foreach( $hidden as $item ) {
440 $wgOut->addHTML( $item );
444 Xml
::closeElement( 'fieldset' ) .
445 Xml
::closeElement( 'form' ) . "\n"
450 * This lets a user set restrictions for log items
452 function showLogItems() {
453 global $wgOut, $wgUser, $action, $wgMessageCache, $wgLang;
456 $wgOut->addWikiMsg( 'logdelete-selected', $wgLang->formatNum( count($this->events
) ) );
459 $wgOut->addHTML( "<ul>" );
461 $where = $logRows = array();
462 $dbr = wfGetDB( DB_SLAVE
);
463 // Run through and pull all our data in one query
465 foreach( $this->events
as $logid ) {
466 $where[] = intval($logid);
468 list($log,$logtype) = explode( '/',$this->page
->getDBKey(), 2 );
469 $result = $dbr->select( 'logging', '*',
471 'log_type' => $logtype,
472 'log_id' => $where ),
474 while( $row = $dbr->fetchObject( $result ) ) {
475 $logRows[$row->log_id
] = $row;
477 $wgMessageCache->loadAllMessages();
478 foreach( $this->events
as $logid ) {
479 // Don't hide from oversight log!!!
480 if( !isset( $logRows[$logid] ) ||
$logRows[$logid]->log_type
=='suppress' ) {
482 } else if( !LogEventsList
::userCan( $logRows[$logid],Revision
::DELETED_RESTRICTED
) ) {
483 // If an event is hidden from sysops
484 if( $action != 'submit') {
485 $wgOut->permissionRequired( 'suppressrevision' );
488 $UserAllowed = false;
491 $wgOut->addHTML( $this->logLine( $logRows[$logid] ) );
492 $bitfields |
= $logRows[$logid]->log_deleted
;
495 $wgOut->showErrorPage( 'revdelete-nologid-title', 'revdelete-nologid-text' );
499 $wgOut->addHTML( "</ul>" );
501 $wgOut->addWikiMsg( 'revdelete-text' );
502 // Normal sysops can always see what they did, but can't always change it
503 if( !$UserAllowed ) return;
506 Xml
::inputLabel( wfMsg( 'revdelete-log' ), 'wpReason', 'wpReason', 60 ),
507 Xml
::submitButton( wfMsg( 'revdelete-submit' ) ) );
509 Xml
::hidden( 'wpEditToken', $wgUser->editToken() ),
510 Xml
::hidden( 'target', $this->page
->getPrefixedText() ),
511 Xml
::hidden( 'type', $this->deleteKey
) );
512 foreach( $this->events
as $logid ) {
513 $hidden[] = Xml
::hidden( 'logid[]', $logid );
516 $special = SpecialPage
::getTitleFor( 'Revisiondelete' );
518 Xml
::openElement( 'form', array( 'method' => 'post', 'action' => $special->getLocalUrl( 'action=submit' ),
519 'id' => 'mw-revdel-form-logs' ) ) .
520 Xml
::fieldset( wfMsg( 'revdelete-legend' ) )
522 // FIXME: all items checked for just on event are checked, even if not set for the others
523 foreach( $this->checks
as $item ) {
524 list( $message, $name, $field ) = $item;
525 $wgOut->addHTML( Xml
::tags( 'div', null, Xml
::checkLabel( wfMsg( $message ), $name, $name, $bitfields & $field ) ) );
527 foreach( $items as $item ) {
528 $wgOut->addHTML( "<p>$item</p>" );
530 foreach( $hidden as $item ) {
531 $wgOut->addHTML( $item );
535 Xml
::closeElement( 'fieldset' ) .
536 Xml
::closeElement( 'form' ) . "\n"
541 * @param Revision $rev
544 private function historyLine( $rev ) {
547 $date = $wgLang->timeanddate( $rev->getTimestamp() );
548 $difflink = $del = '';
550 if( $this->deleteKey
=='oldid' ) {
551 $revlink = $this->skin
->makeLinkObj( $this->page
, $date, 'oldid=' . $rev->getId() );
552 $difflink = '(' . $this->skin
->makeKnownLinkObj( $this->page
, wfMsgHtml('diff'),
553 'diff=' . $rev->getId() . '&oldid=prev' ) . ')';
554 // Archived revisions
556 $undelete = SpecialPage
::getTitleFor( 'Undelete' );
557 $target = $this->page
->getPrefixedText();
558 $revlink = $this->skin
->makeLinkObj( $undelete, $date,
559 "target=$target×tamp=" . $rev->getTimestamp() );
560 $difflink = '(' . $this->skin
->makeKnownLinkObj( $undelete, wfMsgHtml('diff'),
561 "target=$target&diff=prev×tamp=" . $rev->getTimestamp() ) . ')';
564 if( $rev->isDeleted(Revision
::DELETED_TEXT
) ) {
565 $revlink = '<span class="history-deleted">'.$revlink.'</span>';
566 $del = ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
567 if( !$rev->userCan(Revision
::DELETED_TEXT
) ) {
568 $revlink = '<span class="history-deleted">'.$date.'</span>';
569 $difflink = '(' . wfMsgHtml('diff') . ')';
573 return "<li> $difflink $revlink ".$this->skin
->revUserLink( $rev )." ".$this->skin
->revComment( $rev )."$del</li>";
580 private function fileLine( $file ) {
581 global $wgLang, $wgTitle;
583 $target = $this->page
->getPrefixedText();
584 $date = $wgLang->timeanddate( $file->getTimestamp(), true );
588 if( $file->isDeleted(File
::DELETED_FILE
) ) {
589 $del = ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
590 if( !$file->userCan(File
::DELETED_FILE
) ) {
593 $pageLink = $this->skin
->makeKnownLinkObj( $wgTitle, $date,
594 "target=$target&file=$file->sha1.".$file->getExtension() );
596 $pageLink = '<span class="history-deleted">' . $pageLink . '</span>';
599 $url = $file->getUrlRel();
600 $pageLink = "<a href=\"{$url}\">{$date}</a>";
603 $data = wfMsg( 'widthheight',
604 $wgLang->formatNum( $file->getWidth() ),
605 $wgLang->formatNum( $file->getHeight() ) ) .
606 ' (' . wfMsgExt( 'nbytes', 'parsemag', $wgLang->formatNum( $file->getSize() ) ) . ')';
607 $data = htmlspecialchars( $data );
609 return "<li>$pageLink ".$this->fileUserTools( $file )." $data ".$this->fileComment( $file )."$del</li>";
613 * @param ArchivedFile $file
616 private function archivedfileLine( $file ) {
619 $target = $this->page
->getPrefixedText();
620 $date = $wgLang->timeanddate( $file->getTimestamp(), true );
622 $undelete = SpecialPage
::getTitleFor( 'Undelete' );
623 $pageLink = $this->skin
->makeKnownLinkObj( $undelete, $date, "target=$target&file={$file->getKey()}" );
626 if( $file->isDeleted(File
::DELETED_FILE
) ) {
627 $del = ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
630 $data = wfMsg( 'widthheight',
631 $wgLang->formatNum( $file->getWidth() ),
632 $wgLang->formatNum( $file->getHeight() ) ) .
633 ' (' . wfMsgExt( 'nbytes', 'parsemag', $wgLang->formatNum( $file->getSize() ) ) . ')';
634 $data = htmlspecialchars( $data );
636 return "<li> $pageLink ".$this->fileUserTools( $file )." $data ".$this->fileComment( $file )."$del</li>";
640 * @param Array $row row
643 private function logLine( $row ) {
646 $date = $wgLang->timeanddate( $row->log_timestamp
);
647 $paramArray = LogPage
::extractParams( $row->log_params
);
648 $title = Title
::makeTitle( $row->log_namespace
, $row->log_title
);
650 $logtitle = SpecialPage
::getTitleFor( 'Log' );
651 $loglink = $this->skin
->makeKnownLinkObj( $logtitle, wfMsgHtml( 'log' ),
652 wfArrayToCGI( array( 'page' => $title->getPrefixedUrl() ) ) );
654 if( !LogEventsList
::userCan($row,LogPage
::DELETED_ACTION
) ) {
655 $action = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
657 $action = LogPage
::actionText( $row->log_type
, $row->log_action
, $title,
658 $this->skin
, $paramArray, true, true );
659 if( $row->log_deleted
& LogPage
::DELETED_ACTION
)
660 $action = '<span class="history-deleted">' . $action . '</span>';
663 $userLink = $this->skin
->userLink( $row->log_user
, User
::WhoIs($row->log_user
) );
664 if( LogEventsList
::isDeleted($row,LogPage
::DELETED_USER
) ) {
665 $userLink = '<span class="history-deleted">' . $userLink . '</span>';
668 $comment = $wgLang->getDirMark() . $this->skin
->commentBlock( $row->log_comment
);
669 if( LogEventsList
::isDeleted($row,LogPage
::DELETED_COMMENT
) ) {
670 $comment = '<span class="history-deleted">' . $comment . '</span>';
672 return "<li>($loglink) $date $userLink $action $comment</li>";
676 * Generate a user tool link cluster if the current user is allowed to view it
677 * @param ArchivedFile $file
678 * @return string HTML
680 private function fileUserTools( $file ) {
681 if( $file->userCan( Revision
::DELETED_USER
) ) {
682 $link = $this->skin
->userLink( $file->user
, $file->user_text
) .
683 $this->skin
->userToolLinks( $file->user
, $file->user_text
);
685 $link = wfMsgHtml( 'rev-deleted-user' );
687 if( $file->isDeleted( Revision
::DELETED_USER
) ) {
688 return '<span class="history-deleted">' . $link . '</span>';
694 * Wrap and format the given file's comment block, if the current
695 * user is allowed to view it.
697 * @param ArchivedFile $file
698 * @return string HTML
700 private function fileComment( $file ) {
701 if( $file->userCan( File
::DELETED_COMMENT
) ) {
702 $block = $this->skin
->commentBlock( $file->description
);
704 $block = ' ' . wfMsgHtml( 'rev-deleted-comment' );
706 if( $file->isDeleted( File
::DELETED_COMMENT
) ) {
707 return "<span class=\"history-deleted\">$block</span>";
713 * @param WebRequest $request
715 function submit( $request ) {
716 global $wgUser, $wgOut;
718 $bitfield = $this->extractBitfield( $request );
719 $comment = $request->getText( 'wpReason' );
720 # Can the user set this field?
721 if( $bitfield & Revision
::DELETED_RESTRICTED
&& !$wgUser->isAllowed('suppressrevision') ) {
722 $wgOut->permissionRequired( 'suppressrevision' );
725 # If the save went through, go to success message. Otherwise
726 # bounce back to form...
727 if( $this->save( $bitfield, $comment, $this->page
) ) {
729 } else if( $request->getCheck( 'oldid' ) ||
$request->getCheck( 'artimestamp' ) ) {
730 return $this->showRevs();
731 } else if( $request->getCheck( 'logid' ) ) {
732 return $this->showLogs();
733 } else if( $request->getCheck( 'oldimage' ) ||
$request->getCheck( 'fileid' ) ) {
734 return $this->showImages();
738 private function success() {
741 $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
743 $wrap = '<span class="success">$1</span>';
745 if( $this->deleteKey
=='logid' ) {
746 $wgOut->wrapWikiMsg( $wrap, 'logdelete-success' );
747 $this->showLogItems();
748 } else if( $this->deleteKey
=='oldid' ||
$this->deleteKey
=='artimestamp' ) {
749 $wgOut->wrapWikiMsg( $wrap, 'revdelete-success' );
751 } else if( $this->deleteKey
=='fileid' ) {
752 $wgOut->wrapWikiMsg( $wrap, 'revdelete-success' );
754 } else if( $this->deleteKey
=='oldimage' ) {
755 $wgOut->wrapWikiMsg( $wrap, 'revdelete-success' );
761 * Put together a rev_deleted bitfield from the submitted checkboxes
762 * @param WebRequest $request
765 private function extractBitfield( $request ) {
767 foreach( $this->checks
as $item ) {
768 list( /* message */ , $name, $field ) = $item;
769 if( $request->getCheck( $name ) ) {
776 private function save( $bitfield, $reason, $title ) {
777 $dbw = wfGetDB( DB_MASTER
);
778 // Don't allow simply locking the interface for no reason
779 if( $bitfield == Revision
::DELETED_RESTRICTED
) {
782 $deleter = new RevisionDeleter( $dbw );
783 // By this point, only one of the below should be set
784 if( isset($this->revisions
) ) {
785 return $deleter->setRevVisibility( $title, $this->revisions
, $bitfield, $reason );
786 } else if( isset($this->archrevs
) ) {
787 return $deleter->setArchiveVisibility( $title, $this->archrevs
, $bitfield, $reason );
788 } else if( isset($this->ofiles
) ) {
789 return $deleter->setOldImgVisibility( $title, $this->ofiles
, $bitfield, $reason );
790 } else if( isset($this->afiles
) ) {
791 return $deleter->setArchFileVisibility( $title, $this->afiles
, $bitfield, $reason );
792 } else if( isset($this->events
) ) {
793 return $deleter->setEventVisibility( $title, $this->events
, $bitfield, $reason );
799 * Implements the actions for Revision Deletion.
800 * @ingroup SpecialPage
802 class RevisionDeleter
{
803 function __construct( $db ) {
808 * @param $title, the page these events apply to
809 * @param array $items list of revision ID numbers
810 * @param int $bitfield new rev_deleted value
811 * @param string $comment Comment for log records
813 function setRevVisibility( $title, $items, $bitfield, $comment ) {
816 $userAllowedAll = $success = true;
819 // Run through and pull all our data in one query
820 foreach( $items as $revid ) {
821 $where[] = intval($revid);
823 $result = $this->dbw
->select( 'revision', '*',
825 'rev_page' => $title->getArticleID(),
826 'rev_id' => $where ),
828 while( $row = $this->dbw
->fetchObject( $result ) ) {
829 $revObjs[$row->rev_id
] = new Revision( $row );
832 foreach( $items as $revid ) {
833 if( !isset($revObjs[$revid]) ||
$revObjs[$revid]->isCurrent() ) {
835 continue; // Must exist
836 } else if( !$revObjs[$revid]->userCan(Revision
::DELETED_RESTRICTED
) ) {
837 $userAllowedAll=false;
840 // For logging, maintain a count of revisions
841 if( $revObjs[$revid]->mDeleted
!= $bitfield ) {
845 $this->updateRevision( $revObjs[$revid], $bitfield );
846 $this->updateRecentChangesEdits( $revObjs[$revid], $bitfield, false );
850 // Don't log or touch if nothing changed
851 if( $revCount > 0 ) {
852 $this->updateLog( $title, $revCount, $bitfield, $revObjs[$revid]->mDeleted
,
853 $comment, $title, 'oldid', $revIDs );
854 $this->updatePage( $title );
856 // Where all revs allowed to be set?
857 if( !$userAllowedAll ) {
858 //FIXME: still might be confusing???
859 $wgOut->permissionRequired( 'suppressrevision' );
867 * @param $title, the page these events apply to
868 * @param array $items list of revision ID numbers
869 * @param int $bitfield new rev_deleted value
870 * @param string $comment Comment for log records
872 function setArchiveVisibility( $title, $items, $bitfield, $comment ) {
875 $userAllowedAll = $success = true;
878 // Run through and pull all our data in one query
879 foreach( $items as $timestamp ) {
880 $where[] = $this->dbw
->addQuotes( $timestamp );
882 $result = $this->dbw
->select( 'archive', '*',
884 'ar_namespace' => $title->getNamespace(),
885 'ar_title' => $title->getDBKey(),
886 'ar_timestamp' => $where ),
888 while( $row = $this->dbw
->fetchObject( $result ) ) {
889 $revObjs[$row->ar_timestamp
] = new Revision( array(
890 'page' => $title->getArticleId(),
891 'id' => $row->ar_rev_id
,
892 'text' => $row->ar_text_id
,
893 'comment' => $row->ar_comment
,
894 'user' => $row->ar_user
,
895 'user_text' => $row->ar_user_text
,
896 'timestamp' => $row->ar_timestamp
,
897 'minor_edit' => $row->ar_minor_edit
,
898 'text_id' => $row->ar_text_id
,
899 'deleted' => $row->ar_deleted
,
900 'len' => $row->ar_len
) );
903 foreach( $items as $timestamp ) {
904 // This will only select the first revision with this timestamp.
905 // Since they are all selected/deleted at once, we can just check the
906 // permissions of one. UPDATE is done via timestamp, so all revs are set.
907 if( !is_object($revObjs[$timestamp]) ) {
909 continue; // Must exist
910 } else if( !$revObjs[$timestamp]->userCan(Revision
::DELETED_RESTRICTED
) ) {
911 $userAllowedAll=false;
914 // Which revisions did we change anything about?
915 if( $revObjs[$timestamp]->mDeleted
!= $bitfield ) {
916 $Id_set[]=$timestamp;
919 $this->updateArchive( $revObjs[$timestamp], $title, $bitfield );
922 // For logging, maintain a count of revisions
924 $this->updateLog( $title, $count, $bitfield, $revObjs[$timestamp]->mDeleted
,
925 $comment, $title, 'artimestamp', $Id_set );
927 // Where all revs allowed to be set?
928 if( !$userAllowedAll ) {
929 $wgOut->permissionRequired( 'suppressrevision' );
937 * @param $title, the page these events apply to
938 * @param array $items list of revision ID numbers
939 * @param int $bitfield new rev_deleted value
940 * @param string $comment Comment for log records
942 function setOldImgVisibility( $title, $items, $bitfield, $comment ) {
945 $userAllowedAll = $success = true;
948 // Run through and pull all our data in one query
949 foreach( $items as $timestamp ) {
950 $where[] = $this->dbw
->addQuotes( $timestamp.'!'.$title->getDBKey() );
952 $result = $this->dbw
->select( 'oldimage', '*',
954 'oi_name' => $title->getDBKey(),
955 'oi_archive_name' => $where ),
957 while( $row = $this->dbw
->fetchObject( $result ) ) {
958 $filesObjs[$row->oi_archive_name
] = RepoGroup
::singleton()->getLocalRepo()->newFileFromRow( $row );
959 $filesObjs[$row->oi_archive_name
]->user
= $row->oi_user
;
960 $filesObjs[$row->oi_archive_name
]->user_text
= $row->oi_user_text
;
963 foreach( $items as $timestamp ) {
964 $archivename = $timestamp.'!'.$title->getDBKey();
965 if( !isset($filesObjs[$archivename]) ) {
967 continue; // Must exist
968 } else if( !$filesObjs[$archivename]->userCan(File
::DELETED_RESTRICTED
) ) {
969 $userAllowedAll=false;
974 // Which revisions did we change anything about?
975 if( $filesObjs[$archivename]->deleted
!= $bitfield ) {
979 $this->updateOldFiles( $filesObjs[$archivename], $bitfield );
980 // If this image is currently hidden...
981 if( $filesObjs[$archivename]->deleted
& File
::DELETED_FILE
) {
982 if( $bitfield & File
::DELETED_FILE
) {
983 # Leave it alone if we are not changing this...
987 # We are moving this out
988 $transaction = $this->makeOldImagePublic( $filesObjs[$archivename] );
991 // Is it just now becoming hidden?
992 } else if( $bitfield & File
::DELETED_FILE
) {
993 $transaction = $this->makeOldImagePrivate( $filesObjs[$archivename] );
998 // If our file operations fail, then revert back the db
999 if( $transaction==false ) {
1000 $this->dbw
->rollback();
1003 $this->dbw
->commit();
1007 // Log if something was changed
1009 $this->updateLog( $title, $count, $bitfield, $filesObjs[$archivename]->deleted
,
1010 $comment, $title, 'oldimage', $set );
1011 # Purge page/history
1012 $file = wfLocalFile( $title );
1013 $file->purgeCache();
1014 $file->purgeHistory();
1015 # Invalidate cache for all pages using this file
1016 $update = new HTMLCacheUpdate( $title, 'imagelinks' );
1017 $update->doUpdate();
1019 // Where all revs allowed to be set?
1020 if( !$userAllowedAll ) {
1021 $wgOut->permissionRequired( 'suppressrevision' );
1029 * @param $title, the page these events apply to
1030 * @param array $items list of revision ID numbers
1031 * @param int $bitfield new rev_deleted value
1032 * @param string $comment Comment for log records
1034 function setArchFileVisibility( $title, $items, $bitfield, $comment ) {
1037 $userAllowedAll = $success = true;
1041 // Run through and pull all our data in one query
1042 foreach( $items as $id ) {
1043 $where[] = intval($id);
1045 $result = $this->dbw
->select( 'filearchive', '*',
1046 array( 'fa_name' => $title->getDBKey(),
1047 'fa_id' => $where ),
1049 while( $row = $this->dbw
->fetchObject( $result ) ) {
1050 $filesObjs[$row->fa_id
] = ArchivedFile
::newFromRow( $row );
1053 foreach( $items as $fileid ) {
1054 if( !isset($filesObjs[$fileid]) ) {
1056 continue; // Must exist
1057 } else if( !$filesObjs[$fileid]->userCan(File
::DELETED_RESTRICTED
) ) {
1058 $userAllowedAll=false;
1061 // Which revisions did we change anything about?
1062 if( $filesObjs[$fileid]->deleted
!= $bitfield ) {
1066 $this->updateArchFiles( $filesObjs[$fileid], $bitfield );
1069 // Log if something was changed
1071 $this->updateLog( $title, $count, $bitfield, $comment,
1072 $filesObjs[$fileid]->deleted
, $title, 'fileid', $Id_set );
1074 // Where all revs allowed to be set?
1075 if( !$userAllowedAll ) {
1076 $wgOut->permissionRequired( 'suppressrevision' );
1084 * @param $title, the log page these events apply to
1085 * @param array $items list of log ID numbers
1086 * @param int $bitfield new log_deleted value
1087 * @param string $comment Comment for log records
1089 function setEventVisibility( $title, $items, $bitfield, $comment ) {
1092 $userAllowedAll = $success = true;
1096 // Run through and pull all our data in one query
1097 foreach( $items as $logid ) {
1098 $where[] = intval($logid);
1100 list($log,$logtype) = explode( '/',$title->getDBKey(), 2 );
1101 $result = $this->dbw
->select( 'logging', '*',
1103 'log_type' => $logtype,
1104 'log_id' => $where ),
1106 while( $row = $this->dbw
->fetchObject( $result ) ) {
1107 $logRows[$row->log_id
] = $row;
1110 foreach( $items as $logid ) {
1111 if( !isset($logRows[$logid]) ) {
1113 continue; // Must exist
1114 } else if( !LogEventsList
::userCan($logRows[$logid], LogPage
::DELETED_RESTRICTED
)
1115 ||
$logRows[$logid]->log_type
== 'suppress' ) {
1116 // Don't hide from oversight log!!!
1117 $userAllowedAll=false;
1120 // Which logs did we change anything about?
1121 if( $logRows[$logid]->log_deleted
!= $bitfield ) {
1125 $this->updateLogs( $logRows[$logid], $bitfield );
1126 $this->updateRecentChangesLog( $logRows[$logid], $bitfield, true );
1129 // Don't log or touch if nothing changed
1131 $this->updateLog( $title, $count, $bitfield, $logRows[$logid]->log_deleted
,
1132 $comment, $title, 'logid', $log_Ids );
1134 // Were all revs allowed to be set?
1135 if( !$userAllowedAll ) {
1136 $wgOut->permissionRequired( 'suppressrevision' );
1144 * Moves an image to a safe private location
1145 * Caller is responsible for clearing caches
1146 * @param File $oimage
1147 * @returns mixed, timestamp string on success, false on failure
1149 function makeOldImagePrivate( $oimage ) {
1150 $transaction = new FSTransaction();
1151 if( !FileStore
::lock() ) {
1152 wfDebug( __METHOD__
.": failed to acquire file store lock, aborting\n" );
1155 $oldpath = $oimage->getArchivePath() . DIRECTORY_SEPARATOR
. $oimage->archive_name
;
1156 // Dupe the file into the file store
1157 if( file_exists( $oldpath ) ) {
1158 // Is our directory configured?
1159 if( $store = FileStore
::get( 'deleted' ) ) {
1160 if( !$oimage->sha1
) {
1161 $oimage->upgradeRow(); // sha1 may be missing
1163 $key = $oimage->sha1
. '.' . $oimage->getExtension();
1164 $transaction->add( $store->insert( $key, $oldpath, FileStore
::DELETE_ORIGINAL
) );
1168 $transaction = false; // Return an error and do nothing
1171 wfDebug( __METHOD__
." deleting already-missing '$oldpath'; moving on to database\n" );
1174 $transaction = new FSTransaction(); // empty
1177 if( $transaction === false ) {
1179 wfDebug( __METHOD__
.": import to file store failed, aborting\n" );
1180 throw new MWException( "Could not archive and delete file $oldpath" );
1184 wfDebug( __METHOD__
.": set db items, applying file transactions\n" );
1185 $transaction->commit();
1186 FileStore
::unlock();
1188 $m = explode('!',$oimage->archive_name
,2);
1195 * Moves an image from a safe private location
1196 * Caller is responsible for clearing caches
1197 * @param File $oimage
1198 * @returns mixed, string timestamp on success, false on failure
1200 function makeOldImagePublic( $oimage ) {
1201 $transaction = new FSTransaction();
1202 if( !FileStore
::lock() ) {
1203 wfDebug( __METHOD__
." could not acquire filestore lock\n" );
1207 $store = FileStore
::get( 'deleted' );
1209 wfDebug( __METHOD__
.": skipping row with no file.\n" );
1213 $key = $oimage->sha1
.'.'.$oimage->getExtension();
1214 $destDir = $oimage->getArchivePath();
1215 if( !is_dir( $destDir ) ) {
1216 wfMkdirParents( $destDir );
1218 $destPath = $destDir . DIRECTORY_SEPARATOR
. $oimage->archive_name
;
1219 // Check if any other stored revisions use this file;
1220 // if so, we shouldn't remove the file from the hidden
1221 // archives so they will still work. Check hidden files first.
1222 $useCount = $this->dbw
->selectField( 'oldimage', '1',
1223 array( 'oi_sha1' => $oimage->sha1
,
1224 'oi_deleted & '.File
::DELETED_FILE
=> File
::DELETED_FILE
),
1225 __METHOD__
, array( 'FOR UPDATE' ) );
1226 // Check the rest of the deleted archives too.
1227 // (these are the ones that don't show in the image history)
1229 $useCount = $this->dbw
->selectField( 'filearchive', '1',
1230 array( 'fa_storage_group' => 'deleted', 'fa_storage_key' => $key ),
1231 __METHOD__
, array( 'FOR UPDATE' ) );
1234 if( $useCount == 0 ) {
1235 wfDebug( __METHOD__
.": nothing else using {$oimage->sha1}, will deleting after\n" );
1236 $flags = FileStore
::DELETE_ORIGINAL
;
1240 $transaction->add( $store->export( $key, $destPath, $flags ) );
1242 wfDebug( __METHOD__
.": set db items, applying file transactions\n" );
1243 $transaction->commit();
1244 FileStore
::unlock();
1246 $m = explode('!',$oimage->archive_name
,2);
1253 * Update the revision's rev_deleted field
1254 * @param Revision $rev
1255 * @param int $bitfield new rev_deleted bitfield value
1257 function updateRevision( $rev, $bitfield ) {
1258 $this->dbw
->update( 'revision',
1259 array( 'rev_deleted' => $bitfield ),
1260 array( 'rev_id' => $rev->getId(),
1261 'rev_page' => $rev->getPage() ),
1266 * Update the revision's rev_deleted field
1267 * @param Revision $rev
1268 * @param Title $title
1269 * @param int $bitfield new rev_deleted bitfield value
1271 function updateArchive( $rev, $title, $bitfield ) {
1272 $this->dbw
->update( 'archive',
1273 array( 'ar_deleted' => $bitfield ),
1274 array( 'ar_namespace' => $title->getNamespace(),
1275 'ar_title' => $title->getDBKey(),
1276 'ar_timestamp' => $this->dbw
->timestamp( $rev->getTimestamp() ),
1277 'ar_rev_id' => $rev->getId() ),
1282 * Update the images's oi_deleted field
1284 * @param int $bitfield new rev_deleted bitfield value
1286 function updateOldFiles( $file, $bitfield ) {
1287 $this->dbw
->update( 'oldimage',
1288 array( 'oi_deleted' => $bitfield ),
1289 array( 'oi_name' => $file->getName(),
1290 'oi_timestamp' => $this->dbw
->timestamp( $file->getTimestamp() ) ),
1295 * Update the images's fa_deleted field
1296 * @param ArchivedFile $file
1297 * @param int $bitfield new rev_deleted bitfield value
1299 function updateArchFiles( $file, $bitfield ) {
1300 $this->dbw
->update( 'filearchive',
1301 array( 'fa_deleted' => $bitfield ),
1302 array( 'fa_id' => $file->getId() ),
1307 * Update the logging log_deleted field
1309 * @param int $bitfield new rev_deleted bitfield value
1311 function updateLogs( $row, $bitfield ) {
1312 $this->dbw
->update( 'logging',
1313 array( 'log_deleted' => $bitfield ),
1314 array( 'log_id' => $row->log_id
),
1319 * Update the revision's recentchanges record if fields have been hidden
1320 * @param Revision $rev
1321 * @param int $bitfield new rev_deleted bitfield value
1323 function updateRecentChangesEdits( $rev, $bitfield ) {
1324 $this->dbw
->update( 'recentchanges',
1325 array( 'rc_deleted' => $bitfield,
1326 'rc_patrolled' => 1 ),
1327 array( 'rc_this_oldid' => $rev->getId(),
1328 'rc_timestamp' => $this->dbw
->timestamp( $rev->getTimestamp() ) ),
1333 * Update the revision's recentchanges record if fields have been hidden
1335 * @param int $bitfield new rev_deleted bitfield value
1337 function updateRecentChangesLog( $row, $bitfield ) {
1338 $this->dbw
->update( 'recentchanges',
1339 array( 'rc_deleted' => $bitfield,
1340 'rc_patrolled' => 1 ),
1341 array( 'rc_logid' => $row->log_id
,
1342 'rc_timestamp' => $row->log_timestamp
),
1347 * Touch the page's cache invalidation timestamp; this forces cached
1348 * history views to refresh, so any newly hidden or shown fields will
1350 * @param Title $title
1352 function updatePage( $title ) {
1353 $title->invalidateCache();
1354 $title->purgeSquid();
1355 $title->touchLinks();
1356 // Extensions that require referencing previous revisions may need this
1357 wfRunHooks( 'ArticleRevisionVisiblitySet', array( &$title ) );
1361 * Checks for a change in the bitfield for a certain option and updates the
1362 * provided array accordingly.
1364 * @param String $desc Description to add to the array if the option was
1365 * enabled / disabled.
1366 * @param int $field The bitmask describing the single option.
1367 * @param int $diff The xor of the old and new bitfields.
1368 * @param array $arr The array to update.
1370 function checkItem ( $desc, $field, $diff, $new, &$arr ) {
1371 if ( $diff & $field ) {
1372 $arr [ ( $new & $field ) ?
0 : 1 ][] = $desc;
1377 * Gets an array describing the changes made to the visibilit of the revision.
1378 * If the resulting array is $arr, then $arr[0] will contain an array of strings
1379 * describing the items that were hidden, $arr[2] will contain an array of strings
1380 * describing the items that were unhidden, and $arr[3] will contain an array with
1381 * a single string, which can be one of "applied restrictions to sysops",
1382 * "removed restrictions from sysops", or null.
1384 * @param int $n The new bitfield.
1385 * @param int $o The old bitfield.
1386 * @return An array as described above.
1388 function getChanges ( $n, $o ) {
1390 $ret = array ( 0 => array(), 1 => array(), 2 => array() );
1392 $this->checkItem ( wfMsgForContent ( 'revdelete-content' ),
1393 Revision
::DELETED_TEXT
, $diff, $n, $ret );
1394 $this->checkItem ( wfMsgForContent ( 'revdelete-summary' ),
1395 Revision
::DELETED_COMMENT
, $diff, $n, $ret );
1396 $this->checkItem ( wfMsgForContent ( 'revdelete-uname' ),
1397 Revision
::DELETED_USER
, $diff, $n, $ret );
1399 // Restriction application to sysops
1400 if ( $diff & Revision
::DELETED_RESTRICTED
) {
1401 if ( $n & Revision
::DELETED_RESTRICTED
)
1402 $ret[2][] = wfMsgForContent ( 'revdelete-restricted' );
1404 $ret[2][] = wfMsgForContent ( 'revdelete-unrestricted' );
1411 * Gets a log message to describe the given revision visibility change. This
1412 * message will be of the form "[hid {content, edit summary, username}];
1413 * [unhid {...}][applied restrictions to sysops] for $count revisions: $comment".
1415 * @param int $count The number of effected revisions.
1416 * @param int $nbitfield The new bitfield for the revision.
1417 * @param int $obitfield The old bitfield for the revision.
1418 * @param string $comment The comment associated with the change.
1419 * @param bool $isForLog
1421 function getLogMessage ( $count, $nbitfield, $obitfield, $comment, $isForLog = false ) {
1425 $changes = $this->getChanges( $nbitfield, $obitfield );
1427 if ( count ( $changes[0] ) ) {
1428 $s .= wfMsgForContent ( 'revdelete-hid', implode ( ', ', $changes[0] ) );
1431 if ( count ( $changes[1] ) ) {
1434 $s .= wfMsgForContent ( 'revdelete-unhid', implode ( ', ', $changes[1] ) );
1437 if ( count ( $changes[2] )) {
1439 $s .= ' (' . $changes[2][0] . ')';
1441 $s = $changes[2][0];
1444 $msg = $isForLog ?
'logdelete-log-message' : 'revdelete-log-message';
1445 $ret = wfMsgExt ( $msg, array( 'parsemag', 'content' ),
1446 $s, $wgContLang->formatNum( $count ) );
1449 $ret .= ": $comment";
1456 * Record a log entry on the action
1457 * @param Title $title, page where item was removed from
1458 * @param int $count the number of revisions altered for this page
1459 * @param int $nbitfield the new _deleted value
1460 * @param int $obitfield the old _deleted value
1461 * @param string $comment
1462 * @param Title $target, the relevant page
1463 * @param string $param, URL param
1464 * @param Array $items
1466 function updateLog( $title, $count, $nbitfield, $obitfield, $comment, $target, $param, $items = array() ) {
1467 // Put things hidden from sysops in the oversight log
1468 $logtype = ( ($nbitfield |
$obitfield) & Revision
::DELETED_RESTRICTED
) ?
'suppress' : 'delete';
1469 $log = new LogPage( $logtype );
1471 $reason = $this->getLogMessage ( $count, $nbitfield, $obitfield, $comment, $param == 'logid' );
1473 if( $param == 'logid' ) {
1474 $params = array( implode( ',', $items) );
1475 $log->addEntry( 'event', $title, $reason, $params );
1477 // Add params for effected page and ids
1478 $params = array( $param, implode( ',', $items) );
1479 $log->addEntry( 'revision', $title, $reason, $params );