diff --git a/htdocs/js/loris.js b/htdocs/js/loris.js index b0ddcf438b2..a882209c1a4 100644 --- a/htdocs/js/loris.js +++ b/htdocs/js/loris.js @@ -1,6 +1,6 @@ /* exported LorisHelper */ -let LorisHelper = function(configParams, userPerms, studyParams) { +let LorisHelper = function(user, configParams, userPerms, studyParams) { 'use strict'; let lorisObj = configParams; @@ -73,5 +73,7 @@ let LorisHelper = function(configParams, userPerms, studyParams) { return studyParams[param]; }; + lorisObj.user = user; + return lorisObj; }; diff --git a/smarty/templates/main.tpl b/smarty/templates/main.tpl index 7ad1025227b..323deca0e32 100644 --- a/smarty/templates/main.tpl +++ b/smarty/templates/main.tpl @@ -13,7 +13,7 @@ and can access them through the loris global (ie. loris.BaseURL) *} {section name=jsfile loop=$jsfiles} diff --git a/src/Middleware/UserPageDecorationMiddleware.php b/src/Middleware/UserPageDecorationMiddleware.php index 09fc7a1cf43..567e913b2ac 100644 --- a/src/Middleware/UserPageDecorationMiddleware.php +++ b/src/Middleware/UserPageDecorationMiddleware.php @@ -221,7 +221,12 @@ function ($a, $b) { // Do not show menu item if module not active $tpl_data['my_preferences'] = $loris->hasModule('my_preferences'); - + $tpl_data['userjson'] = json_encode( + [ + 'username' => $user->getUsername(), + 'id' => $user->getId(), + ] + ); // Display the footer links, as specified in the config file $links = $this->Config->getExternalLinks('FooterLink');