Last modified: 2011-05-15 09:57:08 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T14211, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 12211 - Show some gadgets only for admins
Show some gadgets only for admins
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
Gadgets (Other open bugs)
unspecified
All All
: Normal enhancement with 3 votes (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch
Depends on:
Blocks: 13742
  Show dependency treegraph
 
Reported: 2007-12-05 12:28 UTC by Rémi Kaupp
Modified: 2011-05-15 09:57 UTC (History)
7 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Proposed patch, also implements bug 13742 (8.70 KB, patch)
2008-07-04 21:31 UTC, Max Semenik
Details

Description Rémi Kaupp 2007-12-05 12:28:03 UTC
In the Gadgets extension, it would be useful to keep some gadgets for admins only. I mean that a dedicated section could show up only for admins and not for regular users, as it may contain gadgets useless for normal users or potentially harmful if used by them. Thanks.
Comment 1 Brion Vibber 2007-12-06 19:18:54 UTC
That seems kind of creepy... SECRET GADGETS OMFG :)
Comment 2 Rémi Kaupp 2007-12-06 21:06:38 UTC
Well, just like some special pages show up only for the caba(ahem) admins...
Comment 3 Daniel Kinzler 2007-12-06 21:10:53 UTC
I have been thinking about that before, but i'm not quite sure how to do it. 
First question: should sections be hidden/shown based on groups, or based on permissions? Seconds question: what would be a good syntax to specify the required group/permission on the MediaWiki:Gadgets-definition page? Using some magic syntax there sucks as it is... but until now, it's pretty close to normal wikitext. No sure how to integrate this. Any suggestions?

Anyway, I don't have much time for this stuff right now - nudge me in a couple of months, or find someone else to do it :)
Comment 4 Brion Vibber 2007-12-07 15:33:43 UTC
You should use permission keys, not groups directly, for this sort of thing. I'd also recommend indicating in the list which ones are restricted, as is doen on Special:Specialpages.
Comment 5 Max Semenik 2008-07-04 21:31:44 UTC
Created attachment 5049 [details]
Proposed patch, also implements bug 13742
Comment 6 Victor Vasiliev 2008-07-07 17:20:55 UTC
Fixed in r37263.
Comment 7 Max Semenik 2008-07-07 19:05:33 UTC
Reverted by Brion in r32278.
Comment 8 Max Semenik 2008-07-07 19:14:04 UTC
r37278, I mean
Comment 9 Siebrand Mazeland 2008-08-18 21:42:33 UTC
By brion in r37278:

Revert r37263 for now:
	* (bug 12211) Show some gadgets only for admins
	* (bug 13742) Allow for gadgets to be turned on by default

I'm a bit leery of the 'on by default' entirely at the moment. :)

A few comments:
* The readme examples don't seem to clearly show the option format
* Why are numeric constants being used as indexes to the option array? Strings are easier to work with and debug.
* There's a lot of stuff like this which feels very ugly:
	if( isset( $gadget->options[Gadget::RIGHTS] ) && !empty( $gadget->options[Gadget::RIGHTS] ) ) {
  Since it's all hard-coded anyway, why not just do something nice and clear like this?
	if( !empty( $gadget->rights ) ) {
* And this:
    if( wfGadgetAllowed( $gadget->options ) ) {
  to:
    if( $gadget->isAllowed() ) {

Please provide a patch that addresses the above concerns.
Comment 10 Mike.lifeguard 2008-11-22 19:08:43 UTC
(In reply to comment #9)
> By brion in r37278:
> I'm a bit leery of the 'on by default' entirely at the moment. :)
> 

You can do things like

var gadget_removeimagetools = 1;

in a gadget. And then check

if(typeof gadget_removeimagetools == 'undefined') gadget_removeimagetools = 0;
if(gadget_removeimagetools != 1) addOnloadHook(add_all_user_tools);

in Common.js or whatever. This lets you disable parts of the common site js.

That can be used as a workaround if that sort of thing can't be done in the php nicely. Though, I doubt Brion would be any less "leery" of this technique.
Comment 11 Max Semenik 2011-04-03 19:02:31 UTC
Done in r85268.
Comment 12 Ryan Kaldari 2011-04-04 18:13:29 UTC
So if this is fixed now, what is the mechanism for designating a gadget so that it is only shown to admins?
Comment 13 Max Semenik 2011-04-04 19:28:38 UTC
Not admins, it can require any user right.
Example: * GadgetName [rights=block] | ....
I've expanded the docs at http://www.mediawiki.org/wiki/Extension:Gadgets#Options now.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links