diff --git a/css/uw_dashboard.css b/css/uw_dashboard.css index 38b8271ced14440a11335edb22a7b4b7455ea2e3..ec50314d6e3cd65b5fd9a8852c42910f47b32207 100644 --- a/css/uw_dashboard.css +++ b/css/uw_dashboard.css @@ -10,3 +10,7 @@ flex-grow: 1; flex-basis: 0; } + +.dashboard__site-info { + float: right; +} diff --git a/uw_dashboard.module b/uw_dashboard.module index d85453f54507a02c56c1271c75649022c8e6ad94..68dca021f6eea1e041e5669d08f93aa3ba3adf85 100644 --- a/uw_dashboard.module +++ b/uw_dashboard.module @@ -5,6 +5,7 @@ * UW Dashboard module file. */ +use Drupal\Core\Link; use Drupal\Core\Url; use Drupal\user\Entity\User; use Drupal\uw_dashboard\Handler\UWWebformEntityListBuilder; @@ -154,3 +155,41 @@ function uw_dashboard_views_pre_execute(ViewExecutable $view) { $view->pager->options['id'] = $view_instances_count; } } + +function uw_dashboard_preprocess_page(&$variables) { + if (\Drupal::routeMatch()->getRouteName() == 'entity.dashboard.canonical') { + // Start building the site info string. + $string = 'WCMS '; + + // Get the profile version. + $string .= \Drupal::service('extension.list.profile')->getList()['uw_base_profile']->info['version']; + + // Get the website lead(s). + $string .= ' • Website lead: '; + $string .= 'not set'; + + // Get the site owner(s). + $query = \Drupal::entityQuery('user') + ->condition('status', 1) // Only active users. + ->condition('roles', 'uw_role_site_owner') // Only site owners. + ->sort('field_uw_last_name', 'ASC') // First sort by status in ascending order + ->sort('field_uw_first_name', 'ASC'); // Then sort by username in ascending order + $uids = $query->execute(); + $users = User::loadMultiple($uids); + $user_list = []; + foreach ($users as $user) { + $user_list[] = Link::fromTextAndUrl($user->getDisplayName(), Url::fromUri('mailto:' . $user->getEmail()))->toString(); + } + if (!$user_list) { + $user_list[] = 'not set'; + } + $string .= ' • Site owner'; + if (count($user_list) > 1) { + $string .= 's'; + } + $string .= ': ' . implode(', ', $user_list); + + // Get the site owner(s). + $variables['page']['help']['#markup'] = '<div class="dashboard__site-info">' . $string . '</div>'; + } +}