From: Bartosz DziewoƄski Date: Wed, 8 Jun 2016 17:24:33 +0000 (+0200) Subject: Make it possible to disable the upload dialog functionality X-Git-Tag: 1.31.0-rc.0~6623^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=eccf8dd01e27165d44729b570e74d32159967cd8 Make it possible to disable the upload dialog functionality One can disable it by setting `$wgForeignUploadTargets = [];`. Change-Id: I2489004271078a78a1ce698304fb591196eeb941 --- diff --git a/RELEASE-NOTES-1.28 b/RELEASE-NOTES-1.28 index 0e423d296c..421def68d2 100644 --- a/RELEASE-NOTES-1.28 +++ b/RELEASE-NOTES-1.28 @@ -13,6 +13,9 @@ production. is configurable via $wgSessionPbkdf2Iterations. * Upload dialog's file upload log comment can now be configured separately for local and foreign uploads. +* $wgForeignUploadTargets now defaults to `[ 'local' ]`, where `'local'` + signifies local uploads. A value of `[]` (empty array) now means that + no upload targets are allowed, effectively disabling the upload dialog. === New features in 1.28 === * User::isBot() method for checking if an account is a bot role account. diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index dc0b60c462..0df20f2621 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -529,11 +529,12 @@ $wgUseInstantCommons = false; * Array of foreign file repo names (set in $wgForeignFileRepos above) that * are allowable upload targets. These wikis must have some method of * authentication (i.e. CentralAuth), and be CORS-enabled for this wiki. + * The string 'local' signifies the default local file repository. * * Example: * $wgForeignUploadTargets = array( 'shared' ); */ -$wgForeignUploadTargets = []; +$wgForeignUploadTargets = [ 'local' ]; /** * Configuration for file uploads using the embeddable upload dialog diff --git a/languages/i18n/en.json b/languages/i18n/en.json index f808093b00..2007717ae1 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -1514,6 +1514,7 @@ "upload-copy-upload-invalid-domain": "Copy uploads are not available from this domain.", "upload-foreign-cant-upload": "This wiki is not configured to upload files to the requested foreign file repository.", "upload-foreign-cant-load-config": "Loading file upload configuration for the foreign file repository failed.", + "upload-dialog-disabled": "File uploads using this dialog are disabled on this wiki.", "upload-dialog-title": "Upload file", "upload-dialog-button-cancel": "Cancel", "upload-dialog-button-done": "Done", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 8c11752f9b..82f10307cf 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -1695,6 +1695,7 @@ "upload-copy-upload-invalid-domain": "Error message shown if a user is trying to upload (i.e. copy) a file from a website that is not in $wgCopyUploadsDomains (if set).\n\nSee also:\n* {{msg-mw|http-invalid-url}}\n* {{msg-mw|tmp-create-error}}\n* {{msg-mw|tmp-write-error}}", "upload-foreign-cant-upload": "Error message shown when a user is trying to upload a file to foreign repository that is not configured to receive file uploads from current wiki.", "upload-foreign-cant-load-config": "Error message shown when a user is trying to upload a file to foreign repository and the foreign wiki is down or otherwise unable to respond to API requests.", + "upload-dialog-disabled": "Message shown when the upload dialog functionality is disabled. (This doesn't mean that uploads in general are disabled, only this specific method of uploading.)", "upload-dialog-title": "Title of the upload dialog box\n{{Identical|Upload file}}", "upload-dialog-button-cancel": "Button to cancel the dialog\n{{Identical|Cancel}}", "upload-dialog-button-done": "Button to close the dialog once upload is complete\n{{Identical|Done}}", diff --git a/resources/Resources.php b/resources/Resources.php index 106a83b101..6004549d98 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -1183,6 +1183,7 @@ return [ ], 'messages' => [ 'uploaddisabledtext', + 'upload-dialog-disabled', 'upload-foreign-cant-upload', ] ], diff --git a/resources/src/mediawiki/mediawiki.ForeignUpload.js b/resources/src/mediawiki/mediawiki.ForeignUpload.js index eeeab68510..781c1dfe26 100644 --- a/resources/src/mediawiki/mediawiki.ForeignUpload.js +++ b/resources/src/mediawiki/mediawiki.ForeignUpload.js @@ -43,7 +43,9 @@ // However, if the target is a remote wiki, we must check the API // to confirm that the target is one that this site is configured to // support. - if ( this.target === 'local' ) { + if ( validTargets.length === 0 ) { + this.apiPromise = $.Deferred().reject( 'upload-dialog-disabled' ); + } else if ( this.target === 'local' ) { // If local uploads were requested, but they are disabled, fail. if ( !mw.config.get( 'wgEnableUploads' ) ) { this.apiPromise = $.Deferred().reject( 'uploaddisabledtext' );