mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)
Mark Smith ([staff profile] mark) wrote in [site community profile] changelog2010-01-05 01:49 am

[dw-free] Reply to comments without unscreening

[commit: http://hg.dwscoalition.org/dw-free/rev/fc55d1b97341]

http://bugs.dwscoalition.org/show_bug.cgi?id=1994

Add ability to reply screened to a screened comment.

Patch by [personal profile] yvi.

Files modified:
  • bin/upgrading/en.dat
  • cgi-bin/LJ/Talk.pm
  • htdocs/talkpost.bml.text
  • htdocs/talkpost_do.bml
  • htdocs/talkread.bml
--------------------------------------------------------------------------------
diff -r 188993a48636 -r fc55d1b97341 bin/upgrading/en.dat
--- a/bin/upgrading/en.dat	Tue Jan 05 01:00:54 2010 +0000
+++ b/bin/upgrading/en.dat	Tue Jan 05 01:49:23 2010 +0000
@@ -3503,8 +3503,6 @@ talk.threadlink=Thread
 
 talk.threadrootlink=Thread from start
 
-talk.unscreentoreply=Unscreen to reply
-
 time.ago.day=[[num]] [[?num|day|days]] ago
 
 time.ago.hour=[[num]] [[?num|hour|hours]] ago
diff -r 188993a48636 -r fc55d1b97341 cgi-bin/LJ/Talk.pm
--- a/cgi-bin/LJ/Talk.pm	Tue Jan 05 01:00:54 2010 +0000
+++ b/cgi-bin/LJ/Talk.pm	Tue Jan 05 01:49:23 2010 +0000
@@ -1205,9 +1205,6 @@ sub talkform {
             if LJ::Talk::Post::over_maxcomments($journalu, $jitemid);
     }
 
-    if (!$editid && $parpost->{'state'} eq "S") {
-        $ret .= "<div class='ljwarnscreened'>$BML::ML{'.warnscreened'}</div>";
-    }
     $ret .= "<form method='post' action='$LJ::SITEROOT/talkpost_do' id='postform'>";
     $ret .= LJ::form_auth();
 
@@ -1759,7 +1756,21 @@ QQ
     # textarea for their message body
     $ret .= "<tr valign='top'><td align='right'>$BML::ML{'.opt.message'}";
     $ret .= "</td><td style='width: 90%'>";
-    $ret .= "<textarea class='textbox' rows='10' cols='75' wrap='soft' name='body' id='commenttext'>" . LJ::ehtml($form->{body}) . "</textarea>";
+    $ret .= "<textarea class='textbox' rows='10' cols='75' wrap='soft' name='body' id='commenttext'>" . LJ::ehtml($form->{body}) . "</textarea><br />";
+
+    # if parent comment is screened, give option to unscreen it
+    # default is not to unscreen
+    if ( $parpost->{state} eq "S" ) {
+        $ret .= "<label for='unscreen_parent'>$BML::ML{'.opt.unscreenparent'}</label>";
+        $ret .= LJ::html_check(
+                {
+                name  => 'unscreen_parent',
+                id    => 'unscreen_parent',
+                value => 1,
+                selected => 0
+                }
+            );
+    }
 
     # Display captcha challenge if over rate limits.
     if ($opts->{do_captcha}) {
@@ -3394,12 +3405,18 @@ sub require_captcha_test {
 
 # returns 1 on success.  0 on fail (with $$errref set)
 sub post_comment {
-    my ($entryu, $journalu, $comment, $parent, $item, $errref) = @_;
+    my ( $entryu, $journalu, $comment, $parent, $item, $errref, $unscreen_parent ) = @_;
 
     # unscreen the parent comment if needed
-    if ($parent->{state} eq 'S') {
+    if ( $parent->{state} eq 'S' && $unscreen_parent ) {
+        # if parent comment is screened and we got this far, the user has the permission to unscreen it
+        # in this case the parent comment needs to be unscreened and the comment posted as normal
         LJ::Talk::unscreen_comment($journalu, $item->{itemid}, $parent->{talkid});
         $parent->{state} = 'A';
+    } elsif ( $parent->{state} eq 'S' ) {
+        # if the parent comment is screened and the unscreen option was not selected, we also want the
+        # reply to be posted as screened
+        $comment->{state} = 'S';
     }
 
     # check for duplicate entry (double submission)
diff -r 188993a48636 -r fc55d1b97341 htdocs/talkpost.bml.text
--- a/htdocs/talkpost.bml.text	Tue Jan 05 01:00:54 2010 +0000
+++ b/htdocs/talkpost.bml.text	Tue Jan 05 01:49:23 2010 +0000
@@ -79,6 +79,8 @@
 
 .opt.submit=Post Comment
 
+.opt.unscreenparent=Unscreen the comment you are replying to (your comment will also be posted unscreened)
+
 .opt.willscreen=(will be screened)
 
 .opt.willscreenfriend=(will be screened if not given access)
@@ -97,5 +99,3 @@ Please either clear the user textbox or 
 Please either clear the user textbox or select the relevant posting mode and try again.
 .
 
-.warnscreened=<b>Notice:</b> This comment is screened. Replying to it will automatically un-screen it and make it visible.
-
diff -r 188993a48636 -r fc55d1b97341 htdocs/talkpost_do.bml
--- a/htdocs/talkpost_do.bml	Tue Jan 05 01:00:54 2010 +0000
+++ b/htdocs/talkpost_do.bml	Tue Jan 05 01:49:23 2010 +0000
@@ -179,6 +179,8 @@ body<=
     my $comment  = $init->{comment};
     my $item     = $init->{item};
 
+    my $unscreen_parent = $POST{unscreen_parent} ? 1 : 0;
+
     # check max comments only if posting a new comment (not when editing)
     unless ($editid) {
         return LJ::bad_input($ML{'.error.maxcomments'})
@@ -208,7 +210,7 @@ body<=
             return LJ::bad_input($err);
         }
     } else {
-        unless (LJ::Talk::Post::post_comment($entryu, $journalu, $comment, $parent, $item, \$err)) {
+        unless ( LJ::Talk::Post::post_comment( $entryu, $journalu, $comment, $parent, $item, \$err, $unscreen_parent ) ) {
             return LJ::bad_input($err);
         }
     }
diff -r 188993a48636 -r fc55d1b97341 htdocs/talkread.bml
--- a/htdocs/talkread.bml	Tue Jan 05 01:00:54 2010 +0000
+++ b/htdocs/talkread.bml	Tue Jan 05 01:49:23 2010 +0000
@@ -51,7 +51,6 @@ body<=
                threadroot      talk.threadrootlink
                expand          talk.expandlink
                replythis       talk.replytothis
-               unscreentoreply talk.unscreentoreply
                screened        talk.screened
                frozen          talk.frozen
                link            talk.commentpermlink
@@ -700,8 +699,8 @@ body<=
                     } else {
                        if ($post->{state} eq 'S') {
                            if ( LJ::Talk::can_unscreen( $remote, LJ::load_userid( $item->{ownerid} ), $item, $u ) ) {
-                               # show unscreen to reply link id comment screened
-                               $ret .= "(<a href='$LJ::SITEROOT/talkscreen?mode=unscreen&amp;${jargent}talkid=$dtid'>$T{'unscreentoreply'}</a>) ";
+                               # if user can unscreen, they can reply, choosing whether to unscreen or not
+                               $ret .= "(" . LJ::make_qr_link($dtid, $post->{subject}, $T{replythis}, $replyurl) .  ") ";
                            } else {
                                $ret .= "($T{ 'screened' })";
                            }
--------------------------------------------------------------------------------
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)

[personal profile] afuna 2010-01-05 02:30 am (UTC)(link)
yvi: Kaylee half-smiling, looking very pretty (Default)

[personal profile] yvi 2010-01-05 01:09 pm (UTC)(link)
Oh yay!
ninetydegrees: Art: self-portrait (Default)

[personal profile] ninetydegrees 2010-01-05 02:21 pm (UTC)(link)
Thank you for this!
turlough: large orange flowers in lush green grass ((dw) creative dreams)

[personal profile] turlough 2010-01-05 01:24 pm (UTC)(link)
Cool!
kate_nepveu: sleeping cat carved in brown wood (Default)

[personal profile] kate_nepveu 2010-01-06 08:26 pm (UTC)(link)
Wow!