You are here

function notifications_requirements in Notifications 7

Test and report Drupal installation requirements.

Parameters

$phase: The current system installation phase.

Return value

An array of system requirements.

File

./notifications.install, line 11

Code

function notifications_requirements($phase) {
  global $base_url;
  $requirements = array();

  // Ensure translations don't break at install time
  $t = get_t();
  if ($phase == 'runtime') {
    if ($disabled = !variable_get('notifications_event_dispatch', TRUE)) {
      $message[] = $t('Notifications are disabled so no new notifications will be sent.');
    }
    $values[] = $disabled ? t('Disabled.') : t('Enabled.');
    $queued = DrupalQueue::get('notifications_event')
      ->numberOfItems();
    $message[] = format_plural($queued, 'There is one notification event in queue.', 'There are @count notification events in queue.');
    $values[] = $t('@count queued.', array(
      '@count' => $queued,
    ));
    $sent_last = db_query('SELECT MAX(send_end) FROM {notifications_event} WHERE notif_success > 0')
      ->fetchField();
    $sent_ago = REQUEST_TIME - $sent_last;
    $message[] = $sent_last ? t('Last successful notification was sent !time ago.', array(
      '!time' => format_interval($sent_ago),
    )) : t('No successful notifications have been sent.');
    $message[] = t('View full <a href="@dblog">notifications logs</a>.', array(
      '@dblog' => url('admin/reports/dblog'),
    ));
    $values[] = t('Last: !date', array(
      '!date' => $sent_last ? format_date($sent_last, 'long') : t('never'),
    ));
    $requirements['notifications'] = array(
      'title' => $t('Notifications status'),
      'value' => implode(' ', $values),
      'description' => implode(' ', $message),
      'severity' => !$disabled && $sent_ago <= variable_get('notifications_last_sent_warning', 86400) ? REQUIREMENT_OK : REQUIREMENT_WARNING,
    );
  }
  return $requirements;
}