From 427fd682f8d29971b415ce20c72b3de06b97f83f Mon Sep 17 00:00:00 2001 From: Tristan Olive Date: Wed, 17 Jun 2015 16:16:39 -0400 Subject: [PATCH] Send a notification every 24 hours to moderators if there is content awaiting moderation (DBOINCP-102) --- .../boinc/modules/boinccore/boinccore.module | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drupal/sites/default/boinc/modules/boinccore/boinccore.module b/drupal/sites/default/boinc/modules/boinccore/boinccore.module index 8415458e9d..e8da9648e4 100644 --- a/drupal/sites/default/boinc/modules/boinccore/boinccore.module +++ b/drupal/sites/default/boinc/modules/boinccore/boinccore.module @@ -94,6 +94,32 @@ function boinccore_enable() { boinccore_admin_default_content_generate(); } +/** + * Implementation of hook_cron() + */ +function boinccore_cron() { + // Notify moderators if there is site content that requires moderator action + $items_in_queue = boincuser_moderation_queue_count(); + $last_notification = variable_get('boinccore_last_content_moderation_reminder', 0); + if ($items_in_queue AND $last_notification < time() - 24*60*60) { + global $base_url; + global $base_path; + $site_name = variable_get('site_name', bts('project')); + $site_url = $base_url . $base_path; + $settings = array( + 'from' => '', + 'subject' => "Content at {$site_name} is awaiting moderation", + 'message' => '' + . "Please visit the moderation queue page to review content that " + . "requires moderator action: \n" + . "\n" + . "{$site_url}moderate", + ); + boinccore_rules_action_mail_to_moderators($settings); + variable_set('boinccore_last_content_moderation_reminder', time()); + } +} + /** * Implementation of hook_rules_action_info(). */ @@ -716,6 +742,7 @@ function boinccore_rules_action_mark_content_for_moderation($node) { * Action: Send mail to moderators. */ function boinccore_rules_action_mail_to_moderators($settings) { + module_load_include('inc', 'rules', 'modules/system.rules'); $mailing_list = variable_get('boinc_moderator_mailing_list', ''); $force_individual_notifications = variable_get('boinc_moderator_force_individual_notifications', 0);