2006-03-16 19:04:25 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
2008-03-21 05:09:23 +00:00
|
|
|
* Special page allowing users with the appropriate permissions to view
|
|
|
|
|
* and hide revisions. Log items can also be hidden.
|
2007-03-16 16:01:07 +00:00
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @file
|
|
|
|
|
* @ingroup SpecialPage
|
2006-03-16 19:04:25 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function wfSpecialRevisiondelete( $par = null ) {
|
2008-04-17 14:48:28 +00:00
|
|
|
global $wgOut, $wgRequest, $wgUser;
|
2009-01-13 01:50:28 +00:00
|
|
|
|
|
|
|
|
if ( wfReadOnly() ) {
|
|
|
|
|
$wgOut->readOnlyPage();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
# Handle our many different possible input types
|
|
|
|
|
$target = $wgRequest->getText( 'target' );
|
|
|
|
|
$oldid = $wgRequest->getArray( 'oldid' );
|
|
|
|
|
$artimestamp = $wgRequest->getArray( 'artimestamp' );
|
2008-04-17 14:48:28 +00:00
|
|
|
$logid = $wgRequest->getArray( 'logid' );
|
2008-03-21 05:09:23 +00:00
|
|
|
$img = $wgRequest->getArray( 'oldimage' );
|
|
|
|
|
$fileid = $wgRequest->getArray( 'fileid' );
|
|
|
|
|
# For reviewing deleted files...
|
|
|
|
|
$file = $wgRequest->getVal( 'file' );
|
|
|
|
|
# If this is a revision, then we need a target page
|
2007-03-16 16:01:07 +00:00
|
|
|
$page = Title::newFromUrl( $target );
|
2008-04-16 18:44:15 +00:00
|
|
|
if( is_null($page) ) {
|
2008-07-09 09:10:23 +00:00
|
|
|
$wgOut->addWikiMsg( 'undelete-header' );
|
2006-03-16 19:04:25 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2008-03-21 05:09:23 +00:00
|
|
|
# Only one target set at a time please!
|
|
|
|
|
$i = (bool)$file + (bool)$oldid + (bool)$logid + (bool)$artimestamp + (bool)$fileid + (bool)$img;
|
|
|
|
|
if( $i !== 1 ) {
|
2009-01-18 07:02:28 +00:00
|
|
|
$wgOut->showErrorPage( 'revdelete-toomanytargets-title', 'revdelete-toomanytargets-text' );
|
2006-09-09 09:33:56 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2008-04-16 18:44:15 +00:00
|
|
|
# Logs must have a type given
|
|
|
|
|
if( $logid && !strpos($page->getDBKey(),'/') ) {
|
2009-01-18 07:02:28 +00:00
|
|
|
$wgOut->showErrorPage( 'revdelete-nologtype-title', 'revdelete-nologtype-text' );
|
2008-04-16 18:44:15 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2008-03-21 05:09:23 +00:00
|
|
|
# Either submit or create our form
|
|
|
|
|
$form = new RevisionDeleteForm( $page, $oldid, $logid, $artimestamp, $fileid, $img, $file );
|
2006-03-16 19:04:25 +00:00
|
|
|
if( $wgRequest->wasPosted() ) {
|
|
|
|
|
$form->submit( $wgRequest );
|
2008-03-21 05:09:23 +00:00
|
|
|
} else if( $oldid || $artimestamp ) {
|
2008-04-24 17:29:46 +00:00
|
|
|
$form->showRevs();
|
2008-03-21 05:09:23 +00:00
|
|
|
} else if( $fileid || $img ) {
|
2008-04-24 17:29:46 +00:00
|
|
|
$form->showImages();
|
2008-03-21 05:09:23 +00:00
|
|
|
} else if( $logid ) {
|
2008-04-24 17:29:46 +00:00
|
|
|
$form->showLogItems();
|
2008-03-21 05:09:23 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
# Show relevant lines from the deletion log. This will show even if said ID
|
2008-03-21 05:09:23 +00:00
|
|
|
# does not exist...might be helpful
|
2008-04-16 18:44:15 +00:00
|
|
|
$wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'delete' ) ) . "</h2>\n" );
|
|
|
|
|
LogEventsList::showLogExtract( $wgOut, 'delete', $page->getPrefixedText() );
|
2008-05-28 19:23:03 +00:00
|
|
|
if( $wgUser->isAllowed( 'suppressionlog' ) ){
|
2008-04-16 18:44:15 +00:00
|
|
|
$wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'suppress' ) ) . "</h2>\n" );
|
|
|
|
|
LogEventsList::showLogExtract( $wgOut, 'suppress', $page->getPrefixedText() );
|
2006-03-16 19:04:25 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-20 08:55:14 +00:00
|
|
|
/**
|
|
|
|
|
* Implements the GUI for Revision Deletion.
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup SpecialPage
|
2007-04-20 08:55:14 +00:00
|
|
|
*/
|
2006-03-16 19:04:25 +00:00
|
|
|
class RevisionDeleteForm {
|
|
|
|
|
/**
|
2008-03-21 05:09:23 +00:00
|
|
|
* @param Title $page
|
|
|
|
|
* @param array $oldids
|
|
|
|
|
* @param array $logids
|
|
|
|
|
* @param array $artimestamps
|
|
|
|
|
* @param array $fileids
|
|
|
|
|
* @param array $img
|
|
|
|
|
* @param string $file
|
2006-03-16 19:04:25 +00:00
|
|
|
*/
|
2008-03-21 05:09:23 +00:00
|
|
|
function __construct( $page, $oldids, $logids, $artimestamps, $fileids, $img, $file ) {
|
2008-03-28 17:31:23 +00:00
|
|
|
global $wgUser, $wgOut;
|
2008-03-21 05:09:23 +00:00
|
|
|
|
|
|
|
|
$this->page = $page;
|
|
|
|
|
# For reviewing deleted files...
|
|
|
|
|
if( $file ) {
|
|
|
|
|
$oimage = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( $page, $file );
|
|
|
|
|
$oimage->load();
|
|
|
|
|
// Check if user is allowed to see this file
|
|
|
|
|
if( !$oimage->userCan(File::DELETED_FILE) ) {
|
2008-05-25 00:31:28 +00:00
|
|
|
$wgOut->permissionRequired( 'suppressrevision' );
|
2008-03-21 05:09:23 +00:00
|
|
|
} else {
|
|
|
|
|
$this->showFile( $file );
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
2007-10-01 19:50:25 +00:00
|
|
|
$this->skin = $wgUser->getSkin();
|
2008-03-28 17:31:23 +00:00
|
|
|
# Give a link to the log for this page
|
|
|
|
|
if( !is_null($this->page) && $this->page->getNamespace() > -1 ) {
|
2008-03-28 19:30:38 +00:00
|
|
|
$links = array();
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-28 17:31:23 +00:00
|
|
|
$logtitle = SpecialPage::getTitleFor( 'Log' );
|
2008-03-28 19:30:38 +00:00
|
|
|
$links[] = $this->skin->makeKnownLinkObj( $logtitle, wfMsgHtml( 'viewpagelogs' ),
|
2008-03-28 17:31:23 +00:00
|
|
|
wfArrayToCGI( array( 'page' => $this->page->getPrefixedUrl() ) ) );
|
2008-04-14 07:45:50 +00:00
|
|
|
# Give a link to the page history
|
2008-03-28 19:30:38 +00:00
|
|
|
$links[] = $this->skin->makeKnownLinkObj( $this->page, wfMsgHtml( 'pagehist' ),
|
2008-03-28 17:31:23 +00:00
|
|
|
wfArrayToCGI( array( 'action' => 'history' ) ) );
|
|
|
|
|
# Link to deleted edits
|
2008-03-28 19:30:38 +00:00
|
|
|
if( $wgUser->isAllowed('undelete') ) {
|
|
|
|
|
$undelete = SpecialPage::getTitleFor( 'Undelete' );
|
|
|
|
|
$links[] = $this->skin->makeKnownLinkObj( $undelete, wfMsgHtml( 'deletedhist' ),
|
2009-02-02 16:29:51 +00:00
|
|
|
wfArrayToCGI( array( 'target' => $this->page->getPrefixedDBkey() ) ) );
|
2008-03-28 19:30:38 +00:00
|
|
|
}
|
2008-03-28 17:31:23 +00:00
|
|
|
# Logs themselves don't have histories or archived revisions
|
2008-03-28 19:30:38 +00:00
|
|
|
$wgOut->setSubtitle( '<p>'.implode($links,' / ').'</p>' );
|
2008-03-28 17:31:23 +00:00
|
|
|
}
|
2008-03-21 05:09:23 +00:00
|
|
|
// At this point, we should only have one of these
|
|
|
|
|
if( $oldids ) {
|
|
|
|
|
$this->revisions = $oldids;
|
|
|
|
|
$hide_content_name = array( 'revdelete-hide-text', 'wpHideText', Revision::DELETED_TEXT );
|
|
|
|
|
$this->deleteKey='oldid';
|
|
|
|
|
} else if( $artimestamps ) {
|
|
|
|
|
$this->archrevs = $artimestamps;
|
|
|
|
|
$hide_content_name = array( 'revdelete-hide-text', 'wpHideText', Revision::DELETED_TEXT );
|
|
|
|
|
$this->deleteKey='artimestamp';
|
|
|
|
|
} else if( $img ) {
|
|
|
|
|
$this->ofiles = $img;
|
|
|
|
|
$hide_content_name = array( 'revdelete-hide-image', 'wpHideImage', File::DELETED_FILE );
|
|
|
|
|
$this->deleteKey='oldimage';
|
|
|
|
|
} else if( $fileids ) {
|
|
|
|
|
$this->afiles = $fileids;
|
|
|
|
|
$hide_content_name = array( 'revdelete-hide-image', 'wpHideImage', File::DELETED_FILE );
|
|
|
|
|
$this->deleteKey='fileid';
|
|
|
|
|
} else if( $logids ) {
|
|
|
|
|
$this->events = $logids;
|
|
|
|
|
$hide_content_name = array( 'revdelete-hide-name', 'wpHideName', LogPage::DELETED_ACTION );
|
|
|
|
|
$this->deleteKey='logid';
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
// Our checkbox messages depends one what we are doing,
|
2008-03-21 05:09:23 +00:00
|
|
|
// e.g. we don't hide "text" for logs or images
|
2006-03-16 19:04:25 +00:00
|
|
|
$this->checks = array(
|
2008-03-21 05:09:23 +00:00
|
|
|
$hide_content_name,
|
2006-06-23 06:31:46 +00:00
|
|
|
array( 'revdelete-hide-comment', 'wpHideComment', Revision::DELETED_COMMENT ),
|
2008-04-24 17:29:46 +00:00
|
|
|
array( 'revdelete-hide-user', 'wpHideUser', Revision::DELETED_USER ) );
|
2008-05-25 00:31:28 +00:00
|
|
|
if( $wgUser->isAllowed('suppressrevision') ) {
|
2008-04-24 17:29:46 +00:00
|
|
|
$this->checks[] = array( 'revdelete-hide-restricted', 'wpHideRestricted', Revision::DELETED_RESTRICTED );
|
|
|
|
|
}
|
2006-03-16 19:04:25 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2006-03-16 19:04:25 +00:00
|
|
|
/**
|
2008-03-21 05:09:23 +00:00
|
|
|
* Show a deleted file version requested by the visitor.
|
|
|
|
|
*/
|
|
|
|
|
private function showFile( $key ) {
|
|
|
|
|
global $wgOut, $wgRequest;
|
|
|
|
|
$wgOut->disable();
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
# We mustn't allow the output to be Squid cached, otherwise
|
|
|
|
|
# if an admin previews a deleted image, and it's cached, then
|
|
|
|
|
# a user without appropriate permissions can toddle off and
|
|
|
|
|
# nab the image, and Squid will serve it
|
|
|
|
|
$wgRequest->response()->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', 0 ) . ' GMT' );
|
|
|
|
|
$wgRequest->response()->header( 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' );
|
|
|
|
|
$wgRequest->response()->header( 'Pragma: no-cache' );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$store = FileStore::get( 'deleted' );
|
|
|
|
|
$store->stream( $key );
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
/**
|
|
|
|
|
* This lets a user set restrictions for live and archived revisions
|
2006-03-16 19:04:25 +00:00
|
|
|
*/
|
2008-04-24 17:29:46 +00:00
|
|
|
function showRevs() {
|
2008-03-21 05:09:23 +00:00
|
|
|
global $wgOut, $wgUser, $action;
|
2007-03-16 12:12:12 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$UserAllowed = true;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
|
|
|
|
$count = ($this->deleteKey=='oldid') ?
|
2008-03-21 05:09:23 +00:00
|
|
|
count($this->revisions) : count($this->archrevs);
|
|
|
|
|
$wgOut->addWikiMsg( 'revdelete-selected', $this->page->getPrefixedText(), $count );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$bitfields = 0;
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML( "<ul>" );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$where = $revObjs = array();
|
|
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
2008-04-20 21:26:42 +00:00
|
|
|
|
|
|
|
|
$revisions = 0;
|
2008-03-21 05:09:23 +00:00
|
|
|
// Live revisions...
|
|
|
|
|
if( $this->deleteKey=='oldid' ) {
|
|
|
|
|
// Run through and pull all our data in one query
|
|
|
|
|
foreach( $this->revisions as $revid ) {
|
|
|
|
|
$where[] = intval($revid);
|
|
|
|
|
}
|
|
|
|
|
$result = $dbr->select( array('revision','page'), '*',
|
2009-01-30 00:15:19 +00:00
|
|
|
array(
|
|
|
|
|
'rev_page' => $this->page->getArticleID(),
|
|
|
|
|
'rev_id' => $where,
|
|
|
|
|
'rev_page = page_id' ),
|
2008-03-21 05:09:23 +00:00
|
|
|
__METHOD__ );
|
|
|
|
|
while( $row = $dbr->fetchObject( $result ) ) {
|
|
|
|
|
$revObjs[$row->rev_id] = new Revision( $row );
|
|
|
|
|
}
|
|
|
|
|
foreach( $this->revisions as $revid ) {
|
|
|
|
|
// Hiding top revisison is bad
|
2008-04-20 21:26:42 +00:00
|
|
|
if( !isset($revObjs[$revid]) || $revObjs[$revid]->isCurrent() ) {
|
|
|
|
|
continue;
|
2008-03-21 05:09:23 +00:00
|
|
|
} else if( !$revObjs[$revid]->userCan(Revision::DELETED_RESTRICTED) ) {
|
|
|
|
|
// If a rev is hidden from sysops
|
|
|
|
|
if( $action != 'submit') {
|
2008-05-25 00:31:28 +00:00
|
|
|
$wgOut->permissionRequired( 'suppressrevision' );
|
2008-03-21 05:09:23 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$UserAllowed = false;
|
|
|
|
|
}
|
2008-04-20 21:26:42 +00:00
|
|
|
$revisions++;
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML( $this->historyLine( $revObjs[$revid] ) );
|
2008-03-21 05:09:23 +00:00
|
|
|
$bitfields |= $revObjs[$revid]->mDeleted;
|
|
|
|
|
}
|
|
|
|
|
// The archives...
|
|
|
|
|
} else {
|
|
|
|
|
// Run through and pull all our data in one query
|
|
|
|
|
foreach( $this->archrevs as $timestamp ) {
|
2009-02-23 16:48:01 +00:00
|
|
|
$where[] = $dbr->timestamp( $timestamp );
|
2008-03-21 05:09:23 +00:00
|
|
|
}
|
|
|
|
|
$result = $dbr->select( 'archive', '*',
|
2009-01-30 00:15:19 +00:00
|
|
|
array(
|
|
|
|
|
'ar_namespace' => $this->page->getNamespace(),
|
2008-04-14 07:45:50 +00:00
|
|
|
'ar_title' => $this->page->getDBKey(),
|
2009-01-30 00:15:19 +00:00
|
|
|
'ar_timestamp' => $where ),
|
2008-03-21 05:09:23 +00:00
|
|
|
__METHOD__ );
|
|
|
|
|
while( $row = $dbr->fetchObject( $result ) ) {
|
2009-02-24 11:52:40 +00:00
|
|
|
$timestamp = wfTimestamp( TS_MW, $row->ar_timestamp );
|
2009-02-23 16:48:01 +00:00
|
|
|
$revObjs[$timestamp] = new Revision( array(
|
2009-02-23 23:05:40 +00:00
|
|
|
'page' => $this->page->getArticleId(),
|
|
|
|
|
'id' => $row->ar_rev_id,
|
|
|
|
|
'text' => $row->ar_text_id,
|
|
|
|
|
'comment' => $row->ar_comment,
|
|
|
|
|
'user' => $row->ar_user,
|
|
|
|
|
'user_text' => $row->ar_user_text,
|
2009-02-24 11:52:40 +00:00
|
|
|
'timestamp' => $timestamp,
|
2009-02-23 23:05:40 +00:00
|
|
|
'minor_edit' => $row->ar_minor_edit,
|
|
|
|
|
'text_id' => $row->ar_text_id,
|
|
|
|
|
'deleted' => $row->ar_deleted,
|
|
|
|
|
'len' => $row->ar_len) );
|
2008-03-21 05:09:23 +00:00
|
|
|
}
|
|
|
|
|
foreach( $this->archrevs as $timestamp ) {
|
2008-04-20 21:26:42 +00:00
|
|
|
if( !isset($revObjs[$timestamp]) ) {
|
|
|
|
|
continue;
|
|
|
|
|
} else if( !$revObjs[$timestamp]->userCan(Revision::DELETED_RESTRICTED) ) {
|
2008-03-21 05:09:23 +00:00
|
|
|
// If a rev is hidden from sysops
|
|
|
|
|
if( $action != 'submit') {
|
2008-05-25 00:31:28 +00:00
|
|
|
$wgOut->permissionRequired( 'suppressrevision' );
|
2008-03-21 05:09:23 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$UserAllowed = false;
|
|
|
|
|
}
|
2008-04-20 21:26:42 +00:00
|
|
|
$revisions++;
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML( $this->historyLine( $revObjs[$timestamp] ) );
|
2008-04-20 21:26:42 +00:00
|
|
|
$bitfields |= $revObjs[$timestamp]->mDeleted;
|
2008-03-21 05:09:23 +00:00
|
|
|
}
|
2008-04-02 07:45:08 +00:00
|
|
|
}
|
2008-04-20 21:26:42 +00:00
|
|
|
if( !$revisions ) {
|
|
|
|
|
$wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML( "</ul>" );
|
2008-04-02 07:45:08 +00:00
|
|
|
|
2008-07-09 09:10:23 +00:00
|
|
|
$wgOut->addWikiMsg( 'revdelete-text' );
|
2008-04-02 07:45:08 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
// Normal sysops can always see what they did, but can't always change it
|
|
|
|
|
if( !$UserAllowed ) return;
|
2008-04-02 07:45:08 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$items = array(
|
2008-04-02 07:45:08 +00:00
|
|
|
Xml::inputLabel( wfMsg( 'revdelete-log' ), 'wpReason', 'wpReason', 60 ),
|
|
|
|
|
Xml::submitButton( wfMsg( 'revdelete-submit' ) )
|
|
|
|
|
);
|
2008-03-21 05:09:23 +00:00
|
|
|
$hidden = array(
|
2008-04-02 07:45:08 +00:00
|
|
|
Xml::hidden( 'wpEditToken', $wgUser->editToken() ),
|
|
|
|
|
Xml::hidden( 'target', $this->page->getPrefixedText() ),
|
|
|
|
|
Xml::hidden( 'type', $this->deleteKey )
|
|
|
|
|
);
|
2008-03-21 05:09:23 +00:00
|
|
|
if( $this->deleteKey=='oldid' ) {
|
|
|
|
|
foreach( $revObjs as $rev )
|
2008-07-09 09:10:23 +00:00
|
|
|
$hidden[] = Xml::hidden( 'oldid[]', $rev->getId() );
|
2008-04-02 07:45:08 +00:00
|
|
|
} else {
|
2008-03-21 05:09:23 +00:00
|
|
|
foreach( $revObjs as $rev )
|
2008-07-09 09:10:23 +00:00
|
|
|
$hidden[] = Xml::hidden( 'artimestamp[]', $rev->getTimestamp() );
|
2008-03-21 05:09:23 +00:00
|
|
|
}
|
|
|
|
|
$special = SpecialPage::getTitleFor( 'Revisiondelete' );
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML(
|
2008-04-16 18:44:15 +00:00
|
|
|
Xml::openElement( 'form', array( 'method' => 'post', 'action' => $special->getLocalUrl( 'action=submit' ),
|
|
|
|
|
'id' => 'mw-revdel-form-revisions' ) ) .
|
2008-04-02 07:45:08 +00:00
|
|
|
Xml::openElement( 'fieldset' ) .
|
|
|
|
|
xml::element( 'legend', null, wfMsg( 'revdelete-legend' ) )
|
|
|
|
|
);
|
2008-03-21 05:09:23 +00:00
|
|
|
// FIXME: all items checked for just one rev are checked, even if not set for the others
|
|
|
|
|
foreach( $this->checks as $item ) {
|
|
|
|
|
list( $message, $name, $field ) = $item;
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML( Xml::tags( 'div', null, Xml::checkLabel( wfMsg( $message ), $name, $name, $bitfields & $field ) ) );
|
2008-03-21 05:09:23 +00:00
|
|
|
}
|
|
|
|
|
foreach( $items as $item ) {
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML( Xml::tags( 'p', null, $item ) );
|
2008-03-21 05:09:23 +00:00
|
|
|
}
|
|
|
|
|
foreach( $hidden as $item ) {
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML( $item );
|
2008-03-21 05:09:23 +00:00
|
|
|
}
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML(
|
2008-04-02 07:45:08 +00:00
|
|
|
Xml::closeElement( 'fieldset' ) .
|
|
|
|
|
Xml::closeElement( 'form' ) . "\n"
|
|
|
|
|
);
|
|
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This lets a user set restrictions for archived images
|
|
|
|
|
*/
|
2008-04-24 17:29:46 +00:00
|
|
|
function showImages() {
|
2008-07-09 09:10:23 +00:00
|
|
|
// What is $action doing here???
|
|
|
|
|
global $wgOut, $wgUser, $action, $wgLang;
|
2008-03-21 05:09:23 +00:00
|
|
|
|
|
|
|
|
$UserAllowed = true;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$count = ($this->deleteKey=='oldimage') ? count($this->ofiles) : count($this->afiles);
|
2008-07-09 09:10:23 +00:00
|
|
|
$wgOut->addWikiMsg( 'revdelete-selected',
|
|
|
|
|
$this->page->getPrefixedText(),
|
|
|
|
|
$wgLang->formatNum($count) );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$bitfields = 0;
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML( "<ul>" );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$where = $filesObjs = array();
|
|
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
|
|
|
|
// Live old revisions...
|
2008-04-20 21:26:42 +00:00
|
|
|
$revisions = 0;
|
2008-03-21 05:09:23 +00:00
|
|
|
if( $this->deleteKey=='oldimage' ) {
|
|
|
|
|
// Run through and pull all our data in one query
|
|
|
|
|
foreach( $this->ofiles as $timestamp ) {
|
2009-02-23 16:48:01 +00:00
|
|
|
$where[] = $timestamp.'!'.$this->page->getDBKey();
|
2008-03-21 05:09:23 +00:00
|
|
|
}
|
|
|
|
|
$result = $dbr->select( 'oldimage', '*',
|
2009-01-30 00:15:19 +00:00
|
|
|
array(
|
|
|
|
|
'oi_name' => $this->page->getDBKey(),
|
|
|
|
|
'oi_archive_name' => $where ),
|
2008-03-21 05:09:23 +00:00
|
|
|
__METHOD__ );
|
|
|
|
|
while( $row = $dbr->fetchObject( $result ) ) {
|
|
|
|
|
$filesObjs[$row->oi_archive_name] = RepoGroup::singleton()->getLocalRepo()->newFileFromRow( $row );
|
|
|
|
|
$filesObjs[$row->oi_archive_name]->user = $row->oi_user;
|
|
|
|
|
$filesObjs[$row->oi_archive_name]->user_text = $row->oi_user_text;
|
|
|
|
|
}
|
|
|
|
|
// Check through our images
|
|
|
|
|
foreach( $this->ofiles as $timestamp ) {
|
2008-11-06 22:38:42 +00:00
|
|
|
$archivename = $timestamp.'!'.$this->page->getDBKey();
|
2008-03-21 05:09:23 +00:00
|
|
|
if( !isset($filesObjs[$archivename]) ) {
|
2008-04-20 21:26:42 +00:00
|
|
|
continue;
|
|
|
|
|
} else if( !$filesObjs[$archivename]->userCan(File::DELETED_RESTRICTED) ) {
|
2008-03-21 05:09:23 +00:00
|
|
|
// If a rev is hidden from sysops
|
|
|
|
|
if( $action != 'submit' ) {
|
2008-05-25 00:31:28 +00:00
|
|
|
$wgOut->permissionRequired( 'suppressrevision' );
|
2008-03-21 05:09:23 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$UserAllowed = false;
|
|
|
|
|
}
|
2008-04-20 21:26:42 +00:00
|
|
|
$revisions++;
|
2008-03-21 05:09:23 +00:00
|
|
|
// Inject history info
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML( $this->fileLine( $filesObjs[$archivename] ) );
|
2008-04-20 21:26:42 +00:00
|
|
|
$bitfields |= $filesObjs[$archivename]->deleted;
|
2008-04-14 07:45:50 +00:00
|
|
|
}
|
2008-03-21 05:09:23 +00:00
|
|
|
// Archived files...
|
|
|
|
|
} else {
|
|
|
|
|
// Run through and pull all our data in one query
|
|
|
|
|
foreach( $this->afiles as $id ) {
|
|
|
|
|
$where[] = intval($id);
|
|
|
|
|
}
|
|
|
|
|
$result = $dbr->select( 'filearchive', '*',
|
2009-01-30 00:15:19 +00:00
|
|
|
array(
|
|
|
|
|
'fa_name' => $this->page->getDBKey(),
|
|
|
|
|
'fa_id' => $where ),
|
2008-03-21 05:09:23 +00:00
|
|
|
__METHOD__ );
|
|
|
|
|
while( $row = $dbr->fetchObject( $result ) ) {
|
|
|
|
|
$filesObjs[$row->fa_id] = ArchivedFile::newFromRow( $row );
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
foreach( $this->afiles as $fileid ) {
|
|
|
|
|
if( !isset($filesObjs[$fileid]) ) {
|
2008-04-20 21:26:42 +00:00
|
|
|
continue;
|
2008-03-21 05:09:23 +00:00
|
|
|
} else if( !$filesObjs[$fileid]->userCan(File::DELETED_RESTRICTED) ) {
|
|
|
|
|
// If a rev is hidden from sysops
|
|
|
|
|
if( $action != 'submit' ) {
|
2008-05-25 00:31:28 +00:00
|
|
|
$wgOut->permissionRequired( 'suppressrevision' );
|
2008-03-21 05:09:23 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$UserAllowed = false;
|
|
|
|
|
}
|
2008-04-20 21:26:42 +00:00
|
|
|
$revisions++;
|
2008-03-21 05:09:23 +00:00
|
|
|
// Inject history info
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML( $this->archivedfileLine( $filesObjs[$fileid] ) );
|
2008-03-21 05:09:23 +00:00
|
|
|
$bitfields |= $filesObjs[$fileid]->deleted;
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-04-20 21:26:42 +00:00
|
|
|
if( !$revisions ) {
|
|
|
|
|
$wgOut->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML( "</ul>" );
|
2008-04-02 07:45:08 +00:00
|
|
|
|
2008-07-09 09:10:23 +00:00
|
|
|
$wgOut->addWikiMsg('revdelete-text' );
|
2008-03-21 05:09:23 +00:00
|
|
|
//Normal sysops can always see what they did, but can't always change it
|
|
|
|
|
if( !$UserAllowed ) return;
|
2008-04-02 07:45:08 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$items = array(
|
2008-04-02 07:45:08 +00:00
|
|
|
Xml::inputLabel( wfMsg( 'revdelete-log' ), 'wpReason', 'wpReason', 60 ),
|
|
|
|
|
Xml::submitButton( wfMsg( 'revdelete-submit' ) )
|
|
|
|
|
);
|
2008-03-21 05:09:23 +00:00
|
|
|
$hidden = array(
|
2008-04-02 07:45:08 +00:00
|
|
|
Xml::hidden( 'wpEditToken', $wgUser->editToken() ),
|
|
|
|
|
Xml::hidden( 'target', $this->page->getPrefixedText() ),
|
|
|
|
|
Xml::hidden( 'type', $this->deleteKey )
|
|
|
|
|
);
|
2008-03-21 05:09:23 +00:00
|
|
|
if( $this->deleteKey=='oldimage' ) {
|
|
|
|
|
foreach( $this->ofiles as $filename )
|
2008-07-09 09:10:23 +00:00
|
|
|
$hidden[] = Xml::hidden( 'oldimage[]', $filename );
|
2008-03-21 05:09:23 +00:00
|
|
|
} else {
|
|
|
|
|
foreach( $this->afiles as $fileid )
|
2008-07-09 09:10:23 +00:00
|
|
|
$hidden[] = Xml::hidden( 'fileid[]', $fileid );
|
2008-03-21 05:09:23 +00:00
|
|
|
}
|
|
|
|
|
$special = SpecialPage::getTitleFor( 'Revisiondelete' );
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML(
|
2008-04-16 18:44:15 +00:00
|
|
|
Xml::openElement( 'form', array( 'method' => 'post', 'action' => $special->getLocalUrl( 'action=submit' ),
|
|
|
|
|
'id' => 'mw-revdel-form-filerevisions' ) ) .
|
2008-07-09 16:49:44 +00:00
|
|
|
Xml::fieldset( wfMsg( 'revdelete-legend' ) )
|
2008-04-02 07:45:08 +00:00
|
|
|
);
|
2008-03-21 05:09:23 +00:00
|
|
|
// FIXME: all items checked for just one file are checked, even if not set for the others
|
|
|
|
|
foreach( $this->checks as $item ) {
|
|
|
|
|
list( $message, $name, $field ) = $item;
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML( Xml::tags( 'div', null, Xml::checkLabel( wfMsg( $message ), $name, $name, $bitfields & $field ) ) );
|
2008-03-21 05:09:23 +00:00
|
|
|
}
|
|
|
|
|
foreach( $items as $item ) {
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML( "<p>$item</p>" );
|
2008-03-21 05:09:23 +00:00
|
|
|
}
|
|
|
|
|
foreach( $hidden as $item ) {
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML( $item );
|
2008-03-21 05:09:23 +00:00
|
|
|
}
|
2008-04-02 07:45:08 +00:00
|
|
|
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML(
|
2008-04-02 07:45:08 +00:00
|
|
|
Xml::closeElement( 'fieldset' ) .
|
|
|
|
|
Xml::closeElement( 'form' ) . "\n"
|
|
|
|
|
);
|
2008-03-21 05:09:23 +00:00
|
|
|
}
|
2008-04-02 07:45:08 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
/**
|
|
|
|
|
* This lets a user set restrictions for log items
|
|
|
|
|
*/
|
2008-04-24 17:29:46 +00:00
|
|
|
function showLogItems() {
|
2008-07-09 09:10:23 +00:00
|
|
|
global $wgOut, $wgUser, $action, $wgMessageCache, $wgLang;
|
2008-03-21 05:09:23 +00:00
|
|
|
|
|
|
|
|
$UserAllowed = true;
|
2008-07-09 09:10:23 +00:00
|
|
|
$wgOut->addWikiMsg( 'logdelete-selected', $wgLang->formatNum( count($this->events) ) );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$bitfields = 0;
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML( "<ul>" );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$where = $logRows = array();
|
|
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
|
|
|
|
// Run through and pull all our data in one query
|
2008-04-20 21:26:42 +00:00
|
|
|
$logItems = 0;
|
2008-03-21 05:09:23 +00:00
|
|
|
foreach( $this->events as $logid ) {
|
|
|
|
|
$where[] = intval($logid);
|
|
|
|
|
}
|
2008-04-16 18:44:15 +00:00
|
|
|
list($log,$logtype) = explode( '/',$this->page->getDBKey(), 2 );
|
2008-04-14 07:45:50 +00:00
|
|
|
$result = $dbr->select( 'logging', '*',
|
2009-01-30 00:15:19 +00:00
|
|
|
array(
|
|
|
|
|
'log_type' => $logtype,
|
|
|
|
|
'log_id' => $where ),
|
2008-03-21 05:09:23 +00:00
|
|
|
__METHOD__ );
|
|
|
|
|
while( $row = $dbr->fetchObject( $result ) ) {
|
|
|
|
|
$logRows[$row->log_id] = $row;
|
|
|
|
|
}
|
2008-04-02 09:00:43 +00:00
|
|
|
$wgMessageCache->loadAllMessages();
|
2008-03-21 05:09:23 +00:00
|
|
|
foreach( $this->events as $logid ) {
|
|
|
|
|
// Don't hide from oversight log!!!
|
2008-04-01 22:50:53 +00:00
|
|
|
if( !isset( $logRows[$logid] ) || $logRows[$logid]->log_type=='suppress' ) {
|
2008-04-20 21:26:42 +00:00
|
|
|
continue;
|
2008-04-02 17:43:57 +00:00
|
|
|
} else if( !LogEventsList::userCan( $logRows[$logid],Revision::DELETED_RESTRICTED) ) {
|
2008-03-21 05:09:23 +00:00
|
|
|
// If an event is hidden from sysops
|
|
|
|
|
if( $action != 'submit') {
|
2008-05-25 00:31:28 +00:00
|
|
|
$wgOut->permissionRequired( 'suppressrevision' );
|
2008-03-21 05:09:23 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$UserAllowed = false;
|
2006-09-09 09:33:56 +00:00
|
|
|
}
|
2008-04-20 21:26:42 +00:00
|
|
|
$logItems++;
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML( $this->logLine( $logRows[$logid] ) );
|
2008-03-21 05:09:23 +00:00
|
|
|
$bitfields |= $logRows[$logid]->log_deleted;
|
2006-03-16 19:04:25 +00:00
|
|
|
}
|
2008-04-20 21:26:42 +00:00
|
|
|
if( !$logItems ) {
|
2009-01-18 07:02:28 +00:00
|
|
|
$wgOut->showErrorPage( 'revdelete-nologid-title', 'revdelete-nologid-text' );
|
2008-04-20 21:26:42 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML( "</ul>" );
|
2008-03-21 05:09:23 +00:00
|
|
|
|
2008-02-18 07:25:35 +00:00
|
|
|
$wgOut->addWikiMsg( 'revdelete-text' );
|
2008-03-21 05:09:23 +00:00
|
|
|
// Normal sysops can always see what they did, but can't always change it
|
|
|
|
|
if( !$UserAllowed ) return;
|
2008-04-02 07:45:08 +00:00
|
|
|
|
2006-03-16 19:04:25 +00:00
|
|
|
$items = array(
|
2008-02-29 19:58:50 +00:00
|
|
|
Xml::inputLabel( wfMsg( 'revdelete-log' ), 'wpReason', 'wpReason', 60 ),
|
|
|
|
|
Xml::submitButton( wfMsg( 'revdelete-submit' ) ) );
|
2006-03-16 19:04:25 +00:00
|
|
|
$hidden = array(
|
2008-02-29 19:58:50 +00:00
|
|
|
Xml::hidden( 'wpEditToken', $wgUser->editToken() ),
|
2008-04-16 18:44:15 +00:00
|
|
|
Xml::hidden( 'target', $this->page->getPrefixedText() ),
|
2008-03-21 05:09:23 +00:00
|
|
|
Xml::hidden( 'type', $this->deleteKey ) );
|
|
|
|
|
foreach( $this->events as $logid ) {
|
|
|
|
|
$hidden[] = Xml::hidden( 'logid[]', $logid );
|
2006-03-16 19:04:25 +00:00
|
|
|
}
|
2008-04-02 07:45:08 +00:00
|
|
|
|
2006-10-30 06:25:31 +00:00
|
|
|
$special = SpecialPage::getTitleFor( 'Revisiondelete' );
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML(
|
2008-04-16 18:44:15 +00:00
|
|
|
Xml::openElement( 'form', array( 'method' => 'post', 'action' => $special->getLocalUrl( 'action=submit' ),
|
|
|
|
|
'id' => 'mw-revdel-form-logs' ) ) .
|
2008-07-09 09:10:23 +00:00
|
|
|
Xml::fieldset( wfMsg( 'revdelete-legend' ) )
|
2008-04-02 07:45:08 +00:00
|
|
|
);
|
2008-03-21 05:09:23 +00:00
|
|
|
// FIXME: all items checked for just on event are checked, even if not set for the others
|
2006-03-16 19:04:25 +00:00
|
|
|
foreach( $this->checks as $item ) {
|
|
|
|
|
list( $message, $name, $field ) = $item;
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML( Xml::tags( 'div', null, Xml::checkLabel( wfMsg( $message ), $name, $name, $bitfields & $field ) ) );
|
2006-03-16 19:04:25 +00:00
|
|
|
}
|
|
|
|
|
foreach( $items as $item ) {
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML( "<p>$item</p>" );
|
2006-03-16 19:04:25 +00:00
|
|
|
}
|
|
|
|
|
foreach( $hidden as $item ) {
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML( $item );
|
2006-03-16 19:04:25 +00:00
|
|
|
}
|
2008-04-02 07:45:08 +00:00
|
|
|
|
2008-11-06 22:20:29 +00:00
|
|
|
$wgOut->addHTML(
|
2008-04-02 07:45:08 +00:00
|
|
|
Xml::closeElement( 'fieldset' ) .
|
|
|
|
|
Xml::closeElement( 'form' ) . "\n"
|
|
|
|
|
);
|
2006-03-16 19:04:25 +00:00
|
|
|
}
|
2008-04-02 07:45:08 +00:00
|
|
|
|
2006-03-16 19:04:25 +00:00
|
|
|
/**
|
|
|
|
|
* @param Revision $rev
|
|
|
|
|
* @returns string
|
|
|
|
|
*/
|
2008-03-21 05:09:23 +00:00
|
|
|
private function historyLine( $rev ) {
|
2009-02-09 22:27:25 +00:00
|
|
|
global $wgLang, $wgUser;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-07-10 08:33:50 +00:00
|
|
|
$date = $wgLang->timeanddate( $rev->getTimestamp() );
|
2008-04-04 03:56:48 +00:00
|
|
|
$difflink = $del = '';
|
2008-03-21 05:09:23 +00:00
|
|
|
// Live revisions
|
|
|
|
|
if( $this->deleteKey=='oldid' ) {
|
2009-02-09 22:27:25 +00:00
|
|
|
$tokenParams = '&unhide=1&token='.urlencode( $wgUser->editToken( $rev->getId() ) );
|
|
|
|
|
$revlink = $this->skin->makeLinkObj( $this->page, $date, 'oldid='.$rev->getId() . $tokenParams );
|
2008-04-14 07:45:50 +00:00
|
|
|
$difflink = '(' . $this->skin->makeKnownLinkObj( $this->page, wfMsgHtml('diff'),
|
2009-02-09 22:27:25 +00:00
|
|
|
'diff=' . $rev->getId() . '&oldid=prev' . $tokenParams ) . ')';
|
2008-03-21 05:09:23 +00:00
|
|
|
// Archived revisions
|
2008-04-04 03:56:48 +00:00
|
|
|
} else {
|
2008-03-21 05:09:23 +00:00
|
|
|
$undelete = SpecialPage::getTitleFor( 'Undelete' );
|
|
|
|
|
$target = $this->page->getPrefixedText();
|
2008-04-14 07:45:50 +00:00
|
|
|
$revlink = $this->skin->makeLinkObj( $undelete, $date,
|
2008-03-21 05:09:23 +00:00
|
|
|
"target=$target×tamp=" . $rev->getTimestamp() );
|
2008-04-14 07:45:50 +00:00
|
|
|
$difflink = '(' . $this->skin->makeKnownLinkObj( $undelete, wfMsgHtml('diff'),
|
2008-04-04 03:56:48 +00:00
|
|
|
"target=$target&diff=prev×tamp=" . $rev->getTimestamp() ) . ')';
|
2008-03-21 05:09:23 +00:00
|
|
|
}
|
2009-02-09 22:27:25 +00:00
|
|
|
// Check permissions; items may be "suppressed"
|
2008-03-21 05:09:23 +00:00
|
|
|
if( $rev->isDeleted(Revision::DELETED_TEXT) ) {
|
|
|
|
|
$revlink = '<span class="history-deleted">'.$revlink.'</span>';
|
|
|
|
|
$del = ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
|
|
|
|
|
if( !$rev->userCan(Revision::DELETED_TEXT) ) {
|
|
|
|
|
$revlink = '<span class="history-deleted">'.$date.'</span>';
|
2008-04-04 03:56:48 +00:00
|
|
|
$difflink = '(' . wfMsgHtml('diff') . ')';
|
2008-03-21 05:09:23 +00:00
|
|
|
}
|
|
|
|
|
}
|
2009-02-09 22:27:25 +00:00
|
|
|
$userlink = $this->skin->revUserLink( $rev );
|
|
|
|
|
$comment = $this->skin->revComment( $rev );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2009-02-09 22:27:25 +00:00
|
|
|
return "<li> $difflink $revlink $userlink $comment{$del}</li>";
|
2008-03-21 05:09:23 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
/**
|
|
|
|
|
* @param File $file
|
|
|
|
|
* @returns string
|
2008-04-14 07:45:50 +00:00
|
|
|
*/
|
2008-03-21 05:09:23 +00:00
|
|
|
private function fileLine( $file ) {
|
2008-07-10 08:33:50 +00:00
|
|
|
global $wgLang, $wgTitle;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$target = $this->page->getPrefixedText();
|
2008-07-10 08:33:50 +00:00
|
|
|
$date = $wgLang->timeanddate( $file->getTimestamp(), true );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$del = '';
|
|
|
|
|
# Hidden files...
|
|
|
|
|
if( $file->isDeleted(File::DELETED_FILE) ) {
|
|
|
|
|
$del = ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
|
|
|
|
|
if( !$file->userCan(File::DELETED_FILE) ) {
|
|
|
|
|
$pageLink = $date;
|
|
|
|
|
} else {
|
2008-04-14 07:45:50 +00:00
|
|
|
$pageLink = $this->skin->makeKnownLinkObj( $wgTitle, $date,
|
2008-03-21 05:09:23 +00:00
|
|
|
"target=$target&file=$file->sha1.".$file->getExtension() );
|
|
|
|
|
}
|
|
|
|
|
$pageLink = '<span class="history-deleted">' . $pageLink . '</span>';
|
|
|
|
|
# Regular files...
|
|
|
|
|
} else {
|
|
|
|
|
$url = $file->getUrlRel();
|
|
|
|
|
$pageLink = "<a href=\"{$url}\">{$date}</a>";
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-07-09 09:10:23 +00:00
|
|
|
$data = wfMsg( 'widthheight',
|
2008-07-10 08:33:50 +00:00
|
|
|
$wgLang->formatNum( $file->getWidth() ),
|
|
|
|
|
$wgLang->formatNum( $file->getHeight() ) ) .
|
2008-07-14 19:10:47 +00:00
|
|
|
' (' . wfMsgExt( 'nbytes', 'parsemag', $wgLang->formatNum( $file->getSize() ) ) . ')';
|
2008-07-09 09:10:23 +00:00
|
|
|
$data = htmlspecialchars( $data );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
return "<li>$pageLink ".$this->fileUserTools( $file )." $data ".$this->fileComment( $file )."$del</li>";
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
/**
|
|
|
|
|
* @param ArchivedFile $file
|
|
|
|
|
* @returns string
|
2008-04-14 07:45:50 +00:00
|
|
|
*/
|
2008-03-21 05:09:23 +00:00
|
|
|
private function archivedfileLine( $file ) {
|
2008-11-04 02:53:47 +00:00
|
|
|
global $wgLang;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$target = $this->page->getPrefixedText();
|
2008-07-10 08:33:50 +00:00
|
|
|
$date = $wgLang->timeanddate( $file->getTimestamp(), true );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$undelete = SpecialPage::getTitleFor( 'Undelete' );
|
|
|
|
|
$pageLink = $this->skin->makeKnownLinkObj( $undelete, $date, "target=$target&file={$file->getKey()}" );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$del = '';
|
|
|
|
|
if( $file->isDeleted(File::DELETED_FILE) ) {
|
|
|
|
|
$del = ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-07-09 09:10:23 +00:00
|
|
|
$data = wfMsg( 'widthheight',
|
2008-07-10 08:33:50 +00:00
|
|
|
$wgLang->formatNum( $file->getWidth() ),
|
|
|
|
|
$wgLang->formatNum( $file->getHeight() ) ) .
|
2008-07-14 19:10:47 +00:00
|
|
|
' (' . wfMsgExt( 'nbytes', 'parsemag', $wgLang->formatNum( $file->getSize() ) ) . ')';
|
2008-07-09 09:10:23 +00:00
|
|
|
$data = htmlspecialchars( $data );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
return "<li> $pageLink ".$this->fileUserTools( $file )." $data ".$this->fileComment( $file )."$del</li>";
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
/**
|
|
|
|
|
* @param Array $row row
|
|
|
|
|
* @returns string
|
|
|
|
|
*/
|
|
|
|
|
private function logLine( $row ) {
|
2008-07-10 08:33:50 +00:00
|
|
|
global $wgLang;
|
2008-03-21 05:09:23 +00:00
|
|
|
|
2008-07-10 08:33:50 +00:00
|
|
|
$date = $wgLang->timeanddate( $row->log_timestamp );
|
2008-03-21 05:09:23 +00:00
|
|
|
$paramArray = LogPage::extractParams( $row->log_params );
|
2008-03-28 17:31:23 +00:00
|
|
|
$title = Title::makeTitle( $row->log_namespace, $row->log_title );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-28 17:31:23 +00:00
|
|
|
$logtitle = SpecialPage::getTitleFor( 'Log' );
|
|
|
|
|
$loglink = $this->skin->makeKnownLinkObj( $logtitle, wfMsgHtml( 'log' ),
|
|
|
|
|
wfArrayToCGI( array( 'page' => $title->getPrefixedUrl() ) ) );
|
2008-03-21 05:09:23 +00:00
|
|
|
// Action text
|
2008-04-02 17:43:57 +00:00
|
|
|
if( !LogEventsList::userCan($row,LogPage::DELETED_ACTION) ) {
|
2008-04-14 07:45:50 +00:00
|
|
|
$action = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
|
2008-03-21 05:09:23 +00:00
|
|
|
} else {
|
2008-04-14 07:45:50 +00:00
|
|
|
$action = LogPage::actionText( $row->log_type, $row->log_action, $title,
|
2008-03-21 05:09:23 +00:00
|
|
|
$this->skin, $paramArray, true, true );
|
|
|
|
|
if( $row->log_deleted & LogPage::DELETED_ACTION )
|
|
|
|
|
$action = '<span class="history-deleted">' . $action . '</span>';
|
|
|
|
|
}
|
|
|
|
|
// User links
|
|
|
|
|
$userLink = $this->skin->userLink( $row->log_user, User::WhoIs($row->log_user) );
|
2008-04-02 17:43:57 +00:00
|
|
|
if( LogEventsList::isDeleted($row,LogPage::DELETED_USER) ) {
|
2008-03-21 05:09:23 +00:00
|
|
|
$userLink = '<span class="history-deleted">' . $userLink . '</span>';
|
|
|
|
|
}
|
|
|
|
|
// Comment
|
2008-07-10 08:33:50 +00:00
|
|
|
$comment = $wgLang->getDirMark() . $this->skin->commentBlock( $row->log_comment );
|
2008-04-02 17:43:57 +00:00
|
|
|
if( LogEventsList::isDeleted($row,LogPage::DELETED_COMMENT) ) {
|
2008-03-21 05:09:23 +00:00
|
|
|
$comment = '<span class="history-deleted">' . $comment . '</span>';
|
|
|
|
|
}
|
2008-03-28 17:31:23 +00:00
|
|
|
return "<li>($loglink) $date $userLink $action $comment</li>";
|
2008-03-21 05:09:23 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
/**
|
|
|
|
|
* Generate a user tool link cluster if the current user is allowed to view it
|
|
|
|
|
* @param ArchivedFile $file
|
|
|
|
|
* @return string HTML
|
|
|
|
|
*/
|
|
|
|
|
private function fileUserTools( $file ) {
|
|
|
|
|
if( $file->userCan( Revision::DELETED_USER ) ) {
|
|
|
|
|
$link = $this->skin->userLink( $file->user, $file->user_text ) .
|
|
|
|
|
$this->skin->userToolLinks( $file->user, $file->user_text );
|
|
|
|
|
} else {
|
|
|
|
|
$link = wfMsgHtml( 'rev-deleted-user' );
|
|
|
|
|
}
|
|
|
|
|
if( $file->isDeleted( Revision::DELETED_USER ) ) {
|
|
|
|
|
return '<span class="history-deleted">' . $link . '</span>';
|
|
|
|
|
}
|
|
|
|
|
return $link;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
/**
|
|
|
|
|
* Wrap and format the given file's comment block, if the current
|
|
|
|
|
* user is allowed to view it.
|
|
|
|
|
*
|
|
|
|
|
* @param ArchivedFile $file
|
|
|
|
|
* @return string HTML
|
|
|
|
|
*/
|
|
|
|
|
private function fileComment( $file ) {
|
|
|
|
|
if( $file->userCan( File::DELETED_COMMENT ) ) {
|
|
|
|
|
$block = $this->skin->commentBlock( $file->description );
|
|
|
|
|
} else {
|
|
|
|
|
$block = ' ' . wfMsgHtml( 'rev-deleted-comment' );
|
|
|
|
|
}
|
|
|
|
|
if( $file->isDeleted( File::DELETED_COMMENT ) ) {
|
|
|
|
|
return "<span class=\"history-deleted\">$block</span>";
|
|
|
|
|
}
|
|
|
|
|
return $block;
|
2006-03-16 19:04:25 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2006-03-16 19:04:25 +00:00
|
|
|
/**
|
|
|
|
|
* @param WebRequest $request
|
|
|
|
|
*/
|
|
|
|
|
function submit( $request ) {
|
2008-04-24 17:29:46 +00:00
|
|
|
global $wgUser, $wgOut;
|
|
|
|
|
|
2006-03-16 19:04:25 +00:00
|
|
|
$bitfield = $this->extractBitfield( $request );
|
|
|
|
|
$comment = $request->getText( 'wpReason' );
|
2008-04-24 17:29:46 +00:00
|
|
|
# Can the user set this field?
|
2008-05-25 00:31:28 +00:00
|
|
|
if( $bitfield & Revision::DELETED_RESTRICTED && !$wgUser->isAllowed('suppressrevision') ) {
|
|
|
|
|
$wgOut->permissionRequired( 'suppressrevision' );
|
2008-04-24 17:29:46 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
# If the save went through, go to success message. Otherwise
|
|
|
|
|
# bounce back to form...
|
|
|
|
|
if( $this->save( $bitfield, $comment, $this->page ) ) {
|
|
|
|
|
$this->success();
|
2008-03-21 05:09:23 +00:00
|
|
|
} else if( $request->getCheck( 'oldid' ) || $request->getCheck( 'artimestamp' ) ) {
|
2008-04-24 17:29:46 +00:00
|
|
|
return $this->showRevs();
|
2008-03-21 05:09:23 +00:00
|
|
|
} else if( $request->getCheck( 'logid' ) ) {
|
2008-04-24 17:29:46 +00:00
|
|
|
return $this->showLogs();
|
2008-03-21 05:09:23 +00:00
|
|
|
} else if( $request->getCheck( 'oldimage' ) || $request->getCheck( 'fileid' ) ) {
|
2008-04-24 17:29:46 +00:00
|
|
|
return $this->showImages();
|
2007-03-16 16:01:07 +00:00
|
|
|
}
|
2006-03-16 19:04:25 +00:00
|
|
|
}
|
2008-03-25 20:06:33 +00:00
|
|
|
|
2008-04-24 17:29:46 +00:00
|
|
|
private function success() {
|
2006-03-16 19:04:25 +00:00
|
|
|
global $wgOut;
|
2008-03-25 20:06:33 +00:00
|
|
|
|
2008-07-09 09:10:23 +00:00
|
|
|
$wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
|
|
|
|
|
|
|
|
|
|
$wrap = '<span class="success">$1</span>';
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
if( $this->deleteKey=='logid' ) {
|
2008-07-09 09:10:23 +00:00
|
|
|
$wgOut->wrapWikiMsg( $wrap, 'logdelete-success' );
|
2008-04-24 17:29:46 +00:00
|
|
|
$this->showLogItems();
|
2008-03-21 05:09:23 +00:00
|
|
|
} else if( $this->deleteKey=='oldid' || $this->deleteKey=='artimestamp' ) {
|
2008-07-09 09:10:23 +00:00
|
|
|
$wgOut->wrapWikiMsg( $wrap, 'revdelete-success' );
|
2008-04-24 17:29:46 +00:00
|
|
|
$this->showRevs();
|
2008-03-21 05:09:23 +00:00
|
|
|
} else if( $this->deleteKey=='fileid' ) {
|
2008-07-09 09:10:23 +00:00
|
|
|
$wgOut->wrapWikiMsg( $wrap, 'revdelete-success' );
|
2008-04-24 17:29:46 +00:00
|
|
|
$this->showImages();
|
2008-03-21 05:09:23 +00:00
|
|
|
} else if( $this->deleteKey=='oldimage' ) {
|
2008-07-09 09:10:23 +00:00
|
|
|
$wgOut->wrapWikiMsg( $wrap, 'revdelete-success' );
|
2008-04-24 17:29:46 +00:00
|
|
|
$this->showImages();
|
2008-03-21 05:09:23 +00:00
|
|
|
}
|
2006-03-16 19:04:25 +00:00
|
|
|
}
|
2008-03-25 20:06:33 +00:00
|
|
|
|
2006-03-16 19:04:25 +00:00
|
|
|
/**
|
|
|
|
|
* Put together a rev_deleted bitfield from the submitted checkboxes
|
|
|
|
|
* @param WebRequest $request
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
2008-03-21 05:09:23 +00:00
|
|
|
private function extractBitfield( $request ) {
|
2006-03-16 19:04:25 +00:00
|
|
|
$bitfield = 0;
|
|
|
|
|
foreach( $this->checks as $item ) {
|
2006-11-23 08:25:56 +00:00
|
|
|
list( /* message */ , $name, $field ) = $item;
|
2006-03-16 19:04:25 +00:00
|
|
|
if( $request->getCheck( $name ) ) {
|
|
|
|
|
$bitfield |= $field;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $bitfield;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
private function save( $bitfield, $reason, $title ) {
|
2006-03-16 19:04:25 +00:00
|
|
|
$dbw = wfGetDB( DB_MASTER );
|
2008-03-21 05:09:23 +00:00
|
|
|
// Don't allow simply locking the interface for no reason
|
|
|
|
|
if( $bitfield == Revision::DELETED_RESTRICTED ) {
|
|
|
|
|
$bitfield = 0;
|
|
|
|
|
}
|
2006-03-16 19:04:25 +00:00
|
|
|
$deleter = new RevisionDeleter( $dbw );
|
2008-03-21 05:09:23 +00:00
|
|
|
// By this point, only one of the below should be set
|
|
|
|
|
if( isset($this->revisions) ) {
|
|
|
|
|
return $deleter->setRevVisibility( $title, $this->revisions, $bitfield, $reason );
|
|
|
|
|
} else if( isset($this->archrevs) ) {
|
|
|
|
|
return $deleter->setArchiveVisibility( $title, $this->archrevs, $bitfield, $reason );
|
|
|
|
|
} else if( isset($this->ofiles) ) {
|
|
|
|
|
return $deleter->setOldImgVisibility( $title, $this->ofiles, $bitfield, $reason );
|
|
|
|
|
} else if( isset($this->afiles) ) {
|
|
|
|
|
return $deleter->setArchFileVisibility( $title, $this->afiles, $bitfield, $reason );
|
|
|
|
|
} else if( isset($this->events) ) {
|
2008-04-16 18:44:15 +00:00
|
|
|
return $deleter->setEventVisibility( $title, $this->events, $bitfield, $reason );
|
2008-03-21 05:09:23 +00:00
|
|
|
}
|
2006-03-16 19:04:25 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-20 08:55:14 +00:00
|
|
|
/**
|
|
|
|
|
* Implements the actions for Revision Deletion.
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup SpecialPage
|
2007-04-20 08:55:14 +00:00
|
|
|
*/
|
2006-03-16 19:04:25 +00:00
|
|
|
class RevisionDeleter {
|
|
|
|
|
function __construct( $db ) {
|
2008-03-21 05:09:23 +00:00
|
|
|
$this->dbw = $db;
|
2006-03-16 19:04:25 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2006-03-16 19:04:25 +00:00
|
|
|
/**
|
2008-03-21 05:09:23 +00:00
|
|
|
* @param $title, the page these events apply to
|
2006-03-16 19:04:25 +00:00
|
|
|
* @param array $items list of revision ID numbers
|
|
|
|
|
* @param int $bitfield new rev_deleted value
|
|
|
|
|
* @param string $comment Comment for log records
|
|
|
|
|
*/
|
2008-03-21 05:09:23 +00:00
|
|
|
function setRevVisibility( $title, $items, $bitfield, $comment ) {
|
|
|
|
|
global $wgOut;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$userAllowedAll = $success = true;
|
|
|
|
|
$revIDs = array();
|
|
|
|
|
$revCount = 0;
|
|
|
|
|
// Run through and pull all our data in one query
|
|
|
|
|
foreach( $items as $revid ) {
|
|
|
|
|
$where[] = intval($revid);
|
|
|
|
|
}
|
|
|
|
|
$result = $this->dbw->select( 'revision', '*',
|
2009-01-30 00:15:19 +00:00
|
|
|
array(
|
|
|
|
|
'rev_page' => $title->getArticleID(),
|
|
|
|
|
'rev_id' => $where ),
|
2008-03-21 05:09:23 +00:00
|
|
|
__METHOD__ );
|
|
|
|
|
while( $row = $this->dbw->fetchObject( $result ) ) {
|
|
|
|
|
$revObjs[$row->rev_id] = new Revision( $row );
|
|
|
|
|
}
|
2006-03-16 19:04:25 +00:00
|
|
|
// To work!
|
|
|
|
|
foreach( $items as $revid ) {
|
2008-03-21 05:09:23 +00:00
|
|
|
if( !isset($revObjs[$revid]) || $revObjs[$revid]->isCurrent() ) {
|
|
|
|
|
$success = false;
|
|
|
|
|
continue; // Must exist
|
|
|
|
|
} else if( !$revObjs[$revid]->userCan(Revision::DELETED_RESTRICTED) ) {
|
2008-04-14 07:45:50 +00:00
|
|
|
$userAllowedAll=false;
|
2008-03-21 05:09:23 +00:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// For logging, maintain a count of revisions
|
|
|
|
|
if( $revObjs[$revid]->mDeleted != $bitfield ) {
|
|
|
|
|
$revCount++;
|
|
|
|
|
$revIDs[]=$revid;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$this->updateRevision( $revObjs[$revid], $bitfield );
|
|
|
|
|
$this->updateRecentChangesEdits( $revObjs[$revid], $bitfield, false );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Clear caches...
|
|
|
|
|
// Don't log or touch if nothing changed
|
|
|
|
|
if( $revCount > 0 ) {
|
2008-04-14 07:45:50 +00:00
|
|
|
$this->updateLog( $title, $revCount, $bitfield, $revObjs[$revid]->mDeleted,
|
2008-03-21 05:09:23 +00:00
|
|
|
$comment, $title, 'oldid', $revIDs );
|
|
|
|
|
$this->updatePage( $title );
|
|
|
|
|
}
|
|
|
|
|
// Where all revs allowed to be set?
|
|
|
|
|
if( !$userAllowedAll ) {
|
|
|
|
|
//FIXME: still might be confusing???
|
2008-05-25 00:31:28 +00:00
|
|
|
$wgOut->permissionRequired( 'suppressrevision' );
|
2008-03-21 05:09:23 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
return $success;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
/**
|
|
|
|
|
* @param $title, the page these events apply to
|
|
|
|
|
* @param array $items list of revision ID numbers
|
|
|
|
|
* @param int $bitfield new rev_deleted value
|
|
|
|
|
* @param string $comment Comment for log records
|
|
|
|
|
*/
|
|
|
|
|
function setArchiveVisibility( $title, $items, $bitfield, $comment ) {
|
|
|
|
|
global $wgOut;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$userAllowedAll = $success = true;
|
2008-04-14 07:45:50 +00:00
|
|
|
$count = 0;
|
2008-03-21 05:09:23 +00:00
|
|
|
$Id_set = array();
|
|
|
|
|
// Run through and pull all our data in one query
|
|
|
|
|
foreach( $items as $timestamp ) {
|
2009-02-23 16:48:01 +00:00
|
|
|
$where[] = $this->dbw->timestamp( $timestamp );
|
2008-03-21 05:09:23 +00:00
|
|
|
}
|
|
|
|
|
$result = $this->dbw->select( 'archive', '*',
|
2009-01-30 00:15:19 +00:00
|
|
|
array(
|
|
|
|
|
'ar_namespace' => $title->getNamespace(),
|
2008-04-14 07:45:50 +00:00
|
|
|
'ar_title' => $title->getDBKey(),
|
2009-01-30 00:15:19 +00:00
|
|
|
'ar_timestamp' => $where ),
|
2008-03-21 05:09:23 +00:00
|
|
|
__METHOD__ );
|
|
|
|
|
while( $row = $this->dbw->fetchObject( $result ) ) {
|
2009-02-24 11:52:40 +00:00
|
|
|
$timestamp = wfTimestamp( TS_MW, $row->ar_timestamp );
|
2009-02-23 16:48:01 +00:00
|
|
|
$revObjs[$timestamp] = new Revision( array(
|
2009-02-17 23:52:18 +00:00
|
|
|
'page' => $title->getArticleId(),
|
|
|
|
|
'id' => $row->ar_rev_id,
|
|
|
|
|
'text' => $row->ar_text_id,
|
|
|
|
|
'comment' => $row->ar_comment,
|
|
|
|
|
'user' => $row->ar_user,
|
|
|
|
|
'user_text' => $row->ar_user_text,
|
2009-02-24 11:52:40 +00:00
|
|
|
'timestamp' => $timestamp,
|
2009-02-17 23:52:18 +00:00
|
|
|
'minor_edit' => $row->ar_minor_edit,
|
|
|
|
|
'text_id' => $row->ar_text_id,
|
|
|
|
|
'deleted' => $row->ar_deleted,
|
|
|
|
|
'len' => $row->ar_len) );
|
2008-03-21 05:09:23 +00:00
|
|
|
}
|
|
|
|
|
// To work!
|
|
|
|
|
foreach( $items as $timestamp ) {
|
|
|
|
|
// This will only select the first revision with this timestamp.
|
2008-04-14 07:45:50 +00:00
|
|
|
// Since they are all selected/deleted at once, we can just check the
|
2008-03-21 05:09:23 +00:00
|
|
|
// permissions of one. UPDATE is done via timestamp, so all revs are set.
|
|
|
|
|
if( !is_object($revObjs[$timestamp]) ) {
|
|
|
|
|
$success = false;
|
|
|
|
|
continue; // Must exist
|
|
|
|
|
} else if( !$revObjs[$timestamp]->userCan(Revision::DELETED_RESTRICTED) ) {
|
|
|
|
|
$userAllowedAll=false;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// Which revisions did we change anything about?
|
|
|
|
|
if( $revObjs[$timestamp]->mDeleted != $bitfield ) {
|
|
|
|
|
$Id_set[]=$timestamp;
|
|
|
|
|
$count++;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-04 04:15:21 +00:00
|
|
|
$this->updateArchive( $revObjs[$timestamp], $title, $bitfield );
|
2008-03-21 05:09:23 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// For logging, maintain a count of revisions
|
|
|
|
|
if( $count > 0 ) {
|
2008-04-14 07:45:50 +00:00
|
|
|
$this->updateLog( $title, $count, $bitfield, $revObjs[$timestamp]->mDeleted,
|
2008-03-21 05:09:23 +00:00
|
|
|
$comment, $title, 'artimestamp', $Id_set );
|
|
|
|
|
}
|
|
|
|
|
// Where all revs allowed to be set?
|
|
|
|
|
if( !$userAllowedAll ) {
|
2008-05-25 00:31:28 +00:00
|
|
|
$wgOut->permissionRequired( 'suppressrevision' );
|
2008-03-21 05:09:23 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
return $success;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
/**
|
|
|
|
|
* @param $title, the page these events apply to
|
|
|
|
|
* @param array $items list of revision ID numbers
|
|
|
|
|
* @param int $bitfield new rev_deleted value
|
|
|
|
|
* @param string $comment Comment for log records
|
|
|
|
|
*/
|
|
|
|
|
function setOldImgVisibility( $title, $items, $bitfield, $comment ) {
|
|
|
|
|
global $wgOut;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$userAllowedAll = $success = true;
|
2008-04-14 07:45:50 +00:00
|
|
|
$count = 0;
|
2008-03-21 05:09:23 +00:00
|
|
|
$set = array();
|
|
|
|
|
// Run through and pull all our data in one query
|
|
|
|
|
foreach( $items as $timestamp ) {
|
2009-02-23 16:48:01 +00:00
|
|
|
$where[] = $timestamp.'!'.$title->getDBKey();
|
2008-03-21 05:09:23 +00:00
|
|
|
}
|
|
|
|
|
$result = $this->dbw->select( 'oldimage', '*',
|
2009-01-30 00:15:19 +00:00
|
|
|
array(
|
|
|
|
|
'oi_name' => $title->getDBKey(),
|
|
|
|
|
'oi_archive_name' => $where ),
|
2008-03-21 05:09:23 +00:00
|
|
|
__METHOD__ );
|
|
|
|
|
while( $row = $this->dbw->fetchObject( $result ) ) {
|
|
|
|
|
$filesObjs[$row->oi_archive_name] = RepoGroup::singleton()->getLocalRepo()->newFileFromRow( $row );
|
|
|
|
|
$filesObjs[$row->oi_archive_name]->user = $row->oi_user;
|
|
|
|
|
$filesObjs[$row->oi_archive_name]->user_text = $row->oi_user_text;
|
|
|
|
|
}
|
|
|
|
|
// To work!
|
|
|
|
|
foreach( $items as $timestamp ) {
|
2008-11-06 22:38:42 +00:00
|
|
|
$archivename = $timestamp.'!'.$title->getDBKey();
|
2008-03-21 05:09:23 +00:00
|
|
|
if( !isset($filesObjs[$archivename]) ) {
|
|
|
|
|
$success = false;
|
|
|
|
|
continue; // Must exist
|
|
|
|
|
} else if( !$filesObjs[$archivename]->userCan(File::DELETED_RESTRICTED) ) {
|
|
|
|
|
$userAllowedAll=false;
|
|
|
|
|
continue;
|
2006-09-09 09:33:56 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$transaction = true;
|
|
|
|
|
// Which revisions did we change anything about?
|
|
|
|
|
if( $filesObjs[$archivename]->deleted != $bitfield ) {
|
|
|
|
|
$count++;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$this->dbw->begin();
|
|
|
|
|
$this->updateOldFiles( $filesObjs[$archivename], $bitfield );
|
|
|
|
|
// If this image is currently hidden...
|
|
|
|
|
if( $filesObjs[$archivename]->deleted & File::DELETED_FILE ) {
|
|
|
|
|
if( $bitfield & File::DELETED_FILE ) {
|
|
|
|
|
# Leave it alone if we are not changing this...
|
|
|
|
|
$set[]=$archivename;
|
|
|
|
|
$transaction = true;
|
|
|
|
|
} else {
|
|
|
|
|
# We are moving this out
|
|
|
|
|
$transaction = $this->makeOldImagePublic( $filesObjs[$archivename] );
|
|
|
|
|
$set[]=$transaction;
|
|
|
|
|
}
|
|
|
|
|
// Is it just now becoming hidden?
|
|
|
|
|
} else if( $bitfield & File::DELETED_FILE ) {
|
|
|
|
|
$transaction = $this->makeOldImagePrivate( $filesObjs[$archivename] );
|
|
|
|
|
$set[]=$transaction;
|
|
|
|
|
} else {
|
|
|
|
|
$set[]=$timestamp;
|
|
|
|
|
}
|
|
|
|
|
// If our file operations fail, then revert back the db
|
|
|
|
|
if( $transaction==false ) {
|
|
|
|
|
$this->dbw->rollback();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$this->dbw->commit();
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
// Log if something was changed
|
|
|
|
|
if( $count > 0 ) {
|
2008-04-14 07:45:50 +00:00
|
|
|
$this->updateLog( $title, $count, $bitfield, $filesObjs[$archivename]->deleted,
|
2008-03-21 05:09:23 +00:00
|
|
|
$comment, $title, 'oldimage', $set );
|
|
|
|
|
# Purge page/history
|
|
|
|
|
$file = wfLocalFile( $title );
|
|
|
|
|
$file->purgeCache();
|
|
|
|
|
$file->purgeHistory();
|
|
|
|
|
# Invalidate cache for all pages using this file
|
|
|
|
|
$update = new HTMLCacheUpdate( $title, 'imagelinks' );
|
|
|
|
|
$update->doUpdate();
|
|
|
|
|
}
|
|
|
|
|
// Where all revs allowed to be set?
|
|
|
|
|
if( !$userAllowedAll ) {
|
2008-05-25 00:31:28 +00:00
|
|
|
$wgOut->permissionRequired( 'suppressrevision' );
|
2008-03-21 05:09:23 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
return $success;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
/**
|
|
|
|
|
* @param $title, the page these events apply to
|
|
|
|
|
* @param array $items list of revision ID numbers
|
|
|
|
|
* @param int $bitfield new rev_deleted value
|
|
|
|
|
* @param string $comment Comment for log records
|
|
|
|
|
*/
|
|
|
|
|
function setArchFileVisibility( $title, $items, $bitfield, $comment ) {
|
|
|
|
|
global $wgOut;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$userAllowedAll = $success = true;
|
2008-04-14 07:45:50 +00:00
|
|
|
$count = 0;
|
2008-03-21 05:09:23 +00:00
|
|
|
$Id_set = array();
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
// Run through and pull all our data in one query
|
|
|
|
|
foreach( $items as $id ) {
|
|
|
|
|
$where[] = intval($id);
|
|
|
|
|
}
|
|
|
|
|
$result = $this->dbw->select( 'filearchive', '*',
|
2008-11-06 22:38:42 +00:00
|
|
|
array( 'fa_name' => $title->getDBKey(),
|
2009-01-30 00:15:19 +00:00
|
|
|
'fa_id' => $where ),
|
2008-03-21 05:09:23 +00:00
|
|
|
__METHOD__ );
|
|
|
|
|
while( $row = $this->dbw->fetchObject( $result ) ) {
|
|
|
|
|
$filesObjs[$row->fa_id] = ArchivedFile::newFromRow( $row );
|
|
|
|
|
}
|
|
|
|
|
// To work!
|
|
|
|
|
foreach( $items as $fileid ) {
|
|
|
|
|
if( !isset($filesObjs[$fileid]) ) {
|
|
|
|
|
$success = false;
|
|
|
|
|
continue; // Must exist
|
|
|
|
|
} else if( !$filesObjs[$fileid]->userCan(File::DELETED_RESTRICTED) ) {
|
|
|
|
|
$userAllowedAll=false;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// Which revisions did we change anything about?
|
|
|
|
|
if( $filesObjs[$fileid]->deleted != $bitfield ) {
|
|
|
|
|
$Id_set[]=$fileid;
|
|
|
|
|
$count++;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$this->updateArchFiles( $filesObjs[$fileid], $bitfield );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Log if something was changed
|
|
|
|
|
if( $count > 0 ) {
|
2008-04-14 07:45:50 +00:00
|
|
|
$this->updateLog( $title, $count, $bitfield, $comment,
|
2008-03-21 05:09:23 +00:00
|
|
|
$filesObjs[$fileid]->deleted, $title, 'fileid', $Id_set );
|
|
|
|
|
}
|
|
|
|
|
// Where all revs allowed to be set?
|
|
|
|
|
if( !$userAllowedAll ) {
|
2008-05-25 00:31:28 +00:00
|
|
|
$wgOut->permissionRequired( 'suppressrevision' );
|
2008-03-21 05:09:23 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
return $success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2008-04-16 18:44:15 +00:00
|
|
|
* @param $title, the log page these events apply to
|
2008-03-21 05:09:23 +00:00
|
|
|
* @param array $items list of log ID numbers
|
|
|
|
|
* @param int $bitfield new log_deleted value
|
|
|
|
|
* @param string $comment Comment for log records
|
|
|
|
|
*/
|
2008-04-16 18:44:15 +00:00
|
|
|
function setEventVisibility( $title, $items, $bitfield, $comment ) {
|
2008-03-21 05:09:23 +00:00
|
|
|
global $wgOut;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$userAllowedAll = $success = true;
|
2008-04-16 18:44:15 +00:00
|
|
|
$count = 0;
|
|
|
|
|
$log_Ids = array();
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
// Run through and pull all our data in one query
|
|
|
|
|
foreach( $items as $logid ) {
|
|
|
|
|
$where[] = intval($logid);
|
|
|
|
|
}
|
2008-04-16 18:44:15 +00:00
|
|
|
list($log,$logtype) = explode( '/',$title->getDBKey(), 2 );
|
2008-04-14 07:45:50 +00:00
|
|
|
$result = $this->dbw->select( 'logging', '*',
|
2009-01-30 00:15:19 +00:00
|
|
|
array(
|
|
|
|
|
'log_type' => $logtype,
|
|
|
|
|
'log_id' => $where ),
|
2008-03-21 05:09:23 +00:00
|
|
|
__METHOD__ );
|
|
|
|
|
while( $row = $this->dbw->fetchObject( $result ) ) {
|
|
|
|
|
$logRows[$row->log_id] = $row;
|
|
|
|
|
}
|
|
|
|
|
// To work!
|
|
|
|
|
foreach( $items as $logid ) {
|
|
|
|
|
if( !isset($logRows[$logid]) ) {
|
|
|
|
|
$success = false;
|
|
|
|
|
continue; // Must exist
|
2008-04-16 18:44:15 +00:00
|
|
|
} else if( !LogEventsList::userCan($logRows[$logid], LogPage::DELETED_RESTRICTED)
|
2008-04-01 22:50:53 +00:00
|
|
|
|| $logRows[$logid]->log_type == 'suppress' ) {
|
2008-03-21 05:09:23 +00:00
|
|
|
// Don't hide from oversight log!!!
|
|
|
|
|
$userAllowedAll=false;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// Which logs did we change anything about?
|
|
|
|
|
if( $logRows[$logid]->log_deleted != $bitfield ) {
|
2008-04-16 18:44:15 +00:00
|
|
|
$log_Ids[]=$logid;
|
|
|
|
|
$count++;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$this->updateLogs( $logRows[$logid], $bitfield );
|
|
|
|
|
$this->updateRecentChangesLog( $logRows[$logid], $bitfield, true );
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-04-16 18:44:15 +00:00
|
|
|
// Don't log or touch if nothing changed
|
|
|
|
|
if( $count > 0 ) {
|
|
|
|
|
$this->updateLog( $title, $count, $bitfield, $logRows[$logid]->log_deleted,
|
|
|
|
|
$comment, $title, 'logid', $log_Ids );
|
2008-03-21 05:09:23 +00:00
|
|
|
}
|
2008-04-23 18:10:24 +00:00
|
|
|
// Were all revs allowed to be set?
|
2008-03-21 05:09:23 +00:00
|
|
|
if( !$userAllowedAll ) {
|
2008-05-25 00:31:28 +00:00
|
|
|
$wgOut->permissionRequired( 'suppressrevision' );
|
2008-03-21 05:09:23 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
return $success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Moves an image to a safe private location
|
|
|
|
|
* Caller is responsible for clearing caches
|
|
|
|
|
* @param File $oimage
|
|
|
|
|
* @returns mixed, timestamp string on success, false on failure
|
2008-04-14 07:45:50 +00:00
|
|
|
*/
|
2008-03-21 05:09:23 +00:00
|
|
|
function makeOldImagePrivate( $oimage ) {
|
|
|
|
|
$transaction = new FSTransaction();
|
|
|
|
|
if( !FileStore::lock() ) {
|
|
|
|
|
wfDebug( __METHOD__.": failed to acquire file store lock, aborting\n" );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$oldpath = $oimage->getArchivePath() . DIRECTORY_SEPARATOR . $oimage->archive_name;
|
|
|
|
|
// Dupe the file into the file store
|
|
|
|
|
if( file_exists( $oldpath ) ) {
|
|
|
|
|
// Is our directory configured?
|
|
|
|
|
if( $store = FileStore::get( 'deleted' ) ) {
|
|
|
|
|
if( !$oimage->sha1 ) {
|
|
|
|
|
$oimage->upgradeRow(); // sha1 may be missing
|
|
|
|
|
}
|
|
|
|
|
$key = $oimage->sha1 . '.' . $oimage->getExtension();
|
|
|
|
|
$transaction->add( $store->insert( $key, $oldpath, FileStore::DELETE_ORIGINAL ) );
|
2007-03-16 16:01:07 +00:00
|
|
|
} else {
|
2008-03-21 05:09:23 +00:00
|
|
|
$group = null;
|
|
|
|
|
$key = null;
|
|
|
|
|
$transaction = false; // Return an error and do nothing
|
2006-03-16 19:04:25 +00:00
|
|
|
}
|
2008-03-21 05:09:23 +00:00
|
|
|
} else {
|
|
|
|
|
wfDebug( __METHOD__." deleting already-missing '$oldpath'; moving on to database\n" );
|
|
|
|
|
$group = null;
|
|
|
|
|
$key = '';
|
|
|
|
|
$transaction = new FSTransaction(); // empty
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( $transaction === false ) {
|
|
|
|
|
// Fail to restore?
|
|
|
|
|
wfDebug( __METHOD__.": import to file store failed, aborting\n" );
|
|
|
|
|
throw new MWException( "Could not archive and delete file $oldpath" );
|
|
|
|
|
return false;
|
2007-03-14 15:50:06 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
wfDebug( __METHOD__.": set db items, applying file transactions\n" );
|
|
|
|
|
$transaction->commit();
|
|
|
|
|
FileStore::unlock();
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$m = explode('!',$oimage->archive_name,2);
|
|
|
|
|
$timestamp = $m[0];
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
return $timestamp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Moves an image from a safe private location
|
|
|
|
|
* Caller is responsible for clearing caches
|
|
|
|
|
* @param File $oimage
|
|
|
|
|
* @returns mixed, string timestamp on success, false on failure
|
2008-04-14 07:45:50 +00:00
|
|
|
*/
|
2008-03-21 05:09:23 +00:00
|
|
|
function makeOldImagePublic( $oimage ) {
|
|
|
|
|
$transaction = new FSTransaction();
|
|
|
|
|
if( !FileStore::lock() ) {
|
|
|
|
|
wfDebug( __METHOD__." could not acquire filestore lock\n" );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$store = FileStore::get( 'deleted' );
|
|
|
|
|
if( !$store ) {
|
|
|
|
|
wfDebug( __METHOD__.": skipping row with no file.\n" );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$key = $oimage->sha1.'.'.$oimage->getExtension();
|
|
|
|
|
$destDir = $oimage->getArchivePath();
|
|
|
|
|
if( !is_dir( $destDir ) ) {
|
|
|
|
|
wfMkdirParents( $destDir );
|
|
|
|
|
}
|
|
|
|
|
$destPath = $destDir . DIRECTORY_SEPARATOR . $oimage->archive_name;
|
|
|
|
|
// Check if any other stored revisions use this file;
|
|
|
|
|
// if so, we shouldn't remove the file from the hidden
|
|
|
|
|
// archives so they will still work. Check hidden files first.
|
|
|
|
|
$useCount = $this->dbw->selectField( 'oldimage', '1',
|
|
|
|
|
array( 'oi_sha1' => $oimage->sha1,
|
|
|
|
|
'oi_deleted & '.File::DELETED_FILE => File::DELETED_FILE ),
|
|
|
|
|
__METHOD__, array( 'FOR UPDATE' ) );
|
2008-04-14 07:45:50 +00:00
|
|
|
// Check the rest of the deleted archives too.
|
2008-03-21 05:09:23 +00:00
|
|
|
// (these are the ones that don't show in the image history)
|
|
|
|
|
if( !$useCount ) {
|
2008-04-14 07:45:50 +00:00
|
|
|
$useCount = $this->dbw->selectField( 'filearchive', '1',
|
2008-03-21 05:09:23 +00:00
|
|
|
array( 'fa_storage_group' => 'deleted', 'fa_storage_key' => $key ),
|
|
|
|
|
__METHOD__, array( 'FOR UPDATE' ) );
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
if( $useCount == 0 ) {
|
|
|
|
|
wfDebug( __METHOD__.": nothing else using {$oimage->sha1}, will deleting after\n" );
|
|
|
|
|
$flags = FileStore::DELETE_ORIGINAL;
|
|
|
|
|
} else {
|
|
|
|
|
$flags = 0;
|
2007-10-01 19:38:28 +00:00
|
|
|
}
|
2008-03-21 05:09:23 +00:00
|
|
|
$transaction->add( $store->export( $key, $destPath, $flags ) );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
wfDebug( __METHOD__.": set db items, applying file transactions\n" );
|
|
|
|
|
$transaction->commit();
|
|
|
|
|
FileStore::unlock();
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
$m = explode('!',$oimage->archive_name,2);
|
|
|
|
|
$timestamp = $m[0];
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
return $timestamp;
|
2007-03-14 15:50:06 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2006-03-16 19:04:25 +00:00
|
|
|
/**
|
|
|
|
|
* Update the revision's rev_deleted field
|
|
|
|
|
* @param Revision $rev
|
|
|
|
|
* @param int $bitfield new rev_deleted bitfield value
|
|
|
|
|
*/
|
|
|
|
|
function updateRevision( $rev, $bitfield ) {
|
2008-03-21 05:09:23 +00:00
|
|
|
$this->dbw->update( 'revision',
|
2006-03-16 19:04:25 +00:00
|
|
|
array( 'rev_deleted' => $bitfield ),
|
2008-04-04 04:15:21 +00:00
|
|
|
array( 'rev_id' => $rev->getId(),
|
|
|
|
|
'rev_page' => $rev->getPage() ),
|
2008-02-29 19:58:50 +00:00
|
|
|
__METHOD__ );
|
2006-03-16 19:04:25 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
/**
|
|
|
|
|
* Update the revision's rev_deleted field
|
|
|
|
|
* @param Revision $rev
|
2008-04-04 04:15:21 +00:00
|
|
|
* @param Title $title
|
2008-03-21 05:09:23 +00:00
|
|
|
* @param int $bitfield new rev_deleted bitfield value
|
|
|
|
|
*/
|
2008-04-04 04:15:21 +00:00
|
|
|
function updateArchive( $rev, $title, $bitfield ) {
|
2008-03-21 05:09:23 +00:00
|
|
|
$this->dbw->update( 'archive',
|
|
|
|
|
array( 'ar_deleted' => $bitfield ),
|
2008-04-04 04:15:21 +00:00
|
|
|
array( 'ar_namespace' => $title->getNamespace(),
|
|
|
|
|
'ar_title' => $title->getDBKey(),
|
|
|
|
|
'ar_timestamp' => $this->dbw->timestamp( $rev->getTimestamp() ),
|
|
|
|
|
'ar_rev_id' => $rev->getId() ),
|
2008-03-21 05:09:23 +00:00
|
|
|
__METHOD__ );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update the images's oi_deleted field
|
2008-04-04 04:15:21 +00:00
|
|
|
* @param File $file
|
2008-03-21 05:09:23 +00:00
|
|
|
* @param int $bitfield new rev_deleted bitfield value
|
|
|
|
|
*/
|
2008-04-04 04:15:21 +00:00
|
|
|
function updateOldFiles( $file, $bitfield ) {
|
2008-03-21 05:09:23 +00:00
|
|
|
$this->dbw->update( 'oldimage',
|
|
|
|
|
array( 'oi_deleted' => $bitfield ),
|
2008-04-04 04:15:21 +00:00
|
|
|
array( 'oi_name' => $file->getName(),
|
2008-04-04 16:00:57 +00:00
|
|
|
'oi_timestamp' => $this->dbw->timestamp( $file->getTimestamp() ) ),
|
2008-03-21 05:09:23 +00:00
|
|
|
__METHOD__ );
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
/**
|
|
|
|
|
* Update the images's fa_deleted field
|
|
|
|
|
* @param ArchivedFile $file
|
|
|
|
|
* @param int $bitfield new rev_deleted bitfield value
|
|
|
|
|
*/
|
|
|
|
|
function updateArchFiles( $file, $bitfield ) {
|
|
|
|
|
$this->dbw->update( 'filearchive',
|
|
|
|
|
array( 'fa_deleted' => $bitfield ),
|
2008-05-22 15:02:33 +00:00
|
|
|
array( 'fa_id' => $file->getId() ),
|
2008-03-21 05:09:23 +00:00
|
|
|
__METHOD__ );
|
2008-04-14 07:45:50 +00:00
|
|
|
}
|
|
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
/**
|
|
|
|
|
* Update the logging log_deleted field
|
|
|
|
|
* @param Row $row
|
|
|
|
|
* @param int $bitfield new rev_deleted bitfield value
|
|
|
|
|
*/
|
|
|
|
|
function updateLogs( $row, $bitfield ) {
|
|
|
|
|
$this->dbw->update( 'logging',
|
|
|
|
|
array( 'log_deleted' => $bitfield ),
|
|
|
|
|
array( 'log_id' => $row->log_id ),
|
|
|
|
|
__METHOD__ );
|
2008-04-14 07:45:50 +00:00
|
|
|
}
|
|
|
|
|
|
2006-03-16 19:04:25 +00:00
|
|
|
/**
|
|
|
|
|
* Update the revision's recentchanges record if fields have been hidden
|
|
|
|
|
* @param Revision $rev
|
|
|
|
|
* @param int $bitfield new rev_deleted bitfield value
|
|
|
|
|
*/
|
2008-03-21 05:09:23 +00:00
|
|
|
function updateRecentChangesEdits( $rev, $bitfield ) {
|
|
|
|
|
$this->dbw->update( 'recentchanges',
|
|
|
|
|
array( 'rc_deleted' => $bitfield,
|
|
|
|
|
'rc_patrolled' => 1 ),
|
2008-04-04 04:15:21 +00:00
|
|
|
array( 'rc_this_oldid' => $rev->getId(),
|
|
|
|
|
'rc_timestamp' => $this->dbw->timestamp( $rev->getTimestamp() ) ),
|
2008-03-21 05:09:23 +00:00
|
|
|
__METHOD__ );
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-21 05:09:23 +00:00
|
|
|
/**
|
|
|
|
|
* Update the revision's recentchanges record if fields have been hidden
|
|
|
|
|
* @param Row $row
|
|
|
|
|
* @param int $bitfield new rev_deleted bitfield value
|
|
|
|
|
*/
|
|
|
|
|
function updateRecentChangesLog( $row, $bitfield ) {
|
|
|
|
|
$this->dbw->update( 'recentchanges',
|
|
|
|
|
array( 'rc_deleted' => $bitfield,
|
|
|
|
|
'rc_patrolled' => 1 ),
|
2008-04-04 04:18:38 +00:00
|
|
|
array( 'rc_logid' => $row->log_id,
|
|
|
|
|
'rc_timestamp' => $row->log_timestamp ),
|
2008-02-29 19:58:50 +00:00
|
|
|
__METHOD__ );
|
2006-03-16 19:04:25 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2006-03-16 19:04:25 +00:00
|
|
|
/**
|
|
|
|
|
* Touch the page's cache invalidation timestamp; this forces cached
|
|
|
|
|
* history views to refresh, so any newly hidden or shown fields will
|
|
|
|
|
* update properly.
|
|
|
|
|
* @param Title $title
|
|
|
|
|
*/
|
|
|
|
|
function updatePage( $title ) {
|
|
|
|
|
$title->invalidateCache();
|
2008-03-21 05:09:23 +00:00
|
|
|
$title->purgeSquid();
|
2008-09-07 06:06:05 +00:00
|
|
|
$title->touchLinks();
|
2008-03-21 05:09:23 +00:00
|
|
|
// Extensions that require referencing previous revisions may need this
|
|
|
|
|
wfRunHooks( 'ArticleRevisionVisiblitySet', array( &$title ) );
|
2006-03-16 19:04:25 +00:00
|
|
|
}
|
2008-04-06 06:30:57 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks for a change in the bitfield for a certain option and updates the
|
|
|
|
|
* provided array accordingly.
|
|
|
|
|
*
|
2008-04-14 07:45:50 +00:00
|
|
|
* @param String $desc Description to add to the array if the option was
|
2008-04-06 06:30:57 +00:00
|
|
|
* enabled / disabled.
|
|
|
|
|
* @param int $field The bitmask describing the single option.
|
|
|
|
|
* @param int $diff The xor of the old and new bitfields.
|
|
|
|
|
* @param array $arr The array to update.
|
|
|
|
|
*/
|
2008-04-06 17:56:07 +00:00
|
|
|
function checkItem ( $desc, $field, $diff, $new, &$arr ) {
|
2008-04-06 06:30:57 +00:00
|
|
|
if ( $diff & $field ) {
|
|
|
|
|
$arr [ ( $new & $field ) ? 0 : 1 ][] = $desc;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets an array describing the changes made to the visibilit of the revision.
|
|
|
|
|
* If the resulting array is $arr, then $arr[0] will contain an array of strings
|
|
|
|
|
* describing the items that were hidden, $arr[2] will contain an array of strings
|
|
|
|
|
* describing the items that were unhidden, and $arr[3] will contain an array with
|
2008-04-14 07:45:50 +00:00
|
|
|
* a single string, which can be one of "applied restrictions to sysops",
|
2008-04-06 06:30:57 +00:00
|
|
|
* "removed restrictions from sysops", or null.
|
|
|
|
|
*
|
|
|
|
|
* @param int $n The new bitfield.
|
|
|
|
|
* @param int $o The old bitfield.
|
|
|
|
|
* @return An array as described above.
|
|
|
|
|
*/
|
2008-04-06 06:50:04 +00:00
|
|
|
function getChanges ( $n, $o ) {
|
2008-04-06 06:30:57 +00:00
|
|
|
$diff = $n ^ $o;
|
|
|
|
|
$ret = array ( 0 => array(), 1 => array(), 2 => array() );
|
|
|
|
|
|
2008-04-14 07:45:50 +00:00
|
|
|
$this->checkItem ( wfMsgForContent ( 'revdelete-content' ),
|
2008-04-06 21:07:40 +00:00
|
|
|
Revision::DELETED_TEXT, $diff, $n, $ret );
|
2008-04-14 07:45:50 +00:00
|
|
|
$this->checkItem ( wfMsgForContent ( 'revdelete-summary' ),
|
2008-04-06 21:07:40 +00:00
|
|
|
Revision::DELETED_COMMENT, $diff, $n, $ret );
|
2008-04-14 07:45:50 +00:00
|
|
|
$this->checkItem ( wfMsgForContent ( 'revdelete-uname' ),
|
2008-04-06 21:07:40 +00:00
|
|
|
Revision::DELETED_USER, $diff, $n, $ret );
|
2008-04-06 06:30:57 +00:00
|
|
|
|
|
|
|
|
// Restriction application to sysops
|
2008-04-06 16:33:27 +00:00
|
|
|
if ( $diff & Revision::DELETED_RESTRICTED ) {
|
|
|
|
|
if ( $n & Revision::DELETED_RESTRICTED )
|
2008-04-06 09:04:58 +00:00
|
|
|
$ret[2][] = wfMsgForContent ( 'revdelete-restricted' );
|
2008-04-06 06:30:57 +00:00
|
|
|
else
|
2008-04-06 09:04:58 +00:00
|
|
|
$ret[2][] = wfMsgForContent ( 'revdelete-unrestricted' );
|
2008-04-06 06:30:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets a log message to describe the given revision visibility change. This
|
2008-04-14 07:45:50 +00:00
|
|
|
* message will be of the form "[hid {content, edit summary, username}];
|
2008-04-06 06:30:57 +00:00
|
|
|
* [unhid {...}][applied restrictions to sysops] for $count revisions: $comment".
|
|
|
|
|
*
|
|
|
|
|
* @param int $count The number of effected revisions.
|
|
|
|
|
* @param int $nbitfield The new bitfield for the revision.
|
|
|
|
|
* @param int $obitfield The old bitfield for the revision.
|
2008-04-06 16:38:20 +00:00
|
|
|
* @param string $comment The comment associated with the change.
|
|
|
|
|
* @param bool $isForLog
|
2008-04-06 06:30:57 +00:00
|
|
|
*/
|
2008-04-06 16:38:20 +00:00
|
|
|
function getLogMessage ( $count, $nbitfield, $obitfield, $comment, $isForLog = false ) {
|
2008-04-06 09:04:58 +00:00
|
|
|
global $wgContLang;
|
2008-04-06 08:11:42 +00:00
|
|
|
|
2008-04-06 06:30:57 +00:00
|
|
|
$s = '';
|
|
|
|
|
$changes = $this->getChanges( $nbitfield, $obitfield );
|
|
|
|
|
|
|
|
|
|
if ( count ( $changes[0] ) ) {
|
2008-04-06 09:04:58 +00:00
|
|
|
$s .= wfMsgForContent ( 'revdelete-hid', implode ( ', ', $changes[0] ) );
|
2008-04-06 06:30:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( count ( $changes[1] ) ) {
|
|
|
|
|
if ($s) $s .= '; ';
|
|
|
|
|
|
2008-04-06 09:04:58 +00:00
|
|
|
$s .= wfMsgForContent ( 'revdelete-unhid', implode ( ', ', $changes[1] ) );
|
2008-04-06 06:30:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( count ( $changes[2] )) {
|
|
|
|
|
if ($s)
|
|
|
|
|
$s .= ' (' . $changes[2][0] . ')';
|
|
|
|
|
else
|
|
|
|
|
$s = $changes[2][0];
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-06 16:38:20 +00:00
|
|
|
$msg = $isForLog ? 'logdelete-log-message' : 'revdelete-log-message';
|
2008-04-14 07:45:50 +00:00
|
|
|
$ret = wfMsgExt ( $msg, array( 'parsemag', 'content' ),
|
2008-04-06 09:04:58 +00:00
|
|
|
$s, $wgContLang->formatNum( $count ) );
|
2008-04-06 07:14:30 +00:00
|
|
|
|
|
|
|
|
if ( $comment )
|
|
|
|
|
$ret .= ": $comment";
|
|
|
|
|
|
|
|
|
|
return $ret;
|
2008-04-06 06:30:57 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2006-03-16 19:04:25 +00:00
|
|
|
/**
|
|
|
|
|
* Record a log entry on the action
|
2008-03-21 05:09:23 +00:00
|
|
|
* @param Title $title, page where item was removed from
|
2006-03-16 19:04:25 +00:00
|
|
|
* @param int $count the number of revisions altered for this page
|
2008-03-21 05:09:23 +00:00
|
|
|
* @param int $nbitfield the new _deleted value
|
|
|
|
|
* @param int $obitfield the old _deleted value
|
2006-03-16 19:04:25 +00:00
|
|
|
* @param string $comment
|
2008-03-21 05:09:23 +00:00
|
|
|
* @param Title $target, the relevant page
|
|
|
|
|
* @param string $param, URL param
|
|
|
|
|
* @param Array $items
|
2006-03-16 19:04:25 +00:00
|
|
|
*/
|
2008-03-21 05:09:23 +00:00
|
|
|
function updateLog( $title, $count, $nbitfield, $obitfield, $comment, $target, $param, $items = array() ) {
|
|
|
|
|
// Put things hidden from sysops in the oversight log
|
2008-04-01 22:50:53 +00:00
|
|
|
$logtype = ( ($nbitfield | $obitfield) & Revision::DELETED_RESTRICTED ) ? 'suppress' : 'delete';
|
2008-03-21 05:09:23 +00:00
|
|
|
$log = new LogPage( $logtype );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-06 16:38:20 +00:00
|
|
|
$reason = $this->getLogMessage ( $count, $nbitfield, $obitfield, $comment, $param == 'logid' );
|
2008-04-06 06:30:57 +00:00
|
|
|
|
2008-04-06 16:38:20 +00:00
|
|
|
if( $param == 'logid' ) {
|
2008-03-21 05:09:23 +00:00
|
|
|
$params = array( implode( ',', $items) );
|
|
|
|
|
$log->addEntry( 'event', $title, $reason, $params );
|
|
|
|
|
} else {
|
|
|
|
|
// Add params for effected page and ids
|
2008-04-16 18:44:15 +00:00
|
|
|
$params = array( $param, implode( ',', $items) );
|
2008-03-21 05:09:23 +00:00
|
|
|
$log->addEntry( 'revision', $title, $reason, $params );
|
|
|
|
|
}
|
2006-03-16 19:04:25 +00:00
|
|
|
}
|
|
|
|
|
}
|