Skip to content
Snippets Groups Projects
Commit debb9fdd authored by Kevin Paxman's avatar Kevin Paxman
Browse files

EXPHR: site info WIP

parent 7fe67cb7
No related branches found
No related tags found
1 merge request!40Feature/exptime kpaxman site info
...@@ -10,3 +10,7 @@ ...@@ -10,3 +10,7 @@
flex-grow: 1; flex-grow: 1;
flex-basis: 0; flex-basis: 0;
} }
.dashboard__site-info {
float: right;
}
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* UW Dashboard module file. * UW Dashboard module file.
*/ */
use Drupal\Core\Link;
use Drupal\Core\Url; use Drupal\Core\Url;
use Drupal\user\Entity\User; use Drupal\user\Entity\User;
use Drupal\uw_dashboard\Handler\UWWebformEntityListBuilder; use Drupal\uw_dashboard\Handler\UWWebformEntityListBuilder;
...@@ -154,3 +155,41 @@ function uw_dashboard_views_pre_execute(ViewExecutable $view) { ...@@ -154,3 +155,41 @@ function uw_dashboard_views_pre_execute(ViewExecutable $view) {
$view->pager->options['id'] = $view_instances_count; $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>';
}
}
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