You are here

function advpoll_electoral_list_page in Advanced Poll 5

Same name and namespace in other branches
  1. 6.3 advpoll.pages.inc \advpoll_electoral_list_page()
  2. 6 advpoll.pages.inc \advpoll_electoral_list_page()
  3. 6.2 advpoll.pages.inc \advpoll_electoral_list_page()
  4. 7.3 includes/advpoll.pages.inc \advpoll_electoral_list_page()
  5. 7 includes/advpoll.pages.inc \advpoll_electoral_list_page()
  6. 7.2 includes/advpoll.pages.inc \advpoll_electoral_list_page()

Display the electoral list page.

1 string reference to 'advpoll_electoral_list_page'
advpoll_menu in ./advpoll.module
Implementation of hook_menu().

File

./advpoll.module, line 869
Advanced Poll - a sophisticated polling module for voting, elections, and group decision-making.

Code

function advpoll_electoral_list_page() {
  if ($node = node_load(arg(1))) {

    // Bail out if electoral list isn't available for this node.
    if (!$node->use_list) {
      drupal_not_found();
      return;
    }
    drupal_set_title(check_plain($node->title));
    if (user_access('administer polls')) {
      $output .= drupal_get_form('advpoll_electoral_list_form', $node->nid);
    }
    $output .= '<p>' . t('This table lists all the eligible voters for this poll.') . '</p>';
    $header[] = array(
      'data' => t('Voter'),
      'field' => 'u.name',
    );
    $result = pager_query("SELECT u.uid, u.name FROM {advpoll_electoral_list} el LEFT JOIN {users} u ON el.uid = u.uid WHERE el.nid = %d" . tablesort_sql($header), 20, 0, NULL, $node->nid);
    $table_rows = array();
    while ($voter = db_fetch_object($result)) {
      $row = array(
        theme('username', $voter),
      );
      if (user_access('administer polls')) {
        $row[] = l(t('remove'), 'node/' . $node->nid . '/remove/' . $voter->uid);
      }
      $table_rows[] = $row;
    }
    $output .= theme('table', $header, $table_rows);
    $output .= theme('pager', NULL, 20, 0);
    print theme('page', $output);
  }
  else {
    drupal_not_found();
  }
}