You are here

function birthdays_requirements in Birthdays 6

Same name and namespace in other branches
  1. 5 birthdays.install \birthdays_requirements()

Implementation of hook_requirements().

File

./birthdays.install, line 48
Installation file for the Birthdays module.

Code

function birthdays_requirements($phase) {
  global $_birthdays_field;
  $t = get_t();
  $requirements = array();
  if ($phase == 'runtime') {
    $value = $t('All requirements are met');
    $severity = REQUIREMENT_OK;
    $date_fields = _birthdays_get_date_fields();
    if (empty($date_fields)) {
      $value = $t('Missing profile field');
      $severity = REQUIREMENT_ERROR;
      $description = $t('No profile fields of type \'date\' were found, please <a href="@profile-settings-page">create one here</a>. Then visit the <a href="@birthdays-settings">birthdays settings page</a> to set up the module.', array(
        '@profile-settings-page' => url('admin/user/profile/add/date'),
        '@birthdays-settings' => url('admin/settings/birthdays'),
      ));
    }
    elseif (!isset($_birthdays_field)) {

      // Set warning/error message when the birthdays profile field hasn't been set yet.
      $value = $t('No date field selected');
      $severity = REQUIREMENT_ERROR;
      $description = $t('The date field has not yet been selected as birthdays field. Please visit the <a href="@birthdays-settings">birthdays settings page</a> to do so.', array(
        '@birthdays-settings' => url('admin/settings/birthdays'),
      ));
    }
    $requirements['birthdays'] = array(
      'title' => $t('Birthdays'),
      'value' => $value,
      'description' => $description,
      'severity' => $severity,
    );
  }
  return $requirements;
}