Simple Machines Community Forum

SMF Development => Bug Reports => Topic started by: Adrek on June 01, 2012, 09:57:24 AM

Title: View results button under poll with results only after voting
Post by: Adrek on June 01, 2012, 09:57:24 AM
If in poll settings you mark option "Only show the results after someone has voted." under this poll regular user can see button "View results" even if they did not voted yet.

Tested on clean SMF 2.0.2 UTF8

Didn't see this reporter before ::)
Title: Re: View results button under poll with results only after voting
Post by: emanuele on June 01, 2012, 11:20:33 AM
But if they press it they don't see anything, right?
Title: Re: View results button under poll with results only after voting
Post by: Adrek on June 01, 2012, 11:42:08 AM
Yes, page is reloaded and they can't see results, but anyway button shouldn't be displayed
Title: Re: View results button under poll with results only after voting
Post by: emanuele on June 01, 2012, 01:31:45 PM
Yes, of course. It was just to be sure. ;)

I think this should fix it:
Code (find) Select
$context['show_view_results_button'] = $context['allow_vote'] && (!$context['allow_poll_view'] || !$context['poll']['show_results'] || !$context['poll']['has_voted']);
Code (replace with) Select
$context['show_view_results_button'] = $context['allow_vote'] && ($context['allow_poll_view'] || $context['poll']['has_voted']) && !$context['poll']['show_results'];

Not tested in many conditions, but should make more sense...
Title: Re: View results button under poll with results only after voting
Post by: Adrek on June 01, 2012, 01:57:55 PM
yes this fixed it :)
Title: Re: View results button under poll with results only after voting
Post by: iksa on January 27, 2013, 09:12:54 AM
Quote from: emanuele on June 01, 2012, 01:31:45 PM
Code (replace with) Select
$context['show_view_results_button'] = $context['allow_vote'] && ($context['allow_poll_view'] || $context['poll']['has_voted']) && !$context['poll']['show_results'];

Apparently the || $context['poll']['has_voted'] part is harmless, because it cannot be true if the user does not have the right to vote (or can it if the right has been taken away afterwards?), but it is unnecessary.
Title: Re: View results button under poll with results only after voting
Post by: emanuele on January 27, 2013, 09:16:21 AM
In fact the fix applied to 2.1 is even different:
$context['show_view_results_button'] = $context['allow_vote'] && (!$context['allow_poll_view'] || !$context['poll']['show_results'] || !$context['poll']['has_voted']);
I think I tested it to come up with this series of conditions, but don't remember anymore... lol
Title: Re: View results button under poll with results only after voting
Post by: iksa on January 27, 2013, 09:25:14 AM
Isn't that the original code that does not work?
Title: Re: View results button under poll with results only after voting
Post by: emanuele on January 27, 2013, 09:50:12 AM
lol
That's embarrassing... :-[