You are here

function signup_node_admin_details_form in Signup 5.2

Same name and namespace in other branches
  1. 6.2 includes/node_admin.inc \signup_node_admin_details_form()
1 string reference to 'signup_node_admin_details_form'
signup_node_admin_page in ./signup.module
Prints the signup details for a single node when the signups tab is clicked

File

./signup.module, line 1899
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_node_admin_details_form($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'),
    ),
  );
  $sql = "SELECT u.uid, u.name, s.anon_mail, s.signup_time, s.form_data 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 and the unique form identifier are different for
    // anon signups and registered user signups.  For registered users,
    // provide a link to the user profile, and use the uid as the
    // identifier.  For anon, use the user's email address as the
    // identifier and name.
    if ($signed_up_user->uid == 0) {
      $key = '__anon:' . $signed_up_user->anon_mail;
      $username = check_plain($signed_up_user->anon_mail);
    }
    else {
      $key = $signed_up_user->uid;
      $username = theme('username', $signed_up_user);
    }
    $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')),
    );
    $form['signup_form_data'][$key] = array(
      '#value' => theme('signup_custom_data', unserialize($signed_up_user->form_data)),
    );
  }
  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['submit_cancel'] = array(
      '#type' => 'submit',
      '#value' => t('Cancel signups'),
    );
    $form['#header'] = $header;
  }
  return $form;
}