Use protocol-relative URL for link to MediaWiki.org (as with the footer logo on each...
[lhc/web/wiklou.git] / includes / specials / SpecialRevisiondelete.php
index 90a2030..dce79d3 100644 (file)
@@ -111,17 +111,12 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
        }
 
        public function execute( $par ) {
+               $this->checkPermissions();
+               $this->checkReadOnly();
+
                $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();
@@ -208,12 +203,12 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                # Show relevant lines from the deletion log
                $output->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'delete' ) ) . "</h2>\n" );
                LogEventsList::showLogExtract( $output, 'delete',
-                       $this->targetObj->getPrefixedText(), '', array( 'lim' => 25, 'conds' => $qc ) );
+                       $this->targetObj, '', array( 'lim' => 25, 'conds' => $qc ) );
                # Show relevant lines from the suppression log
                if( $user->isAllowed( 'suppressionlog' ) ) {
                        $output->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'suppress' ) ) . "</h2>\n" );
                        LogEventsList::showLogExtract( $output, 'suppress',
-                               $this->targetObj->getPrefixedText(), '', array( 'lim' => 25, 'conds' => $qc ) );
+                               $this->targetObj, '', array( 'lim' => 25, 'conds' => $qc ) );
                }
        }
 
@@ -230,7 +225,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                                array(),
                                array( 'page' => $this->targetObj->getPrefixedText() )
                        );
-                       if ( $this->targetObj->getNamespace() != NS_SPECIAL ) {
+                       if ( !$this->targetObj->isSpecialPage() ) {
                                # Give a link to the page history
                                $links[] = Linker::linkKnown(
                                        $this->targetObj,
@@ -250,7 +245,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                                }
                        }
                        # Logs themselves don't have histories or archived revisions
-                       $this->getOutput()->setSubtitle( '<p>' . $this->getLang()->pipeList( $links ) . '</p>' );
+                       $this->getOutput()->addSubtitle( $this->getLanguage()->pipeList( $links ) );
                }
        }
 
@@ -280,7 +275,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                        $this->getOutput()->addWikiMsg( 'revdelete-no-file' );
                        return;
                }
-               if( !$oimage->userCan(File::DELETED_FILE) ) {
+               if( !$oimage->userCan( File::DELETED_FILE, $this->getUser() ) ) {
                        if( $oimage->isDeleted( File::DELETED_RESTRICTED ) ) {
                                $this->getOutput()->permissionRequired( 'suppressrevision' );
                        } else {
@@ -291,15 +286,15 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                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->getLanguage()->date( $oimage->getTimestamp() ),
+                               $this->getLanguage()->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 ) ) )
+                                               '&token=' . urlencode( $this->getUser()->getEditToken( $archiveName ) ) )
                                        )
                                ) .
                                Xml::submitButton( wfMsg( 'revdelete-show-file-submit' ) ) .
@@ -316,12 +311,9 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                $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 );
+               StreamFile::stream( $path );
        }
 
        /**
@@ -343,7 +335,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                $UserAllowed = true;
 
                if ( $this->typeName == 'logging' ) {
-                       $this->getOutput()->addWikiMsg( 'logdelete-selected', $this->getLang()->formatNum( count($this->ids) ) );
+                       $this->getOutput()->addWikiMsg( 'logdelete-selected', $this->getLanguage()->formatNum( count($this->ids) ) );
                } else {
                        $this->getOutput()->addWikiMsg( 'revdelete-selected',
                                $this->targetObj->getPrefixedText(), count( $this->ids ) );
@@ -412,7 +404,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                                        '</td>' .
                                "</tr>\n" .
                                Xml::closeElement( 'table' ) .
-                               Html::hidden( 'wpEditToken', $this->getUser()->editToken() ) .
+                               Html::hidden( 'wpEditToken', $this->getUser()->getEditToken() ) .
                                Html::hidden( 'target', $this->targetObj->getPrefixedText() ) .
                                Html::hidden( 'type', $this->typeName ) .
                                Html::hidden( 'ids', implode( ',', $this->ids ) ) .
@@ -543,7 +535,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
         * Report that the submit operation succeeded
         */
        protected function success() {
-               $this->getOutput()->setPagetitle( wfMsg( 'actioncomplete' ) );
+               $this->getOutput()->setPageTitle( $this->msg( 'actioncomplete' ) );
                $this->getOutput()->wrapWikiMsg( "<span class=\"success\">\n$1\n</span>", $this->typeInfo['success'] );
                $this->list->reloadFromMaster();
                $this->showForm();
@@ -553,7 +545,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
         * Report that the submit operation failed
         */
        protected function failure( $status ) {
-               $this->getOutput()->setPagetitle( wfMsg( 'actionfailed' ) );
+               $this->getOutput()->setPageTitle( $this->msg( 'actionfailed' ) );
                $this->getOutput()->addWikiText( $status->getWikiText( $this->typeInfo['failure'] ) );
                $this->showForm();
        }