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 %need_logids; # hash of "journalid jitemid" => [journalid, jitemid] my $now = time(); my $sth; my $jargent ="journal=$u->{'user'}&"; # Retrieve received { 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) { $need_userid{$r->{posterid}} = 1 if $r->{posterid}; push @recv, $r; $talkids{$r->{jtalkid}} = 1; $need_logids{"$u->{userid} $r->{nodeid}"} = [$u->{userid}, $r->{nodeid}] if $r->{nodetype} eq "L"; } } # 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) { push @posted, $r; $need_logids{"$r->{journalid} $r->{nodeid}"} = [$r->{journalid}, $r->{nodeid}] if $r->{nodetype} eq "L"; $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->{'userid'}, \@recv_talkids, \%props); my $us = LJ::load_userids(keys %need_userid); # setup the parameter to get_logtext2multi my $need_logtext = {}; foreach my $need (values %need_logids) { my $ju = $us->{$need->[0]}; next unless $ju; push @{$need_logtext->{$ju->{clusterid}} ||= []}, $need; } my $comment_text = LJ::get_talktext2($u, keys %talkids); my $log_text = LJ::get_logtext2multi($need_logtext); my $root = LJ::journal_base($u); $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 ? $pu->{user} : ""; $ret .= ""; } $ret .= "
"; $ret .= ($pu ? 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 = $log_text->{"$u->{userid} $r->{nodeid}"}[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 = $log_text->{"$r->{journalid} $r->{nodeid}"}[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?>