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)
This commit is contained in:
Tristan Olive 2015-07-21 16:26:20 -04:00
parent c6bdf2953a
commit 25944ac53c
2 changed files with 12 additions and 3 deletions

View File

@ -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;

View File

@ -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}