Update of /cvs/scoop/scoop/lib/Scoop/Stories
In directory lithium.sabren.com:/tmp/cvs-serv21684/lib/Scoop/Stories
Modified Files:
Elements.pm Views.pm
Log Message:
Event Calendar module, also includes janra's get_sids() and story_data() patches.
Index: Elements.pm
===================================================================
RCS file: /cvs/scoop/scoop/lib/Scoop/Stories/Elements.pm,v
retrieving revision 1.115
retrieving revision 1.116
diff -C2 -d -r1.115 -r1.116
*** Elements.pm 4 Aug 2004 21:49:48 -0000 1.115
--- Elements.pm 21 Jan 2005 14:14:30 -0000 1.116
***************
*** 1,4 ****
--- 1,5 ----
package Scoop;
use strict;
+ my $DEBUG = 0;
sub displaystory {
***************
*** 26,33 ****
unless ($sid eq 'preview') {
! $stories = $S->getstories(
! {-type => 'fullstory',
! -sid => $sid,
! -perm_override => 1});
if ($stories) {
$story = $stories->[0];
--- 27,35 ----
unless ($sid eq 'preview') {
! $stories = $S->story_data([$sid]);
! # $stories = $S->getstories(
! # {-type => 'fullstory',
! # -sid => $sid,
! # -perm_override => 1});
if ($stories) {
$story = $stories->[0];
***************
*** 165,175 ****
my $hotlist = '';
! if ($S->{UID} >= 0 && $story->{displaystatus} >= 0) {
! my $flag = $S->check_for_hotlist_story($story->{sid});
! if ($flag) {
! $hotlist = qq|<A HREF="%%rootdir%%/hotlist/remove/$story->{sid}$oplink">%%hotlist_remove_link%%</A>|;
! } else {
! $hotlist = qq|<A HREF="%%rootdir%%/hotlist/add/$story->{sid}$oplink">%%hotlist_link%%</A>|;
! }
}
--- 167,177 ----
my $hotlist = '';
! # if ($S->{UID} >= 0 && $story->{displaystatus} >= 0) {
! # my $flag = $S->check_for_hotlist_story($story->{sid});
! # if ($flag) {
! if ( $story->{hotlisted} ) {
! $hotlist = qq|<A HREF="%%rootdir%%/hotlist/remove/$story->{sid}$oplink">%%hotlist_remove_link%%</A>|;
! } elsif ($S->{UID} > 0) {
! $hotlist = qq|<A HREF="%%rootdir%%/hotlist/add/$story->{sid}$oplink">%%hotlist_link%%</A>|;
}
***************
*** 204,209 ****
$page =~ s/%%new%%/$is_new/g;
! if( $add_readmore )
! {
my ($more, $stats, $section_link) = $S->story_links( $story );
$page =~ s/%%readmore%%/$more/g;
--- 206,210 ----
$page =~ s/%%new%%/$is_new/g;
! if( $add_readmore ) {
my ($more, $stats, $section_link) = $S->story_links( $story );
$page =~ s/%%readmore%%/$more/g;
***************
*** 216,219 ****
--- 217,230 ----
}
+ =over 4
+
+ =item $S->getstories($args_hashref)
+
+ This is deprecated. It is also rather nutty. Use $S->story_data() instead.
+
+ =back
+
+ =cut
+
sub getstories {
my $S = shift;
***************
*** 222,230 ****
my ($rv, $sth);
my $return_stories = [];
!
my $type = $args->{'-type'};
my $topic = $args->{'-topic'};
my $user = $args->{'-user'};
! my $maxstories = $args->{'-maxstories'} || $S->{UI}->{VARS}->{maxstories};
my $section = $args->{'-section'};
--- 233,241 ----
my ($rv, $sth);
my $return_stories = [];
! warn "(getstories) starting..." if $DEBUG;
my $type = $args->{'-type'};
my $topic = $args->{'-topic'};
my $user = $args->{'-user'};
! my $maxstories = $args->{'-maxstories'} || $S->pref('maxstories');
my $section = $args->{'-section'};
***************
*** 265,274 ****
my $from = qq|stories s LEFT JOIN $db_name u ON s.aid = u.uid|;
! $from .= ", $args->{-from}" if ($args->{-from});
($rv, $sth) = $S->db_select({
! DEBUG => 0,
ARCHIVE => $archive,
! WHAT => qq{sid, tid, aid, u.nickname AS nick, title, dept, $date_format AS ftime, introtext, bodytext, section, displaystatus},
FROM => $from,
WHERE => join(" AND ", @where),
--- 276,285 ----
my $from = qq|stories s LEFT JOIN $db_name u ON s.aid = u.uid|;
! $from .= " $args->{-from}" if ($args->{-from});
($rv, $sth) = $S->db_select({
! DEBUG => $DEBUG,
ARCHIVE => $archive,
! WHAT => qq{s.sid, s.tid, s.aid, u.nickname AS nick, s.title, s.dept, $date_format AS ftime, s.introtext, s.bodytext, s.section, s.displaystatus},
FROM => $from,
WHERE => join(" AND ", @where),
***************
*** 289,293 ****
$sth->finish();
($rv, $sth) = $S->db_select({
! DEBUG => 0,
ARCHIVE => 0,
WHAT => qq|count(sid)|,
--- 300,304 ----
$sth->finish();
($rv, $sth) = $S->db_select({
! DEBUG => $DEBUG,
ARCHIVE => 0,
WHAT => qq|count(sid)|,
***************
*** 302,306 ****
($rv, $sth) = $S->db_select({
ARCHIVE => 1,
! DEBUG => 0,
WHAT => qq|sid, tid, aid, u.nickname AS nick, title, dept, $date_format AS ftime, introtext, bodytext, section, displaystatus|,
FROM => $from,
--- 313,317 ----
($rv, $sth) = $S->db_select({
ARCHIVE => 1,
! DEBUG => $DEBUG,
WHAT => qq|sid, tid, aid, u.nickname AS nick, title, dept, $date_format AS ftime, introtext, bodytext, section, displaystatus|,
FROM => $from,
***************
*** 334,338 ****
FROM => "stories s LEFT JOIN $db_name u ON s.aid = u.uid",
WHERE => qq|sid = '$args->{-sid}' $displaystatus $excl_sect_sql_wAND|,
! DEBUG => 0
});
} elsif ($type eq 'titlesonly') {
--- 345,349 ----
FROM => "stories s LEFT JOIN $db_name u ON s.aid = u.uid",
WHERE => qq|sid = '$args->{-sid}' $displaystatus $excl_sect_sql_wAND|,
! DEBUG => $DEBUG
});
} elsif ($type eq 'titlesonly') {
***************
*** 372,382 ****
($rv, $sth) = $S->db_select({
! DEBUG => 0,
ARCHIVE => $archive,
WHAT => qq{sid, title, $wmd_format AS ftime},
FROM => q{stories},
WHERE => $where,
! LIMIT => $S->{UI}->{VARS}->{maxtitles},
! OFFSET => $S->{UI}->{VARS}->{maxstories},
ORDER_BY => q{time desc}
});
--- 383,393 ----
($rv, $sth) = $S->db_select({
! DEBUG => $DEBUG,
ARCHIVE => $archive,
WHAT => qq{sid, title, $wmd_format AS ftime},
FROM => q{stories},
WHERE => $where,
! LIMIT => $S->pref('maxtitles'),
! OFFSET => $S->pref('maxstories'),
ORDER_BY => q{time desc}
});
***************
*** 384,393 ****
($rv, $sth) = $S->db_select({
ARCHIVE => $archive,
! DEBUG => 0,
WHAT => qq{sid, title, $wmd_format AS ftime},
FROM => q{stories},
WHERE => q{displaystatus >= 0 AND section = 'section' $excl_sect_sql_wAND},
! LIMIT => qq{$S->{UI}->{VARS}->{maxtitles}},
! OFFSET => q{$S->{UI}->{VARS}->{maxstories}},
ORDER_BY => q{time desc}
});
--- 395,404 ----
($rv, $sth) = $S->db_select({
ARCHIVE => $archive,
! DEBUG => $DEBUG,
WHAT => qq{sid, title, $wmd_format AS ftime},
FROM => q{stories},
WHERE => q{displaystatus >= 0 AND section = 'section' $excl_sect_sql_wAND},
! LIMIT => $S->pref('maxtitles'),
! OFFSET => $S->pref('maxstories'),
ORDER_BY => q{time desc}
});
***************
*** 430,434 ****
($rv, $sth) = $S->db_select({
ARCHIVE => 0,
! DEBUG => 1,
WHAT => qq|s.sid as sid, tid, aid, u.nickname AS nick, title, dept, $date_format AS ftime, introtext, bodytext, section, displaystatus|,
FROM => "(stories s LEFT OUTER JOIN viewed_stories v on s.sid = v.sid and v.uid = $S->{UID}) LEFT JOIN users u ON s.aid = u.uid",
--- 441,445 ----
($rv, $sth) = $S->db_select({
ARCHIVE => 0,
! DEBUG => $DEBUG,
WHAT => qq|s.sid as sid, tid, aid, u.nickname AS nick, title, dept, $date_format AS ftime, introtext, bodytext, section, displaystatus|,
FROM => "(stories s LEFT OUTER JOIN viewed_stories v on s.sid = v.sid and v.uid = $S->{UID}) LEFT JOIN users u ON s.aid = u.uid",
***************
*** 440,444 ****
($rv, $sth) = $S->db_select({
ARCHIVE => 0,
! DEBUG => 0,
WHAT => qq|sid, tid, aid, u.nickname AS nick, title, dept, $date_format AS ftime, introtext, bodytext, section, displaystatus|,
FROM => 'stories s LEFT JOIN users u ON s.aid = u.uid',
--- 451,455 ----
($rv, $sth) = $S->db_select({
ARCHIVE => 0,
! DEBUG => $DEBUG,
WHAT => qq|sid, tid, aid, u.nickname AS nick, title, dept, $date_format AS ftime, introtext, bodytext, section, displaystatus|,
FROM => 'stories s LEFT JOIN users u ON s.aid = u.uid',
***************
*** 465,469 ****
($rv, $sth) = $S->db_select({
ARCHIVE => 0,
! DEBUG => 0,
WHAT => qq|count(sid)|,
FROM => 'stories',
--- 476,480 ----
($rv, $sth) = $S->db_select({
ARCHIVE => 0,
! DEBUG => $DEBUG,
WHAT => qq|count(sid)|,
FROM => 'stories',
***************
*** 474,478 ****
($rv, $sth) = $S->db_select({
ARCHIVE => 1,
! DEBUG => 0,
WHAT => qq|sid, tid, aid, u.nickname AS nick, title, dept, $date_format AS ftime, introtext, bodytext, section, displaystatus|,
FROM => "stories s LEFT JOIN users u ON s.aid = u.uid",
--- 485,489 ----
($rv, $sth) = $S->db_select({
ARCHIVE => 1,
! DEBUG => $DEBUG,
WHAT => qq|sid, tid, aid, u.nickname AS nick, title, dept, $date_format AS ftime, introtext, bodytext, section, displaystatus|,
FROM => "stories s LEFT JOIN users u ON s.aid = u.uid",
***************
*** 511,514 ****
--- 522,775 ----
}
+
+ =over 4
+
+ =item $S->get_sids($params)
+ =item $S->story_data($sids)
+
+ These are a replacement for getstories() and should be used instead. It is saner,
+ cleaner, uses a per-request cache, and tries to reduce the database load quite
+ a bit more.
+
+ The first takes a hashref of options, and does all the permission checking and
+ does a select on the stories table (joined with viewed_stories if the hotlisted
+ flag is set) and returns an arrayref of story IDs. It requires you to be more
+ specific than getstories() did, but because of this it doesn't try to be
+ "smart" and prevent you from getting exactly what you want. The values in the
+ hashref of options may be strings or arrayrefs; if arrayrefs, SQL IN() will be
+ used instead of = so you can filter on multiple values at once.
+
+ The second takes an arrayref of story IDs and checks the cache, falling through
+ to the database if necessary and filling the cache, and returns an arrayref
+ containing a hashref for each story (as getstories() did) including all fields
+ from the stories table, the read comments and hotlist information, and the
+ comment counts.
+
+ They will generally be used together, but if you already know the SID(s) you
+ want, the second one can be used alone.
+
+ =back
+
+ =cut
+ sub get_sids {
+ my $S = shift;
+ my $params = shift;
+ my $sids;
+ my $q_uid = $S->dbh->quote($S->{UID});
+
+ warn "(get_sids) starting..." if $DEBUG;
+
+ #aid overrules user
+ $params->{aid} = $S->get_uid_from_nick($params->{user}) if ($params->{user} && !$params->{aid});
+
+ # set up the SQL query
+ my ($joined, $where, $from);
+ my ($disallowed_sections, $subsections, $excl_from_all);
+ my @allowed_auto_fields = qw(sid tid aid time writestatus hits section displaystatus commentstatus totalvotes score rating attached_poll sent_email edit_category);
+ # most story table fields; some excluded because they're more suitable
+ # for search than get_sids
+
+ $from = 'stories s';
+
+ # the where clauses...
+ unless ( $params->{perm_override} ) {
+ # do perm-checking here
+ warn "(get_sids) checking permissions..." if $DEBUG;
+ $disallowed_sections = $S->get_disallowed_sect_sql('norm_read_stories');
+ }
+ # sections excluded from "All"
+ if ( $params->{section} eq '__all__' ) {
+ $excl_from_all = $S->excluded_from_all_stories();
+ delete($params->{section});
+ }
+ # SQL to make sure we get stories from subsections as needed
+ $subsections = ( $S->var('enable_subsections') && $params->{section} )
+ ? $S->get_inheritable_sect_sql($params->{section}) : '';
+
+ $where = $disallowed_sections;
+ $where .= ( $where && $subsections ) ? ' AND ' : '';
+ $where .= $subsections;
+ $where .= ( $where && $excl_from_all ) ? ' AND ' : '';
+ $where .= $excl_from_all;
+
+ if ( $params->{hotlisted} ) {
+ # we want hotlisted stories
+ warn "(get_sids) looking for hotlisted stories" if $DEBUG;
+ $from .= " LEFT JOIN viewed_stories v ON (s.sid = v.sid AND v.uid = $q_uid)";
+ $where .= " AND v.hotlisted = 1";
+ }
+
+ # add WHERE info for the auto fields
+ foreach my $auto (@allowed_auto_fields) {
+ if ( ref($params->{$auto}) eq 'ARRAY' ) {
+ my $sql_auto = join(', ', map {$S->dbh->quote($_)} (@{$params->{$auto}}));
+ $where .= " AND $auto IN ($sql_auto)";
+ } elsif ( defined($params->{$auto}) ) {
+ $where .= " AND $auto = " . $S->dbh->quote($params->{$auto});
+ }
+ }
+
+ $where .= $params->{where} if $params->{where};
+ $from .= " " . $params->{from} if $params->{from};
+
+ $where =~ s/^ AND //;
+ # make sure it doesn't start with an AND...
+
+ my $limit = (defined($params->{limit})) ? $params->{limit} : $S->pref('maxstories');
+ # set limit to zero to disable limits, leave unset to get maxstories
+ my $page = $params->{page} || 1;
+ my $offset = $params->{offset} || ($page-1) * $limit;
+
+ my ($rv,$sth) = $S->db_select({
+ DEBUG => $DEBUG,
+ WHAT => 's.sid',
+ FROM => $from,
+ WHERE => $where,
+ ORDER_BY => 's.time desc',
+ LIMIT => $limit,
+ OFFSET => $offset
+ });
+
+
+ while ( my ($sid) = $sth->fetchrow_array() ) {
+ push @$sids,$sid;
+ }
+ my $fetched = $rv;
+ $sth->finish();
+
+ #FIXME don't forget the archive!
+ if ( ($fetched < $limit || $limit == 0) && $S->{HAVE_ARCHIVE} ) {
+ warn "(get_sids) didn't get all the stories... checking archive db" if $DEBUG;
+
+ # calculate the offset within the archive db
+ ($rv,$sth) = $S->db_select({
+ DEBUG => $DEBUG,
+ WHAT => 'count(sid)',
+ FROM => 'stories',
+ WHERE => $where,
+ ORDER_BY => 's.time desc'
+ });
+ my $maxoffset = $sth->fetchrow;
+ $sth->finish();
+ my $newoffset = $offset - $maxoffset + $fetched;
+
+ my $newfrom = $from;
+ if ( $params->{hotlisted} ) {
+ # we want hotlisted stories
+ # have to join to viewed_stories in the main db to get them
+ if ( lc($S->{CONFIG}->{DBType}) eq 'mysql' ) {
+ $newfrom =~ s/viewed_stories/$S->{CONFIG}->{db_name}.viewed_stories/;
+ }
+ }
+
+ ($rv,$sth) = $S->db_select({
+ DEBUG => $DEBUG,
+ ARCHIVE => 1,
+ WHAT => 's.sid',
+ FROM => $newfrom,
+ WHERE => $where,
+ ORDER_BY => 's.time desc',
+ LIMIT => $limit,
+ OFFSET => $newoffset
+ });
+
+ while ( my ($sid) = $sth->fetchrow_array() ) {
+ push @$sids,$sid;
+ }
+ $sth->finish();
+ }
+
+ if ( $sids ) { warn "(get_sids) returning " . join(', ', @$sids) if $DEBUG; }
+
+ return $sids;
+ }
+
+ sub story_data {
+ my $S = shift;
+ my $sids = shift;
+
+ my $return_stories;
+ my $q_uid = $S->dbh->quote($S->{UID});
+
+ warn "(story_data) starting..." if $DEBUG;
+
+ my $sids_to_fetch;
+ foreach (@$sids) {
+ push @$sids_to_fetch,$_ unless ($S->{STORY_CACHE}->{$_});
+ }
+
+ if ( $sids_to_fetch ) {
+ warn "(story_data) getting @$sids_to_fetch from database" if $DEBUG;
+ my $sids_sql = join(',', map { $S->dbh->quote($_) } (@$sids_to_fetch) );
+
+
+ # build the SQL query for those stories not in the cache
+ my $date_format = $S->date_format('time');
+
+ my ($rv,$sth) = $S->db_select({
+ DEBUG => $DEBUG,
+ WHAT => "s.*,v.hotlisted,v.lastseen,v.highest_idx,u.nickname as nick,$date_format as ftime,count(c.cid) as comments",
+ FROM => "stories s LEFT JOIN users u ON s.aid = u.uid LEFT JOIN viewed_stories v ON (s.sid = v.sid AND v.uid = $q_uid) LEFT JOIN comments c ON s.sid = c.sid",
+ WHERE => "s.sid IN ($sids_sql)",
+ GROUP_BY => 's.sid'
+ });
+
+ while ( my $story = $sth->fetchrow_hashref() ) {
+ # cache them
+ $S->{STORY_CACHE}->{$story->{sid}} = $story;
+ }
+ }
+
+ $sids_to_fetch = [];
+ foreach (@$sids) {
+ push @$sids_to_fetch,$_ unless ( grep { /^$_$/ } (keys %{$S->{STORY_CACHE}}) );
+ # checking to see if we got them all - if not, we look in the archive
+ }
+ if ( $sids_to_fetch && $S->{HAVE_ARCHIVE} ) {
+ warn "(story_data) getting @$sids_to_fetch from archive database" if $DEBUG;
+ my $sids_sql = join(',', map { $S->dbh->quote($_) } (@$sids_to_fetch) );
+
+
+ # build the SQL query for those stories not in the cache
+ my ($usertable,$viewedtable);
+ if ( lc($S->{CONFIG}->{DBType}) eq 'mysql' ) {
+ $usertable = $S->{CONFIG}->{db_name} . ".users";
+ $viewedtable = $S->{CONFIG}->{db_name} . ".viewed_stories";
+ } else {
+ # postgres can't join between two different databases
+ $usertable = 'users';
+ $viewedtable = 'viewed_stories';
+ }
+ my $date_format = $S->date_format('time');
+
+ my ($rv,$sth) = $S->db_select({
+ DEBUG => $DEBUG,
+ ARCHIVE => 1,
+ WHAT => "s.*,v.hotlisted,v.lastseen,v.highest_idx,u.nickname as nick,$date_format as ftime,count(c.cid) as comments",
+ FROM => "stories s LEFT JOIN $usertable u ON s.aid = u.uid LEFT JOIN $viewedtable v ON (s.sid = v.sid AND v.uid = $q_uid) LEFT JOIN comments c ON s.sid = c.sid",
+ WHERE => "s.sid IN ($sids_sql)",
+ GROUP_BY => 's.sid'
+ });
+
+ while ( my $story = $sth->fetchrow_hashref() ) {
+ $story->{archived} = 1;
+ # cache them
+ $S->{STORY_CACHE}->{$story->{sid}} = $story;
+ }
+ }
+
+ foreach (@$sids) {
+ # assume they were given to us in the correct order
+ push @$return_stories,$S->{STORY_CACHE}->{$_} if $S->{STORY_CACHE}->{$_};
+ warn "(story_data) returning $_ ($S->{STORY_CACHE}->{$_}->{title})" if $DEBUG;
+ }
+
+
+ return $return_stories;
+ }
+
+
+
+
# Fetch and SQL-format any optional sections to exclude from
# the "__all__" section
***************
*** 516,525 ****
my $S = shift;
! my @sections = split /,\s*/, $S->{UI}->{VARS}->{'sections_excluded_from_all'};
my $sql;
foreach my $sec (@sections) {
next unless (exists $S->{SECTION_DATA}->{$sec});
! $sql .= qq|AND section != '$sec'|;
}
--- 777,786 ----
my $S = shift;
! my @sections = split /,\s*/, $S->var('sections_excluded_from_all');
my $sql;
foreach my $sec (@sections) {
next unless (exists $S->{SECTION_DATA}->{$sec});
! $sql .= qq| AND section != '$sec'|;
}
***************
*** 575,579 ****
($rv, $sth) = $S->db_select({
ARCHIVE => $S->_check_archivestatus($sid),
! DEBUG => 0,
WHAT => 'sid, title',
FROM => 'stories',
--- 836,840 ----
($rv, $sth) = $S->db_select({
ARCHIVE => $S->_check_archivestatus($sid),
! DEBUG => $DEBUG,
WHAT => 'sid, title',
FROM => 'stories',
***************
*** 590,594 ****
($rv, $sth) = $S->db_select({
! DEBUG => 0,
WHAT => 'sid, title',
FROM => 'stories',
--- 851,855 ----
($rv, $sth) = $S->db_select({
! DEBUG => $DEBUG,
WHAT => 'sid, title',
FROM => 'stories',
***************
*** 730,734 ****
my $quotesid = $S->{DBH}->quote($sid);
my ($rv, $sth) = $S->db_select({
! DEBUG => 0,
WHAT => 'time, vote',
FROM => 'storymoderate',
--- 991,995 ----
my $quotesid = $S->{DBH}->quote($sid);
my ($rv, $sth) = $S->db_select({
! DEBUG => $DEBUG,
WHAT => 'time, vote',
FROM => 'storymoderate',
Index: Views.pm
===================================================================
RCS file: /cvs/scoop/scoop/lib/Scoop/Stories/Views.pm,v
retrieving revision 1.67
retrieving revision 1.68
diff -C2 -d -r1.67 -r1.68
*** Views.pm 4 Aug 2004 21:49:48 -0000 1.67
--- Views.pm 21 Jan 2005 14:14:30 -0000 1.68
***************
*** 24,27 ****
--- 24,39 ----
$story_params->{-where} = $where_additions if $where_additions;
$story_params->{-from} = $from_additions if $from_additions;
+ my $params;
+ $params->{topic} = $topic if $topic;
+ $params->{user} = $user if $user;
+ $params->{page} = $spage if $spage;
+ $params->{where} = $where_additions if $where_additions;
+ $params->{from} = $from_additions if $from_additions;
+ if ( $story_type eq 'main' ) {
+ $params->{displaystatus} = '0';
+ } elsif ( $story_type eq 'section' ) {
+ $params->{displaystatus} = [0,1];
+ $params->{section} = $section;
+ }
# if they don't have permission to view this section, let them know
***************
*** 43,47 ****
}
! my $stories = $S->getstories($story_params);
my $page;
--- 55,61 ----
}
! my $sids = $S->get_sids($params);
! my $stories = $S->story_data($sids);
! # my $stories = $S->getstories($story_params);
my $page;
***************
*** 124,131 ****
my $comment_plural = $S->{UI}->{BLOCKS}->{comment_plural} || 's';
push @readmore, sprintf( "$S->{UI}->{BLOCKS}->{comment_num_format_start}%d$S->{UI}->{BLOCKS}->{comment_num_format_end} %s%s",
! $story->{commentcount},
$comment_word,
! $story->{commentcount} != 1 ? $comment_plural : ''
! ) if( $story->{commentcount} && $S->have_section_perm('norm_read_comments',$story->{section}) );
my $show = $S->{UI}->{VARS}->{show_new_comments};
--- 138,145 ----
my $comment_plural = $S->{UI}->{BLOCKS}->{comment_plural} || 's';
push @readmore, sprintf( "$S->{UI}->{BLOCKS}->{comment_num_format_start}%d$S->{UI}->{BLOCKS}->{comment_num_format_end} %s%s",
! $story->{comments},
$comment_word,
! $story->{comments} != 1 ? $comment_plural : ''
! ) if( $story->{comments} && $S->have_section_perm('norm_read_comments',$story->{section}) );
my $show = $S->{UI}->{VARS}->{show_new_comments};