function advpoll_votes_page in Advanced Poll 7
Same name and namespace in other branches
- 5 advpoll.module \advpoll_votes_page()
- 6.3 advpoll.pages.inc \advpoll_votes_page()
- 6 advpoll.pages.inc \advpoll_votes_page()
- 6.2 advpoll.pages.inc \advpoll_votes_page()
- 7.3 includes/advpoll.pages.inc \advpoll_votes_page()
- 7.2 includes/advpoll.pages.inc \advpoll_votes_page()
1 string reference to 'advpoll_votes_page'
- advpoll_menu in ./
advpoll.module - Implements hook_menu()
File
- includes/
advpoll.pages.inc, line 14
Code
function advpoll_votes_page($node) {
$data = advpoll_get_data($node);
$output = t('This table lists all the recorded votes for this poll.');
if ($data->mode == 'unlimited') {
$output = t('With unlimited voting, a timestamp is used to identify unique votes. If it is important to identify users by ID or IP, switch to normal voting mode which will use your Voting API settings to record votes.');
}
else {
if ($data->mode == 'cookie') {
$output = t('With cookie-based voting, a timestamp is used to identify unique votes while the poll\'s id is set in the cookie to limit votes for a limited time. If it is important to identify users by ID or IP, switch to normal voting mode which will use your Voting API settings to record votes.');
}
else {
$output = t('If anonymous users are allowed to vote, they will be identified by the IP address of the computer they used when they voted.');
}
}
$header = array();
$header[] = array(
'data' => t('Visitor'),
'field' => 'uid',
);
$header[] = array(
'data' => t('Date'),
'field' => 'timestamp',
'sort' => 'asc',
);
$header[] = array(
'data' => t('Choice'),
'tag',
);
$nid = $node->nid;
$query = db_select('votingapi_vote', 'v')
->condition('entity_id', $nid)
->extend('PagerDefault')
->limit(20)
->extend('TableSort')
->orderByHeader($header)
->fields('v', array(
'uid',
'timestamp',
'tag',
'vote_source',
));
$results = $query
->execute();
$userObj = null;
$rows = array();
foreach ($results as $item) {
$userID = $item->uid;
if (!$userID) {
$userID = $item->vote_source;
}
else {
$userObj = user_load($userID);
if ($userObj) {
$userID = l($userObj->name, 'user/' . $userID);
}
}
$rows[] = array(
'data' => array(
$userID,
format_date($item->timestamp),
advpoll_match_tag_to_choice($data->choices, $item->tag),
),
);
}
if ($rows) {
$output .= theme('table', array(
'header' => $header,
'rows' => $rows,
));
$output .= theme('pager', array(
'tags' => array(),
));
if (user_access('administer votes')) {
$output .= drupal_render(drupal_get_form('advpoll_clear_votes_form'));
}
}
else {
$output .= '<hr /><p>' . t('No votes are currently recorded for %title', array(
'%title' => $node->title,
)) . '</p>';
}
return $output;
}