function _signup_date_node_completed in Signup 7
Same name and namespace in other branches
- 5.2 includes/date.5x-2.inc \_signup_date_node_completed()
- 5.2 includes/date.5x-1.inc \_signup_date_node_completed()
- 6.2 includes/date.inc \_signup_date_node_completed()
- 6 includes/date.inc \_signup_date_node_completed()
Returns TRUE if the given node is event-enabled, and the start time has already passed the "Close x hours before" setting.
1 call to _signup_date_node_completed()
- _signup_node_completed in includes/scheduler.inc 
- Determine if the given node has date/time data and if it already started.
File
- includes/date.inc, line 452 
- Code to support using CCK date fields for time-based signup functionality.
Code
function _signup_date_node_completed($node) {
  $field = signup_date_field($node->type);
  if ($field && $field != 'none' && isset($node->{$field['field_name']})) {
    // Grab whatever date value we actually have, regardless of format.
    $date_value = $node->{$field['field_name']}[$node->language][0]['value'];
    // Figure out the timezone handling for this date.
    if ($field['settings']['tz_handling'] == 'date') {
      $tz = $node->{$field['field_name']}[$node->language][0]['timezone'];
    }
    else {
      $tz = date_default_timezone();
    }
    $db_tz = date_get_timezone_db($field['settings']['tz_handling'], $tz);
    // Create a date object
    $date = new DateObject($date_value, $db_tz, NULL);
    // Make sure the date object is going to print UTC values.
    $date
      ->setTimezone(timezone_open('UTC'));
    // Find out how early signups should be automatically closed.
    $close_early_hours = variable_get('signup_close_early', 1);
    $date
      ->modify("-{$close_early_hours} hours");
    $close_time = $date
      ->format('U');
    // Find the current UTC time.
    $now = date_now('UTC');
    if (date_format($now, 'U') >= $close_time) {
      // It's now later than when this node would automatically close signups.
      return TRUE;
    }
  }
  return FALSE;
}