Skip to content

Commit

Permalink
Move anon check to reskeys
Browse files Browse the repository at this point in the history
  • Loading branch information
pudge committed Nov 8, 2005
1 parent a435025 commit 4b38d34
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
4 changes: 4 additions & 0 deletions plugins/PollBooth/ResKey.pm
Expand Up @@ -23,6 +23,10 @@ sub doCheck {
my $constants = getCurrentStatic();
my $user = getCurrentUser();

if ($user->{is_anon} && !$constants->{allow_anon_poll_voting}) {
return(RESKEY_DEATH, ['anon', {}, 'pollBooth']);
}

my $qid = $self->opts->{qid};

return(RESKEY_DEATH, ['no qid', {}, 'pollBooth']) unless $qid;
Expand Down
4 changes: 1 addition & 3 deletions plugins/PollBooth/pollBooth.pl
Expand Up @@ -420,9 +420,7 @@ sub vote {

my $question = $reader->getPollQuestion($qid, ['voters', 'question']);
my $notes = getData('display');
if (getCurrentUser('is_anon') && !getCurrentStatic('allow_anon_poll_voting')) {
$notes = getData('anon');
} elsif ($aid > 0) {
if ($aid > 0) {
my $poll_open = $reader->isPollOpen($qid);

if (!$poll_open) {
Expand Down
14 changes: 9 additions & 5 deletions plugins/PollBooth/templates/data;pollBooth;default
Expand Up @@ -38,11 +38,6 @@ __template__
[% returnme.data_constant = 1 %]
Displaying poll results.

[% CASE 'anon' %]
[% returnme.data_constant = 1 %]
You may not vote anonymously. Please
<a href="[% constants.real_rootdir %]/users.pl">log in</a>.

[% CASE 'uid_voted' %]
[% user.nickname | strip_literal %] at [% env.remote_addr %] has already voted.
[% IF env.http_x_forwarded_for %]
Expand All @@ -68,16 +63,25 @@ __template__
You must provide one or more answers.

[% CASE 'slashbox_head' %]
[% returnme.data_constant = 1 %]
<div id="slashboxes">

[% CASE 'slashbox_foot' %]
[% returnme.data_constant = 1 %]
</div>

[%# for ResKeys %]
[% CASE 'anon' %]
[% returnme.data_constant = 1 %]
You may not vote anonymously. Please
<a href="[% constants.real_rootdir %]/users.pl">log in</a>.

[% CASE 'no qid' %]
[% returnme.data_constant = 1 %]
The poll ID is missing.

[% CASE 'already voted' %]
[% returnme.data_constant = 1 %]
You've already voted.

[% END %]
Expand Down

0 comments on commit 4b38d34

Please sign in to comment.