• Welcome to Simple Machines Community Forum. Please login or sign up.
November 28, 2021, 09:53:27 PM

News:

Want to get involved in developing SMF, then why not lend a hand on our github!


View results button under poll with results only after voting

Started by Adrek, June 01, 2012, 09:57:24 AM

Previous topic - Next topic

Adrek

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 ::)
Polskie wsparcie SMF na simplemachines.org

the simplest solution is most likely the right one

emanuele



Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Adrek

Yes, page is reloaded and they can't see results, but anyway button shouldn't be displayed
Polskie wsparcie SMF na simplemachines.org

the simplest solution is most likely the right one

emanuele

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...


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Adrek

Polskie wsparcie SMF na simplemachines.org

the simplest solution is most likely the right one

iksa

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.

emanuele

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


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

iksa


emanuele



Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Advertisement: