function advpoll_electoral_list_page in Advanced Poll 7.2
Same name and namespace in other branches
- 5 advpoll.module \advpoll_electoral_list_page()
- 6.3 advpoll.pages.inc \advpoll_electoral_list_page()
- 6 advpoll.pages.inc \advpoll_electoral_list_page()
- 6.2 advpoll.pages.inc \advpoll_electoral_list_page()
- 7.3 includes/advpoll.pages.inc \advpoll_electoral_list_page()
- 7 includes/advpoll.pages.inc \advpoll_electoral_list_page()
1 string reference to 'advpoll_electoral_list_page'
- advpoll_menu in ./
advpoll.module - Implements hook_menu()
File
- includes/
advpoll.pages.inc, line 115
Code
function advpoll_electoral_list_page($node) {
$output = '';
if (user_access('administer polls')) {
$rendered_form = drupal_get_form('advpoll_electoral_list_form', $node->nid);
$output .= drupal_render($rendered_form);
}
$output .= '<p>' . t('This table lists all the eligible voters for this poll.') . '</p>';
$header = array();
$header[] = array(
'data' => t('Voter') . ' ',
'field' => 'name',
);
if (user_access('administer polls')) {
$header[] = array(
'data' => t('Remove'),
'field' => 'uid',
);
}
$query = db_select('advpoll_electoral_list', 'el');
$query
->join('users', 'u', 'el.uid = u.uid');
$query
->condition('el.nid', $node->nid);
$query
->extend('PagerDefault')
->limit(20)
->extend('TableSort')
->orderByHeader($header)
->fields('u', array(
'name',
'uid',
));
$results = $query
->execute();
$rows = array();
foreach ($results as $item) {
$voter = '';
if (user_access('administer polls')) {
$voter = l(t('remove'), 'node/' . $node->nid . '/remove/' . $item->uid);
}
if ($voter) {
$rows[] = array(
'data' => array(
$item->name,
$voter,
),
);
}
else {
$rows[] = array(
'data' => array(
$item->name,
),
);
}
}
if ($rows) {
$output .= theme('table', array(
'header' => $header,
'rows' => $rows,
));
$output .= theme('pager', array(
'tags' => array(),
));
}
else {
$output .= '<hr /><p>' . t('No users have currently been added to the electoral list for %title', array(
'%title' => $node->title,
)) . '</p>';
}
return $output;
}