Add global 'withgadget' query parameter for ad-hoc loading of gadgets

When viewing pages, the 'withgadget=' query parameter can be used in
the URL to load a gadget that isn't enabled by the user's preferences.

The gadget is only loaded if all other conditions are still satisfied
(supported skin, supported targets, required user rights).

Bug: T29766
Change-Id: I5b30d4e0010561685eef661a515e2892045bb776
This commit is contained in:
Siddharth VP 2021-10-14 10:16:01 +05:30 committed by Krinkle
parent 32677ff590
commit 14af941e88

View file

@ -172,6 +172,7 @@ class GadgetHooks {
$lb = new LinkBatch();
$lb->setCaller( __METHOD__ );
$enabledLegacyGadgets = [];
$req = $out->getRequest();
/**
* @var $gadget Gadget
@ -192,7 +193,7 @@ class GadgetHooks {
// @todo: Emit warning for invalid peer?
}
}
if ( $gadget->isEnabled( $user )
if ( ( $gadget->isEnabled( $user ) || $req->getRawVal( 'withgadget' ) === $id )
&& $gadget->isAllowed( $user )
&& $gadget->isSkinSupported( $out->getSkin() )
&& ( in_array( $out->getTarget() ?? 'desktop', $gadget->getTargets() ) )