diff --git a/index.cgi b/index.cgi index a7f1232..f45f21f 100755 --- a/index.cgi +++ b/index.cgi @@ -166,10 +166,11 @@ sub list { my $items; if ($show_read) { my $fields = "feeds.id as feed_id, feeds.title as feed_title, allow_img, link, items.title as item_title, content, " - . "items.id as item_id, issued, username, lang"; + . "items.id as item_id, issued, read.username, lang"; my $tables = "items join feeds on items.feed_id=feeds.id left outer join read on (items.id=read.item_id and username=?)"; + my @params = ($q->remote_user); my @where; if (%feed_item_show) { push @where, "feeds.id in (" . join(',', keys %feed_item_show) . ")"; @@ -179,10 +180,15 @@ sub list { } my $where = "where " . join(" and ", @where); + if ($show_later) { + $tables .= " left outer join later on (items.id=later.item_id and later.username=?)"; + push @params, $q->remote_user; + $where .= " or (later.username is not null)" + } my $cmd = "select $fields from $tables $where order by issued"; print_log("$cmd"); - my $items1 = $dbh->selectall_arrayref($cmd, { Slice => {} }, $q->remote_user); + my $items1 = $dbh->selectall_arrayref($cmd, { Slice => {} }, @params); my $nrd = 0; while (@$items1) { my $item = pop @$items1; @@ -208,7 +214,11 @@ sub list { } if (!$show_old) { - push @where, "(items.old is null or items.old = 0)" + if ($show_later) { + push @where, "(later.username is not null or items.old is null or items.old = 0)" + } else { + push @where, "(items.old is null or items.old = 0)" + } } my $where = "where " . join(" and ", @where);