[ABD] Show poll voters for phpBB3

Any abandoned MODs will be moved to this forum.

WARNING: MODs in this forum are not currently being supported or maintained by the original MOD author. Proceed at your own risk.
Forum rules
IMPORTANT: MOD Development Forum rules

WARNING: MODs in this forum are not currently being supported nor updated by the original MOD author. Proceed at your own risk.
Locked
evaarties
Registered User
Posts: 25
Joined: Thu May 12, 2005 8:56 am

[ABD] Show poll voters for phpBB3

Post by evaarties » Wed Aug 01, 2007 12:47 pm

This MOD changes the percentage next to a vote resultbar to a dropdownlist showing the percentage and the users who voted for that option. If the total of votes is different to the number of voters, this is shown as the last item in the list with "<> #nr" wher nr is the difference.

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)
and replace this with

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)
and replace this with

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'])
File /styles/prosilver/viewtopic_body.html, find

Code: Select all

<!-- ELSE -->{poll_option.POLL_OPTION_PERCENT}<!-- ENDIF -->
and replace this with

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)
and replace this with

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)
and replace this with

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'])
File /styles/prosilver/viewtopic_body.html, find

Code: Select all

<!-- ELSE -->{poll_option.POLL_OPTION_PERCENT}<!-- ENDIF -->
and replace this with

Code: Select all

              <!-- ELSE -->
                {poll_option.POLL_OPTION_PERCENT}
                <dd class="resultbar">
                  {poll_option.POLL_OPTION_VOTERS}
                </dd>
              <!-- ENDIF -->
That's it, enjoy this little MOD.

NB RC5 has some changes, see these posts:

http://www.phpbb.com/community/viewtopi ... 5#p3171129
http://www.phpbb.com/community/viewtopi ... 5#p3176368
Last edited by DavidIQ on Sat Dec 18, 2010 9:02 pm, edited 6 times in total.
Reason: Marked as abandoned. Contact a MOD Team member to reclaim topic.

joebanana
Registered User
Posts: 134
Joined: Tue Nov 23, 2004 6:28 pm

Re: [BETA] Show poll voters for phpBB3

Post by joebanana » Wed Aug 01, 2007 1:30 pm

Awesome, I badley needed that :D

I'll give it a try!

joebanana
Registered User
Posts: 134
Joined: Tue Nov 23, 2004 6:28 pm

Re: [BETA] Show poll voters for phpBB3

Post by joebanana » Wed Aug 01, 2007 1:41 pm

Parse error: syntax error, unexpected T_VARIABLE in /home/www/e02ee32f965e0bdc61e91287d309eebc/web/poker/viewtopic.php on line 742

Any clue ?

evaarties
Registered User
Posts: 25
Joined: Thu May 12, 2005 8:56 am

Re: [BETA] Show poll voters for phpBB3

Post by evaarties » Wed Aug 01, 2007 1:56 pm

joebanana wrote:Parse error: syntax error, unexpected T_VARIABLE in /home/www/e02ee32f965e0bdc61e91287d309eebc/web/poker/viewtopic.php on line 742

Any clue ?
Can you post your old & new viewtopic.php ?

PS Which build of phpBB3 do you have?

joebanana
Registered User
Posts: 134
Joined: Tue Nov 23, 2004 6:28 pm

Re: [BETA] Show poll voters for phpBB3

Post by joebanana » Wed Aug 01, 2007 1:59 pm

Nevermind, I made a mistake while editing viewtopic.php

However, when voting, I don't see the username:

Image

evaarties
Registered User
Posts: 25
Joined: Thu May 12, 2005 8:56 am

Re: [BETA] Show poll voters for phpBB3

Post by evaarties » Wed Aug 01, 2007 2:02 pm

joebanana wrote:Nevermind, I made a mistake while editing viewtopic.php

However, when voting, I don't see the username:

Image
Did you replaced this line:

Code: Select all

         'POLL_OPTION_VOTED'      => (in_array($poll_option['poll_option_id'], $cur_voted_id)) ? true : false)
as stated above?

joebanana
Registered User
Posts: 134
Joined: Tue Nov 23, 2004 6:28 pm

Re: [BETA] Show poll voters for phpBB3

Post by joebanana » Wed Aug 01, 2007 2:08 pm

I suck at editing today!

It's showing up now :)

Last problem I have (and this time I double checked all edits):

Image

joebanana
Registered User
Posts: 134
Joined: Tue Nov 23, 2004 6:28 pm

Re: [BETA] Show poll voters for phpBB3

Post by joebanana » Wed Aug 01, 2007 2:11 pm

And last request I have, if I want to display all users who voted just below the percentage bar instead of the dropdown list, what should I do?

evaarties
Registered User
Posts: 25
Joined: Thu May 12, 2005 8:56 am

Re: [BETA] Show poll voters for phpBB3

Post by evaarties » Wed Aug 01, 2007 2:26 pm

joebanana wrote:I suck at editing today!

It's showing up now :)

Last problem I have (and this time I double checked all edits):

Image
Well, with this I can't help you. In my original viewtopic.php, not even the word 'wrote' shows up. Perhaps you have a conflict with another mod? If you'd like me to check, post your viewtopic.php.
joebanana wrote:And last request I have, if I want to display all users who voted just below the percentage bar instead of the dropdown list, what should I do?
You mean something like this:

============BAR=============
user1, user2, user3

?

Or do you mean
============BAR=============
[dropdownlist]

?

The second type can be reached by:

File /styles/prosilver/viewtopic_body.html (I asume you haven't edited this file with my MOD already), find

Code: Select all

<!-- ELSE -->{poll_option.POLL_OPTION_PERCENT}<!-- ENDIF -->
and replace this with

Code: Select all

              <!-- ELSE -->
                {poll_option.POLL_OPTION_PERCENT}
                <dd class="resultbar">
                  <select style="font-size: xx-small;">
                    {poll_option.POLL_OPTION_VOTERS}
                  </select>
                </dd>
              <!-- ENDIF -->

joebanana
Registered User
Posts: 134
Joined: Tue Nov 23, 2004 6:28 pm

Re: [BETA] Show poll voters for phpBB3

Post by joebanana » Wed Aug 01, 2007 2:31 pm

evaarties wrote:Well, with this I can't help you. In my original viewtopic.php, not even the word 'wrote' shows up. Perhaps you have a conflict with another mod? If you'd like me to check, post your viewtopic.php.
VIEWTOPIC
evaarties wrote: You mean something like this:

============BAR=============
user1, user2, user3
Exactly that yes :)

evaarties
Registered User
Posts: 25
Joined: Thu May 12, 2005 8:56 am

Re: [BETA] Show poll voters for phpBB3

Post by evaarties » Wed Aug 01, 2007 2:45 pm

joebanana wrote:
evaarties wrote:Well, with this I can't help you. In my original viewtopic.php, not even the word 'wrote' shows up. Perhaps you have a conflict with another mod? If you'd like me to check, post your viewtopic.php.
VIEWTOPIC
evaarties wrote: You mean something like this:

============BAR=============
user1, user2, user3
Exactly that yes :)

Well, I don't see anything strange in your viewtopic.php and I can't find the word "wrote" in it, you should check all your file for the that word and check those files.

And the other style you want, check the first topic (it might need some tweaking in viewtopic_body.html). It's there. PS It also shows the <> #nr as the last voter when it's relevant.

Good luck. For now I'm on a short holiday ;).

User avatar
playerfr
Registered User
Posts: 851
Joined: Fri Jul 18, 2003 9:50 am
Location: France - Paris

Re: [BETA] Show poll voters for phpBB3

Post by playerfr » Wed Aug 01, 2007 2:57 pm

hello,

Nice mod , but can we limit this to Admin or Super mod ? so that the secret of vote is kept ? :oops:
All kind of help for your Forums / Sites. Installing for you the forum, the Mods, creating Custom Mods : for small fee http://www.phpbbhelpers.com

joebanana
Registered User
Posts: 134
Joined: Tue Nov 23, 2004 6:28 pm

Re: [BETA] Show poll voters for phpBB3

Post by joebanana » Wed Aug 01, 2007 8:40 pm

I made the change with what you edited in your first post and that did the trick. I also resolved the weird message problem (cache problem).

Nice Mod, love it :D

evaarties
Registered User
Posts: 25
Joined: Thu May 12, 2005 8:56 am

Re: [BETA] Show poll voters for phpBB3

Post by evaarties » Mon Aug 06, 2007 6:58 am

playerfr wrote:hello,

Nice mod , but can we limit this to Admin or Super mod ? so that the secret of vote is kept ? :oops:

This should be possible, but I'm not implementing this. You're free to take the code and enhance it to your likings. Just place it in this thread so other people can find it and so the versions stay together.
joebanana wrote:I made the change with what you edited in your first post and that did the trick. I also resolved the weird message problem (cache problem).

Nice Mod, love it :D
Glad you like it :).

User avatar
Dr.Death
QA Team
Posts: 363
Joined: Fri Apr 25, 2003 10:04 am
Location: Germany
Contact:

Re: [BETA] Show poll voters for phpBB3

Post by Dr.Death » Mon Aug 06, 2007 8:14 am

Nice MOD.

Only a little error in the PHP part.

Change :

Code: Select all

		$db->sql_freeresult($result_voters);

to:

Code: Select all

		$db->sql_freeresult($results_voters);
There was a missing " s "
Doc.

Locked

Return to “[3.0.x] Abandoned MODs”