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;
12 # Handle our many different possible input types
13 $target = $wgRequest->getText( 'target' );
14 $oldid = $wgRequest->getArray( 'oldid' );
15 $artimestamp = $wgRequest->getArray( 'artimestamp' );
16 $logid = $wgRequest->getArray( 'logid' );
17 $img = $wgRequest->getArray( 'oldimage' );
18 $fileid = $wgRequest->getArray( 'fileid' );
19 # For reviewing deleted files...
20 $file = $wgRequest->getVal( 'file' );
21 # If this is a revision, then we need a target page
22 $page = Title
::newFromUrl( $target );
23 if( is_null($page) ) {
24 $wgOut->addWikiMsg( 'undelete-header' );
27 # Only one target set at a time please!
28 $i = (bool)$file +
(bool)$oldid +
(bool)$logid +
(bool)$artimestamp +
(bool)$fileid +
(bool)$img;
30 $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
33 # Logs must have a type given
34 if( $logid && !strpos($page->getDBKey(),'/') ) {
35 $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
38 # Either submit or create our form
39 $form = new RevisionDeleteForm( $page, $oldid, $logid, $artimestamp, $fileid, $img, $file );
40 if( $wgRequest->wasPosted() ) {
41 $form->submit( $wgRequest );
42 } else if( $oldid ||
$artimestamp ) {
44 } else if( $fileid ||
$img ) {
47 $form->showLogItems();
49 # Show relevant lines from the deletion log. This will show even if said ID
50 # does not exist...might be helpful
51 $wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage
::logName( 'delete' ) ) . "</h2>\n" );
52 LogEventsList
::showLogExtract( $wgOut, 'delete', $page->getPrefixedText() );
53 if( $wgUser->isAllowed( 'suppressionlog' ) ){
54 $wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage
::logName( 'suppress' ) ) . "</h2>\n" );
55 LogEventsList
::showLogExtract( $wgOut, 'suppress', $page->getPrefixedText() );
60 * Implements the GUI for Revision Deletion.
61 * @ingroup SpecialPage
63 class RevisionDeleteForm
{
66 * @param array $oldids
67 * @param array $logids
68 * @param array $artimestamps
69 * @param array $fileids
73 function __construct( $page, $oldids, $logids, $artimestamps, $fileids, $img, $file ) {
74 global $wgUser, $wgOut;
77 # For reviewing deleted files...
79 $oimage = RepoGroup
::singleton()->getLocalRepo()->newFromArchiveName( $page, $file );
81 // Check if user is allowed to see this file
82 if( !$oimage->userCan(File
::DELETED_FILE
) ) {
83 $wgOut->permissionRequired( 'suppressrevision' );
85 $this->showFile( $file );
89 $this->skin
= $wgUser->getSkin();
90 # Give a link to the log for this page
91 if( !is_null($this->page
) && $this->page
->getNamespace() > -1 ) {
94 $logtitle = SpecialPage
::getTitleFor( 'Log' );
95 $links[] = $this->skin
->makeKnownLinkObj( $logtitle, wfMsgHtml( 'viewpagelogs' ),
96 wfArrayToCGI( array( 'page' => $this->page
->getPrefixedUrl() ) ) );
97 # Give a link to the page history
98 $links[] = $this->skin
->makeKnownLinkObj( $this->page
, wfMsgHtml( 'pagehist' ),
99 wfArrayToCGI( array( 'action' => 'history' ) ) );
100 # Link to deleted edits
101 if( $wgUser->isAllowed('undelete') ) {
102 $undelete = SpecialPage
::getTitleFor( 'Undelete' );
103 $links[] = $this->skin
->makeKnownLinkObj( $undelete, wfMsgHtml( 'deletedhist' ),
104 wfArrayToCGI( array( 'target' => $this->page
->getPrefixedUrl() ) ) );
106 # Logs themselves don't have histories or archived revisions
107 $wgOut->setSubtitle( '<p>'.implode($links,' / ').'</p>' );
109 // At this point, we should only have one of these
111 $this->revisions
= $oldids;
112 $hide_content_name = array( 'revdelete-hide-text', 'wpHideText', Revision
::DELETED_TEXT
);
113 $this->deleteKey
='oldid';
114 } else if( $artimestamps ) {
115 $this->archrevs
= $artimestamps;
116 $hide_content_name = array( 'revdelete-hide-text', 'wpHideText', Revision
::DELETED_TEXT
);
117 $this->deleteKey
='artimestamp';
119 $this->ofiles
= $img;
120 $hide_content_name = array( 'revdelete-hide-image', 'wpHideImage', File
::DELETED_FILE
);
121 $this->deleteKey
='oldimage';
122 } else if( $fileids ) {
123 $this->afiles
= $fileids;
124 $hide_content_name = array( 'revdelete-hide-image', 'wpHideImage', File
::DELETED_FILE
);
125 $this->deleteKey
='fileid';
126 } else if( $logids ) {
127 $this->events
= $logids;
128 $hide_content_name = array( 'revdelete-hide-name', 'wpHideName', LogPage
::DELETED_ACTION
);
129 $this->deleteKey
='logid';
131 // Our checkbox messages depends one what we are doing,
132 // e.g. we don't hide "text" for logs or images
133 $this->checks
= array(
135 array( 'revdelete-hide-comment', 'wpHideComment', Revision
::DELETED_COMMENT
),
136 array( 'revdelete-hide-user', 'wpHideUser', Revision
::DELETED_USER
) );
137 if( $wgUser->isAllowed('suppressrevision') ) {
138 $this->checks
[] = array( 'revdelete-hide-restricted', 'wpHideRestricted', Revision
::DELETED_RESTRICTED
);
143 * Show a deleted file version requested by the visitor.
145 private function showFile( $key ) {
146 global $wgOut, $wgRequest;
149 # We mustn't allow the output to be Squid cached, otherwise
150 # if an admin previews a deleted image, and it's cached, then
151 # a user without appropriate permissions can toddle off and
152 # nab the image, and Squid will serve it
153 $wgRequest->response()->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', 0 ) . ' GMT' );
154 $wgRequest->response()->header( 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' );
155 $wgRequest->response()->header( 'Pragma: no-cache' );
157 $store = FileStore
::get( 'deleted' );
158 $store->stream( $key );
162 * This lets a user set restrictions for live and archived revisions
164 function showRevs() {
165 global $wgOut, $wgUser, $action;
169 $count = ($this->deleteKey
=='oldid') ?
170 count($this->revisions
) : count($this->archrevs
);
171 $wgOut->addWikiMsg( 'revdelete-selected', $this->page
->getPrefixedText(), $count );
174 $wgOut->addHtml( "<ul>" );
176 $where = $revObjs = array();
177 $dbr = wfGetDB( DB_SLAVE
);
181 if( $this->deleteKey
=='oldid' ) {
182 // Run through and pull all our data in one query
183 foreach( $this->revisions
as $revid ) {
184 $where[] = intval($revid);
186 $whereClause = 'rev_id IN(' . implode(',',$where) . ')';
187 $result = $dbr->select( array('revision','page'), '*',
188 array( 'rev_page' => $this->page
->getArticleID(),
189 $whereClause, 'rev_page = page_id' ),
191 while( $row = $dbr->fetchObject( $result ) ) {
192 $revObjs[$row->rev_id
] = new Revision( $row );
194 foreach( $this->revisions
as $revid ) {
195 // Hiding top revisison is bad
196 if( !isset($revObjs[$revid]) ||
$revObjs[$revid]->isCurrent() ) {
198 } else if( !$revObjs[$revid]->userCan(Revision
::DELETED_RESTRICTED
) ) {
199 // If a rev is hidden from sysops
200 if( $action != 'submit') {
201 $wgOut->permissionRequired( 'suppressrevision' );
204 $UserAllowed = false;
207 $wgOut->addHtml( $this->historyLine( $revObjs[$revid] ) );
208 $bitfields |
= $revObjs[$revid]->mDeleted
;
212 // Run through and pull all our data in one query
213 foreach( $this->archrevs
as $timestamp ) {
214 $where[] = $dbr->addQuotes( $timestamp );
216 $whereClause = 'ar_timestamp IN(' . implode(',',$where) . ')';
217 $result = $dbr->select( 'archive', '*',
218 array( 'ar_namespace' => $this->page
->getNamespace(),
219 'ar_title' => $this->page
->getDBKey(),
222 while( $row = $dbr->fetchObject( $result ) ) {
223 $revObjs[$row->ar_timestamp
] = new Revision( array(
224 'page' => $this->page
->getArticleId(),
225 'id' => $row->ar_rev_id
,
226 'text' => $row->ar_text_id
,
227 'comment' => $row->ar_comment
,
228 'user' => $row->ar_user
,
229 'user_text' => $row->ar_user_text
,
230 'timestamp' => $row->ar_timestamp
,
231 'minor_edit' => $row->ar_minor_edit
,
232 'text_id' => $row->ar_text_id
,
233 'deleted' => $row->ar_deleted
,
234 'len' => $row->ar_len
) );
236 foreach( $this->archrevs
as $timestamp ) {
237 if( !isset($revObjs[$timestamp]) ) {
239 } else if( !$revObjs[$timestamp]->userCan(Revision
::DELETED_RESTRICTED
) ) {
240 // If a rev is hidden from sysops
241 if( $action != 'submit') {
242 $wgOut->permissionRequired( 'suppressrevision' );
245 $UserAllowed = false;
248 $wgOut->addHtml( $this->historyLine( $revObjs[$timestamp] ) );
249 $bitfields |
= $revObjs[$timestamp]->mDeleted
;
253 $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
257 $wgOut->addHtml( "</ul>" );
259 $wgOut->addWikiMsg( 'revdelete-text' );
261 // Normal sysops can always see what they did, but can't always change it
262 if( !$UserAllowed ) return;
265 Xml
::inputLabel( wfMsg( 'revdelete-log' ), 'wpReason', 'wpReason', 60 ),
266 Xml
::submitButton( wfMsg( 'revdelete-submit' ) )
269 Xml
::hidden( 'wpEditToken', $wgUser->editToken() ),
270 Xml
::hidden( 'target', $this->page
->getPrefixedText() ),
271 Xml
::hidden( 'type', $this->deleteKey
)
273 if( $this->deleteKey
=='oldid' ) {
274 foreach( $revObjs as $rev )
275 $hidden[] = Xml
::hidden( 'oldid[]', $rev->getId() );
277 foreach( $revObjs as $rev )
278 $hidden[] = Xml
::hidden( 'artimestamp[]', $rev->getTimestamp() );
280 $special = SpecialPage
::getTitleFor( 'Revisiondelete' );
282 Xml
::openElement( 'form', array( 'method' => 'post', 'action' => $special->getLocalUrl( 'action=submit' ),
283 'id' => 'mw-revdel-form-revisions' ) ) .
284 Xml
::openElement( 'fieldset' ) .
285 xml
::element( 'legend', null, wfMsg( 'revdelete-legend' ) )
287 // FIXME: all items checked for just one rev are checked, even if not set for the others
288 foreach( $this->checks
as $item ) {
289 list( $message, $name, $field ) = $item;
290 $wgOut->addHtml( Xml
::tags( 'div', null, Xml
::checkLabel( wfMsg( $message ), $name, $name, $bitfields & $field ) ) );
292 foreach( $items as $item ) {
293 $wgOut->addHtml( Xml
::tags( 'p', null, $item ) );
295 foreach( $hidden as $item ) {
296 $wgOut->addHtml( $item );
299 Xml
::closeElement( 'fieldset' ) .
300 Xml
::closeElement( 'form' ) . "\n"
306 * This lets a user set restrictions for archived images
308 function showImages() {
309 // What is $action doing here???
310 global $wgOut, $wgUser, $action, $wgLang;
314 $count = ($this->deleteKey
=='oldimage') ?
count($this->ofiles
) : count($this->afiles
);
315 $wgOut->addWikiMsg( 'revdelete-selected',
316 $this->page
->getPrefixedText(),
317 $wgLang->formatNum($count) );
320 $wgOut->addHtml( "<ul>" );
322 $where = $filesObjs = array();
323 $dbr = wfGetDB( DB_SLAVE
);
324 // Live old revisions...
326 if( $this->deleteKey
=='oldimage' ) {
327 // Run through and pull all our data in one query
328 foreach( $this->ofiles
as $timestamp ) {
329 $where[] = $dbr->addQuotes( $timestamp.'!'.$this->page
->getDbKey() );
331 $whereClause = 'oi_archive_name IN(' . implode(',',$where) . ')';
332 $result = $dbr->select( 'oldimage', '*',
333 array( 'oi_name' => $this->page
->getDbKey(),
336 while( $row = $dbr->fetchObject( $result ) ) {
337 $filesObjs[$row->oi_archive_name
] = RepoGroup
::singleton()->getLocalRepo()->newFileFromRow( $row );
338 $filesObjs[$row->oi_archive_name
]->user
= $row->oi_user
;
339 $filesObjs[$row->oi_archive_name
]->user_text
= $row->oi_user_text
;
341 // Check through our images
342 foreach( $this->ofiles
as $timestamp ) {
343 $archivename = $timestamp.'!'.$this->page
->getDbKey();
344 if( !isset($filesObjs[$archivename]) ) {
346 } else if( !$filesObjs[$archivename]->userCan(File
::DELETED_RESTRICTED
) ) {
347 // If a rev is hidden from sysops
348 if( $action != 'submit' ) {
349 $wgOut->permissionRequired( 'suppressrevision' );
352 $UserAllowed = false;
355 // Inject history info
356 $wgOut->addHtml( $this->fileLine( $filesObjs[$archivename] ) );
357 $bitfields |
= $filesObjs[$archivename]->deleted
;
361 // Run through and pull all our data in one query
362 foreach( $this->afiles
as $id ) {
363 $where[] = intval($id);
365 $whereClause = 'fa_id IN(' . implode(',',$where) . ')';
366 $result = $dbr->select( 'filearchive', '*',
367 array( 'fa_name' => $this->page
->getDbKey(),
370 while( $row = $dbr->fetchObject( $result ) ) {
371 $filesObjs[$row->fa_id
] = ArchivedFile
::newFromRow( $row );
374 foreach( $this->afiles
as $fileid ) {
375 if( !isset($filesObjs[$fileid]) ) {
377 } else if( !$filesObjs[$fileid]->userCan(File
::DELETED_RESTRICTED
) ) {
378 // If a rev is hidden from sysops
379 if( $action != 'submit' ) {
380 $wgOut->permissionRequired( 'suppressrevision' );
383 $UserAllowed = false;
386 // Inject history info
387 $wgOut->addHtml( $this->archivedfileLine( $filesObjs[$fileid] ) );
388 $bitfields |
= $filesObjs[$fileid]->deleted
;
392 $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
396 $wgOut->addHtml( "</ul>" );
398 $wgOut->addWikiMsg('revdelete-text' );
399 //Normal sysops can always see what they did, but can't always change it
400 if( !$UserAllowed ) return;
403 Xml
::inputLabel( wfMsg( 'revdelete-log' ), 'wpReason', 'wpReason', 60 ),
404 Xml
::submitButton( wfMsg( 'revdelete-submit' ) )
407 Xml
::hidden( 'wpEditToken', $wgUser->editToken() ),
408 Xml
::hidden( 'target', $this->page
->getPrefixedText() ),
409 Xml
::hidden( 'type', $this->deleteKey
)
411 if( $this->deleteKey
=='oldimage' ) {
412 foreach( $this->ofiles
as $filename )
413 $hidden[] = Xml
::hidden( 'oldimage[]', $filename );
415 foreach( $this->afiles
as $fileid )
416 $hidden[] = Xml
::hidden( 'fileid[]', $fileid );
418 $special = SpecialPage
::getTitleFor( 'Revisiondelete' );
420 Xml
::openElement( 'form', array( 'method' => 'post', 'action' => $special->getLocalUrl( 'action=submit' ),
421 'id' => 'mw-revdel-form-filerevisions' ) ) .
422 Xml
::fieldset( wfMsg( 'revdelete-legend' ) )
424 // FIXME: all items checked for just one file are checked, even if not set for the others
425 foreach( $this->checks
as $item ) {
426 list( $message, $name, $field ) = $item;
427 $wgOut->addHtml( Xml
::tags( 'div', null, Xml
::checkLabel( wfMsg( $message ), $name, $name, $bitfields & $field ) ) );
429 foreach( $items as $item ) {
430 $wgOut->addHtml( "<p>$item</p>" );
432 foreach( $hidden as $item ) {
433 $wgOut->addHtml( $item );
437 Xml
::closeElement( 'fieldset' ) .
438 Xml
::closeElement( 'form' ) . "\n"
443 * This lets a user set restrictions for log items
445 function showLogItems() {
446 global $wgOut, $wgUser, $action, $wgMessageCache, $wgLang;
449 $wgOut->addWikiMsg( 'logdelete-selected', $wgLang->formatNum( count($this->events
) ) );
452 $wgOut->addHtml( "<ul>" );
454 $where = $logRows = array();
455 $dbr = wfGetDB( DB_SLAVE
);
456 // Run through and pull all our data in one query
458 foreach( $this->events
as $logid ) {
459 $where[] = intval($logid);
461 list($log,$logtype) = explode( '/',$this->page
->getDBKey(), 2 );
462 $whereClause = "log_type = '$logtype' AND log_id IN(" . implode(',',$where) . ")";
463 $result = $dbr->select( 'logging', '*',
464 array( $whereClause ),
466 while( $row = $dbr->fetchObject( $result ) ) {
467 $logRows[$row->log_id
] = $row;
469 $wgMessageCache->loadAllMessages();
470 foreach( $this->events
as $logid ) {
471 // Don't hide from oversight log!!!
472 if( !isset( $logRows[$logid] ) ||
$logRows[$logid]->log_type
=='suppress' ) {
474 } else if( !LogEventsList
::userCan( $logRows[$logid],Revision
::DELETED_RESTRICTED
) ) {
475 // If an event is hidden from sysops
476 if( $action != 'submit') {
477 $wgOut->permissionRequired( 'suppressrevision' );
480 $UserAllowed = false;
483 $wgOut->addHtml( $this->logLine( $logRows[$logid] ) );
484 $bitfields |
= $logRows[$logid]->log_deleted
;
487 $wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
491 $wgOut->addHtml( "</ul>" );
493 $wgOut->addWikiMsg( 'revdelete-text' );
494 // Normal sysops can always see what they did, but can't always change it
495 if( !$UserAllowed ) return;
498 Xml
::inputLabel( wfMsg( 'revdelete-log' ), 'wpReason', 'wpReason', 60 ),
499 Xml
::submitButton( wfMsg( 'revdelete-submit' ) ) );
501 Xml
::hidden( 'wpEditToken', $wgUser->editToken() ),
502 Xml
::hidden( 'target', $this->page
->getPrefixedText() ),
503 Xml
::hidden( 'type', $this->deleteKey
) );
504 foreach( $this->events
as $logid ) {
505 $hidden[] = Xml
::hidden( 'logid[]', $logid );
508 $special = SpecialPage
::getTitleFor( 'Revisiondelete' );
510 Xml
::openElement( 'form', array( 'method' => 'post', 'action' => $special->getLocalUrl( 'action=submit' ),
511 'id' => 'mw-revdel-form-logs' ) ) .
512 Xml
::fieldset( wfMsg( 'revdelete-legend' ) )
514 // FIXME: all items checked for just on event are checked, even if not set for the others
515 foreach( $this->checks
as $item ) {
516 list( $message, $name, $field ) = $item;
517 $wgOut->addHtml( Xml
::tags( 'div', null, Xml
::checkLabel( wfMsg( $message ), $name, $name, $bitfields & $field ) ) );
519 foreach( $items as $item ) {
520 $wgOut->addHtml( "<p>$item</p>" );
522 foreach( $hidden as $item ) {
523 $wgOut->addHtml( $item );
527 Xml
::closeElement( 'fieldset' ) .
528 Xml
::closeElement( 'form' ) . "\n"
533 * @param Revision $rev
536 private function historyLine( $rev ) {
539 $date = $wgLang->timeanddate( $rev->getTimestamp() );
540 $difflink = $del = '';
542 if( $this->deleteKey
=='oldid' ) {
543 $revlink = $this->skin
->makeLinkObj( $this->page
, $date, 'oldid=' . $rev->getId() );
544 $difflink = '(' . $this->skin
->makeKnownLinkObj( $this->page
, wfMsgHtml('diff'),
545 'diff=' . $rev->getId() . '&oldid=prev' ) . ')';
546 // Archived revisions
548 $undelete = SpecialPage
::getTitleFor( 'Undelete' );
549 $target = $this->page
->getPrefixedText();
550 $revlink = $this->skin
->makeLinkObj( $undelete, $date,
551 "target=$target×tamp=" . $rev->getTimestamp() );
552 $difflink = '(' . $this->skin
->makeKnownLinkObj( $undelete, wfMsgHtml('diff'),
553 "target=$target&diff=prev×tamp=" . $rev->getTimestamp() ) . ')';
556 if( $rev->isDeleted(Revision
::DELETED_TEXT
) ) {
557 $revlink = '<span class="history-deleted">'.$revlink.'</span>';
558 $del = ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
559 if( !$rev->userCan(Revision
::DELETED_TEXT
) ) {
560 $revlink = '<span class="history-deleted">'.$date.'</span>';
561 $difflink = '(' . wfMsgHtml('diff') . ')';
565 return "<li> $difflink $revlink ".$this->skin
->revUserLink( $rev )." ".$this->skin
->revComment( $rev )."$del</li>";
572 private function fileLine( $file ) {
573 global $wgLang, $wgTitle;
575 $target = $this->page
->getPrefixedText();
576 $date = $wgLang->timeanddate( $file->getTimestamp(), true );
580 if( $file->isDeleted(File
::DELETED_FILE
) ) {
581 $del = ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
582 if( !$file->userCan(File
::DELETED_FILE
) ) {
585 $pageLink = $this->skin
->makeKnownLinkObj( $wgTitle, $date,
586 "target=$target&file=$file->sha1.".$file->getExtension() );
588 $pageLink = '<span class="history-deleted">' . $pageLink . '</span>';
591 $url = $file->getUrlRel();
592 $pageLink = "<a href=\"{$url}\">{$date}</a>";
595 $data = wfMsg( 'widthheight',
596 $wgLang->formatNum( $file->getWidth() ),
597 $wgLang->formatNum( $file->getHeight() ) ) .
598 ' (' . wfMsgExt( 'nbytes', 'parsemag', $wgLang->formatNum( $file->getSize() ) ) . ')';
599 $data = htmlspecialchars( $data );
601 return "<li>$pageLink ".$this->fileUserTools( $file )." $data ".$this->fileComment( $file )."$del</li>";
605 * @param ArchivedFile $file
608 private function archivedfileLine( $file ) {
609 global $wgLang, $wgTitle;
611 $target = $this->page
->getPrefixedText();
612 $date = $wgLang->timeanddate( $file->getTimestamp(), true );
614 $undelete = SpecialPage
::getTitleFor( 'Undelete' );
615 $pageLink = $this->skin
->makeKnownLinkObj( $undelete, $date, "target=$target&file={$file->getKey()}" );
618 if( $file->isDeleted(File
::DELETED_FILE
) ) {
619 $del = ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
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 Array $row row
635 private function logLine( $row ) {
638 $date = $wgLang->timeanddate( $row->log_timestamp
);
639 $paramArray = LogPage
::extractParams( $row->log_params
);
640 $title = Title
::makeTitle( $row->log_namespace
, $row->log_title
);
642 $logtitle = SpecialPage
::getTitleFor( 'Log' );
643 $loglink = $this->skin
->makeKnownLinkObj( $logtitle, wfMsgHtml( 'log' ),
644 wfArrayToCGI( array( 'page' => $title->getPrefixedUrl() ) ) );
646 if( !LogEventsList
::userCan($row,LogPage
::DELETED_ACTION
) ) {
647 $action = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
649 $action = LogPage
::actionText( $row->log_type
, $row->log_action
, $title,
650 $this->skin
, $paramArray, true, true );
651 if( $row->log_deleted
& LogPage
::DELETED_ACTION
)
652 $action = '<span class="history-deleted">' . $action . '</span>';
655 $userLink = $this->skin
->userLink( $row->log_user
, User
::WhoIs($row->log_user
) );
656 if( LogEventsList
::isDeleted($row,LogPage
::DELETED_USER
) ) {
657 $userLink = '<span class="history-deleted">' . $userLink . '</span>';
660 $comment = $wgLang->getDirMark() . $this->skin
->commentBlock( $row->log_comment
);
661 if( LogEventsList
::isDeleted($row,LogPage
::DELETED_COMMENT
) ) {
662 $comment = '<span class="history-deleted">' . $comment . '</span>';
664 return "<li>($loglink) $date $userLink $action $comment</li>";
668 * Generate a user tool link cluster if the current user is allowed to view it
669 * @param ArchivedFile $file
670 * @return string HTML
672 private function fileUserTools( $file ) {
673 if( $file->userCan( Revision
::DELETED_USER
) ) {
674 $link = $this->skin
->userLink( $file->user
, $file->user_text
) .
675 $this->skin
->userToolLinks( $file->user
, $file->user_text
);
677 $link = wfMsgHtml( 'rev-deleted-user' );
679 if( $file->isDeleted( Revision
::DELETED_USER
) ) {
680 return '<span class="history-deleted">' . $link . '</span>';
686 * Wrap and format the given file's comment block, if the current
687 * user is allowed to view it.
689 * @param ArchivedFile $file
690 * @return string HTML
692 private function fileComment( $file ) {
693 if( $file->userCan( File
::DELETED_COMMENT
) ) {
694 $block = $this->skin
->commentBlock( $file->description
);
696 $block = ' ' . wfMsgHtml( 'rev-deleted-comment' );
698 if( $file->isDeleted( File
::DELETED_COMMENT
) ) {
699 return "<span class=\"history-deleted\">$block</span>";
705 * @param WebRequest $request
707 function submit( $request ) {
708 global $wgUser, $wgOut;
710 $bitfield = $this->extractBitfield( $request );
711 $comment = $request->getText( 'wpReason' );
712 # Can the user set this field?
713 if( $bitfield & Revision
::DELETED_RESTRICTED
&& !$wgUser->isAllowed('suppressrevision') ) {
714 $wgOut->permissionRequired( 'suppressrevision' );
717 # If the save went through, go to success message. Otherwise
718 # bounce back to form...
719 if( $this->save( $bitfield, $comment, $this->page
) ) {
721 } else if( $request->getCheck( 'oldid' ) ||
$request->getCheck( 'artimestamp' ) ) {
722 return $this->showRevs();
723 } else if( $request->getCheck( 'logid' ) ) {
724 return $this->showLogs();
725 } else if( $request->getCheck( 'oldimage' ) ||
$request->getCheck( 'fileid' ) ) {
726 return $this->showImages();
730 private function success() {
733 $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
735 $wrap = '<span class="success">$1</span>';
737 if( $this->deleteKey
=='logid' ) {
738 $wgOut->wrapWikiMsg( $wrap, 'logdelete-success' );
739 $this->showLogItems();
740 } else if( $this->deleteKey
=='oldid' ||
$this->deleteKey
=='artimestamp' ) {
741 $wgOut->wrapWikiMsg( $wrap, 'revdelete-success' );
743 } else if( $this->deleteKey
=='fileid' ) {
744 $wgOut->wrapWikiMsg( $wrap, 'revdelete-success' );
746 } else if( $this->deleteKey
=='oldimage' ) {
747 $wgOut->wrapWikiMsg( $wrap, 'revdelete-success' );
753 * Put together a rev_deleted bitfield from the submitted checkboxes
754 * @param WebRequest $request
757 private function extractBitfield( $request ) {
759 foreach( $this->checks
as $item ) {
760 list( /* message */ , $name, $field ) = $item;
761 if( $request->getCheck( $name ) ) {
768 private function save( $bitfield, $reason, $title ) {
769 $dbw = wfGetDB( DB_MASTER
);
770 // Don't allow simply locking the interface for no reason
771 if( $bitfield == Revision
::DELETED_RESTRICTED
) {
774 $deleter = new RevisionDeleter( $dbw );
775 // By this point, only one of the below should be set
776 if( isset($this->revisions
) ) {
777 return $deleter->setRevVisibility( $title, $this->revisions
, $bitfield, $reason );
778 } else if( isset($this->archrevs
) ) {
779 return $deleter->setArchiveVisibility( $title, $this->archrevs
, $bitfield, $reason );
780 } else if( isset($this->ofiles
) ) {
781 return $deleter->setOldImgVisibility( $title, $this->ofiles
, $bitfield, $reason );
782 } else if( isset($this->afiles
) ) {
783 return $deleter->setArchFileVisibility( $title, $this->afiles
, $bitfield, $reason );
784 } else if( isset($this->events
) ) {
785 return $deleter->setEventVisibility( $title, $this->events
, $bitfield, $reason );
791 * Implements the actions for Revision Deletion.
792 * @ingroup SpecialPage
794 class RevisionDeleter
{
795 function __construct( $db ) {
800 * @param $title, the page these events apply to
801 * @param array $items list of revision ID numbers
802 * @param int $bitfield new rev_deleted value
803 * @param string $comment Comment for log records
805 function setRevVisibility( $title, $items, $bitfield, $comment ) {
808 $userAllowedAll = $success = true;
811 // Run through and pull all our data in one query
812 foreach( $items as $revid ) {
813 $where[] = intval($revid);
815 $whereClause = 'rev_id IN(' . implode(',',$where) . ')';
816 $result = $this->dbw
->select( 'revision', '*',
817 array( 'rev_page' => $title->getArticleID(),
820 while( $row = $this->dbw
->fetchObject( $result ) ) {
821 $revObjs[$row->rev_id
] = new Revision( $row );
824 foreach( $items as $revid ) {
825 if( !isset($revObjs[$revid]) ||
$revObjs[$revid]->isCurrent() ) {
827 continue; // Must exist
828 } else if( !$revObjs[$revid]->userCan(Revision
::DELETED_RESTRICTED
) ) {
829 $userAllowedAll=false;
832 // For logging, maintain a count of revisions
833 if( $revObjs[$revid]->mDeleted
!= $bitfield ) {
837 $this->updateRevision( $revObjs[$revid], $bitfield );
838 $this->updateRecentChangesEdits( $revObjs[$revid], $bitfield, false );
842 // Don't log or touch if nothing changed
843 if( $revCount > 0 ) {
844 $this->updateLog( $title, $revCount, $bitfield, $revObjs[$revid]->mDeleted
,
845 $comment, $title, 'oldid', $revIDs );
846 $this->updatePage( $title );
848 // Where all revs allowed to be set?
849 if( !$userAllowedAll ) {
850 //FIXME: still might be confusing???
851 $wgOut->permissionRequired( 'suppressrevision' );
859 * @param $title, the page these events apply to
860 * @param array $items list of revision ID numbers
861 * @param int $bitfield new rev_deleted value
862 * @param string $comment Comment for log records
864 function setArchiveVisibility( $title, $items, $bitfield, $comment ) {
867 $userAllowedAll = $success = true;
870 // Run through and pull all our data in one query
871 foreach( $items as $timestamp ) {
872 $where[] = $this->dbw
->addQuotes( $timestamp );
874 $whereClause = 'ar_timestamp IN(' . implode(',',$where) . ')';
875 $result = $this->dbw
->select( 'archive', '*',
876 array( 'ar_namespace' => $title->getNamespace(),
877 'ar_title' => $title->getDBKey(),
880 while( $row = $this->dbw
->fetchObject( $result ) ) {
881 $revObjs[$row->ar_timestamp
] = new Revision( array(
882 'page' => $title->getArticleId(),
883 'id' => $row->ar_rev_id
,
884 'text' => $row->ar_text_id
,
885 'comment' => $row->ar_comment
,
886 'user' => $row->ar_user
,
887 'user_text' => $row->ar_user_text
,
888 'timestamp' => $row->ar_timestamp
,
889 'minor_edit' => $row->ar_minor_edit
,
890 'text_id' => $row->ar_text_id
,
891 'deleted' => $row->ar_deleted
,
892 'len' => $row->ar_len
) );
895 foreach( $items as $timestamp ) {
896 // This will only select the first revision with this timestamp.
897 // Since they are all selected/deleted at once, we can just check the
898 // permissions of one. UPDATE is done via timestamp, so all revs are set.
899 if( !is_object($revObjs[$timestamp]) ) {
901 continue; // Must exist
902 } else if( !$revObjs[$timestamp]->userCan(Revision
::DELETED_RESTRICTED
) ) {
903 $userAllowedAll=false;
906 // Which revisions did we change anything about?
907 if( $revObjs[$timestamp]->mDeleted
!= $bitfield ) {
908 $Id_set[]=$timestamp;
911 $this->updateArchive( $revObjs[$timestamp], $title, $bitfield );
914 // For logging, maintain a count of revisions
916 $this->updateLog( $title, $count, $bitfield, $revObjs[$timestamp]->mDeleted
,
917 $comment, $title, 'artimestamp', $Id_set );
919 // Where all revs allowed to be set?
920 if( !$userAllowedAll ) {
921 $wgOut->permissionRequired( 'suppressrevision' );
929 * @param $title, the page these events apply to
930 * @param array $items list of revision ID numbers
931 * @param int $bitfield new rev_deleted value
932 * @param string $comment Comment for log records
934 function setOldImgVisibility( $title, $items, $bitfield, $comment ) {
937 $userAllowedAll = $success = true;
940 // Run through and pull all our data in one query
941 foreach( $items as $timestamp ) {
942 $where[] = $this->dbw
->addQuotes( $timestamp.'!'.$title->getDbKey() );
944 $whereClause = 'oi_archive_name IN(' . implode(',',$where) . ')';
945 $result = $this->dbw
->select( 'oldimage', '*',
946 array( 'oi_name' => $title->getDbKey(),
949 while( $row = $this->dbw
->fetchObject( $result ) ) {
950 $filesObjs[$row->oi_archive_name
] = RepoGroup
::singleton()->getLocalRepo()->newFileFromRow( $row );
951 $filesObjs[$row->oi_archive_name
]->user
= $row->oi_user
;
952 $filesObjs[$row->oi_archive_name
]->user_text
= $row->oi_user_text
;
955 foreach( $items as $timestamp ) {
956 $archivename = $timestamp.'!'.$title->getDbKey();
957 if( !isset($filesObjs[$archivename]) ) {
959 continue; // Must exist
960 } else if( !$filesObjs[$archivename]->userCan(File
::DELETED_RESTRICTED
) ) {
961 $userAllowedAll=false;
966 // Which revisions did we change anything about?
967 if( $filesObjs[$archivename]->deleted
!= $bitfield ) {
971 $this->updateOldFiles( $filesObjs[$archivename], $bitfield );
972 // If this image is currently hidden...
973 if( $filesObjs[$archivename]->deleted
& File
::DELETED_FILE
) {
974 if( $bitfield & File
::DELETED_FILE
) {
975 # Leave it alone if we are not changing this...
979 # We are moving this out
980 $transaction = $this->makeOldImagePublic( $filesObjs[$archivename] );
983 // Is it just now becoming hidden?
984 } else if( $bitfield & File
::DELETED_FILE
) {
985 $transaction = $this->makeOldImagePrivate( $filesObjs[$archivename] );
990 // If our file operations fail, then revert back the db
991 if( $transaction==false ) {
992 $this->dbw
->rollback();
995 $this->dbw
->commit();
999 // Log if something was changed
1001 $this->updateLog( $title, $count, $bitfield, $filesObjs[$archivename]->deleted
,
1002 $comment, $title, 'oldimage', $set );
1003 # Purge page/history
1004 $file = wfLocalFile( $title );
1005 $file->purgeCache();
1006 $file->purgeHistory();
1007 # Invalidate cache for all pages using this file
1008 $update = new HTMLCacheUpdate( $title, 'imagelinks' );
1009 $update->doUpdate();
1011 // Where all revs allowed to be set?
1012 if( !$userAllowedAll ) {
1013 $wgOut->permissionRequired( 'suppressrevision' );
1021 * @param $title, the page these events apply to
1022 * @param array $items list of revision ID numbers
1023 * @param int $bitfield new rev_deleted value
1024 * @param string $comment Comment for log records
1026 function setArchFileVisibility( $title, $items, $bitfield, $comment ) {
1029 $userAllowedAll = $success = true;
1033 // Run through and pull all our data in one query
1034 foreach( $items as $id ) {
1035 $where[] = intval($id);
1037 $whereClause = 'fa_id IN(' . implode(',',$where) . ')';
1038 $result = $this->dbw
->select( 'filearchive', '*',
1039 array( 'fa_name' => $title->getDbKey(),
1042 while( $row = $this->dbw
->fetchObject( $result ) ) {
1043 $filesObjs[$row->fa_id
] = ArchivedFile
::newFromRow( $row );
1046 foreach( $items as $fileid ) {
1047 if( !isset($filesObjs[$fileid]) ) {
1049 continue; // Must exist
1050 } else if( !$filesObjs[$fileid]->userCan(File
::DELETED_RESTRICTED
) ) {
1051 $userAllowedAll=false;
1054 // Which revisions did we change anything about?
1055 if( $filesObjs[$fileid]->deleted
!= $bitfield ) {
1059 $this->updateArchFiles( $filesObjs[$fileid], $bitfield );
1062 // Log if something was changed
1064 $this->updateLog( $title, $count, $bitfield, $comment,
1065 $filesObjs[$fileid]->deleted
, $title, 'fileid', $Id_set );
1067 // Where all revs allowed to be set?
1068 if( !$userAllowedAll ) {
1069 $wgOut->permissionRequired( 'suppressrevision' );
1077 * @param $title, the log page these events apply to
1078 * @param array $items list of log ID numbers
1079 * @param int $bitfield new log_deleted value
1080 * @param string $comment Comment for log records
1082 function setEventVisibility( $title, $items, $bitfield, $comment ) {
1085 $userAllowedAll = $success = true;
1089 // Run through and pull all our data in one query
1090 foreach( $items as $logid ) {
1091 $where[] = intval($logid);
1093 list($log,$logtype) = explode( '/',$title->getDBKey(), 2 );
1094 $whereClause = "log_type ='$logtype' AND log_id IN(" . implode(',',$where) . ")";
1095 $result = $this->dbw
->select( 'logging', '*',
1096 array( $whereClause ),
1098 while( $row = $this->dbw
->fetchObject( $result ) ) {
1099 $logRows[$row->log_id
] = $row;
1102 foreach( $items as $logid ) {
1103 if( !isset($logRows[$logid]) ) {
1105 continue; // Must exist
1106 } else if( !LogEventsList
::userCan($logRows[$logid], LogPage
::DELETED_RESTRICTED
)
1107 ||
$logRows[$logid]->log_type
== 'suppress' ) {
1108 // Don't hide from oversight log!!!
1109 $userAllowedAll=false;
1112 // Which logs did we change anything about?
1113 if( $logRows[$logid]->log_deleted
!= $bitfield ) {
1117 $this->updateLogs( $logRows[$logid], $bitfield );
1118 $this->updateRecentChangesLog( $logRows[$logid], $bitfield, true );
1121 // Don't log or touch if nothing changed
1123 $this->updateLog( $title, $count, $bitfield, $logRows[$logid]->log_deleted
,
1124 $comment, $title, 'logid', $log_Ids );
1126 // Were all revs allowed to be set?
1127 if( !$userAllowedAll ) {
1128 $wgOut->permissionRequired( 'suppressrevision' );
1136 * Moves an image to a safe private location
1137 * Caller is responsible for clearing caches
1138 * @param File $oimage
1139 * @returns mixed, timestamp string on success, false on failure
1141 function makeOldImagePrivate( $oimage ) {
1142 $transaction = new FSTransaction();
1143 if( !FileStore
::lock() ) {
1144 wfDebug( __METHOD__
.": failed to acquire file store lock, aborting\n" );
1147 $oldpath = $oimage->getArchivePath() . DIRECTORY_SEPARATOR
. $oimage->archive_name
;
1148 // Dupe the file into the file store
1149 if( file_exists( $oldpath ) ) {
1150 // Is our directory configured?
1151 if( $store = FileStore
::get( 'deleted' ) ) {
1152 if( !$oimage->sha1
) {
1153 $oimage->upgradeRow(); // sha1 may be missing
1155 $key = $oimage->sha1
. '.' . $oimage->getExtension();
1156 $transaction->add( $store->insert( $key, $oldpath, FileStore
::DELETE_ORIGINAL
) );
1160 $transaction = false; // Return an error and do nothing
1163 wfDebug( __METHOD__
." deleting already-missing '$oldpath'; moving on to database\n" );
1166 $transaction = new FSTransaction(); // empty
1169 if( $transaction === false ) {
1171 wfDebug( __METHOD__
.": import to file store failed, aborting\n" );
1172 throw new MWException( "Could not archive and delete file $oldpath" );
1176 wfDebug( __METHOD__
.": set db items, applying file transactions\n" );
1177 $transaction->commit();
1178 FileStore
::unlock();
1180 $m = explode('!',$oimage->archive_name
,2);
1187 * Moves an image from a safe private location
1188 * Caller is responsible for clearing caches
1189 * @param File $oimage
1190 * @returns mixed, string timestamp on success, false on failure
1192 function makeOldImagePublic( $oimage ) {
1193 $transaction = new FSTransaction();
1194 if( !FileStore
::lock() ) {
1195 wfDebug( __METHOD__
." could not acquire filestore lock\n" );
1199 $store = FileStore
::get( 'deleted' );
1201 wfDebug( __METHOD__
.": skipping row with no file.\n" );
1205 $key = $oimage->sha1
.'.'.$oimage->getExtension();
1206 $destDir = $oimage->getArchivePath();
1207 if( !is_dir( $destDir ) ) {
1208 wfMkdirParents( $destDir );
1210 $destPath = $destDir . DIRECTORY_SEPARATOR
. $oimage->archive_name
;
1211 // Check if any other stored revisions use this file;
1212 // if so, we shouldn't remove the file from the hidden
1213 // archives so they will still work. Check hidden files first.
1214 $useCount = $this->dbw
->selectField( 'oldimage', '1',
1215 array( 'oi_sha1' => $oimage->sha1
,
1216 'oi_deleted & '.File
::DELETED_FILE
=> File
::DELETED_FILE
),
1217 __METHOD__
, array( 'FOR UPDATE' ) );
1218 // Check the rest of the deleted archives too.
1219 // (these are the ones that don't show in the image history)
1221 $useCount = $this->dbw
->selectField( 'filearchive', '1',
1222 array( 'fa_storage_group' => 'deleted', 'fa_storage_key' => $key ),
1223 __METHOD__
, array( 'FOR UPDATE' ) );
1226 if( $useCount == 0 ) {
1227 wfDebug( __METHOD__
.": nothing else using {$oimage->sha1}, will deleting after\n" );
1228 $flags = FileStore
::DELETE_ORIGINAL
;
1232 $transaction->add( $store->export( $key, $destPath, $flags ) );
1234 wfDebug( __METHOD__
.": set db items, applying file transactions\n" );
1235 $transaction->commit();
1236 FileStore
::unlock();
1238 $m = explode('!',$oimage->archive_name
,2);
1245 * Update the revision's rev_deleted field
1246 * @param Revision $rev
1247 * @param int $bitfield new rev_deleted bitfield value
1249 function updateRevision( $rev, $bitfield ) {
1250 $this->dbw
->update( 'revision',
1251 array( 'rev_deleted' => $bitfield ),
1252 array( 'rev_id' => $rev->getId(),
1253 'rev_page' => $rev->getPage() ),
1258 * Update the revision's rev_deleted field
1259 * @param Revision $rev
1260 * @param Title $title
1261 * @param int $bitfield new rev_deleted bitfield value
1263 function updateArchive( $rev, $title, $bitfield ) {
1264 $this->dbw
->update( 'archive',
1265 array( 'ar_deleted' => $bitfield ),
1266 array( 'ar_namespace' => $title->getNamespace(),
1267 'ar_title' => $title->getDBKey(),
1268 'ar_timestamp' => $this->dbw
->timestamp( $rev->getTimestamp() ),
1269 'ar_rev_id' => $rev->getId() ),
1274 * Update the images's oi_deleted field
1276 * @param int $bitfield new rev_deleted bitfield value
1278 function updateOldFiles( $file, $bitfield ) {
1279 $this->dbw
->update( 'oldimage',
1280 array( 'oi_deleted' => $bitfield ),
1281 array( 'oi_name' => $file->getName(),
1282 'oi_timestamp' => $this->dbw
->timestamp( $file->getTimestamp() ) ),
1287 * Update the images's fa_deleted field
1288 * @param ArchivedFile $file
1289 * @param int $bitfield new rev_deleted bitfield value
1291 function updateArchFiles( $file, $bitfield ) {
1292 $this->dbw
->update( 'filearchive',
1293 array( 'fa_deleted' => $bitfield ),
1294 array( 'fa_id' => $file->getId() ),
1299 * Update the logging log_deleted field
1301 * @param int $bitfield new rev_deleted bitfield value
1303 function updateLogs( $row, $bitfield ) {
1304 $this->dbw
->update( 'logging',
1305 array( 'log_deleted' => $bitfield ),
1306 array( 'log_id' => $row->log_id
),
1311 * Update the revision's recentchanges record if fields have been hidden
1312 * @param Revision $rev
1313 * @param int $bitfield new rev_deleted bitfield value
1315 function updateRecentChangesEdits( $rev, $bitfield ) {
1316 $this->dbw
->update( 'recentchanges',
1317 array( 'rc_deleted' => $bitfield,
1318 'rc_patrolled' => 1 ),
1319 array( 'rc_this_oldid' => $rev->getId(),
1320 'rc_timestamp' => $this->dbw
->timestamp( $rev->getTimestamp() ) ),
1325 * Update the revision's recentchanges record if fields have been hidden
1327 * @param int $bitfield new rev_deleted bitfield value
1329 function updateRecentChangesLog( $row, $bitfield ) {
1330 $this->dbw
->update( 'recentchanges',
1331 array( 'rc_deleted' => $bitfield,
1332 'rc_patrolled' => 1 ),
1333 array( 'rc_logid' => $row->log_id
,
1334 'rc_timestamp' => $row->log_timestamp
),
1339 * Touch the page's cache invalidation timestamp; this forces cached
1340 * history views to refresh, so any newly hidden or shown fields will
1342 * @param Title $title
1344 function updatePage( $title ) {
1345 $title->invalidateCache();
1346 $title->purgeSquid();
1347 $title->touchLinks();
1348 // Extensions that require referencing previous revisions may need this
1349 wfRunHooks( 'ArticleRevisionVisiblitySet', array( &$title ) );
1353 * Checks for a change in the bitfield for a certain option and updates the
1354 * provided array accordingly.
1356 * @param String $desc Description to add to the array if the option was
1357 * enabled / disabled.
1358 * @param int $field The bitmask describing the single option.
1359 * @param int $diff The xor of the old and new bitfields.
1360 * @param array $arr The array to update.
1362 function checkItem ( $desc, $field, $diff, $new, &$arr ) {
1363 if ( $diff & $field ) {
1364 $arr [ ( $new & $field ) ?
0 : 1 ][] = $desc;
1369 * Gets an array describing the changes made to the visibilit of the revision.
1370 * If the resulting array is $arr, then $arr[0] will contain an array of strings
1371 * describing the items that were hidden, $arr[2] will contain an array of strings
1372 * describing the items that were unhidden, and $arr[3] will contain an array with
1373 * a single string, which can be one of "applied restrictions to sysops",
1374 * "removed restrictions from sysops", or null.
1376 * @param int $n The new bitfield.
1377 * @param int $o The old bitfield.
1378 * @return An array as described above.
1380 function getChanges ( $n, $o ) {
1382 $ret = array ( 0 => array(), 1 => array(), 2 => array() );
1384 $this->checkItem ( wfMsgForContent ( 'revdelete-content' ),
1385 Revision
::DELETED_TEXT
, $diff, $n, $ret );
1386 $this->checkItem ( wfMsgForContent ( 'revdelete-summary' ),
1387 Revision
::DELETED_COMMENT
, $diff, $n, $ret );
1388 $this->checkItem ( wfMsgForContent ( 'revdelete-uname' ),
1389 Revision
::DELETED_USER
, $diff, $n, $ret );
1391 // Restriction application to sysops
1392 if ( $diff & Revision
::DELETED_RESTRICTED
) {
1393 if ( $n & Revision
::DELETED_RESTRICTED
)
1394 $ret[2][] = wfMsgForContent ( 'revdelete-restricted' );
1396 $ret[2][] = wfMsgForContent ( 'revdelete-unrestricted' );
1403 * Gets a log message to describe the given revision visibility change. This
1404 * message will be of the form "[hid {content, edit summary, username}];
1405 * [unhid {...}][applied restrictions to sysops] for $count revisions: $comment".
1407 * @param int $count The number of effected revisions.
1408 * @param int $nbitfield The new bitfield for the revision.
1409 * @param int $obitfield The old bitfield for the revision.
1410 * @param string $comment The comment associated with the change.
1411 * @param bool $isForLog
1413 function getLogMessage ( $count, $nbitfield, $obitfield, $comment, $isForLog = false ) {
1417 $changes = $this->getChanges( $nbitfield, $obitfield );
1419 if ( count ( $changes[0] ) ) {
1420 $s .= wfMsgForContent ( 'revdelete-hid', implode ( ', ', $changes[0] ) );
1423 if ( count ( $changes[1] ) ) {
1426 $s .= wfMsgForContent ( 'revdelete-unhid', implode ( ', ', $changes[1] ) );
1429 if ( count ( $changes[2] )) {
1431 $s .= ' (' . $changes[2][0] . ')';
1433 $s = $changes[2][0];
1436 $msg = $isForLog ?
'logdelete-log-message' : 'revdelete-log-message';
1437 $ret = wfMsgExt ( $msg, array( 'parsemag', 'content' ),
1438 $s, $wgContLang->formatNum( $count ) );
1441 $ret .= ": $comment";
1448 * Record a log entry on the action
1449 * @param Title $title, page where item was removed from
1450 * @param int $count the number of revisions altered for this page
1451 * @param int $nbitfield the new _deleted value
1452 * @param int $obitfield the old _deleted value
1453 * @param string $comment
1454 * @param Title $target, the relevant page
1455 * @param string $param, URL param
1456 * @param Array $items
1458 function updateLog( $title, $count, $nbitfield, $obitfield, $comment, $target, $param, $items = array() ) {
1459 // Put things hidden from sysops in the oversight log
1460 $logtype = ( ($nbitfield |
$obitfield) & Revision
::DELETED_RESTRICTED
) ?
'suppress' : 'delete';
1461 $log = new LogPage( $logtype );
1463 $reason = $this->getLogMessage ( $count, $nbitfield, $obitfield, $comment, $param == 'logid' );
1465 if( $param == 'logid' ) {
1466 $params = array( implode( ',', $items) );
1467 $log->addEntry( 'event', $title, $reason, $params );
1469 // Add params for effected page and ids
1470 $params = array( $param, implode( ',', $items) );
1471 $log->addEntry( 'revision', $title, $reason, $params );