You are here

function _signup_date_admin_sql in Signup 6

Same name and namespace in other branches
  1. 5.2 includes/date.inc \_signup_date_admin_sql()
  2. 6.2 includes/date.inc \_signup_date_admin_sql()

Return value

Array of SQL clauses for admin overview page query builder.

1 call to _signup_date_admin_sql()
signup_admin_sql in includes/scheduler.inc

File

includes/date.inc, line 13
Code to support using CCK date fields for time-based signup functionality.

Code

function _signup_date_admin_sql($content_type) {

  // Get the date field information for this content type.
  $field = signup_date_field($content_type);

  // In the case where the same CCK date field is being reused on multiple
  // content types, we'll potentially be JOINing on the same tables and
  // columns for different content types.  To defend against duplicate table
  // names or ambiguous columns in the query, use the content type to alias.
  // Also, prefix it to make sure it's never a reserved word.
  $alias = 'signup_alias_' . db_escape_table($content_type);

  // See what fields to SELECT.
  $fields[] = $alias . '.' . $field['database']['columns']['value']['column'];
  if (isset($field['database']['columns']['timezone']['column'])) {
    $fields[] = $alias . '.' . $field['database']['columns']['timezone']['column'];
  }
  $table = '{' . $field['database']['table'] . "} " . $alias;
  return array(
    'fields' => $fields,
    'joins' => array(
      "LEFT JOIN {$table} ON {$alias}.vid = n.vid",
    ),
    'group_by' => $fields,
  );
}