r76090 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76089‎ | r76090 | r76091 >
Date:13:25, 5 November 2010
Author:maxsem
Status:deferred (Comments)
Tags:
Comment:
Moved prefs check to Gadget class
Modified paths:
  • /branches/Gadgets-work/Gadgets_body.php (modified) (history)

Diff [purge]

Index: branches/Gadgets-work/Gadgets_body.php
@@ -126,8 +126,7 @@
127127 $pages = array();
128128
129129 foreach ( $gadgets as $gadget ) {
130 - $tname = 'gadget-' . $gadget->getName();
131 - if ( $wgUser->getOption( $tname ) ) {
 130+ if ( $gadget->isEnabled() ) {
132131 if ( $gadget->hasModule() ) {
133132 $out->addModules( $gadget->getModuleName() );
134133 }
@@ -234,6 +233,14 @@
235234 }
236235
237236 /**
 237+ * @return Boolean: Whether this gadget is enabled for current user
 238+ */
 239+ public function isEnabled() {
 240+ global $wgUser;
 241+ return (bool)$wgUser->getOption( "gadget-{$this->name}" );
 242+ }
 243+
 244+ /**
238245 * @return Boolean: Whether all of this gadget's JS components support ResourceLoader
239246 */
240247 public function supportsResourceLoader() {

Comments

#Comment by Nikerabbit (talk | contribs)   15:19, 5 November 2010

Could we pass the user as a parameter instead of using the global?

Status & tagging log