Андрей (andy) wrote in changelog,
Андрей
andy
changelog

[livejournal] r16281: LJSV-605 (Add "lock comments" feature to...

Committer: ailyin
LJSV-605 (Add "lock comments" feature to community journals)

U   trunk/bin/upgrading/en.dat
U   trunk/bin/upgrading/proplists.dat
U   trunk/bin/upgrading/s2layers/core1.s2
U   trunk/cgi-bin/LJ/Entry.pm
U   trunk/cgi-bin/LJ/PingBack.pm
U   trunk/cgi-bin/LJ/S2/DayPage.pm
U   trunk/cgi-bin/LJ/S2/EntryPage.pm
U   trunk/cgi-bin/LJ/S2/FriendsPage.pm
U   trunk/cgi-bin/LJ/S2/MonthPage.pm
U   trunk/cgi-bin/LJ/S2/RecentPage.pm
U   trunk/cgi-bin/LJ/Widget/EntryForm.pm
U   trunk/cgi-bin/LJ/Widget/RecentEntry.pm
U   trunk/cgi-bin/ljfeed.pl
U   trunk/cgi-bin/ljviews.pl
U   trunk/cgi-bin/talklib.pl
U   trunk/cgi-bin/weblib.pl
U   trunk/htdocs/preview/entry.bml
U   trunk/htdocs/talkread.bml
Modified: trunk/bin/upgrading/en.dat
===================================================================
--- trunk/bin/upgrading/en.dat	2010-02-27 10:05:16 UTC (rev 16280)
+++ trunk/bin/upgrading/en.dat	2010-02-27 10:19:51 UTC (rev 16281)
@@ -1144,6 +1144,8 @@
 
 entryform.comment.settings.nocomments=Disabled
 
+entryform.comment.settings.lockcomments=Locked
+
 entryform.comment.settings.noemail=Don't E-mail
 
 entryform.comment.settings2=Allow Comments?

Modified: trunk/bin/upgrading/proplists.dat
===================================================================
--- trunk/bin/upgrading/proplists.dat	2010-02-27 10:05:16 UTC (rev 16280)
+++ trunk/bin/upgrading/proplists.dat	2010-02-27 10:19:51 UTC (rev 16281)
@@ -1321,6 +1321,12 @@
 logproplist.opt_nocomments:
   datatype: bool
   des: Turn on if readers can't post comments on this entry.
+  prettyname: Don't Allow Comments and hide comments already posted to the entry
+  sortorder: 25
+
+logproplist.opt_lockcomments:
+  datatype: bool
+  des: Turn on if readers can't post comments on this entry.
   prettyname: Don't Allow Comments
   sortorder: 25
 

Modified: trunk/bin/upgrading/s2layers/core1.s2
===================================================================
--- trunk/bin/upgrading/s2layers/core1.s2	2010-02-27 10:05:16 UTC (rev 16280)
+++ trunk/bin/upgrading/s2layers/core1.s2	2010-02-27 10:19:51 UTC (rev 16281)
@@ -230,6 +230,7 @@
     var int count "Current number of comments available to be read by the viewer.";
     var bool screened "Set to true if there are screened comments and remote user can unscreen them.";
     var bool enabled "Set to false if comments disabled journal-wide or just on this item.";
+    var bool locked "Set to true if no further comments can be left on this entry.";
     var bool maxcomments "Set to true if entry has reached a comment maximum.";
     var bool show_postlink "Indicates whether the Post Comment link for this entry should be shown.";
     var bool show_readlink "Indicates whether the Read Comments link for this entry should be shown.";

Modified: trunk/cgi-bin/LJ/Entry.pm
===================================================================
--- trunk/cgi-bin/LJ/Entry.pm	2010-02-27 10:05:16 UTC (rev 16280)
+++ trunk/cgi-bin/LJ/Entry.pm	2010-02-27 10:19:51 UTC (rev 16281)
@@ -413,15 +413,21 @@
     return $self->{props} || {};
 }
 
+sub handle_prefetched_props {
+    my ($self, $props) = @_;
+
+    $self->{props} = $props;
+    $self->{_loaded_props} = 1;
+}
+
 sub _load_props {
     my $self = shift;
     return 1 if $self->{_loaded_props};
 
     my $props = {};
-    LJ::load_log_props2($self->{u}, [ $self->{jitemid} ], $props);
-    $self->{props} = $props->{ $self->{jitemid} };
+    LJ::load_log_props2($self->{u}, [ $self->jitemid ], $props);
 
-    $self->{_loaded_props} = 1;
+    $self->handle_prefetched_props($props->{$self->jitemid});
     return 1;
 }
 
@@ -1253,6 +1259,25 @@
     return 1;
 }
 
+sub comments_shown {
+    my ($self) = @_;
+
+    return 0 unless $self->journal->{'opt_showtalklinks'} eq 'Y';
+    return 0 if $self->prop('opt_nocomments');
+
+    return 1;
+}
+
+sub posting_comments_allowed {
+    my ($self) = @_;
+
+    return 0 unless $self->journal->{'opt_showtalklinks'} eq 'Y';
+    return 0 if $self->prop('opt_nocomments');
+    return 0 if $self->prop('opt_lockcomments');
+
+    return 1;
+}
+
 package LJ;
 
 use Class::Autouse qw (

Modified: trunk/cgi-bin/LJ/PingBack.pm
===================================================================
--- trunk/cgi-bin/LJ/PingBack.pm	2010-02-27 10:05:16 UTC (rev 16280)
+++ trunk/cgi-bin/LJ/PingBack.pm	2010-02-27 10:19:51 UTC (rev 16281)
@@ -86,7 +86,7 @@
     return 0 if $target_entry->journal->readonly; # Check "is_readonly".
     
     # are comments allowed?
-    return 0 if $target_entry->prop('opt_nocomments');
+    return 0 unless $target_entry->posting_comments_allowed;
 
     # did user allow to add pingbacks?
     # journal's default. We do not store "J" value in DB.

Modified: trunk/cgi-bin/LJ/S2/DayPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/DayPage.pm	2010-02-27 10:05:16 UTC (rev 16280)
+++ trunk/cgi-bin/LJ/S2/DayPage.pm	2010-02-27 10:19:51 UTC (rev 16281)
@@ -117,6 +117,7 @@
 
         my $ditemid = $itemid*256 + $anum;
         my $entry_obj = LJ::Entry->new($u, ditemid => $ditemid);
+        $entry_obj->handle_prefetched_props($logprops{$itemid});
 
         my $replycount = $logprops{$itemid}->{'replycount'};
         my $subject = $logtext->{$itemid}->[0];
@@ -161,12 +162,13 @@
             'post_url' => $posturl,
             'count' => $replycount,
             'maxcomments' => ($replycount >= LJ::get_cap($u, 'maxcomments')) ? 1 : 0,
-            'enabled' => ($u->{'opt_showtalklinks'} eq "Y" && ! $logprops{$itemid}->{'opt_nocomments'}) ? 1 : 0,
+            'enabled' => $entry_obj->comments_shown,
+            'locked' => !$entry_obj->posting_comments_allowed,
             'screened' => ($logprops{$itemid}->{'hasscreened'} && $remote &&
                            ($remote->{'user'} eq $u->{'user'} || LJ::can_manage($remote, $u))) ? 1 : 0,
         });
-        $comments->{show_postlink} = $comments->{enabled};
-        $comments->{show_readlink} = $comments->{enabled} && ($replycount || $comments->{screened});
+        $comments->{show_postlink} = $entry_obj->posting_comments_allowed;
+        $comments->{show_readlink} = $entry_obj->comments_shown && ($replycount || $comments->{'screened'});
 
         my $userlite_poster = $userlite_journal;
         my $pu = $u;

Modified: trunk/cgi-bin/LJ/S2/EntryPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/EntryPage.pm	2010-02-27 10:05:16 UTC (rev 16280)
+++ trunk/cgi-bin/LJ/S2/EntryPage.pm	2010-02-27 10:19:51 UTC (rev 16281)
@@ -99,9 +99,8 @@
 
     my $userlite_journal = UserLite($u);
 
-    # Only load comments if commenting is enabled on the entry
     my @comments;
-    if ($p->{'entry'}->{'comments'}->{'enabled'}) {
+    if ($entry->comments_shown) {
         @comments = LJ::Talk::load_comments($u, $remote, "L", $itemid, $copts);
     }
 
@@ -218,7 +217,7 @@
                 'depth' => $depth,
                 'parent_url' => $par_url,
                 'screened' => $com->{'state'} eq "S" ? 1 : 0,
-                'frozen' => $com->{'state'} eq "F" ? 1 : 0,
+                'frozen' => $com->{'state'} eq "F" || !$entry->posting_comments_allowed ? 1 : 0,
                 'deleted' => $com->{'state'} eq "D" ? 1 : 0,
                 'link_keyseq' => [ 'delete_comment' ],
                 'anchor' => "t$dtalkid",
@@ -247,7 +246,9 @@
             # Conditionally add more links to the keyseq
             my $link_keyseq = $s2com->{'link_keyseq'};
             push @$link_keyseq, $s2com->{'screened'} ? 'unscreen_comment' : 'screen_comment';
-            push @$link_keyseq, $s2com->{'frozen'} ? 'unfreeze_thread' : 'freeze_thread';
+            if ($entry->posting_comments_allowed) {
+                push @$link_keyseq, $s2com->{'frozen'} ? 'unfreeze_thread' : 'freeze_thread';
+            }
             push @$link_keyseq, "watch_thread" unless $LJ::DISABLED{'esn'};
             push @$link_keyseq, "unwatch_thread" unless $LJ::DISABLED{'esn'};
             push @$link_keyseq, "watching_parent" unless $LJ::DISABLED{'esn'};
@@ -441,12 +442,13 @@
         'post_url' => $posturl,
         'count' => $replycount,
         'maxcomments' => ($replycount >= LJ::get_cap($u, 'maxcomments')) ? 1 : 0,
-        'enabled' => ($viewall || ($u->{'opt_showtalklinks'} eq "Y" && !$entry->prop("opt_nocomments"))) ? 1 : 0,
+        'enabled' => $entry->comments_shown,
+        'locked' => !$entry->posting_comments_allowed,
         'screened' => ($entry->prop("hasscreened") && $remote &&
                        ($remote->{'user'} eq $u->{'user'} || LJ::can_manage($remote, $u))) ? 1 : 0,
     });
-    $comments->{show_postlink} = $comments->{enabled} && $get->{mode} ne 'reply';
-    $comments->{show_readlink} = $comments->{enabled} && ($replycount || $comments->{screened}) && $get->{mode} eq 'reply';
+    $comments->{show_postlink} = $entry->posting_comments_allowed;
+    $comments->{show_readlink} = $entry->comments_shown && ($replycount || $comments->{'screened'});
 
     # load tags
     my @taglist;

Modified: trunk/cgi-bin/LJ/S2/FriendsPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/FriendsPage.pm	2010-02-27 10:05:16 UTC (rev 16280)
+++ trunk/cgi-bin/LJ/S2/FriendsPage.pm	2010-02-27 10:19:51 UTC (rev 16281)
@@ -252,6 +252,7 @@
         }
 
         my $eobj = LJ::Entry->new($friends{$friendid}, ditemid => $ditemid);
+        $eobj->handle_prefetched_props($logprops{$datakey});
 
         # do the picture
         my $picid = 0;
@@ -283,13 +284,13 @@
             'post_url' => $posturl,
             'count' => $replycount,
             'maxcomments' => ($replycount >= LJ::get_cap($u, 'maxcomments')) ? 1 : 0,
-            'enabled' => ($friends{$friendid}->{'opt_showtalklinks'} eq "Y" &&
-                          ! $logprops{$datakey}->{'opt_nocomments'}) ? 1 : 0,
+            'enabled' => $eobj->comments_shown,
+            'locked' => !$eobj->posting_comments_allowed,
             'screened' => ($logprops{$datakey}->{'hasscreened'} && $remote &&
                            ($remote->{'user'} eq $fr->{'user'} || LJ::can_manage($remote, $fr))) ? 1 : 0,
         });
-        $comments->{show_postlink} = $comments->{enabled};
-        $comments->{show_readlink} = $comments->{enabled} && ($replycount || $comments->{screened});
+        $comments->{show_postlink} = $eobj->posting_comments_allowed;
+        $comments->{show_readlink} = $eobj->comments_shown && ($replycount || $comments->{'screened'});
 
         my $moodthemeid = $u->{'opt_forcemoodtheme'} eq 'Y' ?
             $u->{'moodthemeid'} : $friends{$friendid}->{'moodthemeid'};

Modified: trunk/cgi-bin/LJ/S2/MonthPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/MonthPage.pm	2010-02-27 10:05:16 UTC (rev 16280)
+++ trunk/cgi-bin/LJ/S2/MonthPage.pm	2010-02-27 10:19:51 UTC (rev 16281)
@@ -106,6 +106,7 @@
 
         my $ditemid = $itemid*256 + $anum;
         my $entry_obj = LJ::Entry->new($u, ditemid => $ditemid);
+        $entry_obj->handle_prefetched_props($logprops{$itemid});
 
         # don't show posts from suspended users or suspended posts
         next unless $pu{$posterid};
@@ -135,7 +136,8 @@
             'post_url' => $posturl,
             'count' => $replycount,
             'maxcomments' => ($replycount >= LJ::get_cap($u, 'maxcomments')) ? 1 : 0,
-            'enabled' => ($u->{'opt_showtalklinks'} eq "Y" && ! $logprops{$itemid}->{'opt_nocomments'}) ? 1 : 0,
+            'enabled' => $entry_obj->comments_shown,
+            'locked' => !$entry_obj->posting_comments_allowed,
             'screened' => ($logprops{$itemid}->{'hasscreened'} && $remote &&
                            ($remote->{'user'} eq $u->{'user'} || LJ::can_manage($remote, $u))) ? 1 : 0,
         });

Modified: trunk/cgi-bin/LJ/S2/RecentPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/RecentPage.pm	2010-02-27 10:05:16 UTC (rev 16280)
+++ trunk/cgi-bin/LJ/S2/RecentPage.pm	2010-02-27 10:19:51 UTC (rev 16281)
@@ -141,6 +141,7 @@
 
         my $ditemid = $itemid * 256 + $item->{'anum'};
         my $entry_obj = LJ::Entry->new($u, ditemid => $ditemid);
+        $entry_obj->handle_prefetched_props($logprops{$itemid});
 
         my $replycount = $logprops{$itemid}->{'replycount'};
         my $subject = $logtext->{$itemid}->[0];
@@ -201,7 +202,6 @@
         $readurl .= "?$nc" if $nc;
         my $posturl = $permalink . "?mode=reply";
 
-        my $comments_enabled = ($u->{'opt_showtalklinks'} eq "Y" && ! $logprops{$itemid}->{'opt_nocomments'}) ? 1 : 0;
         my $has_screened = ($logprops{$itemid}->{'hasscreened'} && LJ::can_manage($remote, $u)) ? 1 : 0;
 
         my $comments = CommentInfo({
@@ -209,10 +209,11 @@
             'post_url' => $posturl,
             'count' => $replycount,
             'maxcomments' => ($replycount >= LJ::get_cap($u, 'maxcomments')) ? 1 : 0,
-            'enabled' => $comments_enabled,
+            'enabled' => $entry_obj->comments_shown,
+            'locked' => !$entry_obj->posting_comments_allowed,
             'screened' => $has_screened,
-            'show_readlink' => $comments_enabled && ($replycount || $has_screened),
-            'show_postlink' => $comments_enabled,
+            'show_readlink' => $entry_obj->comments_shown && ($replycount || $has_screened),
+            'show_postlink' => $entry_obj->posting_comments_allowed,
         });
 
         my $userlite_poster = $userlite_journal;

Modified: trunk/cgi-bin/LJ/Widget/EntryForm.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/EntryForm.pm	2010-02-27 10:05:16 UTC (rev 16280)
+++ trunk/cgi-bin/LJ/Widget/EntryForm.pm	2010-02-27 10:19:51 UTC (rev 16281)
@@ -828,6 +828,7 @@
             my $comment_settings_selected = sub {
                 return "noemail" if $opts->{'prop_opt_noemail'};
                 return "nocomments" if $opts->{'prop_opt_nocomments'};
+                return "lockcomments" if $opts->{'prop_opt_lockcomments'};
                 return $opts->{'comment_settings'};
             };
 
@@ -842,6 +843,7 @@
                 (
                     "" => BML::ml('entryform.comment.settings.default5'),
                     "nocomments" => BML::ml('entryform.comment.settings.nocomments'),
+                    "lockcomments" => BML::ml('entryform.comment.settings.lockcomments'),
                     "noemail" => BML::ml('entryform.comment.settings.noemail'),
                 )
             );

Modified: trunk/cgi-bin/LJ/Widget/RecentEntry.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/RecentEntry.pm	2010-02-27 10:05:16 UTC (rev 16280)
+++ trunk/cgi-bin/LJ/Widget/RecentEntry.pm	2010-02-27 10:19:51 UTC (rev 16281)
@@ -56,7 +56,7 @@
             } else {
                 $ret .= "<a href='$link'><strong>Link</strong></a>";
             }
-            unless ($entry->prop('opt_nocomments')) {
+            if ($entry->posting_comments_allowed) {
                 $ret .= " | <a href='$link?mode=reply'><strong>Leave a comment</strong></a>";
             }
         } else {

Modified: trunk/cgi-bin/ljfeed.pl
===================================================================
--- trunk/cgi-bin/ljfeed.pl	2010-02-27 10:05:16 UTC (rev 16280)
+++ trunk/cgi-bin/ljfeed.pl	2010-02-27 10:19:51 UTC (rev 16281)
@@ -173,6 +173,7 @@
         my $itemid  = $it->{'itemid'};
         my $ditemid = $itemid*256 + $it->{'anum'};
         my $entry_obj = LJ::Entry->new($u, ditemid => $ditemid);
+        $entry_obj->handle_prefetched_props($logprops{$itemid});
 
         next ENTRY if $posteru{$it->{'posterid'}} && $posteru{$it->{'posterid'}}->{'statusvis'} eq 'S';
         next ENTRY if $entry_obj && $entry_obj->is_suspended_for($remote);
@@ -259,7 +260,7 @@
             createtime => $createtime,
             eventtime  => $it->{alldatepart},  # ugly: this is of a different format than the other two times.
             modtime    => $logprops{$itemid}->{revtime} || $createtime,
-            comments   => ($logprops{$itemid}->{'opt_nocomments'} == 0),
+            comments   => $entry_obj->comments_shown,
             music      => $logprops{$itemid}->{'current_music'},
             mood       => $mood,
             ppid       => $ppid,

Modified: trunk/cgi-bin/ljviews.pl
===================================================================
--- trunk/cgi-bin/ljviews.pl	2010-02-27 10:05:16 UTC (rev 16280)
+++ trunk/cgi-bin/ljviews.pl	2010-02-27 10:19:51 UTC (rev 16281)
@@ -1267,6 +1267,7 @@
 
         my $ditemid = $itemid * 256 + $item->{'anum'};
         my $entry_obj = LJ::Entry->new($u, ditemid => $ditemid);
+        $entry_obj->handle_prefetched_props($logprops{$itemid});
 
         my $pu = $posteru{$posterid};
         next ENTRY if $pu && $pu->{'statusvis'} eq 'S' && !$viewsome;
@@ -1340,11 +1341,7 @@
             $lastn_event{'subject'} = "<a href='$permalink'>" . $lastn_event{'subject'} . "</a>";
         }
 
-        if ($u->{'opt_showtalklinks'} eq "Y" &&
-            ! $logprops{$itemid}->{'opt_nocomments'}
-            )
-        {
-
+        if ($entry_obj->comments_shown) {
             my $nc;
             $nc = "nc=$replycount" if $replycount && $remote && $remote->{'opt_nctalklinks'};
 
@@ -1764,6 +1761,7 @@
 
         my $datakey = "$friendid $itemid";
 
+        $entry_obj->handle_prefetched_props($logprops{$datakey});
         my $replycount = $logprops{$datakey}->{'replycount'};
         my $subject = $logtext->{$datakey}->[0];
         my $event = $logtext->{$datakey}->[1];
@@ -1884,9 +1882,7 @@
 
         $friends_event{'subject'} = "<a href='$permalink'>" . $friends_event{'subject'} . "</a>";
 
-        if ($friends{$friendid}->{'opt_showtalklinks'} eq "Y" &&
-            ! $logprops{$datakey}->{'opt_nocomments'}
-            )
+        if ($entry_obj->comments_shown)
         {
             my $dispreadlink = $replycount ||
                 ($logprops{$datakey}->{'hasscreened'} && LJ::can_manage($remote, $friendid));
@@ -2497,6 +2493,7 @@
 
         my $ditemid = $itemid*256 + $anum;
         my $entry_obj = LJ::Entry->new($u, ditemid => $ditemid);
+        $entry_obj->handle_prefetched_props($logprops{$itemid});
 
         next ENTRY if $posteru{$posterid} && $posteru{$posterid}->{'statusvis'} eq 'S' && !$viewsome;
         next ENTRY if $entry_obj && $entry_obj->is_suspended_for($remote);
@@ -2548,9 +2545,7 @@
 
         $day_event{'subject'} = "<a href='$permalink'>" . $day_event{'subject'} . "</a>";
 
-        if ($u->{'opt_showtalklinks'} eq "Y" &&
-            ! $logprops{$itemid}->{'opt_nocomments'}
-            )
+        if ($entry_obj->comments_shown)
         {
             my $nc;
             $nc = "nc=$replycount" if $replycount && $remote && $remote->{'opt_nctalklinks'};

Modified: trunk/cgi-bin/talklib.pl
===================================================================
--- trunk/cgi-bin/talklib.pl	2010-02-27 10:05:16 UTC (rev 16280)
+++ trunk/cgi-bin/talklib.pl	2010-02-27 10:19:51 UTC (rev 16281)
@@ -2495,6 +2495,9 @@
     my $iprops = $item->{'props'};
     my $ditemid = $init->{'ditemid'}+0;
 
+    my $entry = LJ::Entry->new($journalu, ditemid => $ditemid);
+    $entry->handle_prefetched_props($iprops);
+
     my $talkurl = LJ::journal_base($journalu) . "/$ditemid.html";
     $init->{talkurl} = $talkurl;
 
@@ -2755,7 +2758,7 @@
         $bmlerr->("$SC.error.noanon");
     }
 
-    if ($iprops->{'opt_nocomments'}) {
+    unless ($entry->posting_comments_allowed) {
         $bmlerr->("$SC.error.nocomments");
     }
 

Modified: trunk/cgi-bin/weblib.pl
===================================================================
--- trunk/cgi-bin/weblib.pl	2010-02-27 10:05:16 UTC (rev 16280)
+++ trunk/cgi-bin/weblib.pl	2010-02-27 10:19:51 UTC (rev 16281)
@@ -1128,7 +1128,7 @@
                 prop_picture_keyword prop_current_moodid
                 prop_current_mood prop_current_music
                 prop_opt_screening prop_opt_noemail
-                prop_opt_preformatted prop_opt_nocomments
+                prop_opt_preformatted prop_opt_nocomments prop_opt_lockcomments
                 prop_current_location prop_current_coords
                 prop_taglist prop_qotdid)) {
         $req->{$_} = $POST->{$_};
@@ -1141,6 +1141,7 @@
     $req->{"prop_opt_preformatted"} ||= $POST->{'switched_rte_on'} ? 1 :
         $POST->{'event_format'} eq "preformatted" ? 1 : 0;
     $req->{"prop_opt_nocomments"}   ||= $POST->{'comment_settings'} eq "nocomments" ? 1 : 0;
+    $req->{'prop_opt_lockcomments'} ||= $POST->{'comment_settings'} eq 'lockcomments' ? 1 : 0;
     $req->{"prop_opt_noemail"}      ||= $POST->{'comment_settings'} eq "noemail" ? 1 : 0;
     $req->{'prop_opt_backdated'}      = $POST->{'prop_opt_backdated'} ? 1 : 0;
     $req->{'prop_copyright'} = $POST->{'prop_copyright'} ? 'P' : 'C' if LJ::is_enabled('default_copyright', LJ::get_remote()) 

Modified: trunk/htdocs/preview/entry.bml
===================================================================
--- trunk/htdocs/preview/entry.bml	2010-02-27 10:05:16 UTC (rev 16280)
+++ trunk/htdocs/preview/entry.bml	2010-02-27 10:19:51 UTC (rev 16281)
@@ -226,8 +226,13 @@
             'post_url' => "#",
             'count' => "0",
             'maxcomments' => 0,
-            'enabled' => ($u->{'opt_showtalklinks'} eq "Y" && !
-                          $req{'prop_opt_nocomments'}) ? 1 : 0,
+            'enabled' => ($u->{'opt_showtalklinks'} eq "Y" &&
+                          ! $req{'prop_opt_nocomments'}
+                          ) ? 1 : 0,
+            'locked' => ($u->{'opt_showtalklinks'} eq "Y" &&
+                          ! $req{'prop_opt_nocomments'} &&
+                          ! $req{'prop_opt_lockcomments'}
+                          ) ? 0 : 1,
                 'screened' => 0,
             });
 

Modified: trunk/htdocs/talkread.bml
===================================================================
--- trunk/htdocs/talkread.bml	2010-02-27 10:05:16 UTC (rev 16280)
+++ trunk/htdocs/talkread.bml	2010-02-27 10:19:51 UTC (rev 16281)
@@ -172,8 +172,10 @@
  }
 
  my $props = $item->{'props'};
- my $nocomments = $viewall                         ? 0 :
+ my $nocomments_old = $viewall ? 0 :
                   $u->{'opt_showtalklinks'} eq "N" ? 1 : $props->{'opt_nocomments'};
+ my $comments_shown = $viewall || $entry->comments_shown;
+ my $allow_commenting = $entry->posting_comments_allowed;
 
  # See if we should inject QuickReply javascript
  LJ::load_user_props($remote, "opt_no_quickreply");
@@ -184,7 +186,7 @@
 
  LJ::need_res('js/thread_expander.js');
 
- if (($remote && !$remote->{'opt_no_quickreply'}) && !$nocomments) {
+ if (($remote && !$remote->{'opt_no_quickreply'}) && $allow_commenting) {
     # quickreply js libs
     LJ::need_res(qw(
                     js/core.js
@@ -690,26 +692,27 @@
              $ret .= "$event$edit_html";
 
              $ret .= "<p style='margin: 0.7em 0 0.2em 0'><font size='-2'>";
-                     
 
-             my $replyurl = LJ::Talk::talkargs($talkurl, "replyto=$dtid", $stylemine, $formatlight);
-             if ($post->{'state'} eq 'F') {
-                 $ret .= "($T{'frozen'})";
-             } elsif ($remote) {
-                 # See if we want to force them to change their password
-                 my $bp = LJ::bad_password_redirect({ 'returl' => 1 });
-                 if ($bp) {
-                     $ret .= "(<a href='$bp'>$T{'replythis'}</a>) ";
+             if ($allow_commenting) {
+                 my $replyurl = LJ::Talk::talkargs($talkurl, "replyto=$dtid", $stylemine, $formatlight);
+                 if ($post->{'state'} eq 'F') {
+                     $ret .= "($T{'frozen'})";
+                 } elsif ($remote) {
+                     # See if we want to force them to change their password
+                     my $bp = LJ::bad_password_redirect({ 'returl' => 1 });
+                     if ($bp) {
+                         $ret .= "(<a href='$bp'>$T{'replythis'}</a>) ";
+                     } else {
+                        if ($post->{state} eq 'S') {
+                            # show unscreen to reply link id comment screened
+                            $ret .= "(<a href='$LJ::SITEROOT/talkscreen.bml?mode=unscreen&amp;${jargent}talkid=$dtid'>$T{'unscreentoreply'}</a>) ";
+                        } else {
+                            $ret .= "(" . LJ::make_qr_link($dtid, $post->{'subject'}, $T{'replythis'}, $replyurl) .  ") ";
+                        }
+                     }
                  } else {
-                    if ($post->{state} eq 'S') {
-                        # show unscreen to reply link id comment screened
-                        $ret .= "(<a href='$LJ::SITEROOT/talkscreen.bml?mode=unscreen&amp;${jargent}talkid=$dtid'>$T{'unscreentoreply'}</a>) ";
-                    } else {
-                        $ret .= "(" . LJ::make_qr_link($dtid, $post->{'subject'}, $T{'replythis'}, $replyurl) .  ") ";
-                    }
+                     $ret .= "(<a href='$replyurl'>$T{'replythis'}</a>) ";
                  }
-             } else {
-                 $ret .= "(<a href='$replyurl'>$T{'replythis'}</a>) ";
              }
 
              my $parentid = $post->{'parenttalkid'} || $post->{'parenttalkid_actual'};
@@ -755,7 +758,7 @@
      }
  };
 
- unless ($nocomments)
+ if ($comments_shown)
  {
      $ret .= "<div id='Comments'>";
      $ret .= "<a name='comments'></a>";
@@ -770,9 +773,11 @@
 	 if ($dthread && $pages == 1) {
          my $readurl = LJ::Talk::talkargs($talkurl, $stylemine, $formatlight);
 
-         $readlink = "(<a href='$readurl#comments'>$readlink_text</a>) - ";
-     } else { if ($replycount > 0) { $readlink = "($comments_count) - "; }
-	}
+         $readlink = "(<a href='$readurl#comments'>$readlink_text</a>)";
+     } elsif ($replycount > 0) {
+         $readlink = "($comments_count)";
+     }
+     $readlink .= ' - ' if $allow_commenting;
 
      my $posturl = LJ::Talk::talkargs($talkurl, "mode=reply", $stylemine, $formatlight);
 
@@ -794,16 +799,18 @@
      # Quick Reply when posting a new top level comment
      # requires setup when logged in.
      $ret .= "<p class='lesstop' align='center'><b>$readlink";
-     if ($remote) {
-         # See if we want to force them to change their password
-         my $bp = LJ::bad_password_redirect({ 'returl' => 1 });
-         if ($bp) {
-             $ret .= "(<a href='$bp'>$T{'replythis'} </a>)";
+     if ($allow_commenting) {
+         if ($remote) {
+             # See if we want to force them to change their password
+             my $bp = LJ::bad_password_redirect({ 'returl' => 1 });
+             if ($bp) {
+                 $ret .= "(<a href='$bp'>$T{'replythis'} </a>)";
+             } else {
+                 $ret .= "(" . LJ::make_qr_link('top', '', $T{'postcomments'}, $posturl) . "</a>)";
+             }
          } else {
-             $ret .= "(" . LJ::make_qr_link('top', '', $T{'postcomments'}, $posturl) . "</a>)";
+             $ret .= "(<a href='$posturl'>$T{'postcomments'}</a>)";
          }
-     } else {
-         $ret .= "(<a href='$posturl'>$T{'postcomments'}</a>)";
      }
 
      $ret .= "</b></p>";
@@ -838,18 +845,19 @@
          }
 
          $ret .= "<hr /><p class='lesstop' align='center'><b>$readlink";
-	     if ($remote) {
-	         # See if we want to force them to change their password
-	         my $bp = LJ::bad_password_redirect({ 'returl' => 1 });
-	         if ($bp) {
-	             $ret .= "(<a href='$bp'>$T{'replythis'} </a>)";
-	         } else {
-	             $ret .= "(" . LJ::make_qr_link('bottom', '', $T{'postcomments'}, $posturl) . "</a>)";
-	         }
-	     } else {
-	         $ret .= "(<a href='$posturl'>$T{'postcomments'}</a>)";
-	     }
-         #$ret .= "(" . LJ::make_qr_link('bottom', '', $T{'postcomments'}, $posturl) . "</a>)" if $remote;
+         if ($allow_commenting) {
+             if ($remote) {
+                 # See if we want to force them to change their password
+                 my $bp = LJ::bad_password_redirect({ 'returl' => 1 });
+                 if ($bp) {
+                     $ret .= "(<a href='$bp'>$T{'replythis'} </a>)";
+                 } else {
+                     $ret .= "(" . LJ::make_qr_link('bottom', '', $T{'postcomments'}, $posturl) . "</a>)";
+                 }
+             } else {
+                 $ret .= "(<a href='$posturl'>$T{'postcomments'}</a>)";
+             }
+         }
          $ret .= "</b></p>";
          $ret .= "<div align='center'>" . LJ::make_qr_target('bottom') . "</div>" if $remote;
 

Tags: andy, bml, dat, livejournal, pl, pm, s2
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments