Skip to content

Commit

Permalink
Feature: Show the logged-in user's full name in the user menu, resolves
Browse files Browse the repository at this point in the history
  • Loading branch information
abias authored Mar 19, 2024
1 parent 847afbb commit 5cf2382
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Changes

### Unreleased

* 2024-03-16 - Feature: Show the logged-in user's full name in the user menu, resolves #439.
* 2024-03-16 - Bugfix: Leave the last item's link in the breadcrumb only if it's really needed, resolves #595

### v4.3-r9
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@ With this setting, you can set an alternative link URL which will be used as lin

##### User menu

###### Show full name in the user menu

With this setting, you can show the logged-in user's full name at the top of the user menu. This can be especially helpful for exam situations where teachers have to confirm that the user is logged in with his own account, but it might also be helpful for the user himself. In contrast to the Classic theme which shows the user's full name in the navbar near the avatar, this approach here does not claim any additional rare space in the navbar.

###### Add preferred language link to language menu

With this setting, you can add a 'Set preferred language' setting to the language menu within the user menu. Understandably, this setting is only processed if the language menu is enabled at all.
Expand Down
4 changes: 4 additions & 0 deletions lang/en/theme_boost_union.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,10 @@

// ... Section: User menu.
$string['usermenuheading'] = 'User menu';
// ... ... Settings: Show full name in the user menu.
$string['showfullnameinusermenussetting'] = 'Show full name in the user menu';
$string['showfullnameinusermenussetting_desc'] = 'With this setting, you can show the logged-in user\'s full name at the top of the user menu. This can be especially helpful for exam situations where teachers have to confirm that the user is logged in with his own account, but it might also be helpful for the user himself. In contrast to the Classic theme which shows the user\'s full name in the navbar near the avatar, this approach here does not claim any additional rare space in the navbar.';
$string['showfullnameinusermenussetting_loggedinas'] = 'You are logged in as:';
// ... ... Settings: Add preferred language link to language menu.
$string['addpreferredlangsetting'] = 'Add preferred language link to language menu';
$string['addpreferredlangsetting_desc'] = 'With this setting, you can add a \'Set preferred language\' setting to the language menu within the user menu. Understandably, this setting is only processed if the setting <a href="{$a->url1}">Display language menu</a> is enabled, and if at least <a href="{$a->url2}">a second language pack is installed</a> and <a href="{$a->url3}">offered for selection</a>.';
Expand Down
2 changes: 1 addition & 1 deletion layout/columns2.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
// Include the template content for the info banners.
require_once(__DIR__ . '/includes/infobanners.php');

// Include the template content for the navbar styling.
// Include the template content for the navbar.
require_once(__DIR__ . '/includes/navbar.php');

// Include the template content for the smart menus.
Expand Down
2 changes: 1 addition & 1 deletion layout/drawers.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
// Include the template content for the info banners.
require_once(__DIR__ . '/includes/infobanners.php');

// Include the template content for the navbar styling.
// Include the template content for the navbar.
require_once(__DIR__ . '/includes/navbar.php');

// Include the template content for the advertisement tiles, but only if we are on the frontpage.
Expand Down
7 changes: 7 additions & 0 deletions layout/includes/navbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,10 @@
// Add the logo link URL to templatecontext.
$templatecontext['alternativelogolinkurl'] = $alternativelogolinkurlsetting;
}

// If showing the user name in the user menu is activated.
$showfullnameinusermenusetting = get_config('theme_boost_union', 'showfullnameinusermenu');
if ($showfullnameinusermenusetting == THEME_BOOST_UNION_SETTING_SELECT_YES) {
// Set a flag in the templatecontext.
$templatecontext['showfullnameinusermenu'] = true;
}
8 changes: 8 additions & 0 deletions scss/boost_union/post.scss
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,14 @@ body.hascourseindexcplsol.editing {
* Settings: Feel -> Navigation.
======================================*/

/*---------------------------------------
* Setting: Show full name in the user menu.
--------------------------------------*/

#user-action-menu .loggedinas {
padding: .25rem 1.75rem .25rem .75rem;
}

/*---------------------------------------
* Setting: Add preferred language link to language menu.
--------------------------------------*/
Expand Down
7 changes: 7 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -1246,6 +1246,13 @@
$setting = new admin_setting_heading($name, $title, null);
$tab->add($setting);

// Setting: Show full name in the user menu.
$name = 'theme_boost_union/showfullnameinusermenu';
$title = get_string('showfullnameinusermenussetting', 'theme_boost_union', null, true);
$description = get_string('showfullnameinusermenussetting_desc', 'theme_boost_union', null, true);
$setting = new admin_setting_configselect($name, $title, $description, THEME_BOOST_UNION_SETTING_SELECT_NO, $yesnooption);
$tab->add($setting);

// Setting: Add preferred language link to language menu.
$name = 'theme_boost_union/addpreferredlang';
$title = get_string('addpreferredlangsetting', 'theme_boost_union', null, true);
Expand Down
11 changes: 10 additions & 1 deletion templates/core/user_menu.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"title": "Submenu title",
"items": []
}
]
],
"showfullnameinusermenu": true
}
}}
{{!
Expand All @@ -58,6 +59,7 @@
Modifications compared to the original template:
* Include submenus custom return id, helps to get back to the submenus parent from third level child.
* Add icon support to items.
* Add user full name at the top of the user menu.
}}
<div class="usermenu">
{{#unauthenticateduser}}
Expand All @@ -83,6 +85,13 @@
<div id="usermenu-carousel" class="carousel slide" data-touch="false" data-interval="false" data-keyboard="false">
<div class="carousel-inner">
<div id="carousel-item-main" class="carousel-item active" role="menu" tabindex="-1" aria-label="{{#str}}user{{/str}}">
{{#showfullnameinusermenu}}
<div class="loggedinas">
<small>{{#str}}showfullnameinusermenussetting_loggedinas, theme_boost_union{{/str}}</small><br />
<strong>{{userfullname}}</strong>
</div>
<div class="dropdown-divider"></div>
{{/showfullnameinusermenu}}
{{> core/user_action_menu_items }}
</div>
{{#submenus}}
Expand Down
19 changes: 19 additions & 0 deletions tests/behat/theme_boost_union_feelsettings_navigation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,25 @@ Feature: Configuring the theme_boost_union plugin for the "Navigation" tab on th
| | /my/ |
| https://foo.bar | https://foo.bar |

@javascript
Scenario Outline: Setting: Show full name in the user menu.
Given the following config values are set as admin:
| config | value | plugin |
| showfullnameinusermenu | <setting> | theme_boost_union |
And the following "users" exist:
| username | firstname | lastname |
| menutestuser | Menutest | User |
When I log in as "menutestuser"
And I click on "User menu" "button" in the ".usermenu" "css_element"
Then ".usermenu .loggedinas" "css_element" <shouldornot> exist
And I <shouldornot> see "You are logged in as:" in the ".usermenu .carousel-inner" "css_element"
And I <shouldornot> see "Menutest User" in the ".usermenu .carousel-inner" "css_element"

Examples:
| setting | shouldornot |
| yes | should |
| no | should not |

@javascript
Scenario Outline: Setting: Add preferred language link to language menu.
Given the following "language packs" exist:
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();

$plugin->component = 'theme_boost_union';
$plugin->version = 2023102028;
$plugin->version = 2023102029;
$plugin->release = 'v4.3-r9';
$plugin->requires = 2023100900;
$plugin->supported = [403, 403];
Expand Down

0 comments on commit 5cf2382

Please sign in to comment.