Skip to content
Snippets Groups Projects
Commit f39ec8fd authored by Eric Bremner's avatar Eric Bremner
Browse files

Merge branch 'feature/EXPTIME-kpaxman-site_info' into '1.0.x'

Feature/exptime kpaxman site info

See merge request !40
parents 7fe67cb7 6fef7476
No related branches found
No related tags found
1 merge request!40Feature/exptime kpaxman site info
...@@ -10,3 +10,8 @@ ...@@ -10,3 +10,8 @@
flex-grow: 1; flex-grow: 1;
flex-basis: 0; flex-basis: 0;
} }
.dashboard__site-info {
float: right;
margin-bottom: 0.2rem;
}
...@@ -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,59 @@ function uw_dashboard_views_pre_execute(ViewExecutable $view) { ...@@ -154,3 +155,59 @@ function uw_dashboard_views_pre_execute(ViewExecutable $view) {
$view->pager->options['id'] = $view_instances_count; $view->pager->options['id'] = $view_instances_count;
} }
} }
/**
* Implements hook_preprocess_page().
*/
function uw_dashboard_preprocess_page(&$variables) {
if (\Drupal::routeMatch()->getRouteName() == 'entity.dashboard.canonical') {
// Start building the site info string with the version information.
$string = 'WCMS version ' . \Drupal::service('extension.list.profile')->getList()['uw_base_profile']->info['version'];
$string = Link::fromTextAndUrl($string, Url::fromUri('https://uwaterloo.ca/web-resources/news?tags[90]=90'))->toString();
// Get the website lead(s).
$query = \Drupal::entityQuery('user')
->condition('status', 1)
->condition('roles', 'uw_role_website_lead')
->sort('field_uw_last_name', 'ASC')
->sort('field_uw_first_name', 'ASC');
$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 .= ' • Website lead';
if (count($user_list) > 1) {
$string .= 's';
}
$string .= ': ' . implode(', ', $user_list);
// Get the site owner(s).
$query = \Drupal::entityQuery('user')
->condition('status', 1)
->condition('roles', 'uw_role_site_owner')
->sort('field_uw_last_name', 'ASC')
->sort('field_uw_first_name', 'ASC');
$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