Description:
This is the box that displays the statistics of who voted what for each story.
Box Code:
my $sid = $ARGS[0];
$sid = $S->{CGI}->param('sid') unless $sid;
return unless $sid;
my $q_sid = $S->{DBH}->quote($sid);
my ($rv, $t_sth) = $S->db_select({
WHAT => 'displaystatus',
FROM => 'stories',
WHERE => qq{sid = $q_sid}});
my $disp = $t_sth->fetchrow();
return unless ($disp == '-2');
my ($stat, $trash) = $S->_mod_or_show($sid);
return '' unless ($stat eq 'show');
my ($totalvotes, $score) = $S->_get_total_votes($sid);
my $sth = $S->_get_story_mods($sid);
my $head = $S->{UI}->{BLOCKS}->{moderate_head};
$head =~ s/%%votes%%/$totalvotes/g;
$head =~ s/%%score%%/$score/g;
my ($this_row, $user);
my $for = qq{<FORM NAME="mod_stat_show" ACTION="%%rootdir%%/" METHOD="get">
<INPUT TYPE="hidden" NAME="op" VALUE="user">
<INPUT TYPE="hidden" NAME="tool" VALUE="info">};
my $against = qq{<FORM NAME="mod_stat_show" ACTION="%%rootdir%%/" METHOD="get">
<INPUT TYPE="hidden" NAME="op" VALUE="user">
<INPUT TYPE="hidden" NAME="tool" VALUE="info">};
my $neutral = qq{<FORM NAME="mod_stat_show" ACTION="%%rootdir%%/" METHOD="get">
<INPUT TYPE="hidden" NAME="op" VALUE="user">
<INPUT TYPE="hidden" NAME="tool" VALUE="info">};
#'
my $f = 0;
my $a = 0;
my $n = 0;
$for .= qq{<small>
<SELECT NAME="uid" SIZE=1>
<OPTION VALUE="">Voted for: (%%for%%)};
$against .= qq{<small>
<SELECT NAME="uid" SIZE=1>
<OPTION VALUE="">Voted against: (%%against%%)};
$neutral .= qq{<small>
<SELECT NAME="uid" SIZE=1>
<OPTION VALUE="">Didn't care: (%%neutral%%)};
while (my $mod_rec = $sth->fetchrow_hashref) {
my $nick = $S->get_nick($mod_rec->{uid});
$nick =~ s/^(.{0,20})/$1/;
my $link = qq{
<OPTION VALUE="$mod_rec->{uid}">$nick};
if ($mod_rec->{vote} == 1) {
$for .= qq|
$link|;
$f++;
} elsif ($mod_rec->{vote} == 0) {
$neutral .= qq|
$link|;
$n++;
} elsif ($mod_rec->{vote} == -1) {
$against .= qq|
$link|;
$a++;
}
}
$sth->finish;
$for .= qq{</SELECT> <INPUT TYPE="submit" NAME="get" VALUE="Get User Info"></small></FORM>};
$against .= qq{</SELECT> <INPUT TYPE="submit" NAME="get" VALUE="Get User Info"></small></FORM>};
$neutral .= qq{</SELECT> <INPUT TYPE="submit" NAME="get" VALUE="Get User Info"></small></FORM>};
$for =~ s/%%for%%/$f/;
$against =~ s/%%against%%/$a/;
$neutral =~ s/%%neutral%%/$n/;
my $content = $head.'%%smallfont%%'.$for.$against.$neutral.'%%smallfont_end%%';
return { content => $content };
|