array( 'check-label' => 'revdelete-hide-text', 'deletion-bits' => Revision::DELETED_TEXT, 'success' => 'revdelete-success', 'failure' => 'revdelete-failure', 'list-class' => 'RevDel_RevisionList', ), 'archive' => array( 'check-label' => 'revdelete-hide-text', 'deletion-bits' => Revision::DELETED_TEXT, 'success' => 'revdelete-success', 'failure' => 'revdelete-failure', 'list-class' => 'RevDel_ArchiveList', ), 'oldimage'=> array( 'check-label' => 'revdelete-hide-image', 'deletion-bits' => File::DELETED_FILE, 'success' => 'revdelete-success', 'failure' => 'revdelete-failure', 'list-class' => 'RevDel_FileList', ), 'filearchive' => array( 'check-label' => 'revdelete-hide-image', 'deletion-bits' => File::DELETED_FILE, 'success' => 'revdelete-success', 'failure' => 'revdelete-failure', 'list-class' => 'RevDel_ArchivedFileList', ), 'logging' => array( 'check-label' => 'revdelete-hide-name', 'deletion-bits' => LogPage::DELETED_ACTION, 'success' => 'logdelete-success', 'failure' => 'logdelete-failure', 'list-class' => 'RevDel_LogList', ), ); /** Type map to support old log entries */ static $deprecatedTypeMap = array( 'oldid' => 'revision', 'artimestamp' => 'archive', 'oldimage' => 'oldimage', 'fileid' => 'filearchive', 'logid' => 'logging', ); public function __construct() { parent::__construct( 'Revisiondelete', 'deletedhistory' ); } public function execute( $par ) { $output = $this->getOutput(); $user = $this->getUser(); if( !$user->isAllowed( 'deletedhistory' ) ) { throw new PermissionsError( 'deletedhistory' ); } elseif( wfReadOnly() ) { throw new ReadOnlyError; } elseif( $user->isBlocked() ) { throw new UserBlockedError( $user->getBlock() ); } $this->mIsAllowed = $user->isAllowed('deleterevision'); // for changes $this->setHeaders(); $this->outputHeader(); $request = $this->getRequest(); $this->submitClicked = $request->wasPosted() && $request->getBool( 'wpSubmit' ); # Handle our many different possible input types. $ids = $request->getVal( 'ids' ); if ( !is_null( $ids ) ) { # Allow CSV, for backwards compatibility, or a single ID for show/hide links $this->ids = explode( ',', $ids ); } else { # Array input $this->ids = array_keys( $request->getArray('ids',array()) ); } // $this->ids = array_map( 'intval', $this->ids ); $this->ids = array_unique( array_filter( $this->ids ) ); if ( $request->getVal( 'action' ) == 'historysubmit' ) { // For show/hide form submission from history page // Since we are access through index.php?title=XXX&action=historysubmit // getFullTitle() will contain the target title and not our title $this->targetObj = $this->getFullTitle(); $this->typeName = 'revision'; } else { $this->typeName = $request->getVal( 'type' ); $this->targetObj = Title::newFromText( $request->getText( 'target' ) ); } # For reviewing deleted files... $this->archiveName = $request->getVal( 'file' ); $this->token = $request->getVal( 'token' ); if ( $this->archiveName && $this->targetObj ) { $this->tryShowFile( $this->archiveName ); return; } if ( isset( self::$deprecatedTypeMap[$this->typeName] ) ) { $this->typeName = self::$deprecatedTypeMap[$this->typeName]; } # No targets? if( !isset( self::$allowedTypes[$this->typeName] ) || count( $this->ids ) == 0 ) { $output->showErrorPage( 'revdelete-nooldid-title', 'revdelete-nooldid-text' ); return; } $this->typeInfo = self::$allowedTypes[$this->typeName]; # If we have revisions, get the title from the first one # since they should all be from the same page. This allows # for more flexibility with page moves... if( $this->typeName == 'revision' ) { $rev = Revision::newFromId( $this->ids[0] ); $this->targetObj = $rev ? $rev->getTitle() : $this->targetObj; } $this->otherReason = $request->getVal( 'wpReason' ); # We need a target page! if( is_null($this->targetObj) ) { $output->addWikiMsg( 'undelete-header' ); return; } # Give a link to the logs/hist for this page $this->showConvenienceLinks(); # Initialise checkboxes $this->checks = array( array( $this->typeInfo['check-label'], 'wpHidePrimary', $this->typeInfo['deletion-bits'] ), array( 'revdelete-hide-comment', 'wpHideComment', Revision::DELETED_COMMENT ), array( 'revdelete-hide-user', 'wpHideUser', Revision::DELETED_USER ) ); if( $user->isAllowed('suppressrevision') ) { $this->checks[] = array( 'revdelete-hide-restricted', 'wpHideRestricted', Revision::DELETED_RESTRICTED ); } # Either submit or create our form if( $this->mIsAllowed && $this->submitClicked ) { $this->submit( $request ); } else { $this->showForm(); } $qc = $this->getLogQueryCond(); # Show relevant lines from the deletion log $output->addHTML( "
' . $this->getLang()->pipeList( $links ) . '
' ); } } /** * Get the condition used for fetching log snippets */ protected function getLogQueryCond() { $conds = array(); // Revision delete logs for these item $conds['log_type'] = array( 'delete', 'suppress' ); $conds['log_action'] = $this->getList()->getLogAction(); $conds['ls_field'] = RevisionDeleter::getRelationType( $this->typeName ); $conds['ls_value'] = $this->ids; return $conds; } /** * Show a deleted file version requested by the visitor. * TODO Mostly copied from Special:Undelete. Refactor. */ protected function tryShowFile( $archiveName ) { $repo = RepoGroup::singleton()->getLocalRepo(); $oimage = $repo->newFromArchiveName( $this->targetObj, $archiveName ); $oimage->load(); // Check if user is allowed to see this file if ( !$oimage->exists() ) { $this->getOutput()->addWikiMsg( 'revdelete-no-file' ); return; } if( !$oimage->userCan(File::DELETED_FILE) ) { if( $oimage->isDeleted( File::DELETED_RESTRICTED ) ) { $this->getOutput()->permissionRequired( 'suppressrevision' ); } else { $this->getOutput()->permissionRequired( 'deletedtext' ); } return; } if ( !$this->getUser()->matchEditToken( $this->token, $archiveName ) ) { $this->getOutput()->addWikiMsg( 'revdelete-show-file-confirm', $this->targetObj->getText(), $this->getLang()->date( $oimage->getTimestamp() ), $this->getLang()->time( $oimage->getTimestamp() ) ); $this->getOutput()->addHTML( Xml::openElement( 'form', array( 'method' => 'POST', 'action' => $this->getTitle()->getLocalUrl( 'target=' . urlencode( $oimage->getName() ) . '&file=' . urlencode( $archiveName ) . '&token=' . urlencode( $this->getUser()->editToken( $archiveName ) ) ) ) ) . Xml::submitButton( wfMsg( 'revdelete-show-file-submit' ) ) . '' ); return; } $this->getOutput()->disable(); # 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 $this->getRequest()->response()->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', 0 ) . ' GMT' ); $this->getRequest()->response()->header( 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' ); $this->getRequest()->response()->header( 'Pragma: no-cache' ); # Stream the file to the client global $IP; require_once( "$IP/includes/StreamFile.php" ); $key = $oimage->getStorageKey(); $path = $repo->getZonePath( 'deleted' ) . '/' . $repo->getDeletedHashPath( $key ) . $key; wfStreamFile( $path ); } /** * Get the list object for this request */ protected function getList() { if ( is_null( $this->list ) ) { $class = $this->typeInfo['list-class']; $this->list = new $class( $this->getContext(), $this->targetObj, $this->ids ); } return $this->list; } /** * Show a list of items that we will operate on, and show a form with checkboxes * which will allow the user to choose new visibility settings. */ protected function showForm() { $UserAllowed = true; if ( $this->typeName == 'logging' ) { $this->getOutput()->addWikiMsg( 'logdelete-selected', $this->getLang()->formatNum( count($this->ids) ) ); } else { $this->getOutput()->addWikiMsg( 'revdelete-selected', $this->targetObj->getPrefixedText(), count( $this->ids ) ); } $this->getOutput()->addHTML( "'.wfMsgHtml('revdelete-radio-same').' | '; $html .= ''.wfMsgHtml('revdelete-radio-unset').' | '; $html .= ''.wfMsgHtml('revdelete-radio-set').' | '; $html .= "' . Xml::radio( $name, -1, $selected == -1 ) . ' | '; $line .= '' . Xml::radio( $name, 0, $selected == 0 ) . ' | '; $line .= '' . Xml::radio( $name, 1, $selected == 1 ) . ' | '; $label = wfMsgHtml($message); if( $field == Revision::DELETED_RESTRICTED ) { $label = "$label"; } $line .= "$label | "; $html .= "
---|---|---|---|