You are here

function signup_admin_form in Signup 5.2

Same name and namespace in other branches
  1. 6.2 includes/admin.signup_administration.inc \signup_admin_form()
  2. 6 includes/admin.signup_administration.inc \signup_admin_form()
  3. 7 includes/admin.signup_administration.inc \signup_admin_form()
1 string reference to 'signup_admin_form'
signup_admin_page in ./signup.module
Prints the admin signup overview page located at admin/content/signup

File

./signup.module, line 1240
The Signup module (http://drupal.org/project/signup) manages replies to nodes. In particular, it's good for event management. Signup supports sending reminder emails and automatically closing signups for nodes with a start time, via the Event…

Code

function signup_admin_form() {

  // 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.
    $node_admin_form = signup_node_admin_summary_form($signup_node);
    $row['title'] = array(
      '#type' => 'markup',
      '#value' => l($signup_node->title, "node/{$signup_node->nid}"),
    );
    $row['status'] = $node_admin_form['status'];
    $row['total'] = array(
      '#type' => 'markup',
      '#value' => $signup_node->signup_total,
    );
    $row['limit'] = $node_admin_form['limit'];
    $op_links = l(t('View signups'), "node/{$signup_node->nid}/signups");
    if ($access_broadcast) {
      $op_links .= '<br />';
      $op_links .= l(t('Signup broadcast'), "node/{$signup_node->nid}/signup-broadcast", array(
        'title' => t('Send an email message to all users who signed up.'),
      ));
    }
    $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;
}