From: Ori Livneh Date: Tue, 22 Jan 2013 22:44:22 +0000 (-0800) Subject: Expose additional user attributes as JS vars X-Git-Tag: 1.31.0-rc.0~20550^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/bilan.php?a=commitdiff_plain;h=559cc276e71be0e3a2594e6153d4ffef2c09d144;p=lhc%2Fweb%2Fwiklou.git Expose additional user attributes as JS vars This change adds user ID, registration time, and edit count to the default set of JavaScript configuration variables. These values are all included in $mCacheVars and so require no additional database lookups. Change-Id: Id0adb795567d4ba932104938f2793cdb4084883c --- diff --git a/includes/OutputPage.php b/includes/OutputPage.php index f71942163d..525fc24b7a 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -3002,6 +3002,8 @@ $templates implode( "\t", $digitTransTable ), ); + $user = $this->getUser(); + $vars = array( 'wgCanonicalNamespace' => $nsname, 'wgCanonicalSpecialPageName' => $canonicalName, @@ -3012,8 +3014,8 @@ $templates 'wgArticleId' => $pageID, 'wgIsArticle' => $this->isArticle(), 'wgAction' => Action::getActionName( $this->getContext() ), - 'wgUserName' => $this->getUser()->isAnon() ? null : $this->getUser()->getName(), - 'wgUserGroups' => $this->getUser()->getEffectiveGroups(), + 'wgUserName' => $user->isAnon() ? null : $user->getName(), + 'wgUserGroups' => $user->getEffectiveGroups(), 'wgCategories' => $this->getCategories(), 'wgBreakFrames' => $this->getFrameOptions() == 'DENY', 'wgPageContentLanguage' => $lang->getCode(), @@ -3024,6 +3026,11 @@ $templates 'wgMonthNamesShort' => $lang->getMonthAbbreviationsArray(), 'wgRelevantPageName' => $relevantTitle->getPrefixedDBKey(), ); + if ( $user->isLoggedIn() ) { + $vars['wgUserId'] = $user->getId(); + $vars['wgUserEditCount'] = $user->getEditCount(); + $vars['wgUserRegistration'] = $user->getRegistration(); + } if ( $wgContLang->hasVariants() ) { $vars['wgUserVariant'] = $wgContLang->getPreferredVariant(); }