[dw-free] Allow community maintainers to disable comments on entries
[commit: http://hg.dwscoalition.org/dw-free/rev/7867263254ab]
http://bugs.dwscoalition.org/show_bug.cgi?id=11
Allow community administrators to disable comments on an entry. If these
were disabled by a maintainer, have a message on the comments page
explicitly stating it as such.
Patch by
yvi.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=11
Allow community administrators to disable comments on an entry. If these
were disabled by a maintainer, have a message on the comments page
explicitly stating it as such.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- bin/upgrading/en.dat
- bin/upgrading/proplists.dat
- bin/upgrading/s2layers/core2.s2
- cgi-bin/LJ/Entry.pm
- cgi-bin/LJ/S2.pm
- cgi-bin/LJ/S2/EntryPage.pm
- cgi-bin/LJ/Talk.pm
- cgi-bin/LJ/Widget/RecentEntry.pm
- cgi-bin/ljprotocol.pl
- cgi-bin/weblib.pl
- htdocs/editjournal.bml
- htdocs/talkpost.bml
- htdocs/talkread.bml
-------------------------------------------------------------------------------- diff -r 4fff89dcba6e -r 7867263254ab bin/upgrading/en.dat --- a/bin/upgrading/en.dat Sun Mar 14 09:13:57 2010 -0700 +++ b/bin/upgrading/en.dat Sun Mar 14 10:43:32 2010 -0700 @@ -989,6 +989,8 @@ entryform.backdated2=Backdate & excl entryform.backdated3=Date Out of Order +entryform.comment.disable=Disable comments? + entryform.comment.screening=Screen Comments: entryform.comment.screening2=Comment Screening: @@ -1006,6 +1008,8 @@ entryform.comment.settings.default5=Jour entryform.comment.settings.default5=Journal Default entryform.comment.settings.nocomments=Disabled + +entryform.comment.settings.nocomments.maintainer=Disabled by maintainer entryform.comment.settings.noemail=Don't E-mail @@ -3423,6 +3427,8 @@ talk.commentsread.counted=Read [[replyco talk.comments.counted=[[replycount]] [[?replycount|comment|comments]] +talk.comments.disabled_maintainer=Comments disabled by a maintainer of this community + talk.commentsread.nocomments=No comments talk.curname_groups=<b>Custom friends groups:</b> diff -r 4fff89dcba6e -r 7867263254ab bin/upgrading/proplists.dat --- a/bin/upgrading/proplists.dat Sun Mar 14 09:13:57 2010 -0700 +++ b/bin/upgrading/proplists.dat Sun Mar 14 10:43:32 2010 -0700 @@ -1257,6 +1257,13 @@ logproplist.opt_nocomments: sortorder: 25 ownership: user +logproplist.opt_nocomments_maintainer: + datatype: bool + des: Disables comments on this entry -- community maintainer override. + prettyname: Don't Allow Comments (Maintainer Override) + sortorder: 105 + ownership: system + logproplist.opt_noemail: datatype: bool des: Turn on if the poster isn't interested in receiving comments to this post by email diff -r 4fff89dcba6e -r 7867263254ab bin/upgrading/s2layers/core2.s2 --- a/bin/upgrading/s2layers/core2.s2 Sun Mar 14 09:13:57 2010 -0700 +++ b/bin/upgrading/s2layers/core2.s2 Sun Mar 14 10:43:32 2010 -0700 @@ -247,6 +247,7 @@ class CommentInfo 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 comments_disabled_maintainer "Set to true if the comments on this entry were disabled by a community maintainer"; 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."; @@ -2194,6 +2195,12 @@ property string text_read_comments_threa example = "1 response // # responses"; } set text_read_comments_threads = "1 response // # responses"; + +property string text_comments_disabled_maintainer { + des = "Text shown instead of comments if a community maintainer has disabled comments"; + example = "Comments disabled by a maintainer of this community"; +} +set text_comments_disabled_maintainer = "Comments disabled by a maintainer of this community"; ##=============================== ## Text - entry actions @@ -5045,11 +5052,14 @@ function EntryPage::print_comment_sectio function EntryPage::print_comment_section(Entry e) { "<div id='comments'><div class='inner'>"; $.comment_pages->print({ "anchor" => "comments", "class" => "comment-pages" }); + if ( $e.comments.comments_disabled_maintainer ) { + """<div class='comments-message'>$*text_comments_disabled_maintainer</div>"""; + } if ($.comment_pages.total_subitems > 0) { $this->print_multiform_start(); } $this->print_comments($.comments); - if ($.comment_pages.total_subitems > 0) { + if ($.comment_pages.total_subitems > 0) { "<div class='bottomcomment'>"; $e->print_management_links(); $e->print_interaction_links("bottomcomment"); @@ -5057,7 +5067,7 @@ function EntryPage::print_comment_sectio $this->print_multiform_actionline(); $this->print_multiform_end(); "</div>"; - } + } $.comment_pages->print({ "anchor" => "comments", "class" => "comment-pages" }); "</div></div>"; } diff -r 4fff89dcba6e -r 7867263254ab cgi-bin/LJ/Entry.pm --- a/cgi-bin/LJ/Entry.pm Sun Mar 14 09:13:57 2010 -0700 +++ b/cgi-bin/LJ/Entry.pm Sun Mar 14 10:43:32 2010 -0700 @@ -913,6 +913,25 @@ sub adult_content_marker { return "community" if $self->adult_content_maintainer; return "poster" if $self->adult_content; return $self->journal->adult_content_marker; +} + +# return whether this entry has comments disabled, either by the poster or by the maintainer +sub comments_disabled { + my $self = $_[0]; + + return $self->prop( 'opt_nocomments' ) || $self->prop( 'opt_nocomments_maintainer' ); +} + +# return whether comments were disabled by the entry poster +sub comments_disabled_poster { + return $_[0]->prop( 'opt_nocomments' ); +} + +# return whether this post had its comments disabled by a community maintainer (not by the poster, who can override the community moderator) +sub comments_disabled_maintainer { + my $self = $_[0]; + + return $self->prop( 'opt_nocomments_maintainer' ) && !$self->comments_disabled_poster; } sub qotdid { diff -r 4fff89dcba6e -r 7867263254ab cgi-bin/LJ/S2.pm --- a/cgi-bin/LJ/S2.pm Sun Mar 14 09:13:57 2010 -0700 +++ b/cgi-bin/LJ/S2.pm Sun Mar 14 10:43:32 2010 -0700 @@ -1975,7 +1975,7 @@ sub Entry_from_entryobj my $readurl = LJ::Talk::talkargs( $permalink, $nc, $style_args ); my $posturl = LJ::Talk::talkargs( $permalink, 'mode=reply', $style_args ); - my $comments_enabled = ( ( $journal->{opt_showtalklinks} eq "Y" ) && ( ! $entry_obj->props->{opt_nocomments} ) ) ? 1 : 0; + my $comments_enabled = ( ( $journal->{opt_showtalklinks} eq "Y" ) && !$entry_obj->comments_disabled ) ? 1 : 0; my $has_screened = ( $entry_obj->props->{hasscreened} && LJ::can_manage( $remote, $journal ) ) ? 1 : 0; # building the CommentInfo and Entry objects diff -r 4fff89dcba6e -r 7867263254ab cgi-bin/LJ/S2/EntryPage.pm --- a/cgi-bin/LJ/S2/EntryPage.pm Sun Mar 14 09:13:57 2010 -0700 +++ b/cgi-bin/LJ/S2/EntryPage.pm Sun Mar 14 10:43:32 2010 -0700 @@ -489,7 +489,8 @@ sub EntryPage_entry 'permalink_url' => $linkurl, 'count' => $replycount, 'maxcomments' => ( $replycount >= $u->count_maxcomments ) ? 1 : 0, - 'enabled' => ($viewall || ($u->{'opt_showtalklinks'} eq "Y" && !$entry->prop("opt_nocomments"))) ? 1 : 0, + enabled => ( $viewall || ( $u->{opt_showtalklinks} eq "Y" && !$entry->comments_disabled ) ) ? 1 : 0, + comments_disabled_maintainer => $entry->comments_disabled_maintainer, 'screened' => ($entry->prop("hasscreened") && $remote && LJ::can_manage($remote, $u)) ? 1 : 0, }); $comments->{show_postlink} = $comments->{enabled} && $get->{mode} ne 'reply'; diff -r 4fff89dcba6e -r 7867263254ab cgi-bin/LJ/Talk.pm --- a/cgi-bin/LJ/Talk.pm Sun Mar 14 09:13:57 2010 -0700 +++ b/cgi-bin/LJ/Talk.pm Sun Mar 14 10:43:32 2010 -0700 @@ -3176,7 +3176,7 @@ sub init { $bmlerr->("$SC.error.noanon"); } - if ($iprops->{'opt_nocomments'}) { + if ( $ent->comments_disabled ) { $bmlerr->("$SC.error.nocomments"); } diff -r 4fff89dcba6e -r 7867263254ab cgi-bin/LJ/Widget/RecentEntry.pm --- a/cgi-bin/LJ/Widget/RecentEntry.pm Sun Mar 14 09:13:57 2010 -0700 +++ b/cgi-bin/LJ/Widget/RecentEntry.pm Sun Mar 14 10:43:32 2010 -0700 @@ -68,7 +68,7 @@ sub render_body { } else { $ret .= "<a href='$link'><strong>Link</strong></a>"; } - unless ($entry->prop('opt_nocomments')) { + unless ( $entry->comments_disabled ) { $ret .= " | <a href='$link?mode=reply'><strong>Leave a comment</strong></a>"; } } else { diff -r 4fff89dcba6e -r 7867263254ab cgi-bin/ljprotocol.pl --- a/cgi-bin/ljprotocol.pl Sun Mar 14 09:13:57 2010 -0700 +++ b/cgi-bin/ljprotocol.pl Sun Mar 14 10:43:32 2010 -0700 @@ -1810,6 +1810,11 @@ sub editevent $props_byname{$key} = $req->{'props'}->{$key}; } } + # additionally, if the 'opt_nocomments_maintainer' prop was set before and the poster now sets + # 'opt_nocomments' to 0 again, 'opt_nocomments_maintainer' should be set to 0 again, as well + # so comments are enabled again + $req->{props}->{opt_nocomments_maintainer} = 0 + if defined $req->{props}->{opt_nocomments} && !$req->{props}->{opt_nocomments}; my $event = $req->{'event'}; my $owneru = LJ::load_userid($ownerid); diff -r 4fff89dcba6e -r 7867263254ab cgi-bin/weblib.pl --- a/cgi-bin/weblib.pl Sun Mar 14 09:13:57 2010 -0700 +++ b/cgi-bin/weblib.pl Sun Mar 14 10:43:32 2010 -0700 @@ -1577,7 +1577,7 @@ MOODS # Comment Settings my $comment_settings_selected = sub { return "noemail" if $opts->{'prop_opt_noemail'}; - return "nocomments" if $opts->{'prop_opt_nocomments'}; + return "nocomments" if $opts->{prop_opt_nocomments} || $opts->{prop_opt_nocomments_maintainer}; return $opts->{'comment_settings'}; }; @@ -1587,10 +1587,13 @@ MOODS return "Enabled"; }; + my $nocomments_display = $opts->{prop_opt_nocomments_maintainer} ? + 'entryform.comment.settings.nocomments.maintainer' : 'entryform.comment.settings.nocomments'; + my $comment_settings_default = BML::ml('entryform.comment.settings.default5', {'aopts' => $comment_settings_journaldefault->()}); $out .= LJ::html_select({ 'name' => "comment_settings", 'id' => 'comment_settings', 'class' => 'select', 'selected' => $comment_settings_selected->(), - 'tabindex' => $tabindex->() }, - "", $comment_settings_default, "nocomments", BML::ml('entryform.comment.settings.nocomments',"noemail"), "noemail", BML::ml('entryform.comment.settings.noemail')); + 'tabindex' => $tabindex->() }, + "", $comment_settings_default, "nocomments", BML::ml( $nocomments_display ,"noemail" ), "noemail", BML::ml( 'entryform.comment.settings.noemail' )); $out .= LJ::help_icon_html("comment", "", " "); $out .= "\n"; $out .= "</span>\n"; @@ -1818,6 +1821,7 @@ PREVIEW $out .= "<em>" . BML::ml('entryform.maintainer') . "</em>\n"; $out .= "</p>\n"; + # adult content settings if ( LJ::is_enabled( 'adult_content' ) ) { $out .= "<p class='pkg'>\n"; my %poster_adult_content_menu = ( @@ -1862,6 +1866,28 @@ PREVIEW $out .= "</p>"; } + # comment disabling/enabling + # only possible if comments weren't disabled by poster + unless ( $opts->{prop_opt_nocomments} ) { + $out .= "<p class='pkg'>"; + $out .= "<label for='prop_opt_nocomments_maintainer' class='left options'>" . BML::ml( 'entryform.comment.disable' ) . "</label>"; + + # comment disabling is done via a checkbox as it has only two settings + # if we got this far, this is always set to the maintainer setting + my $selected = $opts->{prop_opt_nocomments_maintainer}; + $out .= LJ::html_check( + { + type => 'checkbox', + name => "prop_opt_nocomments_maintainer", + id => "prop_opt_nocomments_maintainer", + class => 'check', + value => '1', + selected => $selected, + tabindex => $tabindex->(), + } + ); + $out .= "</p>"; + } } $out .= "</div><!-- end #options -->\n\n"; diff -r 4fff89dcba6e -r 7867263254ab htdocs/editjournal.bml --- a/htdocs/editjournal.bml Sun Mar 14 09:13:57 2010 -0700 +++ b/htdocs/editjournal.bml Sun Mar 14 10:43:32 2010 -0700 @@ -206,7 +206,7 @@ body<= if ($POST{'action:savemaintainer'} && !$disabled_spamdelete) { return LJ::bad_input($ML{'error.invalidform'}) unless LJ::check_form_auth(); - my @props = qw(adult_content_maintainer_reason adult_content_maintainer); + my @props = qw( adult_content_maintainer_reason adult_content_maintainer opt_nocomments_maintainer ); my $propset = {}; foreach my $pname (@props) { diff -r 4fff89dcba6e -r 7867263254ab htdocs/talkpost.bml --- a/htdocs/talkpost.bml Sun Mar 14 09:13:57 2010 -0700 +++ b/htdocs/talkpost.bml Sun Mar 14 10:43:32 2010 -0700 @@ -381,7 +381,7 @@ body<= $ret .= "<p align='center' class='lesstop'><b>(<a href=\"$readurl#comments\">$readlink_text</a>)</b></p>"; # can a comment even be made? - if ($props->{'opt_nocomments'}) { + if ( $entry->comments_disabled ) { $ret .= "<?h1 $ML{'Sorry'} h1?><?p $ML{'.error.nocommentspost'} p?>"; return $ret; } diff -r 4fff89dcba6e -r 7867263254ab htdocs/talkread.bml --- a/htdocs/talkread.bml Sun Mar 14 09:13:57 2010 -0700 +++ b/htdocs/talkread.bml Sun Mar 14 10:43:32 2010 -0700 @@ -196,8 +196,7 @@ body<= my $props = $item->{'props'}; my $nocomments = $viewall ? 0 : - $u->{'opt_showtalklinks'} eq "N" ? 1 : $props->{'opt_nocomments'}; - + $u->{'opt_showtalklinks'} eq "N" ? 1 : $entry->comments_disabled; # # End of permissions logic @@ -784,8 +783,9 @@ body<= # # Display comment threads and commenting UI # - unless ($nocomments) - { + if ( $nocomments ) { + $ret .= BML::ml( "talk.comments.disabled_maintainer" ) if $entry->comments_disabled_maintainer; + } else { $ret .= "<div id='Comments'>"; $ret .= "<a name='comments'></a>"; $ret .= "<p>$navcrap</p>" if $navcrap; --------------------------------------------------------------------------------
no subject
Just giving this the emphasis it needs ;)
no subject