]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blobdiff - includes/specials/SpecialImport.php
MediaWiki 1.16.3
[autoinstallsdev/mediawiki.git] / includes / specials / SpecialImport.php
index 457e03b4d8634fcd4f354708b749ed91eb716bf6..248709a87c582b355f2e9e99d93bf5ca5ac30905 100644 (file)
@@ -45,7 +45,7 @@ class SpecialImport extends SpecialPage {
         * Execute
         */
        function execute( $par ) {
-               global $wgRequest;
+               global $wgRequest, $wgUser, $wgOut;
                
                $this->setHeaders();
                $this->outputHeader();
@@ -56,6 +56,28 @@ class SpecialImport extends SpecialPage {
                        return;
                }
                
+               if( !$wgUser->isAllowed( 'import' ) && !$wgUser->isAllowed( 'importupload' ) )
+                       return $wgOut->permissionRequired( 'import' );
+
+               # TODO: allow Title::getUserPermissionsErrors() to take an array
+               # FIXME: Title::checkSpecialsAndNSPermissions() has a very wierd expectation of what
+               # getUserPermissionsErrors() might actually be used for, hence the 'ns-specialprotected'
+               $errors = wfMergeErrorArrays(
+                       $this->getTitle()->getUserPermissionsErrors(
+                               'import', $wgUser, true,
+                               array( 'ns-specialprotected', 'badaccess-group0', 'badaccess-groups' )
+                       ),
+                       $this->getTitle()->getUserPermissionsErrors(
+                               'importupload', $wgUser, true,
+                               array( 'ns-specialprotected', 'badaccess-group0', 'badaccess-groups' )
+                       )
+               );
+
+               if( $errors ){
+                       $wgOut->showPermissionsErrorPage( $errors );
+                       return;
+               }
+
                if ( $wgRequest->wasPosted() && $wgRequest->getVal( 'action' ) == 'submit' ) {
                        $this->doImport();
                }
@@ -84,6 +106,9 @@ class SpecialImport extends SpecialPage {
                                return $wgOut->permissionRequired( 'importupload' );
                        }
                } elseif ( $sourceName == "interwiki" ) {
+                       if( !$wgUser->isAllowed( 'import' ) ){
+                               return $wgOut->permissionRequired( 'import' );
+                       }
                        $this->interwiki = $wgRequest->getVal( 'interwiki' );
                        if ( !in_array( $this->interwiki, $wgImportSources ) ) {
                                $source = new WikiErrorMsg( "import-invalid-interwiki" );
@@ -132,11 +157,9 @@ class SpecialImport extends SpecialPage {
        }
 
        private function showForm() {
-               global $wgUser, $wgOut, $wgRequest, $wgTitle, $wgImportSources, $wgExportMaxLinkDepth;
-               if( !$wgUser->isAllowed( 'import' ) && !$wgUser->isAllowed( 'importupload' ) )
-                       return $wgOut->permissionRequired( 'import' );
+               global $wgUser, $wgOut, $wgRequest, $wgImportSources, $wgExportMaxLinkDepth;
 
-               $action = $wgTitle->getLocalUrl( 'action=submit' );
+               $action = $this->getTitle()->getLocalUrl( array( 'action' => 'submit' ) );
 
                if( $wgUser->isAllowed( 'importupload' ) ) {
                        $wgOut->addWikiMsg( "importtext" );
@@ -273,7 +296,7 @@ class SpecialImport extends SpecialPage {
  * @ingroup SpecialPage
  */
 class ImportReporter {
-      private $reason=false;
+       private $reason=false;
 
        function __construct( $importer, $upload, $interwiki , $reason=false ) {
                $importer->setPageOutCallback( array( $this, 'reportPage' ) );
@@ -299,7 +322,7 @@ class ImportReporter {
                $contentCount = $wgContLang->formatNum( $successCount );
 
                if( $successCount > 0 ) {
-                       $wgOut->addHTML( "<li>" . $skin->makeKnownLinkObj( $title ) . " " .
+                       $wgOut->addHTML( "<li>" . $skin->linkKnown( $title ) . " " .
                                wfMsgExt( 'import-revision-count', array( 'parsemag', 'escape' ), $localCount ) .
                                "</li>\n"
                        );
@@ -309,7 +332,7 @@ class ImportReporter {
                                $detail = wfMsgExt( 'import-logentry-upload-detail', array( 'content', 'parsemag' ),
                                        $contentCount );
                                if ( $this->reason ) {
-                                       $detail .=  wfMsgForContent( 'colon-separator' ) . $this->reason;
+                                       $detail .=  wfMsgForContent( 'colon-separator' ) . $this->reason;
                                }
                                $log->addEntry( 'upload', $title, $detail );
                        } else {
@@ -318,7 +341,7 @@ class ImportReporter {
                                $detail = wfMsgExt( 'import-logentry-interwiki-detail', array( 'content', 'parsemag' ),
                                        $contentCount, $interwiki );
                                if ( $this->reason ) {
-                                       $detail .=  wfMsgForContent( 'colon-separator' ) . $this->reason;
+                                       $detail .=  wfMsgForContent( 'colon-separator' ) . $this->reason;
                                }
                                $log->addEntry( 'interwiki', $title, $detail );
                        }
@@ -333,7 +356,8 @@ class ImportReporter {
                        $article->updateRevisionOn( $dbw, $nullRevision );
                        wfRunHooks( 'NewRevisionFromEditComplete', array($article, $nullRevision, $latest, $wgUser) );
                } else {
-                       $wgOut->addHTML( '<li>' . wfMsgHtml( 'import-nonewrevisions' ) . '</li>' );
+                       $wgOut->addHTML( "<li>" . $skin->linkKnown( $title ) . " " .
+                               wfMsgHtml( 'import-nonewrevisions' ) . "</li>\n" );
                }
        }