You are here

function node_registration_registrations_page in Node registration 7

Page callback for viewing registrations.

DEPRECATED & UNUSED, but left here for backward compatibility.

File

./node_registration.module, line 951

Code

function node_registration_registrations_page($node) {
  $module_path = _node_registration_type_to_uri('node_registration');
  $registrations = node_registration_load_multiple(FALSE, array(
    'nid' => $node->nid,
    'cancelled' => 0,
  ));
  if ($registrations) {
    $rows = array();
    foreach ($registrations as $registration) {
      $user = '';
      if ($registration->uid) {
        $user = user_load($registration->uid);
        $users[] = $user;
        $user = l($user->name, 'user/' . $user->uid);
      }
      else {
        $users[] = NULL;
      }
      $actions = array(
        l(t('view'), 'registration/' . $registration->registration_id),
        l(t('edit'), 'registration/' . $registration->registration_id . '/edit'),
        l(t('cancel'), 'registration/' . $registration->registration_id . '/cancel'),
      );
      $rows[] = array(
        'data' => array(
          l($registration->registration_id, 'registration/' . $registration->registration_id),
          l($registration->email, 'mailto:' . $registration->email),
          $user,
          $registration->slots,
          format_date($registration->created),
          implode(' | ', $actions),
        ),
      );
    }
    $table = array(
      'header' => array(
        t('id'),
        t('Email'),
        t('User'),
        t('Slots'),
        t('Created'),
        t('Actions'),
      ),
      'rows' => $rows,
      'attributes' => array(
        'class' => array(
          'registrations',
        ),
      ),
    );
    $context = array(
      'node' => $node,
      'users' => $users,
      'registrations' => array_values($registrations),
    );
    drupal_alter('node_registration_table_registrations', $table, $context);
    $out = theme('table', $table);
  }
  else {
    $out = t('There are no registrees for %name.', array(
      '%name' => $node->title,
    ));
  }
  return $out;
}