Skip to content
Snippets Groups Projects

Feature/istwcms 4874 l26yan make people and reports show on dashboard toolbar

1 file
+ 18
21
Compare changes
  • Side-by-side
  • Inline
+ 18
21
@@ -235,30 +235,27 @@ function uw_cfg_common_toolbar_alter(&$items) {
@@ -235,30 +235,27 @@ function uw_cfg_common_toolbar_alter(&$items) {
// Get the current user.
// Get the current user.
$current_user = \Drupal::currentUser();
$current_user = \Drupal::currentUser();
// No changes for user 1.
// Remove the "manage" people for non-admin users.
if ((int) $current_user->id() === 1) {
return;
}
// Adjust toolbar for non-admin users.
if (!$current_user->hasPermission('access manage toolbar item')) {
if (!$current_user->hasPermission('access manage toolbar item')) {
// Remove "Manage" toolbar item.
// Remove "Manage" toolbar item.
unset($items['administration']);
unset($items['administration']);
// Add links to "Workbench". 'dashboards' is renamed in
}
// uw_dashboard_toolbar_alter().
$links = [
// Add "people" and "reports" links to "Workbench".
'entity.user.collection' => t('People'),
// Note: 'dashboards' is renamed in
'system.admin_reports' => t('Reports'),
// uw_dashboard_toolbar_alter().
];
$links = [
foreach ($links as $route => $title) {
'entity.user.collection' => t('People'),
$url = Url::fromRoute($route);
'system.admin_reports' => t('Reports'),
if ($url->access()) {
];
$items['dashboards']['tray']['dashboards']['#items'][] = [
foreach ($links as $route => $title) {
'#type' => 'link',
$url = Url::fromRoute($route);
'#title' => $title,
if ($url->access()) {
'#url' => $url,
$items['dashboards']['tray']['dashboards']['#items'][] = [
];
'#type' => 'link',
}
'#title' => $title,
 
'#url' => $url,
 
];
}
}
}
}
}
}
Loading