From 20359124f7bc0a382f2f9a3abad82fe19ebd9cbc Mon Sep 17 00:00:00 2001 From: Tristan Olive Date: Thu, 4 Jun 2015 14:23:43 -0400 Subject: [PATCH] Added speech bubble indicator of items in the moderation queue to the Moderation menu item (DBOINCP-102) --- .../boinc/modules/boincuser/boincuser.module | 15 +++++++++++++++ .../sites/default/boinc/themes/boinc/template.php | 8 ++++++++ 2 files changed, 23 insertions(+) diff --git a/drupal/sites/default/boinc/modules/boincuser/boincuser.module b/drupal/sites/default/boinc/modules/boincuser/boincuser.module index ba5deb1cd5..c10e30e614 100644 --- a/drupal/sites/default/boinc/modules/boincuser/boincuser.module +++ b/drupal/sites/default/boinc/modules/boincuser/boincuser.module @@ -1288,6 +1288,21 @@ function boincuser_moderate_community_access() { return FALSE; } +/** + * Get the count of items in the moderation queue + */ +function boincuser_moderation_queue_count() { + if (user_access(array('edit any profile content'))) { + return db_result(db_query(" + SELECT COUNT(*) + FROM {node} + WHERE type = 'profile' + AND moderate = 1" + )); + } + return NULL; +} + /** * Controller for handling simple user account status configuration. * Allow community membership status to be set for users by direct link rather diff --git a/drupal/sites/default/boinc/themes/boinc/template.php b/drupal/sites/default/boinc/themes/boinc/template.php index 9732ff3946..7dca110182 100644 --- a/drupal/sites/default/boinc/themes/boinc/template.php +++ b/drupal/sites/default/boinc/themes/boinc/template.php @@ -100,6 +100,14 @@ function boinc_links__system_main_menu($links, $menu, $element) { } } } + // Put a count of items on the Moderation menu item + if ($link['href'] == 'moderate') { + $item_count = boincuser_moderation_queue_count(); + if ($item_count) { + $link['title'] .= '
' . $item_count . '
'; + $link['html'] = TRUE; + } + } $html .= l($link['title'], $link['href'], $link); $html .= ''; $i++;