Scoop -- the swiss army chainsaw of content management
Front Page · Everything · News · Code · Help! · Wishlist · Project · Scoop Sites · Dev Notes · Latest CVS changes · Development Activities
Scoop Box Exchange - Show Box: mod_stats 1.00

Author: Scoop Developers

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 };
Display: Sort:
Menu
· create account
· faq
· search
· report bugs
· Scoop Administrators Guide
· Scoop Box Exchange

Scoop Site Scroller: Get one yourself!
Keepers of Lists
Got Lists? We've got over 1800

Login
Make a new account
Username:
Password:

Hosted by ScoopHost.com Powered by Scoop
All trademarks and copyrights on this page are owned by their respective companies. Comments are owned by the Poster. The Rest © 1999 The Management

create account | faq | search