b777b351d15724376063194769689b1bcb5f5796
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->timestamp( $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 $timestamp = wfTimestamp( TS_MW
, $row->ar_timestamp
);
231 $revObjs[$timestamp] = new Revision( array(
232 'page' => $this->page
->getArticleId(),
233 'id' => $row->ar_rev_id
,
234 'text' => $row->ar_text_id
,
235 'comment' => $row->ar_comment
,
236 'user' => $row->ar_user
,
237 'user_text' => $row->ar_user_text
,
238 'timestamp' => $timestamp,
239 'minor_edit' => $row->ar_minor_edit
,
240 'text_id' => $row->ar_text_id
,
241 'deleted' => $row->ar_deleted
,
242 'len' => $row->ar_len
) );
244 foreach( $this->archrevs
as $timestamp ) {
245 if( !isset($revObjs[$timestamp]) ) {
247 } else if( !$revObjs[$timestamp]->userCan(Revision
::DELETED_RESTRICTED
) ) {
248 // If a rev is hidden from sysops
249 if( $action != 'submit') {
250 $wgOut->permissionRequired( 'suppressrevision' );
253 $UserAllowed = false;
256 $wgOut->addHTML( $this->historyLine( $revObjs[$timestamp] ) );
257 $bitfields |
= $revObjs[$timestamp]->mDeleted
;
261 $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
265 $wgOut->addHTML( "</ul>" );
267 $this->addUsageText();
269 // Normal sysops can always see what they did, but can't always change it
270 if( !$UserAllowed ) return;
273 Xml
::inputLabel( wfMsg( 'revdelete-log' ), 'wpReason', 'wpReason', 60 ),
274 Xml
::submitButton( wfMsg( 'revdelete-submit' ) )
277 Xml
::hidden( 'wpEditToken', $wgUser->editToken() ),
278 Xml
::hidden( 'target', $this->page
->getPrefixedText() ),
279 Xml
::hidden( 'type', $this->deleteKey
)
281 if( $this->deleteKey
=='oldid' ) {
282 foreach( $revObjs as $rev )
283 $hidden[] = Xml
::hidden( 'oldid[]', $rev->getId() );
285 foreach( $revObjs as $rev )
286 $hidden[] = Xml
::hidden( 'artimestamp[]', $rev->getTimestamp() );
288 $special = SpecialPage
::getTitleFor( 'Revisiondelete' );
290 Xml
::openElement( 'form', array( 'method' => 'post', 'action' => $special->getLocalUrl( 'action=submit' ),
291 'id' => 'mw-revdel-form-revisions' ) ) .
292 Xml
::openElement( 'fieldset' ) .
293 xml
::element( 'legend', null, wfMsg( 'revdelete-legend' ) )
296 $wgOut->addHTML( $this->buildCheckBoxes( $bitfields ) );
297 foreach( $items as $item ) {
298 $wgOut->addHTML( Xml
::tags( 'p', null, $item ) );
300 foreach( $hidden as $item ) {
301 $wgOut->addHTML( $item );
304 Xml
::closeElement( 'fieldset' ) .
305 Xml
::closeElement( 'form' ) . "\n"
310 * This lets a user set restrictions for archived images
312 function showImages() {
313 // What is $action doing here???
314 global $wgOut, $wgUser, $action, $wgLang;
318 $count = ($this->deleteKey
=='oldimage') ?
count($this->ofiles
) : count($this->afiles
);
319 $wgOut->addWikiMsg( 'revdelete-selected',
320 $this->page
->getPrefixedText(),
321 $wgLang->formatNum($count) );
324 $wgOut->addHTML( "<ul>" );
326 $where = $filesObjs = array();
327 $dbr = wfGetDB( DB_SLAVE
);
328 // Live old revisions...
330 if( $this->deleteKey
=='oldimage' ) {
331 // Run through and pull all our data in one query
332 foreach( $this->ofiles
as $timestamp ) {
333 $where[] = $timestamp.'!'.$this->page
->getDBKey();
335 $result = $dbr->select( 'oldimage', '*',
337 'oi_name' => $this->page
->getDBKey(),
338 'oi_archive_name' => $where ),
340 while( $row = $dbr->fetchObject( $result ) ) {
341 $filesObjs[$row->oi_archive_name
] = RepoGroup
::singleton()->getLocalRepo()->newFileFromRow( $row );
342 $filesObjs[$row->oi_archive_name
]->user
= $row->oi_user
;
343 $filesObjs[$row->oi_archive_name
]->user_text
= $row->oi_user_text
;
345 // Check through our images
346 foreach( $this->ofiles
as $timestamp ) {
347 $archivename = $timestamp.'!'.$this->page
->getDBKey();
348 if( !isset($filesObjs[$archivename]) ) {
350 } else if( !$filesObjs[$archivename]->userCan(File
::DELETED_RESTRICTED
) ) {
351 // If a rev is hidden from sysops
352 if( $action != 'submit' ) {
353 $wgOut->permissionRequired( 'suppressrevision' );
356 $UserAllowed = false;
359 // Inject history info
360 $wgOut->addHTML( $this->fileLine( $filesObjs[$archivename] ) );
361 $bitfields |
= $filesObjs[$archivename]->deleted
;
365 // Run through and pull all our data in one query
366 foreach( $this->afiles
as $id ) {
367 $where[] = intval($id);
369 $result = $dbr->select( 'filearchive', '*',
371 'fa_name' => $this->page
->getDBKey(),
374 while( $row = $dbr->fetchObject( $result ) ) {
375 $filesObjs[$row->fa_id
] = ArchivedFile
::newFromRow( $row );
378 foreach( $this->afiles
as $fileid ) {
379 if( !isset($filesObjs[$fileid]) ) {
381 } else if( !$filesObjs[$fileid]->userCan(File
::DELETED_RESTRICTED
) ) {
382 // If a rev is hidden from sysops
383 if( $action != 'submit' ) {
384 $wgOut->permissionRequired( 'suppressrevision' );
387 $UserAllowed = false;
390 // Inject history info
391 $wgOut->addHTML( $this->archivedfileLine( $filesObjs[$fileid] ) );
392 $bitfields |
= $filesObjs[$fileid]->deleted
;
396 $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
400 $wgOut->addHTML( "</ul>" );
402 $this->addUsageText();
403 // Normal sysops can always see what they did, but can't always change it
404 if( !$UserAllowed ) return;
407 Xml
::inputLabel( wfMsg( 'revdelete-log' ), 'wpReason', 'wpReason', 60 ),
408 Xml
::submitButton( wfMsg( 'revdelete-submit' ) )
411 Xml
::hidden( 'wpEditToken', $wgUser->editToken() ),
412 Xml
::hidden( 'target', $this->page
->getPrefixedText() ),
413 Xml
::hidden( 'type', $this->deleteKey
)
415 if( $this->deleteKey
=='oldimage' ) {
416 foreach( $this->ofiles
as $filename )
417 $hidden[] = Xml
::hidden( 'oldimage[]', $filename );
419 foreach( $this->afiles
as $fileid )
420 $hidden[] = Xml
::hidden( 'fileid[]', $fileid );
422 $special = SpecialPage
::getTitleFor( 'Revisiondelete' );
424 Xml
::openElement( 'form', array( 'method' => 'post', 'action' => $special->getLocalUrl( 'action=submit' ),
425 'id' => 'mw-revdel-form-filerevisions' ) ) .
426 Xml
::fieldset( wfMsg( 'revdelete-legend' ) )
429 $wgOut->addHTML( $this->buildCheckBoxes( $bitfields ) );
430 foreach( $items as $item ) {
431 $wgOut->addHTML( "<p>$item</p>" );
433 foreach( $hidden as $item ) {
434 $wgOut->addHTML( $item );
438 Xml
::closeElement( 'fieldset' ) .
439 Xml
::closeElement( 'form' ) . "\n"
444 * This lets a user set restrictions for log items
446 function showLogItems() {
447 global $wgOut, $wgUser, $action, $wgMessageCache, $wgLang;
450 $wgOut->addWikiMsg( 'logdelete-selected', $wgLang->formatNum( count($this->events
) ) );
453 $wgOut->addHTML( "<ul>" );
455 $where = $logRows = array();
456 $dbr = wfGetDB( DB_SLAVE
);
457 // Run through and pull all our data in one query
459 foreach( $this->events
as $logid ) {
460 $where[] = intval($logid);
462 list($log,$logtype) = explode( '/',$this->page
->getDBKey(), 2 );
463 $result = $dbr->select( 'logging', '*',
465 'log_type' => $logtype,
466 'log_id' => $where ),
468 while( $row = $dbr->fetchObject( $result ) ) {
469 $logRows[$row->log_id
] = $row;
471 $wgMessageCache->loadAllMessages();
472 foreach( $this->events
as $logid ) {
473 // Don't hide from oversight log!!!
474 if( !isset( $logRows[$logid] ) ||
$logRows[$logid]->log_type
=='suppress' ) {
476 } else if( !LogEventsList
::userCan( $logRows[$logid],Revision
::DELETED_RESTRICTED
) ) {
477 // If an event is hidden from sysops
478 if( $action != 'submit') {
479 $wgOut->permissionRequired( 'suppressrevision' );
482 $UserAllowed = false;
485 $wgOut->addHTML( $this->logLine( $logRows[$logid] ) );
486 $bitfields |
= $logRows[$logid]->log_deleted
;
489 $wgOut->showErrorPage( 'revdelete-nologid-title', 'revdelete-nologid-text' );
493 $wgOut->addHTML( "</ul>" );
495 $this->addUsageText();
496 // Normal sysops can always see what they did, but can't always change it
497 if( !$UserAllowed ) return;
500 Xml
::inputLabel( wfMsg( 'revdelete-log' ), 'wpReason', 'wpReason', 60 ),
501 Xml
::submitButton( wfMsg( 'revdelete-submit' ) ) );
503 Xml
::hidden( 'wpEditToken', $wgUser->editToken() ),
504 Xml
::hidden( 'target', $this->page
->getPrefixedText() ),
505 Xml
::hidden( 'type', $this->deleteKey
) );
506 foreach( $this->events
as $logid ) {
507 $hidden[] = Xml
::hidden( 'logid[]', $logid );
510 $special = SpecialPage
::getTitleFor( 'Revisiondelete' );
512 Xml
::openElement( 'form', array( 'method' => 'post', 'action' => $special->getLocalUrl( 'action=submit' ),
513 'id' => 'mw-revdel-form-logs' ) ) .
514 Xml
::fieldset( wfMsg( 'revdelete-legend' ) )
517 $wgOut->addHTML( $this->buildCheckBoxes( $bitfields ) );
518 foreach( $items as $item ) {
519 $wgOut->addHTML( "<p>$item</p>" );
521 foreach( $hidden as $item ) {
522 $wgOut->addHTML( $item );
526 Xml
::closeElement( 'fieldset' ) .
527 Xml
::closeElement( 'form' ) . "\n"
531 private function addUsageText() {
532 global $wgOut, $wgUser;
533 $wgOut->addWikiMsg( 'revdelete-text' );
534 if( $wgUser->isAllowed( 'hiderevision' ) ) {
535 $wgOut->addWikiMsg( 'revdelete-suppress-text' );
540 * @param int $bitfields, aggregate bitfield of all the bitfields
541 * @returns string HTML
543 private function buildCheckBoxes( $bitfields ) {
545 // FIXME: all items checked for just one rev are checked, even if not set for the others
546 foreach( $this->checks
as $item ) {
547 list( $message, $name, $field ) = $item;
548 $line = Xml
::tags( 'div', null, Xml
::checkLabel( wfMsg($message), $name, $name,
549 $bitfields & $field ) );
550 if( $field == Revision
::DELETED_RESTRICTED
) $line = "<b>$line</b>";
557 * @param Revision $rev
560 private function historyLine( $rev ) {
561 global $wgLang, $wgUser;
563 $date = $wgLang->timeanddate( $rev->getTimestamp() );
564 $difflink = $del = '';
566 if( $this->deleteKey
=='oldid' ) {
567 $tokenParams = '&unhide=1&token='.urlencode( $wgUser->editToken( $rev->getId() ) );
568 $revlink = $this->skin
->makeLinkObj( $this->page
, $date, 'oldid='.$rev->getId() . $tokenParams );
569 $difflink = '(' . $this->skin
->makeKnownLinkObj( $this->page
, wfMsgHtml('diff'),
570 'diff=' . $rev->getId() . '&oldid=prev' . $tokenParams ) . ')';
571 // Archived revisions
573 $undelete = SpecialPage
::getTitleFor( 'Undelete' );
574 $target = $this->page
->getPrefixedText();
575 $revlink = $this->skin
->makeLinkObj( $undelete, $date,
576 "target=$target×tamp=" . $rev->getTimestamp() );
577 $difflink = '(' . $this->skin
->makeKnownLinkObj( $undelete, wfMsgHtml('diff'),
578 "target=$target&diff=prev×tamp=" . $rev->getTimestamp() ) . ')';
580 // Check permissions; items may be "suppressed"
581 if( $rev->isDeleted(Revision
::DELETED_TEXT
) ) {
582 $revlink = '<span class="history-deleted">'.$revlink.'</span>';
583 $del = ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
584 if( !$rev->userCan(Revision
::DELETED_TEXT
) ) {
585 $revlink = '<span class="history-deleted">'.$date.'</span>';
586 $difflink = '(' . wfMsgHtml('diff') . ')';
589 $userlink = $this->skin
->revUserLink( $rev );
590 $comment = $this->skin
->revComment( $rev );
592 return "<li> $difflink $revlink $userlink $comment{$del}</li>";
599 private function fileLine( $file ) {
600 global $wgLang, $wgTitle;
602 $target = $this->page
->getPrefixedText();
603 $date = $wgLang->timeanddate( $file->getTimestamp(), true );
607 if( $file->isDeleted(File
::DELETED_FILE
) ) {
608 $del = ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
609 if( !$file->userCan(File
::DELETED_FILE
) ) {
612 $pageLink = $this->skin
->makeKnownLinkObj( $wgTitle, $date,
613 "target=$target&file=$file->sha1.".$file->getExtension() );
615 $pageLink = '<span class="history-deleted">' . $pageLink . '</span>';
618 $url = $file->getUrlRel();
619 $pageLink = "<a href=\"{$url}\">{$date}</a>";
622 $data = wfMsg( 'widthheight',
623 $wgLang->formatNum( $file->getWidth() ),
624 $wgLang->formatNum( $file->getHeight() ) ) .
625 ' (' . wfMsgExt( 'nbytes', 'parsemag', $wgLang->formatNum( $file->getSize() ) ) . ')';
626 $data = htmlspecialchars( $data );
628 return "<li>$pageLink ".$this->fileUserTools( $file )." $data ".$this->fileComment( $file )."$del</li>";
632 * @param ArchivedFile $file
635 private function archivedfileLine( $file ) {
638 $target = $this->page
->getPrefixedText();
639 $date = $wgLang->timeanddate( $file->getTimestamp(), true );
641 $undelete = SpecialPage
::getTitleFor( 'Undelete' );
642 $pageLink = $this->skin
->makeKnownLinkObj( $undelete, $date, "target=$target&file={$file->getKey()}" );
645 if( $file->isDeleted(File
::DELETED_FILE
) ) {
646 $del = ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
649 $data = wfMsg( 'widthheight',
650 $wgLang->formatNum( $file->getWidth() ),
651 $wgLang->formatNum( $file->getHeight() ) ) .
652 ' (' . wfMsgExt( 'nbytes', 'parsemag', $wgLang->formatNum( $file->getSize() ) ) . ')';
653 $data = htmlspecialchars( $data );
655 return "<li> $pageLink ".$this->fileUserTools( $file )." $data ".$this->fileComment( $file )."$del</li>";
659 * @param Array $row row
662 private function logLine( $row ) {
665 $date = $wgLang->timeanddate( $row->log_timestamp
);
666 $paramArray = LogPage
::extractParams( $row->log_params
);
667 $title = Title
::makeTitle( $row->log_namespace
, $row->log_title
);
669 $logtitle = SpecialPage
::getTitleFor( 'Log' );
670 $loglink = $this->skin
->makeKnownLinkObj( $logtitle, wfMsgHtml( 'log' ),
671 wfArrayToCGI( array( 'page' => $title->getPrefixedUrl() ) ) );
673 if( !LogEventsList
::userCan($row,LogPage
::DELETED_ACTION
) ) {
674 $action = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
676 $action = LogPage
::actionText( $row->log_type
, $row->log_action
, $title,
677 $this->skin
, $paramArray, true, true );
678 if( $row->log_deleted
& LogPage
::DELETED_ACTION
)
679 $action = '<span class="history-deleted">' . $action . '</span>';
682 $userLink = $this->skin
->userLink( $row->log_user
, User
::WhoIs($row->log_user
) );
683 if( LogEventsList
::isDeleted($row,LogPage
::DELETED_USER
) ) {
684 $userLink = '<span class="history-deleted">' . $userLink . '</span>';
687 $comment = $wgLang->getDirMark() . $this->skin
->commentBlock( $row->log_comment
);
688 if( LogEventsList
::isDeleted($row,LogPage
::DELETED_COMMENT
) ) {
689 $comment = '<span class="history-deleted">' . $comment . '</span>';
691 return "<li>($loglink) $date $userLink $action $comment</li>";
695 * Generate a user tool link cluster if the current user is allowed to view it
696 * @param ArchivedFile $file
697 * @return string HTML
699 private function fileUserTools( $file ) {
700 if( $file->userCan( Revision
::DELETED_USER
) ) {
701 $link = $this->skin
->userLink( $file->user
, $file->user_text
) .
702 $this->skin
->userToolLinks( $file->user
, $file->user_text
);
704 $link = wfMsgHtml( 'rev-deleted-user' );
706 if( $file->isDeleted( Revision
::DELETED_USER
) ) {
707 return '<span class="history-deleted">' . $link . '</span>';
713 * Wrap and format the given file's comment block, if the current
714 * user is allowed to view it.
716 * @param ArchivedFile $file
717 * @return string HTML
719 private function fileComment( $file ) {
720 if( $file->userCan( File
::DELETED_COMMENT
) ) {
721 $block = $this->skin
->commentBlock( $file->description
);
723 $block = ' ' . wfMsgHtml( 'rev-deleted-comment' );
725 if( $file->isDeleted( File
::DELETED_COMMENT
) ) {
726 return "<span class=\"history-deleted\">$block</span>";
732 * @param WebRequest $request
734 function submit( $request ) {
735 global $wgUser, $wgOut;
737 $bitfield = $this->extractBitfield( $request );
738 $comment = $request->getText( 'wpReason' );
739 # Can the user set this field?
740 if( $bitfield & Revision
::DELETED_RESTRICTED
&& !$wgUser->isAllowed('suppressrevision') ) {
741 $wgOut->permissionRequired( 'suppressrevision' );
744 # If the save went through, go to success message. Otherwise
745 # bounce back to form...
746 if( $this->save( $bitfield, $comment, $this->page
) ) {
748 } else if( $request->getCheck( 'oldid' ) ||
$request->getCheck( 'artimestamp' ) ) {
749 return $this->showRevs();
750 } else if( $request->getCheck( 'logid' ) ) {
751 return $this->showLogs();
752 } else if( $request->getCheck( 'oldimage' ) ||
$request->getCheck( 'fileid' ) ) {
753 return $this->showImages();
757 private function success() {
760 $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
762 $wrap = '<span class="success">$1</span>';
764 if( $this->deleteKey
=='logid' ) {
765 $wgOut->wrapWikiMsg( $wrap, 'logdelete-success' );
766 $this->showLogItems();
767 } else if( $this->deleteKey
=='oldid' ||
$this->deleteKey
=='artimestamp' ) {
768 $wgOut->wrapWikiMsg( $wrap, 'revdelete-success' );
770 } else if( $this->deleteKey
=='fileid' ) {
771 $wgOut->wrapWikiMsg( $wrap, 'revdelete-success' );
773 } else if( $this->deleteKey
=='oldimage' ) {
774 $wgOut->wrapWikiMsg( $wrap, 'revdelete-success' );
780 * Put together a rev_deleted bitfield from the submitted checkboxes
781 * @param WebRequest $request
784 private function extractBitfield( $request ) {
786 foreach( $this->checks
as $item ) {
787 list( /* message */ , $name, $field ) = $item;
788 if( $request->getCheck( $name ) ) {
795 private function save( $bitfield, $reason, $title ) {
796 $dbw = wfGetDB( DB_MASTER
);
797 // Don't allow simply locking the interface for no reason
798 if( $bitfield == Revision
::DELETED_RESTRICTED
) {
801 $deleter = new RevisionDeleter( $dbw );
802 // By this point, only one of the below should be set
803 if( isset($this->revisions
) ) {
804 return $deleter->setRevVisibility( $title, $this->revisions
, $bitfield, $reason );
805 } else if( isset($this->archrevs
) ) {
806 return $deleter->setArchiveVisibility( $title, $this->archrevs
, $bitfield, $reason );
807 } else if( isset($this->ofiles
) ) {
808 return $deleter->setOldImgVisibility( $title, $this->ofiles
, $bitfield, $reason );
809 } else if( isset($this->afiles
) ) {
810 return $deleter->setArchFileVisibility( $title, $this->afiles
, $bitfield, $reason );
811 } else if( isset($this->events
) ) {
812 return $deleter->setEventVisibility( $title, $this->events
, $bitfield, $reason );
818 * Implements the actions for Revision Deletion.
819 * @ingroup SpecialPage
821 class RevisionDeleter
{
822 function __construct( $db ) {
827 * @param $title, the page these events apply to
828 * @param array $items list of revision ID numbers
829 * @param int $bitfield new rev_deleted value
830 * @param string $comment Comment for log records
832 function setRevVisibility( $title, $items, $bitfield, $comment ) {
835 $userAllowedAll = $success = true;
838 // Run through and pull all our data in one query
839 foreach( $items as $revid ) {
840 $where[] = intval($revid);
842 $result = $this->dbw
->select( 'revision', '*',
844 'rev_page' => $title->getArticleID(),
845 'rev_id' => $where ),
847 while( $row = $this->dbw
->fetchObject( $result ) ) {
848 $revObjs[$row->rev_id
] = new Revision( $row );
851 foreach( $items as $revid ) {
852 if( !isset($revObjs[$revid]) ||
$revObjs[$revid]->isCurrent() ) {
854 continue; // Must exist
855 } else if( !$revObjs[$revid]->userCan(Revision
::DELETED_RESTRICTED
) ) {
856 $userAllowedAll=false;
859 // For logging, maintain a count of revisions
860 if( $revObjs[$revid]->mDeleted
!= $bitfield ) {
864 $this->updateRevision( $revObjs[$revid], $bitfield );
865 $this->updateRecentChangesEdits( $revObjs[$revid], $bitfield, false );
869 // Don't log or touch if nothing changed
870 if( $revCount > 0 ) {
871 $this->updateLog( $title, $revCount, $bitfield, $revObjs[$revid]->mDeleted
,
872 $comment, $title, 'oldid', $revIDs );
873 $this->updatePage( $title );
875 // Where all revs allowed to be set?
876 if( !$userAllowedAll ) {
877 //FIXME: still might be confusing???
878 $wgOut->permissionRequired( 'suppressrevision' );
886 * @param $title, the page these events apply to
887 * @param array $items list of revision ID numbers
888 * @param int $bitfield new rev_deleted value
889 * @param string $comment Comment for log records
891 function setArchiveVisibility( $title, $items, $bitfield, $comment ) {
894 $userAllowedAll = $success = true;
897 // Run through and pull all our data in one query
898 foreach( $items as $timestamp ) {
899 $where[] = $this->dbw
->timestamp( $timestamp );
901 $result = $this->dbw
->select( 'archive', '*',
903 'ar_namespace' => $title->getNamespace(),
904 'ar_title' => $title->getDBKey(),
905 'ar_timestamp' => $where ),
907 while( $row = $this->dbw
->fetchObject( $result ) ) {
908 $timestamp = wfTimestamp( TS_MW
, $row->ar_timestamp
);
909 $revObjs[$timestamp] = new Revision( array(
910 'page' => $title->getArticleId(),
911 'id' => $row->ar_rev_id
,
912 'text' => $row->ar_text_id
,
913 'comment' => $row->ar_comment
,
914 'user' => $row->ar_user
,
915 'user_text' => $row->ar_user_text
,
916 'timestamp' => $timestamp,
917 'minor_edit' => $row->ar_minor_edit
,
918 'text_id' => $row->ar_text_id
,
919 'deleted' => $row->ar_deleted
,
920 'len' => $row->ar_len
) );
923 foreach( $items as $timestamp ) {
924 // This will only select the first revision with this timestamp.
925 // Since they are all selected/deleted at once, we can just check the
926 // permissions of one. UPDATE is done via timestamp, so all revs are set.
927 if( !is_object($revObjs[$timestamp]) ) {
929 continue; // Must exist
930 } else if( !$revObjs[$timestamp]->userCan(Revision
::DELETED_RESTRICTED
) ) {
931 $userAllowedAll=false;
934 // Which revisions did we change anything about?
935 if( $revObjs[$timestamp]->mDeleted
!= $bitfield ) {
936 $Id_set[]=$timestamp;
939 $this->updateArchive( $revObjs[$timestamp], $title, $bitfield );
942 // For logging, maintain a count of revisions
944 $this->updateLog( $title, $count, $bitfield, $revObjs[$timestamp]->mDeleted
,
945 $comment, $title, 'artimestamp', $Id_set );
947 // Where all revs allowed to be set?
948 if( !$userAllowedAll ) {
949 $wgOut->permissionRequired( 'suppressrevision' );
957 * @param $title, the page these events apply to
958 * @param array $items list of revision ID numbers
959 * @param int $bitfield new rev_deleted value
960 * @param string $comment Comment for log records
962 function setOldImgVisibility( $title, $items, $bitfield, $comment ) {
965 $userAllowedAll = $success = true;
968 // Run through and pull all our data in one query
969 foreach( $items as $timestamp ) {
970 $where[] = $timestamp.'!'.$title->getDBKey();
972 $result = $this->dbw
->select( 'oldimage', '*',
974 'oi_name' => $title->getDBKey(),
975 'oi_archive_name' => $where ),
977 while( $row = $this->dbw
->fetchObject( $result ) ) {
978 $filesObjs[$row->oi_archive_name
] = RepoGroup
::singleton()->getLocalRepo()->newFileFromRow( $row );
979 $filesObjs[$row->oi_archive_name
]->user
= $row->oi_user
;
980 $filesObjs[$row->oi_archive_name
]->user_text
= $row->oi_user_text
;
983 foreach( $items as $timestamp ) {
984 $archivename = $timestamp.'!'.$title->getDBKey();
985 if( !isset($filesObjs[$archivename]) ) {
987 continue; // Must exist
988 } else if( !$filesObjs[$archivename]->userCan(File
::DELETED_RESTRICTED
) ) {
989 $userAllowedAll=false;
994 // Which revisions did we change anything about?
995 if( $filesObjs[$archivename]->deleted
!= $bitfield ) {
999 $this->updateOldFiles( $filesObjs[$archivename], $bitfield );
1000 // If this image is currently hidden...
1001 if( $filesObjs[$archivename]->deleted
& File
::DELETED_FILE
) {
1002 if( $bitfield & File
::DELETED_FILE
) {
1003 # Leave it alone if we are not changing this...
1004 $set[]=$archivename;
1005 $transaction = true;
1007 # We are moving this out
1008 $transaction = $this->makeOldImagePublic( $filesObjs[$archivename] );
1009 $set[]=$transaction;
1011 // Is it just now becoming hidden?
1012 } else if( $bitfield & File
::DELETED_FILE
) {
1013 $transaction = $this->makeOldImagePrivate( $filesObjs[$archivename] );
1014 $set[]=$transaction;
1018 // If our file operations fail, then revert back the db
1019 if( $transaction==false ) {
1020 $this->dbw
->rollback();
1023 $this->dbw
->commit();
1027 // Log if something was changed
1029 $this->updateLog( $title, $count, $bitfield, $filesObjs[$archivename]->deleted
,
1030 $comment, $title, 'oldimage', $set );
1031 # Purge page/history
1032 $file = wfLocalFile( $title );
1033 $file->purgeCache();
1034 $file->purgeHistory();
1035 # Invalidate cache for all pages using this file
1036 $update = new HTMLCacheUpdate( $title, 'imagelinks' );
1037 $update->doUpdate();
1039 // Where all revs allowed to be set?
1040 if( !$userAllowedAll ) {
1041 $wgOut->permissionRequired( 'suppressrevision' );
1049 * @param $title, the page these events apply to
1050 * @param array $items list of revision ID numbers
1051 * @param int $bitfield new rev_deleted value
1052 * @param string $comment Comment for log records
1054 function setArchFileVisibility( $title, $items, $bitfield, $comment ) {
1057 $userAllowedAll = $success = true;
1061 // Run through and pull all our data in one query
1062 foreach( $items as $id ) {
1063 $where[] = intval($id);
1065 $result = $this->dbw
->select( 'filearchive', '*',
1066 array( 'fa_name' => $title->getDBKey(),
1067 'fa_id' => $where ),
1069 while( $row = $this->dbw
->fetchObject( $result ) ) {
1070 $filesObjs[$row->fa_id
] = ArchivedFile
::newFromRow( $row );
1073 foreach( $items as $fileid ) {
1074 if( !isset($filesObjs[$fileid]) ) {
1076 continue; // Must exist
1077 } else if( !$filesObjs[$fileid]->userCan(File
::DELETED_RESTRICTED
) ) {
1078 $userAllowedAll=false;
1081 // Which revisions did we change anything about?
1082 if( $filesObjs[$fileid]->deleted
!= $bitfield ) {
1086 $this->updateArchFiles( $filesObjs[$fileid], $bitfield );
1089 // Log if something was changed
1091 $this->updateLog( $title, $count, $bitfield, $comment,
1092 $filesObjs[$fileid]->deleted
, $title, 'fileid', $Id_set );
1094 // Where all revs allowed to be set?
1095 if( !$userAllowedAll ) {
1096 $wgOut->permissionRequired( 'suppressrevision' );
1104 * @param $title, the log page these events apply to
1105 * @param array $items list of log ID numbers
1106 * @param int $bitfield new log_deleted value
1107 * @param string $comment Comment for log records
1109 function setEventVisibility( $title, $items, $bitfield, $comment ) {
1112 $userAllowedAll = $success = true;
1116 // Run through and pull all our data in one query
1117 foreach( $items as $logid ) {
1118 $where[] = intval($logid);
1120 list($log,$logtype) = explode( '/',$title->getDBKey(), 2 );
1121 $result = $this->dbw
->select( 'logging', '*',
1123 'log_type' => $logtype,
1124 'log_id' => $where ),
1126 while( $row = $this->dbw
->fetchObject( $result ) ) {
1127 $logRows[$row->log_id
] = $row;
1130 foreach( $items as $logid ) {
1131 if( !isset($logRows[$logid]) ) {
1133 continue; // Must exist
1134 } else if( !LogEventsList
::userCan($logRows[$logid], LogPage
::DELETED_RESTRICTED
)
1135 ||
$logRows[$logid]->log_type
== 'suppress' ) {
1136 // Don't hide from oversight log!!!
1137 $userAllowedAll=false;
1140 // Which logs did we change anything about?
1141 if( $logRows[$logid]->log_deleted
!= $bitfield ) {
1145 $this->updateLogs( $logRows[$logid], $bitfield );
1146 $this->updateRecentChangesLog( $logRows[$logid], $bitfield, true );
1149 // Don't log or touch if nothing changed
1151 $this->updateLog( $title, $count, $bitfield, $logRows[$logid]->log_deleted
,
1152 $comment, $title, 'logid', $log_Ids );
1154 // Were all revs allowed to be set?
1155 if( !$userAllowedAll ) {
1156 $wgOut->permissionRequired( 'suppressrevision' );
1164 * Moves an image to a safe private location
1165 * Caller is responsible for clearing caches
1166 * @param File $oimage
1167 * @returns mixed, timestamp string on success, false on failure
1169 function makeOldImagePrivate( $oimage ) {
1170 $transaction = new FSTransaction();
1171 if( !FileStore
::lock() ) {
1172 wfDebug( __METHOD__
.": failed to acquire file store lock, aborting\n" );
1175 $oldpath = $oimage->getArchivePath() . DIRECTORY_SEPARATOR
. $oimage->archive_name
;
1176 // Dupe the file into the file store
1177 if( file_exists( $oldpath ) ) {
1178 // Is our directory configured?
1179 if( $store = FileStore
::get( 'deleted' ) ) {
1180 if( !$oimage->sha1
) {
1181 $oimage->upgradeRow(); // sha1 may be missing
1183 $key = $oimage->sha1
. '.' . $oimage->getExtension();
1184 $transaction->add( $store->insert( $key, $oldpath, FileStore
::DELETE_ORIGINAL
) );
1188 $transaction = false; // Return an error and do nothing
1191 wfDebug( __METHOD__
." deleting already-missing '$oldpath'; moving on to database\n" );
1194 $transaction = new FSTransaction(); // empty
1197 if( $transaction === false ) {
1199 wfDebug( __METHOD__
.": import to file store failed, aborting\n" );
1200 throw new MWException( "Could not archive and delete file $oldpath" );
1204 wfDebug( __METHOD__
.": set db items, applying file transactions\n" );
1205 $transaction->commit();
1206 FileStore
::unlock();
1208 $m = explode('!',$oimage->archive_name
,2);
1215 * Moves an image from a safe private location
1216 * Caller is responsible for clearing caches
1217 * @param File $oimage
1218 * @returns mixed, string timestamp on success, false on failure
1220 function makeOldImagePublic( $oimage ) {
1221 $transaction = new FSTransaction();
1222 if( !FileStore
::lock() ) {
1223 wfDebug( __METHOD__
." could not acquire filestore lock\n" );
1227 $store = FileStore
::get( 'deleted' );
1229 wfDebug( __METHOD__
.": skipping row with no file.\n" );
1233 $key = $oimage->sha1
.'.'.$oimage->getExtension();
1234 $destDir = $oimage->getArchivePath();
1235 if( !is_dir( $destDir ) ) {
1236 wfMkdirParents( $destDir );
1238 $destPath = $destDir . DIRECTORY_SEPARATOR
. $oimage->archive_name
;
1239 // Check if any other stored revisions use this file;
1240 // if so, we shouldn't remove the file from the hidden
1241 // archives so they will still work. Check hidden files first.
1242 $useCount = $this->dbw
->selectField( 'oldimage', '1',
1243 array( 'oi_sha1' => $oimage->sha1
,
1244 'oi_deleted & '.File
::DELETED_FILE
=> File
::DELETED_FILE
),
1245 __METHOD__
, array( 'FOR UPDATE' ) );
1246 // Check the rest of the deleted archives too.
1247 // (these are the ones that don't show in the image history)
1249 $useCount = $this->dbw
->selectField( 'filearchive', '1',
1250 array( 'fa_storage_group' => 'deleted', 'fa_storage_key' => $key ),
1251 __METHOD__
, array( 'FOR UPDATE' ) );
1254 if( $useCount == 0 ) {
1255 wfDebug( __METHOD__
.": nothing else using {$oimage->sha1}, will deleting after\n" );
1256 $flags = FileStore
::DELETE_ORIGINAL
;
1260 $transaction->add( $store->export( $key, $destPath, $flags ) );
1262 wfDebug( __METHOD__
.": set db items, applying file transactions\n" );
1263 $transaction->commit();
1264 FileStore
::unlock();
1266 $m = explode('!',$oimage->archive_name
,2);
1273 * Update the revision's rev_deleted field
1274 * @param Revision $rev
1275 * @param int $bitfield new rev_deleted bitfield value
1277 function updateRevision( $rev, $bitfield ) {
1278 $this->dbw
->update( 'revision',
1279 array( 'rev_deleted' => $bitfield ),
1280 array( 'rev_id' => $rev->getId(),
1281 'rev_page' => $rev->getPage() ),
1286 * Update the revision's rev_deleted field
1287 * @param Revision $rev
1288 * @param Title $title
1289 * @param int $bitfield new rev_deleted bitfield value
1291 function updateArchive( $rev, $title, $bitfield ) {
1292 $this->dbw
->update( 'archive',
1293 array( 'ar_deleted' => $bitfield ),
1294 array( 'ar_namespace' => $title->getNamespace(),
1295 'ar_title' => $title->getDBKey(),
1296 'ar_timestamp' => $this->dbw
->timestamp( $rev->getTimestamp() ),
1297 'ar_rev_id' => $rev->getId() ),
1302 * Update the images's oi_deleted field
1304 * @param int $bitfield new rev_deleted bitfield value
1306 function updateOldFiles( $file, $bitfield ) {
1307 $this->dbw
->update( 'oldimage',
1308 array( 'oi_deleted' => $bitfield ),
1309 array( 'oi_name' => $file->getName(),
1310 'oi_timestamp' => $this->dbw
->timestamp( $file->getTimestamp() ) ),
1315 * Update the images's fa_deleted field
1316 * @param ArchivedFile $file
1317 * @param int $bitfield new rev_deleted bitfield value
1319 function updateArchFiles( $file, $bitfield ) {
1320 $this->dbw
->update( 'filearchive',
1321 array( 'fa_deleted' => $bitfield ),
1322 array( 'fa_id' => $file->getId() ),
1327 * Update the logging log_deleted field
1329 * @param int $bitfield new rev_deleted bitfield value
1331 function updateLogs( $row, $bitfield ) {
1332 $this->dbw
->update( 'logging',
1333 array( 'log_deleted' => $bitfield ),
1334 array( 'log_id' => $row->log_id
),
1339 * Update the revision's recentchanges record if fields have been hidden
1340 * @param Revision $rev
1341 * @param int $bitfield new rev_deleted bitfield value
1343 function updateRecentChangesEdits( $rev, $bitfield ) {
1344 $this->dbw
->update( 'recentchanges',
1345 array( 'rc_deleted' => $bitfield,
1346 'rc_patrolled' => 1 ),
1347 array( 'rc_this_oldid' => $rev->getId(),
1348 'rc_timestamp' => $this->dbw
->timestamp( $rev->getTimestamp() ) ),
1353 * Update the revision's recentchanges record if fields have been hidden
1355 * @param int $bitfield new rev_deleted bitfield value
1357 function updateRecentChangesLog( $row, $bitfield ) {
1358 $this->dbw
->update( 'recentchanges',
1359 array( 'rc_deleted' => $bitfield,
1360 'rc_patrolled' => 1 ),
1361 array( 'rc_logid' => $row->log_id
,
1362 'rc_timestamp' => $row->log_timestamp
),
1367 * Touch the page's cache invalidation timestamp; this forces cached
1368 * history views to refresh, so any newly hidden or shown fields will
1370 * @param Title $title
1372 function updatePage( $title ) {
1373 $title->invalidateCache();
1374 $title->purgeSquid();
1375 $title->touchLinks();
1376 // Extensions that require referencing previous revisions may need this
1377 wfRunHooks( 'ArticleRevisionVisiblitySet', array( &$title ) );
1381 * Checks for a change in the bitfield for a certain option and updates the
1382 * provided array accordingly.
1384 * @param String $desc Description to add to the array if the option was
1385 * enabled / disabled.
1386 * @param int $field The bitmask describing the single option.
1387 * @param int $diff The xor of the old and new bitfields.
1388 * @param array $arr The array to update.
1390 function checkItem ( $desc, $field, $diff, $new, &$arr ) {
1391 if ( $diff & $field ) {
1392 $arr [ ( $new & $field ) ?
0 : 1 ][] = $desc;
1397 * Gets an array describing the changes made to the visibilit of the revision.
1398 * If the resulting array is $arr, then $arr[0] will contain an array of strings
1399 * describing the items that were hidden, $arr[2] will contain an array of strings
1400 * describing the items that were unhidden, and $arr[3] will contain an array with
1401 * a single string, which can be one of "applied restrictions to sysops",
1402 * "removed restrictions from sysops", or null.
1404 * @param int $n The new bitfield.
1405 * @param int $o The old bitfield.
1406 * @return An array as described above.
1408 function getChanges ( $n, $o ) {
1410 $ret = array ( 0 => array(), 1 => array(), 2 => array() );
1412 $this->checkItem ( wfMsgForContent ( 'revdelete-content' ),
1413 Revision
::DELETED_TEXT
, $diff, $n, $ret );
1414 $this->checkItem ( wfMsgForContent ( 'revdelete-summary' ),
1415 Revision
::DELETED_COMMENT
, $diff, $n, $ret );
1416 $this->checkItem ( wfMsgForContent ( 'revdelete-uname' ),
1417 Revision
::DELETED_USER
, $diff, $n, $ret );
1419 // Restriction application to sysops
1420 if ( $diff & Revision
::DELETED_RESTRICTED
) {
1421 if ( $n & Revision
::DELETED_RESTRICTED
)
1422 $ret[2][] = wfMsgForContent ( 'revdelete-restricted' );
1424 $ret[2][] = wfMsgForContent ( 'revdelete-unrestricted' );
1431 * Gets a log message to describe the given revision visibility change. This
1432 * message will be of the form "[hid {content, edit summary, username}];
1433 * [unhid {...}][applied restrictions to sysops] for $count revisions: $comment".
1435 * @param int $count The number of effected revisions.
1436 * @param int $nbitfield The new bitfield for the revision.
1437 * @param int $obitfield The old bitfield for the revision.
1438 * @param string $comment The comment associated with the change.
1439 * @param bool $isForLog
1441 function getLogMessage ( $count, $nbitfield, $obitfield, $comment, $isForLog = false ) {
1445 $changes = $this->getChanges( $nbitfield, $obitfield );
1447 if ( count ( $changes[0] ) ) {
1448 $s .= wfMsgForContent ( 'revdelete-hid', implode ( ', ', $changes[0] ) );
1451 if ( count ( $changes[1] ) ) {
1454 $s .= wfMsgForContent ( 'revdelete-unhid', implode ( ', ', $changes[1] ) );
1457 if ( count ( $changes[2] )) {
1459 $s .= ' (' . $changes[2][0] . ')';
1461 $s = $changes[2][0];
1464 $msg = $isForLog ?
'logdelete-log-message' : 'revdelete-log-message';
1465 $ret = wfMsgExt ( $msg, array( 'parsemag', 'content' ),
1466 $s, $wgContLang->formatNum( $count ) );
1469 $ret .= ": $comment";
1476 * Record a log entry on the action
1477 * @param Title $title, page where item was removed from
1478 * @param int $count the number of revisions altered for this page
1479 * @param int $nbitfield the new _deleted value
1480 * @param int $obitfield the old _deleted value
1481 * @param string $comment
1482 * @param Title $target, the relevant page
1483 * @param string $param, URL param
1484 * @param Array $items
1486 function updateLog( $title, $count, $nbitfield, $obitfield, $comment, $target, $param, $items = array() ) {
1487 // Put things hidden from sysops in the oversight log
1488 $logtype = ( ($nbitfield |
$obitfield) & Revision
::DELETED_RESTRICTED
) ?
'suppress' : 'delete';
1489 $log = new LogPage( $logtype );
1491 $reason = $this->getLogMessage ( $count, $nbitfield, $obitfield, $comment, $param == 'logid' );
1493 if( $param == 'logid' ) {
1494 $params = array( implode( ',', $items) );
1495 $log->addEntry( 'event', $title, $reason, $params );
1497 // Add params for effected page and ids
1498 $params = array( $param, implode( ',', $items) );
1499 $log->addEntry( 'revision', $title, $reason, $params );