You are here

function health_cron_email_send in Health Status 7

Sends a health status on cron run when necessary.

1 call to health_cron_email_send()
health_cron in ./health.module
Implements hook_cron().

File

./health.module, line 125
Contains the basic hooks and function used by the Health system.

Code

function health_cron_email_send() {

  // Need to include admin file for the table functions.
  module_load_include('inc', 'health', 'health.admin');
  $emails = explode(PHP_EOL, variable_get('health_email_users'));
  $data = health_get_data();
  $monitors = health_get_monitors();
  $tables = array();
  foreach ($data as $group => $results) {
    $tables[$group] = theme('table', array(
      'rows' => health_admin_dashboard_rows($monitors[$group], $results),
      'header' => health_admin_dashboard_headers(),
    ));
  }
  $params = array(
    'site_name' => variable_get('site_name'),
    'data' => health_get_data(),
    'tables' => $tables,
  );
  foreach ($emails as $to) {
    drupal_mail('health', 'health_status', $to, language_default(), $params, variable_get('site_email'), TRUE);
  }
}