You are here

function signup_admin_form in Signup 7

Same name and namespace in other branches
  1. 5.2 signup.module \signup_admin_form()
  2. 6.2 includes/admin.signup_administration.inc \signup_admin_form()
  3. 6 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/people/signup.

File

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

Code

function signup_admin_form($form, &$form_state) {

  // Build the sortable table header.
  $header = array(
    'title' => array(
      'data' => t('Title'),
      'field' => 'n.title',
      'sort' => 'asc',
    ),
    'total' => array(
      'data' => t('Signups'),
      'field' => 'signup_total',
    ),
    'limit' => array(
      'data' => t('Limit'),
      'field' => 'signup_close_signup_limit',
    ),
    'status' => array(
      'data' => t('Status'),
      'field' => 'signup_status',
    ),
    'operations' => array(
      'data' => t('Operations'),
    ),
  );
  $start_column = signup_admin_form_header();
  if (!empty($start_column)) {
    $header = array(
      'start' => $start_column,
    ) + $header;
  }

  // Prepare the list of nodes.
  $nodes = signup_admin_form_query($header);
  $destination = drupal_get_destination();
  $options = array();
  foreach ($nodes as $node) {
    $form['limit'][$node->nid] = array(
      '#type' => 'textfield',
      '#title' => t('Limit'),
      '#title_display' => 'invisible',
      '#default_value' => $node->signup_close_signup_limit,
      '#size' => 3,
    );
    $form['status'][$node->nid] = array(
      '#type' => 'select',
      '#title' => t('Status'),
      '#title_display' => 'invisible',
      '#options' => array(
        0 => t('Closed'),
        1 => t('Open'),
      ),
      '#default_value' => $node->signup_status,
    );
    $options[$node->nid] = array(
      'start' => signup_format_date($node),
      'title' => array(
        'data' => array(
          '#type' => 'link',
          '#title' => check_plain($node->title),
          '#href' => 'node/' . $node->nid,
        ),
      ),
      'total' => $node->signup_total,
      'limit' => $node->signup_close_signup_limit,
      'status' => $node->signup_status ? t('Open') : t('Closed'),
    );

    // Build a list of all the accessible operations for the current node.
    $operations = array();
    $operations['view'] = array(
      'title' => t('View signups'),
      'href' => 'node/' . $node->nid . '/signups',
      'query' => $destination,
    );
    if (user_access('email all signed up users')) {
      $operations['broadcast'] = array(
        'title' => t('Broadcast'),
        'href' => 'node/' . $node->nid . '/signups/broadcast',
        'query' => $destination,
      );
    }
    $options[$node->nid]['operations'] = array();
    if (count($operations) > 1) {

      // Render an unordered list of operations links.
      $options[$node->nid]['operations'] = array(
        'data' => array(
          '#theme' => 'links__node_operations',
          '#links' => $operations,
          '#attributes' => array(
            'class' => array(
              'links',
              'inline',
            ),
          ),
        ),
      );
    }
    elseif (!empty($operations)) {

      // Render the first and only operation as a link.
      $link = reset($operations);
      $options[$node->nid]['operations'] = array(
        'data' => array(
          '#type' => 'link',
          '#title' => check_plain($link['title']),
          '#href' => $link['href'],
          '#options' => array(
            'query' => $link['query'],
          ),
        ),
      );
    }
  }
  $form['nodes'] = array(
    '#type' => 'tableselect',
    '#header' => $header,
    '#options' => $options,
    '#empty' => t('No content available.'),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Update'),
  );
  $form['pager'] = array(
    '#markup' => theme('pager'),
  );
  $form['#tree'] = TRUE;
  $form['#after_build'] = array(
    'signup_admin_form_after_build',
  );
  return $form;
}