You are here

function _signup_date_autoclose_sql in Signup 5.2

Same name in this branch
  1. 5.2 includes/date.5x-2.inc \_signup_date_autoclose_sql()
  2. 5.2 includes/date.5x-1.inc \_signup_date_autoclose_sql()
Same name and namespace in other branches
  1. 6.2 includes/date.inc \_signup_date_autoclose_sql()
  2. 6 includes/date.inc \_signup_date_autoclose_sql()
  3. 7 includes/date.inc \_signup_date_autoclose_sql()

Return value

Array of SQL clauses for cron auto-close query builder.

1 call to _signup_date_autoclose_sql()
signup_autoclose_sql in includes/scheduler.inc

File

includes/date.5x-1.inc, line 34
Code required to support version 5.x-1.* of the CCK date field module.

Code

function _signup_date_autoclose_sql($content_type) {
  require_once drupal_get_path('module', 'date') . '/date.inc';
  global $db_type;
  $close_early = variable_get('signup_close_early', 1);
  switch ($db_type) {
    case 'mysql':
    case 'mysqli':
      $interval = "INTERVAL '" . $close_early . "' HOUR";
      break;
    case 'pgsql':
      $interval = "INTERVAL '" . $close_early . " hours'";
      break;
  }
  $field = signup_date_field($content_type);
  $date_type = $field['type'] == 'datestamp' ? 'int' : 'iso';
  $start_time = date_sql('DATE', $field['database']['columns']['value']['column'], $date_type);
  $where = "NOW() + " . $interval . " > " . $start_time;
  return array(
    'fields' => array(
      $field['database']['columns']['value']['column'],
    ),
    'joins' => array(
      'INNER JOIN {' . $field['database']['table'] . '} ON {' . $field['database']['table'] . '}.vid = n.vid',
    ),
    'where' => array(
      $where,
    ),
  );
}