This MOD has been made for phpBB 3 RC4 and has no limitations, ie everyone that may see the poll results will also see who voted for which option.
File /viewtopic.php, find:
Code: Select all
$poll_info[$i]['poll_option_text'] = str_replace("\n", '<br />', $poll_info[$i]['poll_option_text']);
if ($poll_bbcode !== false)
Code: Select all
$poll_info[$i]['poll_option_text'] = str_replace("\n", '<br />', $poll_info[$i]['poll_option_text']);
/* Begin 'Show voters' MOD by Ernst Vaarties */
$sql_voters = '
SELECT username, vote_user_id
FROM ' . POLL_VOTES_TABLE . ', ' . USERS_TABLE . '
WHERE topic_id = ' . $topic_id . '
AND poll_option_id = ' . $poll_info[$i]['poll_option_id'] . '
AND ' . POLL_VOTES_TABLE . '.vote_user_id = ' . USERS_TABLE . '.user_id
ORDER BY username ASC, vote_user_id ASC';
$results_voters = $db->sql_query($sql_voters);
$voters_total = 0;
$voters_string = "";
// Add all voters to a string.
while ($row_voters = $db->sql_fetchrow($results_voters)) {
$voters_total = $voters_total + 1;
$voters_string = $voters_string . "<option value='u=" . $row_voters['vote_user_id'] . "'>" . $row_voters['username'] ."</option>";
}
// Is the total nr of voters <> the nr of votes for the poll? Add this to the same string.
if ($voters_total <> $poll_info[$i]['poll_option_total']){
$voters_string = $voters_string . "<option><> " . ($poll_info[$i]['poll_option_total'] - $voters_total) . "</option>";
}
// Add the string to the list.
$poll_info[$i]['poll_option_voters'] = $voters_string;
$db->sql_freeresult($results_voters);
/* End 'Show voters' MOD by Ernst Vaarties */
if ($poll_bbcode !== false)
and find
Code: Select all
'POLL_OPTION_VOTED' => (in_array($poll_option['poll_option_id'], $cur_voted_id)) ? true : false)
Code: Select all
'POLL_OPTION_VOTED' => (in_array($poll_option['poll_option_id'], $cur_voted_id)) ? true : false,
'POLL_OPTION_VOTERS' => $poll_option['poll_option_voters'])
Code: Select all
<!-- ELSE -->{poll_option.POLL_OPTION_PERCENT}<!-- ENDIF -->
Code: Select all
<!-- ELSE -->
<span>
<select style="font-size: xx-small;">
<option>{poll_option.POLL_OPTION_PERCENT}</option>
<option>--------------------</option>";
{poll_option.POLL_OPTION_VOTERS}
</select>
</span>
<!-- ENDIF -->
Or use this variant to show all voters underneath the percentagebar:
File /viewtopic.php, find:
Code: Select all
$poll_info[$i]['poll_option_text'] = str_replace("\n", '<br />', $poll_info[$i]['poll_option_text']);
if ($poll_bbcode !== false)
Code: Select all
$poll_info[$i]['poll_option_text'] = str_replace("\n", '<br />', $poll_info[$i]['poll_option_text']);
/* Begin 'Show voters' MOD by Ernst Vaarties */
$sql_voters = '
SELECT username, vote_user_id
FROM ' . POLL_VOTES_TABLE . ', ' . USERS_TABLE . '
WHERE topic_id = ' . $topic_id . '
AND poll_option_id = ' . $poll_info[$i]['poll_option_id'] . '
AND ' . POLL_VOTES_TABLE . '.vote_user_id = ' . USERS_TABLE . '.user_id
ORDER BY username ASC, vote_user_id ASC';
$results_voters = $db->sql_query($sql_voters);
$voters_total = 0;
$voters_string = "";
// Add all voters to a string.
while ($row_voters = $db->sql_fetchrow($results_voters)) {
$voters_total = $voters_total + 1;
$voters_string = $voters_string . ", " . $row_voters['username'];
}
// Is the total nr of voters <> the nr of votes for the poll? Add this to the same string.
if ($voters_total <> $poll_info[$i]['poll_option_total']){
$voters_string = $voters_string . ", <> " . ($poll_info[$i]['poll_option_total'] - $voters_total);
}
$voters_string = ltrim($voters_string, ", ");
// Add the string to the list.
$poll_info[$i]['poll_option_voters'] = $voters_string;
$db->sql_freeresult($results_voters);
/* End 'Show voters' MOD by Ernst Vaarties */
if ($poll_bbcode !== false)
and find
Code: Select all
'POLL_OPTION_VOTED' => (in_array($poll_option['poll_option_id'], $cur_voted_id)) ? true : false)
Code: Select all
'POLL_OPTION_VOTED' => (in_array($poll_option['poll_option_id'], $cur_voted_id)) ? true : false,
'POLL_OPTION_VOTERS' => $poll_option['poll_option_voters'])
Code: Select all
<!-- ELSE -->{poll_option.POLL_OPTION_PERCENT}<!-- ENDIF -->
Code: Select all
<!-- ELSE -->
{poll_option.POLL_OPTION_PERCENT}
<dd class="resultbar">
{poll_option.POLL_OPTION_VOTERS}
</dd>
<!-- ENDIF -->
NB RC5 has some changes, see these posts:
http://www.phpbb.com/community/viewtopi ... 5#p3171129
http://www.phpbb.com/community/viewtopi ... 5#p3176368