You are here

function _sms_user_sleep_active in SMS Framework 6.2

Same name and namespace in other branches
  1. 5 modules/sms_user/sms_user.module \_sms_user_sleep_active()
  2. 6 modules/sms_user/sms_user.module \_sms_user_sleep_active()
  3. 7 modules/sms_user/sms_user.module \_sms_user_sleep_active()

Is the user sleeping?

Parameters

$account: User account object.

Return value

TRUE if its currently in the user user sleep time.

1 call to _sms_user_sleep_active()
sms_user_sms_send in modules/sms_user/sms_user.module
Implementation of hook_sms_send().

File

modules/sms_user/sms_user.module, line 116
Provides integration between the SMS Framework and Drupal users.

Code

function _sms_user_sleep_active($account) {

  //if the user has a timezone set in his account get the time there
  if (!empty($account->timezone_name)) {
    $timezone = new DateTimeZone($account->timezone_name);
    $date = new DateTime();
    $date
      ->setTimezone($timezone);
    $current_hour = $date
      ->format('G');
  }
  else {
    $current_hour = date('G');
  }
  if ($account->sms_user['sleep_start_time'] <= $current_hour && $account->sms_user['sleep_end_time'] > $current_hour) {
    return TRUE;
  }
  return FALSE;
}