You are here

function timezone_detect_requirements in Timezone Detect 7

Same name and namespace in other branches
  1. 8 timezone_detect.install \timezone_detect_requirements()
  2. 6 timezone_detect.install \timezone_detect_requirements()

Implements hook_requirements().

File

./timezone_detect.install, line 41
(Un)installs the Timezone Detect module.

Code

function timezone_detect_requirements($phase) {
  $requirements = array();
  $t = get_t();

  // Check that default user timezone is set to "empty timezone", or that
  // Timezone Detect is configured to update user timezone on every login
  // (otherwise automatic timezone detection will not work).
  $default_timezone_okay = FALSE;
  $user_default_timezone = variable_get('user_default_timezone', DRUPAL_USER_TIMEZONE_DEFAULT);
  $timezone_update_mode = variable_get('timezone_detect_mode');
  if ($timezone_update_mode != TIMEZONE_DETECT_MODE_DEFAULT || $user_default_timezone == DRUPAL_USER_TIMEZONE_EMPTY) {
    $default_timezone_okay = TRUE;
  }
  switch ($phase) {
    case 'runtime':
      if (!$default_timezone_okay) {
        $requirements['timezone_detect'] = array(
          'title' => $t('Timezone Detect'),
          'value' => $t('Incompatible default user timezone'),
          'description' => $t('For automatic timezone detection to work correctly, please change default user timezone to "empty timezone" on your site\'s !regional_settings_url.', array(
            '!regional_settings_url' => l($t('regional settings page'), 'admin/config/regional/settings'),
          )),
          'severity' => REQUIREMENT_ERROR,
        );
      }
      break;
  }
  return $requirements;
}