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: hotlist_flex 1.00

Author: hillct [Info]

Description:

This is version 0.2.3 of the hotlist_flex box which in addition to the treditonal hotlist display, also allos the user to view a predefined hotlist of that user's own stories, as well as (most significantly) displaying a list of stories on which the user commented and to which comments there have been replies made. The display mode of the box is stored in the user's session hash.

Box Code:

### Start hotlist_flex Box ###
# Display Hotlist, Stories and unread replies to user comments
# Version 0.2.3 by hillct

my($view,$content,$item);
my $uri=$S->{APACHE}->uri;
my $arg = $S->apache->args();
$arg =~ s/set-view=\w+//g;
$arg =~ s/;$//;

$uri .= ($arg) ? "?$arg;" : '?';

if($S->{GID} ne 'Anonymous') { # Only if we're logged in
if($S->{CGI}->param('set-view')=~/Hotlist\|Replies\|Stories/){
$view=$S->{CGI}->param('set-view');
$S->session('hotlist-view',$view);
} else {$view = $S->session('hotlist-view') \|\| 'Hotlist';}

$content="<center><b>\|</b> ";
for ('Hotlist','Replies','Stories'){
$content.=(($_ eq $view)?"<b>$_ \|</b> ":"<a
href=\"$uri"."set-view=$_\">$_</a> <b>\|</b> ");
} $content.="</center><br>";

if($view eq 'Hotlist'){
if ($S->{HOTLIST} && $#{$S->{HOTLIST}} >= 0) {
foreach my $sid (@{$S->{HOTLIST}}) {
my $stories = $S->getstories(
{-type => 'fullstory',
-sid => $sid});
my $story = $stories->[0];

my $show = $S->{UI}->{VARS}->{show_new_comments};
my $num_new = $S->new_comments_since_last_seen($sid) if
($show eq "hotlist" \|\| $show eq "all");

my $end_s = ($story->{commentcount} == 1) ? '' : 's';
$content .= qq{|dot| <A CLASS="light"
HREF="|rootdir|/story/$sid">$story->{title}</a> ($story->{commentcount}
comment$end_s};
$content .= qq{, $num_new new} if defined($num_new);
$content .= qq{)<BR>};
}
} else{ $content.="<font size=1>No Hotlisted Stories</font>"; }
}elsif($view eq 'Replies'){

my($results,$comment,$sid);
my ($rv, $sth) = $S->db_select({
WHAT => 'c1.sid,c2.cid,c2.subject',
FROM => 'comments AS c1 LEFT JOIN comments as c2 on c2.sid=c1.sid
AND c2.pid=c1.cid LEFT JOIN viewed_stories ON viewed_stories.sid=c1.sid
AND viewed_stories.uid=c1.uid',
WHERE => qq{c1.uid=$S->{UID} AND c2.sid IS NOT NULL AND c2.cid > viewed_stories.highest_idx}
});

while ($comment = $sth->fetchrow_hashref()) {
$results->{$comment->{'sid'}}.=qq{
|dot|
<a
href="|rootdir|/comments/$comment->{'sid'}/$comment->{'cid'}#$comment->{'cid'}"><font
size="1">$comment->{'subject'}</font></a><br>
};
}
for $sid (keys %$results){
my $story = $S->getstories({
-type => 'titlesonly',
-sid => $sid
});
$content.=qq{
<a href="|rootdir|/story/$sid"><font
size="2">$story->[0]->{title}</font></a><br>
$results->{$sid}
};
}

$content.="<font size=1>No New Replies to your Comments</font>" if $rv eq '0E0';
}elsif($view eq 'Stories'){

my ($results,$story);
my ($rv, $sth) = $S->db_select({
WHAT => 'stories.title,stories.sid,COUNT(comments.cid) AS
commentcount',
FROM => 'stories LEFT JOIN comments ON comments.sid=stories.sid',
WHERE => qq{aid='$S->{NICK}'},
GROUP_BY => 'stories.sid',
ORDER_BY => 'time DESC'
});

while ($story = $sth->fetchrow_hashref()) {
my $sid=$story->{sid};
my $show = $S->{UI}->{VARS}->{show_new_comments};
my $num_new = $S->new_comments_since_last_seen($sid) if
($show eq "hotlist" \|\| $show eq "all");

my $end_s = ($story->{commentcount} == 1) ? '' : 's';
$content .= qq{|dot| <A CLASS="light"
HREF="|rootdir|/story/$sid">$story->{title}</a> ($story->{commentcount}
comment$end_s};
$content .= qq{, $num_new new} if defined($num_new);
$content .= qq{)<BR>};
}
$content.="<font size=1>You have written no stories</font>" if $rv eq '0E0';

}else{$content.="This error should never occur.";}

return {title => "$S->{NICK}'s $view", content => $content};
}

### End hotlist_flex Box ###


Announcement and Discussion
Display: Sort:
Needed Feature (none / 0) (#1)
by MagnaCarta on Tue Dec 27, 2005 at 08:45:08 AM PST

This is a great Box... only one thing I would add if I had the expertise....

It would be nice to see when a comment FIRST appears on a story submitted by the user.

If a user submits a story 2 weeks ago but another user makes a comment on it yesterday it would be nice to see that story pop up in the hotlist so the author can be informed of a comment...

Seems kind of like a minor addition but I don't know how to do it so.... will just leave this suggestion here..



Menu
· create account
· faq
· search
· report bugs
· Scoop Administrators Guide
· Scoop Box Exchange

Scoop Site Scroller: Get one yourself!
Smokedot
It's 4:19... do you know where your bong is?

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