You are here

function _signup_date_node_completed in Signup 5.2

Same name in this branch
  1. 5.2 includes/date.5x-2.inc \_signup_date_node_completed()
  2. 5.2 includes/date.5x-1.inc \_signup_date_node_completed()
Same name and namespace in other branches
  1. 6.2 includes/date.inc \_signup_date_node_completed()
  2. 6 includes/date.inc \_signup_date_node_completed()
  3. 7 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.5x-2.inc, line 109
Code required to support version 5.x-2.* of the CCK date field module.

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']}[0]['value'];

    // Figure out the timezone handling for this date.
    if ($field['tz_handling'] == 'date') {
      $tz = $node->{$field['field_name']}[0]['timezone'];
    }
    else {
      $tz = date_default_timezone_name();
    }
    $db_tz = date_get_timezone_db($field['tz_handling'], $tz);

    // Create a date object
    $date = date_make_date($date_value, $db_tz, $field['type']);

    // Make sure the date object is going to print UTC values.
    date_timezone_set($date, timezone_open('UTC'));

    // Find out how early signups should be automatically closed.
    $close_early_hours = variable_get('signup_close_early', 1);
    date_modify($date, "-{$close_early_hours} hours");
    $close_time = date_format($date, '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;
}