Do not allow a user to delete a page they can't edit
[lhc/web/wiklou.git] / includes / api / ApiUpload.php
index 49306d7..2b840fe 100644 (file)
@@ -34,8 +34,6 @@ class ApiUpload extends ApiBase {
        protected $mParams;
 
        public function execute() {
-               global $wgEnableAsyncUploads;
-
                // Check whether upload is enabled
                if ( !UploadBase::isEnabled() ) {
                        $this->dieUsageMsg( 'uploaddisabled' );
@@ -47,7 +45,7 @@ class ApiUpload extends ApiBase {
                $this->mParams = $this->extractRequestParams();
                $request = $this->getMain()->getRequest();
                // Check if async mode is actually supported (jobs done in cli mode)
-               $this->mParams['async'] = ( $this->mParams['async'] && $wgEnableAsyncUploads );
+               $this->mParams['async'] = ( $this->mParams['async'] && $this->getConfig()->get( 'EnableAsyncUploads' ) );
                // Add the uploaded file to the params array
                $this->mParams['file'] = $request->getFileName( 'file' );
                $this->mParams['chunk'] = $request->getFileName( 'chunk' );
@@ -471,8 +469,6 @@ class ApiUpload extends ApiBase {
         * Performs file verification, dies on error.
         */
        protected function checkVerification( array $verification ) {
-               global $wgFileExtensions;
-
                // @todo Move them to ApiBase's message map
                switch ( $verification['status'] ) {
                        // Recoverable errors
@@ -504,7 +500,7 @@ class ApiUpload extends ApiBase {
                        case UploadBase::FILETYPE_BADTYPE:
                                $extradata = array(
                                        'filetype' => $verification['finalExt'],
-                                       'allowed' => array_values( array_unique( $wgFileExtensions ) )
+                                       'allowed' => array_values( array_unique( $this->getConfig()->get( 'FileExtensions' ) ) )
                                );
                                $this->getResult()->setIndexedTagName( $extradata['allowed'], 'ext' );
 
@@ -666,8 +662,7 @@ class ApiUpload extends ApiBase {
         * Checks if asynchronous copy uploads are enabled and throws an error if they are not.
         */
        protected function checkAsyncDownloadEnabled() {
-               global $wgAllowAsyncCopyUploads;
-               if ( !$wgAllowAsyncCopyUploads ) {
+               if ( !$this->getConfig()->get( 'AllowAsyncCopyUploads' ) ) {
                        $this->dieUsage( 'Asynchronous copy uploads disabled', 'asynccopyuploaddisabled' );
                }
        }
@@ -765,41 +760,6 @@ class ApiUpload extends ApiBase {
                return $params;
        }
 
-       public function getResultProperties() {
-               return array(
-                       '' => array(
-                               'result' => array(
-                                       ApiBase::PROP_TYPE => array(
-                                               'Success',
-                                               'Warning',
-                                               'Continue',
-                                               'Queued'
-                                       ),
-                               ),
-                               'filekey' => array(
-                                       ApiBase::PROP_TYPE => 'string',
-                                       ApiBase::PROP_NULLABLE => true
-                               ),
-                               'sessionkey' => array(
-                                       ApiBase::PROP_TYPE => 'string',
-                                       ApiBase::PROP_NULLABLE => true
-                               ),
-                               'offset' => array(
-                                       ApiBase::PROP_TYPE => 'integer',
-                                       ApiBase::PROP_NULLABLE => true
-                               ),
-                               'statuskey' => array(
-                                       ApiBase::PROP_TYPE => 'string',
-                                       ApiBase::PROP_NULLABLE => true
-                               ),
-                               'filename' => array(
-                                       ApiBase::PROP_TYPE => 'string',
-                                       ApiBase::PROP_NULLABLE => true
-                               )
-                       )
-               );
-       }
-
        public function getDescription() {
                return array(
                        'Upload a file, or get the status of pending uploads. Several methods are available:',
@@ -811,32 +771,6 @@ class ApiUpload extends ApiBase {
                );
        }
 
-       public function getPossibleErrors() {
-               return array_merge( parent::getPossibleErrors(),
-                       $this->getRequireOnlyOneParameterErrorMessages( array( 'filekey', 'file', 'url', 'statuskey' ) ),
-                       array(
-                               array( 'uploaddisabled' ),
-                               array( 'invalid-file-key' ),
-                               array( 'uploaddisabled' ),
-                               array( 'mustbeloggedin', 'upload' ),
-                               array( 'badaccess-groups' ),
-                               array( 'code' => 'fetchfileerror', 'info' => '' ),
-                               array( 'code' => 'nomodule', 'info' => 'No upload module set' ),
-                               array( 'code' => 'empty-file', 'info' => 'The file you submitted was empty' ),
-                               array( 'code' => 'filetype-missing', 'info' => 'The file is missing an extension' ),
-                               array( 'code' => 'filename-tooshort', 'info' => 'The filename is too short' ),
-                               array( 'code' => 'overwrite', 'info' => 'Overwriting an existing file is not allowed' ),
-                               array( 'code' => 'stashfailed', 'info' => 'Stashing temporary file failed' ),
-                               array( 'code' => 'publishfailed', 'info' => 'Publishing of stashed file failed' ),
-                               array( 'code' => 'internal-error', 'info' => 'An internal error occurred' ),
-                               array( 'code' => 'asynccopyuploaddisabled', 'info' => 'Asynchronous copy uploads disabled' ),
-                               array( 'code' => 'stasherror', 'info' => 'An upload stash error occurred' ),
-                               array( 'fileexists-forbidden' ),
-                               array( 'fileexists-shared-forbidden' ),
-                       )
-               );
-       }
-
        public function needsToken() {
                return true;
        }