You are here

function signup_admin_form in Signup 6.2

Same name and namespace in other branches
  1. 5.2 signup.module \signup_admin_form()
  2. 6 includes/admin.signup_administration.inc \signup_admin_form()
  3. 7 includes/admin.signup_administration.inc \signup_admin_form()

Form builder for the main form on the signup administration page.

1 string reference to 'signup_admin_form'
signup_admin_page in includes/admin.signup_administration.inc
Print the admin signup overview page located at admin/content/signup.

File

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

Code

function signup_admin_form($form_state) {

  // Figure out if the current user has permission to use signup broadcast.
  $access_broadcast = user_access('email all signed up users');
  $header = array(
    array(
      'data' => t('Title'),
      'field' => 'n.title',
      'sort' => 'asc',
    ),
    array(
      'data' => t('Signups'),
      'field' => 'signup_total',
    ),
    array(
      'data' => t('Limit'),
      'field' => 'signup_close_signup_limit',
    ),
    array(
      'data' => t('Status'),
      'field' => 'signup_status',
    ),
    array(
      'data' => t('Operations'),
    ),
  );
  $start_column = signup_admin_form_header();
  if (!empty($start_column)) {
    array_unshift($header, $start_column);
  }
  list($sql, $sql_count) = signup_admin_form_sql();
  $form['header']['#value'] = $header;
  $sql .= tablesort_sql($header);
  $result = pager_query($sql, 25, 0, $sql_count);

  // Loop through the signup nodes, and generate our form elements
  while ($signup_node = db_fetch_object($result)) {
    $row = array();
    if (!empty($start_column)) {
      $row['start'] = signup_admin_form_extra($signup_node);
    }

    // Instead of duplicating the logic from the node/N/signups admin
    // form, we just call that form builder here and lift the elements
    // we need directly from that.
    module_load_include('inc', 'signup', 'includes/node_admin_summary');
    $node_admin_form = signup_node_admin_summary_form(array(), $signup_node);
    $row['title'] = array(
      '#type' => 'markup',
      '#value' => l($signup_node->title, "node/{$signup_node->nid}"),
    );
    $row['status'] = $node_admin_form['status'];
    unset($row['status']['#title']);
    $row['total'] = array(
      '#type' => 'markup',
      '#value' => $signup_node->signup_total,
    );
    $row['limit'] = $node_admin_form['limit'];
    unset($row['limit']['#title']);
    $op_links = l(t('View signups'), "node/{$signup_node->nid}/signups");
    if ($access_broadcast) {
      $op_links .= '<br />';
      $options['attributes']['title'] = t('Send an email message to all users who signed up.');
      $op_links .= l(t('Signup broadcast'), "node/{$signup_node->nid}/signups/broadcast", $options);
    }
    $row['operations'] = array(
      '#type' => 'markup',
      '#value' => $op_links,
    );
    $form['nids'][$signup_node->nid] = $row;
  }
  $form['#tree'] = TRUE;
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Update'),
  );
  return $form;
}