You are here

function timezone_detect_enable in Timezone Detect 7

Same name and namespace in other branches
  1. 6 timezone_detect.install \timezone_detect_enable()

Implements hook_enable().

File

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

Code

function timezone_detect_enable() {
  drupal_set_message(t('The Timezone Detect module was successfully enabled.'), 'status');

  // Set default user timezone to "none." Otherwise this module will not do
  // anything in its default configuration ("set user timezone only if it
  // is not set").
  $user_default_timezone = variable_get('user_default_timezone', DRUPAL_USER_TIMEZONE_DEFAULT);
  if ($user_default_timezone != DRUPAL_USER_TIMEZONE_EMPTY) {
    variable_set('user_default_timezone', DRUPAL_USER_TIMEZONE_EMPTY);
    drupal_set_message(t('Default user timezone set to "empty timezone" for best results with Timezone Detect.'), 'status');
  }

  // Disable "remind users at login if their time zone is not set." Otherwise
  // users may be asked to set their timezone on first login even when this
  // module has already set it via ajax callback.
  $empty_timezone_message = variable_get('empty_timezone_message', 0);
  if ($empty_timezone_message != 0) {
    variable_set('empty_timezone_message', 0);
    drupal_set_message(t('"Remind users at login if their time zone is not set" set to FALSE for best results with Timezone Detect.'), 'status');
  }
}