Make it possible to disable the upload dialog functionality
authorBartosz Dziewoński <matma.rex@gmail.com>
Wed, 8 Jun 2016 17:24:33 +0000 (19:24 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Mon, 13 Jun 2016 21:00:27 +0000 (23:00 +0200)
One can disable it by setting `$wgForeignUploadTargets = [];`.

Change-Id: I2489004271078a78a1ce698304fb591196eeb941

RELEASE-NOTES-1.28
includes/DefaultSettings.php
languages/i18n/en.json
languages/i18n/qqq.json
resources/Resources.php
resources/src/mediawiki/mediawiki.ForeignUpload.js

index 0e423d2..421def6 100644 (file)
@@ -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.
   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.
 
 === New features in 1.28 ===
 * User::isBot() method for checking if an account is a bot role account.
index dc0b60c..0df20f2 100644 (file)
@@ -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.
  * 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' );
  */
  *
  * Example:
  * $wgForeignUploadTargets = array( 'shared' );
  */
-$wgForeignUploadTargets = [];
+$wgForeignUploadTargets = [ 'local' ];
 
 /**
  * Configuration for file uploads using the embeddable upload dialog
 
 /**
  * Configuration for file uploads using the embeddable upload dialog
index f808093..2007717 100644 (file)
        "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-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",
        "upload-dialog-title": "Upload file",
        "upload-dialog-button-cancel": "Cancel",
        "upload-dialog-button-done": "Done",
index 8c11752..82f1030 100644 (file)
        "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-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}}",
        "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}}",
index 106a83b..6004549 100644 (file)
@@ -1183,6 +1183,7 @@ return [
                ],
                'messages' => [
                        'uploaddisabledtext',
                ],
                'messages' => [
                        'uploaddisabledtext',
+                       'upload-dialog-disabled',
                        'upload-foreign-cant-upload',
                ]
        ],
                        'upload-foreign-cant-upload',
                ]
        ],
index eeeab68..781c1df 100644 (file)
@@ -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.
                // 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' );
                        // If local uploads were requested, but they are disabled, fail.
                        if ( !mw.config.get( 'wgEnableUploads' ) ) {
                                this.apiPromise = $.Deferred().reject( 'uploaddisabledtext' );