mediawiki.Upload.BookletLayout: If the user can't upload, don't show them the form
authorBartosz Dziewoński <matma.rex@gmail.com>
Thu, 22 Oct 2015 19:25:32 +0000 (21:25 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Thu, 22 Oct 2015 20:17:03 +0000 (22:17 +0200)
To improve in the future:
* Check the rights on the target wiki rather than current, they might
  not be the same
* Use a better error message when not all logged-in users can upload

Bug: T115866
Change-Id: I6f68122b5399f4b8766825c752e964478ae7563d

resources/Resources.php
resources/src/mediawiki/mediawiki.Upload.BookletLayout.js

index 59ce155..3a6a3b5 100644 (file)
@@ -1171,6 +1171,7 @@ return array(
                ),
                'dependencies' => array(
                        'oojs-ui',
+                       'mediawiki.user',
                        'mediawiki.Upload',
                        'mediawiki.jqueryMsg',
                ),
index dd199ce..0a1121b 100644 (file)
                                content: [ this.insertForm ]
                        } )
                ] );
+
+               // If the user can't upload anything, don't give them the option to
+               // TODO Check the rights on the target wiki rather than current, they might not be the same
+               mw.user.getRights().done( function ( rights ) {
+                       if ( rights.indexOf( 'upload' ) === -1 ) {
+                               this.getPage( 'upload' ).$element
+                                       .empty()
+                                       // TODO Use a better error message when not all logged-in users can upload
+                                       .msg( 'api-error-mustbeloggedin' );
+                       }
+               }.bind( this ) );
        };
 
        /* Setup */