Don't show "Latest Posted" in the standout bar of recent comments for 
communities.

        Patch by denise. 

diffs (332 lines):

diff -r cee04c6a50dc -r e33b88bd9edc htdocs/tools/recent_comments.bml
--- a/htdocs/tools/recent_comments.bml  Thu Dec 17 15:32:05 2009 +0000
+++ b/htdocs/tools/recent_comments.bml  Thu Dec 17 16:07:49 2009 +0000
@@ -53,7 +53,7 @@ body<=
     my $jargent ="journal=$u->{'user'}&amp;";
 
     # Retrieve received
-    {
+    if ( $u->is_person || $u->is_community ) {
         @recv = $u->get_recent_talkitems($count);
         foreach my $post (@recv) {
             $need_userid{$post->{posterid}} = 1 if $post->{posterid};
@@ -78,40 +78,47 @@ body<=
         }
     }
 
-    # anchors for 'latest received' and  'latest posted', link to Manage 
Comment Settings
-    # options for how many comments to view
-    $ret .= "<?standout <div style='text-align: center'>";
-    $ret .= "<a name='received'></a>";
-    $ret .= BML::ml('Actionlink', { link => $ML{'.latest.received'}}) . " "
-        if $u->is_person;
-    $ret .= BML::ml('Actionlink', { link => "<a 
href='#posted'>$ML{'.latest.posted'}</a>"}) . " ";
-    my $getextra = $authas ne $remote->user ? "?authas=$authas" : "";
-    $ret .= BML::ml('Actionlink', { link => "<a 
href='$LJ::SITEROOT/manage/comments$getextra'>$ML{'.managesettings'}</a>"});
+    my $standoutbox = sub {
+        # anchors for 'latest received' and  'latest posted', link to Manage 
Comment Settings
+        # options for how many comments to view
+        # Turning results into a function, since it's going to be used 
elsewhere.
+        my $anchorname = $_[0];
+        my $anchor = $anchorname ? "#$anchorname" : "";
+        my $standoutbox = "<?standout <div style='text-align: center'>";
+        $standoutbox .= "<a name='$anchorname'></a>";
 
-    $ret .= "<br />";
-    $ret .= " $ML{ '.view.latest' } [ ";
-    my @values = qw(10 25 50 100);
-    push @values, $count
-        unless grep { $count == $_ } @values;
-    push @values, $max
-        unless grep { $max == $_ } @values;
-    my $getextra = LJ::u_equals($u, $remote) ? "" : "&authas=" . $u->user;
+        my $latest_received = $anchorname eq "received" ? 
$ML{'.latest.received'} : "<a href='#received'>$ML{'.latest.received'}</a>";
+        my $latest_posted = $anchorname eq "posted" ? $ML{'.latest.posted'} : 
"<a href='#posted'>$ML{'.latest.posted'}</a>";
+        $standoutbox .= BML::ml( 'Actionlink', { link => $latest_received } ) 
. " "
+            if $u->is_person || $u->is_community;
+        $standoutbox .= BML::ml( 'Actionlink', { link => $latest_posted } ) . 
" "
+            if $u->is_person;
+        my $getextra = $authas ne $remote->user ? "?authas=$authas" : "";
+        $standoutbox .= BML::ml('Actionlink', { link => "<a 
href='$LJ::SITEROOT/manage/comments$getextra'>$ML{'.managesettings'}</a>"});
 
-    @values = sort { $a <=> $b } @values;
+        $standoutbox .= "<br />";
+        $standoutbox .= " $ML{ '.view.latest' } [ ";
+        my @values = qw(10 25 50 100);
+        push @values, $count
+            unless grep { $count == $_ } @values;
+        push @values, $max
+            unless grep { $max == $_ } @values;
+        my $getextra = LJ::u_equals($u, $remote) ? "" : "&authas=" . $u->user;
 
-    foreach my $val ( @values ) {
-        next if $val > $max;
-        if ( $val == $count ) {
-            $ret .= " <b>$val</b> ";
-        } else {
-            $ret .= " <a href='?show=$val$getextra'>$val</a> ";
+        @values = sort { $a <=> $b } @values;
+
+        foreach my $val ( @values ) {
+            next if $val > $max;
+            if ( $val == $count ) {
+                $standoutbox .= " <b>$val</b> ";
+            } else {
+                $standoutbox .= " <a 
href='?show=$val$getextra$anchor'>$val</a> ";
+            }
         }
-    }
-    $ret .= "] $ML{ '.comments' } </div> standout?>";
-
-    $ret .= "<?h1 $ML{ '.latest.received' } h1?>";
-    $ret .= "<?p " . (%talkids ? BML::ml('.last.num.posted.in', {num => 
$count}) : "$ML{ '.no.comments.posted' }") . " " . LJ::ljuser($u) . " p?>";
-
+        $standoutbox .= "] $ML{ '.comments' } </div> standout?>";
+        # end anchor/standout box.
+    };
+ 
     @recv = sort { $b->{datepostunix} <=> $a->{datepostunix} } @recv;
     my @recv_talkids = map { $_->{'jtalkid'} } @recv;
 
@@ -132,140 +139,132 @@ body<=
     my $log_text     = LJ::get_logtext2multi($need_logtext);
     my $root = LJ::journal_base($u);
 
-    $ret .= "<table style='width: 100%' cellpadding='5' cellspacing='0'>";
-    foreach my $r (@recv) {
-        next unless $r->{nodetype} eq "L";
-        next if $r->{state} eq "D";
+    # Begin "latest received" box. We only want to see this if we're a
+    # community or personal account, since OpenID accounts can't
+    # post entries and thus can't receive comments:
 
-        my $pu = $us->{$r->{posterid}};
-        next if $pu && ( $pu->is_expunged || $pu->is_suspended );
+    if ( $u->is_person || $u->is_community ) {
+        $ret .= $standoutbox->( "received" );
+        $ret .= "<?h1 $ML{ '.latest.received' } h1?>";
+        $ret .= "<?p " . (%talkids ? BML::ml('.last.num.posted.in', {num => 
$count}) : "$ML{ '.no.comments.posted' }") . " " . LJ::ljuser($u) . " p?>";
+        $ret .= "<table style='width: 100%' cellpadding='5' cellspacing='0'>";
+        foreach my $r (@recv) {
+            next unless $r->{nodetype} eq "L";
+            next if $r->{state} eq "D";
 
-        $r->{'props'} = $props{$r->{'jtalkid'}};
+            my $pu = $us->{$r->{posterid}};
+            next if $pu && ( $pu->is_expunged || $pu->is_suspended );
 
-        my $lrow = $logrow{"$u->{userid} $r->{nodeid}"} ||= 
LJ::get_log2_row($u, $r->{'nodeid'});
-        my $talkid = ($r->{'jtalkid'} << 8) + $lrow->{'anum'};
+            $r->{'props'} = $props{$r->{'jtalkid'}};
 
-        my $ditemid = "$root/$lrow->{ditemid}.html";
-        my $commentanchor = LJ::Talk::comment_anchor( $talkid );
-        my $talkurl = 
"$root/$lrow->{ditemid}.html?thread=$talkid$commentanchor";
+            my $lrow = $logrow{"$u->{userid} $r->{nodeid}"} ||= 
LJ::get_log2_row($u, $r->{'nodeid'});
+            my $talkid = ($r->{'jtalkid'} << 8) + $lrow->{'anum'};
 
-        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 $ditemid = "$root/$lrow->{ditemid}.html";
+            my $commentanchor = LJ::Talk::comment_anchor( $talkid );
+            my $talkurl = 
"$root/$lrow->{ditemid}.html?thread=$talkid$commentanchor";
 
-        my $ljcmt = $LJ_cmtinfo{$talkid} = {};
-        $ljcmt->{u} = $pu ? $pu->{user} : "";
-
-        $ret .= "<tr valign='top' id='cmtbar$talkid'><td style='width: 150px; 
line-height: 1.5em; border-top: 1px solid #999; background-color: $bgcolor' 
id='cmtbar$talkid'>";
-         $ret .= (LJ::isu($pu) ? LJ::ljuser($pu) : $ML{ '.anonymous' }) . "<br 
/>";
-
-        $ret .= LJ::ago_text($now - $r->{datepostunix}) . "<br />";
-        $ret .= "<div id='state$talkid'>$state</div>" if $r->{state} ne "D";
-
-        unless ($r->{state} eq "D")
-        {
-            $ret .= "<a href='/delcomment?${jargent}id=$talkid'>";
-            $ret .= LJ::img("btn_del", "", { 'align' => 'absmiddle', 'hspace' 
=> 2, 'vspace' => }) . "</a>";
-            if ($r->{'state'} ne 'F') {
-                $ret .= "<a 
href='/talkscreen?mode=freeze&amp;${jargent}talkid=$talkid'>";
-                $ret .= LJ::img("btn_freeze", "", { align => 'absmiddle', 
hspace => 2, vspace => }) . "</a>";
+            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";
             }
 
-            if ($r->{'state'} eq 'F') {
-                $ret .= "<a 
href='/talkscreen?mode=unfreeze&amp;${jargent}talkid=$talkid'>";
-                $ret .= LJ::img("btn_unfreeze", "", { align => 'absmiddle', 
hspace => 2, vspace => }) . "</a>";
+            my $ljcmt = $LJ_cmtinfo{$talkid} = {};
+            $ljcmt->{u} = $pu ? $pu->{user} : "";
+
+            $ret .= "<tr valign='top' id='cmtbar$talkid'><td style='width: 
150px; line-height: 1.5em; border-top: 1px solid #999; background-color: 
$bgcolor' id='cmtbar$talkid'>";
+            $ret .= (LJ::isu($pu) ? LJ::ljuser($pu) : $ML{ '.anonymous' }) . 
"<br />";
+
+            $ret .= LJ::ago_text($now - $r->{datepostunix}) . "<br />";
+            $ret .= "<div id='state$talkid'>$state</div>" if $r->{state} ne 
"D";
+
+            unless ($r->{state} eq "D") {
+                $ret .= "<a href='/delcomment?${jargent}id=$talkid'>";
+                $ret .= LJ::img("btn_del", "", { 'align' => 'absmiddle', 
'hspace' => 2, 'vspace' => }) . "</a>";
+                if ($r->{'state'} ne 'F') {
+                    $ret .= "<a 
href='/talkscreen?mode=freeze&amp;${jargent}talkid=$talkid'>";
+                    $ret .= LJ::img("btn_freeze", "", { align => 'absmiddle', 
hspace => 2, vspace => }) . "</a>";
+                }
+
+                if ($r->{'state'} eq 'F') {
+                    $ret .= "<a 
href='/talkscreen?mode=unfreeze&amp;${jargent}talkid=$talkid'>";
+                    $ret .= LJ::img("btn_unfreeze", "", { align => 
'absmiddle', hspace => 2, vspace => }) . "</a>";
+                }
+
+                if ($r->{'state'} ne 'S') {
+                   $ret .= "<a 
href='/talkscreen?mode=screen&amp;${jargent}talkid=$talkid'>";
+                    $ret .= LJ::img("btn_scr", "", { 'align' => 'absmiddle', 
'hspace' => 2, 'vspace' => }) . "</a>";
+                }
+
+                if ($r->{'state'} eq 'S') {
+                     $ret .= "<a 
href='/talkscreen?mode=unscreen&amp;${jargent}talkid=$talkid'>";
+                     $ret .= LJ::img("btn_unscr", "", { 'align' => 
'absmiddle', 'hspace' => 2, 'vspace' => }) . "</a>";
+                 }
             }
 
-            if ($r->{'state'} ne 'S') {
-                $ret .= "<a 
href='/talkscreen?mode=screen&amp;${jargent}talkid=$talkid'>";
-                $ret .= LJ::img("btn_scr", "", { 'align' => 'absmiddle', 
'hspace' => 2, 'vspace' => }) . "</a>";
+            # FIXME: (David?) We'll have to make talk_multi.bml understand 
jtalkids in multiple posts
+            #$ret .= " <nobr><input type='checkbox' 
name='selected_$r->{jtalkid}' id='s$r->{jtalkid}' />";
+            #$ret .= " <label 
for='s$r->{jtalkid}'>$ML{'/talkread.bml.select'}</label></nobr>";
+
+            $ret .= "</td><td id='" . LJ::Talk::comment_htmlid( $talkid );
+            $ret .= "' style='text-align: left; border-top: 1px solid #999; 
border-left: 1px solid #999'>";
+
+            my $subject = $log_text->{"$u->{userid} $r->{nodeid}"}[0];
+            LJ::CleanHTML::clean_subject(\$subject) if $subject ne "";
+
+            $ret .= "<strong style='float: left; text-decoration: 
underline'>$subject</strong> " if $subject ne "";
+            $ret .= "<strong style='float: right'>(<a href='$ditemid'>$ML{ 
'.entry.link' }</a>)</strong>" unless $lrow->{ditemid} == undef;
+            $ret .= "<br /><br />";
+            my $subject = LJ::ehtml($comment_text->{$r->{jtalkid}}[0]);
+
+            if ($subject && $subject !~ /^Re:\s*$/) {
+                $ret .= "<cite>$subject</cite><br />";
             }
 
-            if ($r->{'state'} eq 'S') {
-                 $ret .= "<a 
href='/talkscreen?mode=unscreen&amp;${jargent}talkid=$talkid'>";
-                 $ret .= LJ::img("btn_unscr", "", { 'align' => 'absmiddle', 
'hspace' => 2, 'vspace' => }) . "</a>";
-             }
-         }
-
-        # FIXME: (David?) We'll have to make talk_multi.bml understand 
jtalkids in multiple posts
-        #$ret .= " <nobr><input type='checkbox' name='selected_$r->{jtalkid}' 
id='s$r->{jtalkid}' />";
-        #$ret .= " <label 
for='s$r->{jtalkid}'>$ML{'/talkread.bml.select'}</label></nobr>";
-
-        $ret .= "</td><td id='" . LJ::Talk::comment_htmlid( $talkid );
-        $ret .= "' style='text-align: left; border-top: 1px solid #999; 
border-left: 1px solid #999'>";
-
-        my $subject = $log_text->{"$u->{userid} $r->{nodeid}"}[0];
-        LJ::CleanHTML::clean_subject(\$subject) if $subject ne "";
-
-        $ret .= "<strong style='float: left; text-decoration: 
underline'>$subject</strong> " if $subject ne "";
-        $ret .= "<strong style='float: right'>(<a href='$ditemid'>$ML{ 
'.entry.link' }</a>)</strong>" unless $lrow->{ditemid} == undef;
-        $ret .= "<br /><br />";
-        my $subject = LJ::ehtml($comment_text->{$r->{jtalkid}}[0]);
-
-        if ($subject && $subject !~ /^Re:\s*$/) {
-            $ret .= "<cite>$subject</cite><br />";
-        }
-
-        my $comment = $comment_text->{$r->{jtalkid}}[1];
-        LJ::CleanHTML::clean_comment(\$comment, { 'preformatted' => 
$r->{'props'}->{'opt_preformatted'},
+            my $comment = $comment_text->{$r->{jtalkid}}[1];
+            LJ::CleanHTML::clean_comment(\$comment, { 'preformatted' => 
$r->{'props'}->{'opt_preformatted'},
                                                   'anon_comment' => 
!LJ::isu($pu),
                                                   'nocss' => 1,
                                               });
-        BML::ebml(\$comment);
+            BML::ebml(\$comment);
 
-        $ret .= "$comment<br /><br />";
+            $ret .= "$comment<br /><br />";
 
-        $ret .= "(<a href='$talkurl'>$ML{ '.comment.link' }</a>) " unless 
$r->{state} eq "D" || $lrow->{ditemid} == undef;
+            $ret .= "(<a href='$talkurl'>$ML{ '.comment.link' }</a>) " 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 .= "<strong>($ML{ '.post.deleted' })</strong>";
-        } elsif ($r->{'state'} eq 'F') {
-            $ret .= "($ML{'talk.frozen'}) ";
-        } elsif ($r->{'state'} eq "D") {
-            $ret .= "<strong>($ML{ '.comment.deleted' })</strong>";
-        } else {
-            $ret .= "(<a href='$replyurl'>$ML{'talk.replytothis'}</a>) ";
+            my $stylemine = 0;
+            my $replyurl = LJ::Talk::talkargs($ditemid, "replyto=$talkid", 
$stylemine);
+            if ($lrow->{ditemid} == undef) {
+                $ret .= "<strong>($ML{ '.post.deleted' })</strong>";
+            } elsif ($r->{'state'} eq 'F') {
+                $ret .= "($ML{'talk.frozen'}) ";
+            } elsif ($r->{'state'} eq "D") {
+                $ret .= "<strong>($ML{ '.comment.deleted' })</strong>";
+            } else {
+                $ret .= "(<a href='$replyurl'>$ML{'talk.replytothis'}</a>) ";
+            }
+
+            $ret .= "</td></tr>";
+
         }
+        $ret .= "</table>";
 
-        $ret .= "</td></tr>";
-
-    }
-    $ret .= "</table>";
-
-    $ret .= "<?p " . BML::ml('/tools/recent_comments.bml.maxnotshown',
+        $ret .= "<?p " . BML::ml('/tools/recent_comments.bml.maxnotshown',
                              { 'current' => $max, 'max' => 
$LJ::TOOLS_RECENT_COMMENTS_MAX }).
                                  " p?>" unless $max >= 
$LJ::TOOLS_RECENT_COMMENTS_MAX;
+    }
+
+    # End "latest received" box.
 
     if ($u->is_individual) {
 
-        $ret .= "<?standout <div style='text-align: center'>";
-        $ret .= "<a name='posted'></a>";
-        $ret .= BML::ml('Actionlink', { link => "<a 
href='#received'>$ML{'.latest.received'}</a>"}) . " "
-            if $u->is_person;
-        $ret .= BML::ml('Actionlink', { link => $ML{'.latest.posted'}}) . " ";
-        $ret .= BML::ml('Actionlink', { link => "<a 
href='$LJ::SITEROOT/manage/comments'>$ML{'.managesettings'}</a>"});
-
-        $ret .= "<br />";
-        $ret .= " $ML{ '.view.latest' } [ ";
-        foreach my $val ( @values ) {
-            next if $val > $max;
-            if ( $val == $count ) {
-                $ret .= " <b>$val</b> ";
-            } else {
-                $ret .= " <a href='?show=$val$getextra#posted'>$val</a> ";
-            }
-        }
-        $ret .= "] $ML{ '.comments' } </div> standout?>";
-
+        $ret .= $standoutbox->( "posted" );
         $ret .= "<?h1 $ML{ '.latest.posted' } h1?><?p " . 
BML::ml('.last.num.posted.by', {num => $count, user => LJ::ljuser($u) }) . " 
p?>";
         my %jcount;  # jid -> ct
         $ret .= "<table style='text-align: left'>";
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog

Reply via email to