Index: branches/RL2/extensions/Gadgets/Gadgets.php |
— | — | @@ -98,6 +98,7 @@ |
99 | 99 | $wgHooks['MakeGlobalVariablesScript'][] = 'GadgetHooks::makeGlobalVariablesScript'; |
100 | 100 | $wgHooks['CanonicalNamespaces'][] = 'GadgetHooks::canonicalNamespaces'; |
101 | 101 | $wgHooks['GetPreferences'][] = 'GadgetHooks::getPreferences'; |
| 102 | +$wgHooks['UserGetDefaultOptions'][] = 'GadgetHooks::userGetDefaultOptions'; |
102 | 103 | $wgHooks['LoadExtensionSchemaUpdates'][] = 'GadgetHooks::loadExtensionSchemaUpdates'; |
103 | 104 | $wgHooks['ResourceLoaderRegisterModules'][] = 'GadgetHooks::registerModules'; |
104 | 105 | $wgHooks['TitleIsCssOrJsPage'][] = 'GadgetHooks::titleIsCssOrJsPage'; |
Index: branches/RL2/extensions/Gadgets/GadgetHooks.php |
— | — | @@ -189,6 +189,22 @@ |
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
| 193 | + * UserGetDefaultOptions hook handler |
| 194 | + * @param $defaultOptions Array of default preference keys and values |
| 195 | + */ |
| 196 | + public static function userGetDefaultOptions( &$defaultOptions ) { |
| 197 | + $repo = LocalGadgetRepo::singleton(); |
| 198 | + $gadgetIds = $repo->getGadgetIds(); |
| 199 | + foreach ( $gadgetIds as $gadgetId ) { |
| 200 | + $gadget = $repo->getGadget( $gadgetId ); |
| 201 | + if ( $gadget->isEnabledByDefault() ) { |
| 202 | + $defaultOptions['gadget-' . $gadget->getId()] = 1; |
| 203 | + } |
| 204 | + } |
| 205 | + return true; |
| 206 | + } |
| 207 | + |
| 208 | + /** |
193 | 209 | * GetPreferences hook handler. |
194 | 210 | * @param $user User |
195 | 211 | * @param $preferences Array: Preference descriptions |