You are here

function signup_admin_form_query in Signup 7

The database query to get the needed information of nodes with signups.

1 call to signup_admin_form_query()
signup_admin_form in includes/admin.signup_administration.inc
Form builder for the main form on the signup administration page.

File

includes/admin.signup_administration.inc, line 208
Code related to the Signup administration page (admin/content/signup).

Code

function signup_admin_form_query($header) {
  $query = db_select('node', 'n')
    ->extend('PagerDefault')
    ->extend('TableSort');
  if (isset($_SESSION['signup_status_filter']) && $_SESSION['signup_status_filter'] != 'all') {
    $status = $_SESSION['signup_status_filter'] == 'open' ? 1 : 0;
    $query
      ->condition('s.status', $status);
  }
  $query
    ->innerJoin('signup', 's', 's.nid = n.nid');
  $query
    ->leftJoin('signup_log', 's_l', 's.nid = s_l.nid');
  $query
    ->fields('n', array(
    'nid',
    'title',
    'type',
    'language',
  ));
  $query
    ->addField('s', 'status', 'signup_status');
  $query
    ->addField('s', 'close_signup_limit', 'signup_close_signup_limit');
  $query
    ->addExpression('COUNT(s_l.nid)', 'signup_total');
  $query
    ->groupBy('nid');
  $query
    ->groupBy('title');
  $query
    ->groupBy('type');
  $query
    ->groupBy('signup_status');
  $query
    ->groupBy('signup_close_signup_limit');

  // Get the right query elements from the currently installed scheduler backend.
  foreach (signup_content_types() as $content_type) {
    signup_admin_query($query, $content_type);
  }
  $nodes = $query
    ->limit(25)
    ->orderByHeader($header)
    ->execute();
  return $nodes;
}