Skip to content
Snippets Groups Projects
Commit 6fb10123 authored by Liam Morland's avatar Liam Morland
Browse files

ISTWCMS-4025: Refactor code that skips user 1

parent 0ac096b3
No related branches found
No related tags found
1 merge request!65ISTWCMS-4631, ISTWCMS-4636: Toolbar adjustments
...@@ -174,25 +174,24 @@ function uw_cfg_common_webform_create(WebformInterface $webform) { ...@@ -174,25 +174,24 @@ function uw_cfg_common_webform_create(WebformInterface $webform) {
* Remove the Manage link from the toolbar for authenticated users. * Remove the Manage link from the toolbar for authenticated users.
*/ */
function uw_cfg_common_toolbar_alter(&$items) { function uw_cfg_common_toolbar_alter(&$items) {
// Get the current user. // Get the current user.
$current_user = \Drupal::currentUser(); $current_user = \Drupal::currentUser();
// Ensure that the current user is not user1. // No changes for user 1.
if ($current_user->id() !== '1') { if ((int) $current_user->id() === 1) {
return;
// Get the roles of the user. }
$roles = $current_user->getRoles();
// If there is only 1 role and that first role is authenticated, remove the // Get the roles of the user.
// manage link. If there are multiple roles then we know that they will have $roles = $current_user->getRoles();
// the Manage link, we are only removing the manage link for strictly
// authenticated users only.
if (count($roles) == 1 && $roles[0] == 'authenticated') {
// Remove the manage link. // If there is only 1 role and that first role is authenticated, remove the
unset($items['administration']); // manage link. If there are multiple roles then we know that they will have
} // the Manage link, we are only removing the manage link for strictly
// authenticated users only.
if (count($roles) == 1 && $roles[0] == 'authenticated') {
// Remove the manage link.
unset($items['administration']);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment