Ori.livneh has uploaded a new change for review.
https://gerrit.wikimedia.org/r/51081
Change subject: Expose additional user attributes as JS vars
......................................................................
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
---
M includes/OutputPage.php
1 file changed, 9 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/81/51081/1
diff --git a/includes/OutputPage.php b/includes/OutputPage.php
index f719421..d612f70 100644
--- a/includes/OutputPage.php
+++ b/includes/OutputPage.php
@@ -3002,6 +3002,8 @@
implode( "\t", $digitTransTable ),
);
+ $user = $this->getUser();
+
$vars = array(
'wgCanonicalNamespace' => $nsname,
'wgCanonicalSpecialPageName' => $canonicalName,
@@ -3012,8 +3014,7 @@
'wgArticleId' => $pageID,
'wgIsArticle' => $this->isArticle(),
'wgAction' => Action::getActionName(
$this->getContext() ),
- 'wgUserName' => $this->getUser()->isAnon() ? null :
$this->getUser()->getName(),
- 'wgUserGroups' =>
$this->getUser()->getEffectiveGroups(),
+ 'wgUserGroups' => $user->getEffectiveGroups(),
'wgCategories' => $this->getCategories(),
'wgBreakFrames' => $this->getFrameOptions() == 'DENY',
'wgPageContentLanguage' => $lang->getCode(),
@@ -3024,6 +3025,12 @@
'wgMonthNamesShort' =>
$lang->getMonthAbbreviationsArray(),
'wgRelevantPageName' =>
$relevantTitle->getPrefixedDBKey(),
);
+ if ( $user->isLoggedIn() ) {
+ $vars['wgUserName'] = $user->getName();
+ $vars['wgUserId'] = $user->getId();
+ $vars['wgEditCount'] = $user->getEditCount();
+ $vars['wgRegistration'] = $user->getRegistration();
+ }
if ( $wgContLang->hasVariants() ) {
$vars['wgUserVariant'] =
$wgContLang->getPreferredVariant();
}
--
To view, visit https://gerrit.wikimedia.org/r/51081
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id0adb795567d4ba932104938f2793cdb4084883c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits