You are here

function signup_node_admin_details_form in Signup 6.2

Same name and namespace in other branches
  1. 5.2 signup.module \signup_node_admin_details_form()
1 string reference to 'signup_node_admin_details_form'
signup_node_admin_page in includes/node_admin.inc
Print the signup administration tab for a single node.

File

includes/node_admin.inc, line 54
Code related to the signup administration tab on each node.

Code

function signup_node_admin_details_form(&$form_state, $node) {
  unset($_SESSION['signup_cancel_multiple_users']);
  $form = array();

  // Prepare a table header that allows sorting on name and signup time.
  $header = array(
    theme('table_select_header_cell'),
    array(
      'data' => t('Name'),
      'field' => 'u.name',
      'sort' => 'asc',
    ),
    array(
      'data' => t('Signup time'),
      'field' => 's.signup_time',
    ),
    array(
      'data' => t('Extra information'),
    ),
    array(
      'data' => t('Attendance'),
      'field' => 's.attended',
    ),
  );
  $sql = "SELECT u.uid, u.name, s.* FROM {signup_log} s INNER JOIN {users} u ON u.uid = s.uid WHERE s.nid = %d";
  $sql .= tablesort_sql($header);
  $result = db_query($sql, $node->nid);

  // Loop through the users, unserializing their user data.
  while ($signed_up_user = db_fetch_object($result)) {

    // The "username" to print is different for anon signups and registered
    // user signups.  For registered users, provide a link to the user profile
    // For anon, use the user's email address as the name.
    if ($signed_up_user->uid == 0) {
      $username = check_plain($signed_up_user->anon_mail);
    }
    else {
      $username = theme('username', $signed_up_user);
    }
    $key = $signed_up_user->sid;
    $users[$key] = '';
    $form['username'][$key] = array(
      '#value' => $username,
    );
    $form['signup_date'][$key] = array(
      '#value' => format_date($signed_up_user->signup_time, variable_get('signup_date_format', 'small')),
    );

    // Unpack the stored signup form data.
    $signup_form_data = unserialize($signed_up_user->form_data);

    // Invoke hook_signup_form_data_display_alter() to let other modules
    // (in particular pane modules) alter the data for output.
    // This may involve internal data being removed.
    drupal_alter('signup_form_data_display', $signup_form_data, $node->nid, $key, $signed_up_user->uid, 'list');
    $form['signup_form_data'][$key] = array(
      '#value' => theme('signup_custom_data', $signup_form_data),
    );
    $form['attended'][$key] = array(
      '#value' => theme('signup_attended_text', $signed_up_user->attended),
    );
  }
  if (empty($users)) {
    $form['no_users'] = array(
      '#value' => t('No users have signed up for this %node_type.', array(
        '%node_type' => node_get_types('name', $node->type),
      )),
    );
  }
  else {
    $form['nid'] = array(
      '#type' => 'hidden',
      '#value' => $node->nid,
    );
    $form['users'] = array(
      '#type' => 'checkboxes',
      '#options' => $users,
    );
    $form['operation'] = array(
      '#type' => 'select',
      '#options' => array(
        'attend_yes' => t('Mark as attended'),
        'attend_no' => t('Mark as did not attend'),
      ),
    );
    if (user_access('cancel signups')) {
      $form['operation']['#options']['cancel'] = t('Cancel signup');
    }
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Update'),
      '#submit' => array(
        'signup_node_admin_multiple_submit',
      ),
      '#validate' => array(
        'signup_node_admin_multiple_validate',
      ),
    );
    $form['#header'] = $header;
  }
  return $form;
}