Show poll Voters for phpBB3

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment!
Scam Warning
Locked
gregtampa
Registered User
Posts: 13
Joined: Sat Oct 09, 2004 3:10 pm
Location: Boca Raton, FL
Name: Greg
Contact:

Show poll Voters for phpBB3

Post by gregtampa » Tue Jul 19, 2011 3:19 pm

This is a direct topic related to http://www.phpbb.com/community/viewtopi ... &start=120
I have no idea why that thread was locked, so i'm starting a new one since it was very useful and works for the current version of phpBB3 3.0.8
On the last post on that thread by Luba there was an error! Here is the fix which includes everything that needs to be modded to make the whole show voters work in phpBB3 on a poll.


################ viewtopic.php
//SEARCH FOR

Code: Select all

foreach ($poll_info as $poll_option)
{
   $option_pct = ($poll_total > 0) ? $poll_option['poll_option_total'] / $poll_total : 0;
   $option_pct_txt = sprintf("%.1d%%", round($option_pct * 100));
//ADD AFTER

Code: Select all

/* ###############Begin 'Show voters' MOD by Ernst Vaarties */
/* ###############Begin 'Show voters' MOD by Ernst Vaarties */
$sql_voters = 
'SELECT username
FROM ' . POLL_VOTES_TABLE . ', ' . USERS_TABLE . '
WHERE topic_id = ' . $topic_id . '
AND poll_option_id = ' . $poll_option['poll_option_id'] . '
AND ' . POLL_VOTES_TABLE . '.vote_user_id = ' . USERS_TABLE . '.user_id
ORDER BY username 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_option['poll_option_total'])
{
   $voters_string = $voters_string . ", <> " . ($poll_option['poll_option_total'] - $voters_total);
}

$voters_string = ltrim($voters_string, ", ");

// Add the string to the list.
$poll_option['poll_option_voters'] = $voters_string;
$db->sql_freeresult($results_voters);
/* ####################End 'Show voters' MOD by Ernst Vaarties */ 
/* ####################End 'Show voters' MOD by Ernst Vaarties */ 
//SEARCH FOR

Code: Select all

'POLL_OPTION_VOTED' => (in_array($poll_option['poll_option_id'], $cur_voted_id)) ? true : false)
//ADD BEFORE
(This one had an error prior, I fixed it)

Code: Select all

'POLL_OPTION_VOTERS'    => $poll_option['poll_option_voters'],

//################ styles/prosilver/template/viewtopic_body.php
If your not using prosilver just find where POLL_OPTION_RESULT is located and add below.
I noticed in my theme I was using td not dd show I made the correct changes, to be safe just use what is in front of the poll_option.
//SEARCH FOR

Code: Select all

<dd><!-- IF poll_option.POLL_OPTION_RESULT == 0 -->{L_NO_VOTES}<!-- ELSE -->{poll_option.POLL_OPTION_PERCENT}<!-- ENDIF --></dd>

If anyone has a question or can't get this to work, I will assist you any way I can, just post a reply.

User avatar
Derky
Development Team Member
Development Team Member
Posts: 4821
Joined: Sun Apr 10, 2005 9:58 am
Location: Netherlands
Contact:

Re: Show poll Voters for phpBB3

Post by Derky » Tue Jul 19, 2011 10:06 pm

That topic was marked as [ABD] - Abandoned as the mod author has not been active recently.

This topic currently doesn't follow the MOD Development forum guidelines.
We only allow MOD development topics in this forum. If you want to take over the MOD please edit your topic starter as outlined in Modifications Development Forum Rules section 4a.

Locked

Return to “[3.0.x] MODs in Development”