[dw-free] show # of participants in poll before voting
[commit: http://hg.dwscoalition.org/dw-free/rev/1ed4c51bc408]
http://bugs.dwscoalition.org/show_bug.cgi?id=3250
Always show the number of participants in the poll.
Patch by
fu.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=3250
Always show the number of participants in the poll.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- cgi-bin/LJ/Poll.pm
-------------------------------------------------------------------------------- diff -r bf8281e97826 -r 1ed4c51bc408 cgi-bin/LJ/Poll.pm --- a/cgi-bin/LJ/Poll.pm Mon May 16 21:32:45 2011 +0800 +++ b/cgi-bin/LJ/Poll.pm Mon May 16 21:50:56 2011 +0800 @@ -925,17 +925,13 @@ $ret .= LJ::Lang::ml('poll.security2', { 'whovote' => LJ::Lang::ml('poll.security.'.$self->whovote), 'whoview' => LJ::Lang::ml('poll.security.'.$whoview) }); + $ret .= LJ::Lang::ml('poll.participants', { 'total' => $self->num_participants }); if ( $mode eq 'enter' && $self->can_view( $remote ) ) { $ret .= "<br />\n"; $ret .= "[ <a href='$LJ::SITEROOT/poll/?id=$pollid&mode=results'>" . LJ::Lang::ml( 'poll.seeresults' ) . "</a> ] "; $ret .= "  [ <a href='$LJ::SITEROOT/poll/?id=$pollid&mode=clear' class='LJ_PollClearLink' id='LJ_PollClearLink_${pollid}' lj_pollid='$pollid'> " . BML::ml('poll.clear') ."</a> ]"; } elsif ( $mode eq 'results' ) { - #include number of participants - my $sth = $self->journal->prepare( "SELECT count(DISTINCT userid) FROM pollresult2 WHERE pollid=? AND journalid=?" ); - $sth->execute( $pollid, $self->journalid ); - my ( $participants ) = $sth->fetchrow_array; - $ret .= LJ::Lang::ml('poll.participants', { 'total' => $participants }); $ret .= "<br />\n"; # change vote link $ret .= "[ <a href='$LJ::SITEROOT/poll/?id=$pollid&mode=enter'>" . LJ::Lang::ml( 'poll.changevote' ) . "</a> ]" if $self->can_vote( $remote ) && !$self->is_closed; @@ -1231,6 +1227,15 @@ return 0; } +sub num_participants { + my ( $self ) = @_; + + my $sth = $self->journal->prepare( "SELECT count(DISTINCT userid) FROM pollresult2 WHERE pollid=? AND journalid=?" ); + $sth->execute( $self->pollid, $self->journalid ); + my ( $participants ) = $sth->fetchrow_array; + + return $participants; +} ########## Questions # returns list of LJ::Poll::Question objects associated with this poll --------------------------------------------------------------------------------
no subject