Recent Comments head<= <=head body<= {user}; $LJ_cmtinfo{'journal'} = $remote->{user}; my $authas = $GET{'authas'} || $remote->{'user'}; my $u = LJ::get_authas_user($authas); return LJ::bad_input($ML{'error.invalidauth'}) unless $u; my $user = $u->{'user'}; my $dbcr = LJ::get_cluster_reader($u); return "Error: can't get DB for user" unless $dbcr; my $count = LJ::get_cap($u, "tools_recent_comments_display"); # authas switcher form $ret .= "
\n"; $ret .= LJ::make_authas_select($remote, { 'authas' => $GET{'authas'} }) . "\n"; $ret .= "
\n\n"; my (@recv, @posted, %talkids); my %need_userid; my %logrow; # "jid nodeid" -> $logrow my $now = time(); my $sth; my $jargent ="journal=$u->{'user'}&"; # Retrieve recv { my $max = $dbcr->selectrow_array("SELECT MAX(jtalkid) FROM talk2 WHERE journalid=?", undef, $u->{userid}); $sth = $dbcr->prepare("SELECT jtalkid, nodetype, nodeid, parenttalkid, ". " posterid, UNIX_TIMESTAMP(datepost) as 'datepostunix', state ". "FROM talk2 ". "WHERE journalid=? AND jtalkid > ?"); $sth->execute($u->{userid}, $max - $count); die $dbcr->errstr if $dbcr->err; while (my $r = $sth->fetchrow_hashref) { $r->{itemid} = $r->{nodeid}; # fill_items_with required field push @recv, $r; $need_userid{$r->{posterid}} = 1 if $r->{posterid}; $talkids{$r->{jtalkid}} = 1; } } # Retrieve posted if ($u->{journaltype} eq "P") { $sth = $dbcr->prepare("SELECT posttime, journalid, nodetype, nodeid, jtalkid, publicitem ". "FROM talkleft ". "WHERE userid=? ORDER BY posttime DESC LIMIT $count"); $sth->execute($u->{'userid'}); my %jcount; # jid -> ct $ret .= ""; while (my $r = $sth->fetchrow_hashref) { $r->{ownerid} = $r->{journalid}; $r->{itemid} = $r->{nodeid}; # fill_items_with...multiowner required fields: ownerid, userid ! push @posted, $r; $need_userid{$r->{journalid}} = 1; } } $ret .= "
" . BML::ml('Actionlink', { 'link' => "Latest Received"}) . " " . BML::ml('Actionlink', { 'link'=>"Latest Posted"}) . "
" if $u->{journaltype} eq "P"; $ret .= ""; $ret .= ""; @recv = sort { $b->{datepostunix} <=> $a->{datepostunix} } @recv; my @recv_talkids = map { $_->{'jtalkid'} } @recv; my %props; LJ::load_talk_props2($u, \@recv_talkids, \%props); my $comment_text = LJ::get_talktext2($u, keys %talkids); my $root = LJ::journal_base($u); my $us = LJ::load_userids(keys %need_userid); LJ::fill_items_with_text_props(\@recv, $u, {'only_subject' => 1}); LJ::fill_items_with_text_props(\@posted, $us, {'multiowner' => 1, 'only_subject' => 1}); $ret .= "
"; foreach my $r ( @recv) { next unless $r->{nodetype} eq "L"; next if $r->{state} eq "D"; my $pu = $us->{$r->{posterid}}; next if $pu->{statusvis} =~ /[XS]/; $r->{'props'} = $props{$r->{'jtalkid'}}; my $lrow = $logrow{"$u->{userid} $r->{nodeid}"} ||= LJ::get_log2_row($u, $r->{'nodeid'}); my $talkid = ($r->{'jtalkid'} << 8) + $lrow->{'anum'}; my $ditemid = "$root/$lrow->{ditemid}.html"; my $talkurl = "$root/$lrow->{ditemid}.html?thread=$talkid\#t$talkid"; my $bgcolor = "transparent"; my $state = ""; if ($r->{state} eq "S") { $bgcolor = BML::fill_template("screenedbarcolor"); $state = "Screened"; } elsif ($r->{state} eq "D") { $state = "Deleted"; } elsif ($r->{state} eq "F") { $state = "Frozen"; } my $ljcmt = $LJ_cmtinfo{$talkid} = {}; $ljcmt->{u} = $pu->{userid} ? $pu->{user} : ""; $ret .= ""; } $ret .= "
"; $ret .= ($pu->{userid} ? LJ::ljuser($pu) : "Anonymous") . "
"; $ret .= LJ::ago_text($now - $r->{datepostunix}) . "
"; $ret .= "
$state
" if $r->{state} ne "D"; unless ($r->{state} eq "D") { $ret .= "" . LJ::img("btn_del", "", { 'align' => 'absmiddle', 'hspace' => 2, 'vspace' => }) . ""; if ($r->{'state'} ne 'F') { $ret .= "" . LJ::img("btn_freeze", "", { align => 'absmiddle', hspace => 2, vspace => }) . ""; } if ($r->{'state'} eq 'F') { $ret .= "" . LJ::img("btn_unfreeze", "", { align => 'absmiddle', hspace => 2, vspace => }) . ""; } if ($r->{'state'} ne 'S') { $ret .= "" . LJ::img("btn_scr", "", { 'align' => 'absmiddle', 'hspace' => 2, 'vspace' => }) . ""; } if ($r->{'state'} eq 'S') { $ret .= "" . LJ::img("btn_unscr", "", { 'align' => 'absmiddle', 'hspace' => 2, 'vspace' => }) . ""; } } # FIXME: (David?) We'll have to make talk_multi.bml understand jtalkids in multiple posts #$ret .= " "; #$ret .= " "; $ret .= "
"; my $subject = $r->{'text'}->[0]; LJ::CleanHTML::clean_subject(\$subject) if $subject ne ""; $ret .= "$subject " if $subject ne ""; $ret .= "(Entry Link)" unless $lrow->{ditemid} == undef; $ret .= "

"; my $subject = $comment_text->{$r->{jtalkid}}[0]; LJ::CleanHTML::clean_subject(\$subject); if ($subject && $subject !~ /^Re:\s*$/) { $ret .= "$subject
"; } my $comment = $comment_text->{$r->{jtalkid}}[1]; LJ::CleanHTML::clean_comment(\$comment, { 'preformatted' => $r->{'props'}->{'opt_preformatted'}, 'anon_comment' => !$pu }); $ret .= "$comment

"; $ret .= "(Comment Link) " unless $r->{state} eq "D" || $lrow->{ditemid} == undef; my $stylemine = 0; my $replyurl = LJ::Talk::talkargs($ditemid, "replyto=$talkid", $stylemine); if ($lrow->{ditemid} == undef) { $ret .= "(Post Deleted)"; } elsif ($r->{'state'} eq 'F') { $ret .= "($ML{'talk.frozen'}) "; } elsif ($r->{'state'} eq "D") { $ret .= "(Comment Deleted)"; } else { $ret .= "($ML{'talk.replytothis'}) "; } $ret .= "
"; $ret .= " $count, 'max' => $LJ::TOOLS_RECENT_COMMENTS_MAX }). " p?>" unless $count == $LJ::TOOLS_RECENT_COMMENTS_MAX; if ($u->{journaltype} eq "P") { $ret .= "
" . BML::ml('Actionlink', { 'link'=>"Latest Received"}) . BML::ml('Actionlink', { 'link' => "Latest Posted"}) . " " . "
"; $ret .= ""; my %jcount; # jid -> ct $ret .= ""; $ret .= ""; foreach my $r (@posted) { $jcount{$r->{'journalid'}}++; next unless $r->{'nodetype'} eq "L"; # log2 comment my $ju = $us->{$r->{journalid}}; my $lrow = $logrow{"$ju->{userid} $r->{nodeid}"} ||= LJ::get_log2_row($ju, $r->{'nodeid'}); my $talkid = ($r->{'jtalkid'} << 8) + $lrow->{'anum'}; my $logurl = "$LJ::SITEROOT/users/$ju->{user}/$lrow->{ditemid}.html"; my $talkurl = "$logurl?thread=$talkid\#t$talkid"; my $hr_ago = LJ::ago_text($now - $r->{'posttime'}); my $subject; if (defined $lrow->{ditemid}) { $hr_ago = "$hr_ago"; $subject = $r->{'text'}->[0] || "$lrow->{ditemid}.html"; LJ::CleanHTML::clean_subject(\$subject); $subject = "$subject"; } else { $subject = "Post Deleted"; } my $links = "[Comment] [Entry]\n"; $ret .= ""; } $ret .= "
TimeLocation
$hr_ago" . LJ::ljuser($ju->{user}) . ": $subject
"; } my $js_screen_color = "\"" . LJ::ejs(BML::get_template_def("screenedbarcolor")) . "\""; $ret .= ""; return $@ || $ret; } _code?> <=body page?>