From 25944ac53c8f854b9d23f8d6ca5b06cfb74f3ca4 Mon Sep 17 00:00:00 2001 From: Tristan Olive Date: Tue, 21 Jul 2015 16:26:20 -0400 Subject: [PATCH] Bypass user_access check on boincuser_moderation_queue_count() when calling from cron (this may be preventing notifications from being sent to moderators, as the function is returning NULL, suggesting to cron that there are no items in the queue) (DBOINCP-102) --- .../boinc/modules/boinccore/boinccore.module | 2 +- .../boinc/modules/boincuser/boincuser.module | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drupal/sites/default/boinc/modules/boinccore/boinccore.module b/drupal/sites/default/boinc/modules/boinccore/boinccore.module index 4ca1a54e72..dfc76f4bc1 100644 --- a/drupal/sites/default/boinc/modules/boinccore/boinccore.module +++ b/drupal/sites/default/boinc/modules/boinccore/boinccore.module @@ -165,7 +165,7 @@ function boinccore_enable() { */ function boinccore_cron() { // Notify moderators if there is site content that requires moderator action - $items_in_queue = boincuser_moderation_queue_count(); + $items_in_queue = boincuser_moderation_queue_count('cron'); $last_notification = variable_get('boinccore_last_content_moderation_reminder', 0); if ($items_in_queue AND $last_notification < time() - 24*60*60) { global $base_url; diff --git a/drupal/sites/default/boinc/modules/boincuser/boincuser.module b/drupal/sites/default/boinc/modules/boincuser/boincuser.module index e6d564a97f..297f24c634 100644 --- a/drupal/sites/default/boinc/modules/boincuser/boincuser.module +++ b/drupal/sites/default/boinc/modules/boincuser/boincuser.module @@ -1351,8 +1351,17 @@ function boincuser_moderate_community_access() { /** * Get the count of items in the moderation queue */ -function boincuser_moderation_queue_count() { - if (user_access('edit any profile content')) { +function boincuser_moderation_queue_count($caller = 'user') { + $allowed = FALSE; + switch ($caller) { + case 'cron': + $allowed = TRUE; + break; + case 'user': + default: + $allowed = user_access('edit any profile content'); + } + if ($allowed) { return db_result(db_query(" SELECT COUNT(*) FROM {node}