kareila: (Default)
kareila ([personal profile] kareila) wrote in [site community profile] changelog2009-10-17 04:48 am

[dw-free] warn if you are about to send a PM with no text

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

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

Warn the user on the first attempt; allow on the second attempt.

Patch by [personal profile] meowth.

Files modified:
  • htdocs/inbox/compose.bml
  • htdocs/inbox/compose.bml.text
--------------------------------------------------------------------------------
diff -r 8669cb208a92 -r b19aa1d9e107 htdocs/inbox/compose.bml
--- a/htdocs/inbox/compose.bml	Sat Oct 17 00:24:32 2009 +0000
+++ b/htdocs/inbox/compose.bml	Fri Oct 16 23:48:00 2009 -0500
@@ -33,6 +33,7 @@ body<=
     my $msg_body = ''; # reply body
     my $msg_parent = ''; # Hidden msg field containing id of parent message
     my $msg_limit = LJ::get_cap($remote, "usermessage_length");
+    my $force = 0; # flag for if user wants to force an empty PM
 
     my @errors;
 
@@ -60,6 +61,13 @@ body<=
                   { msg_length => LJ::commafy( $msg_len_c ),
                   => msg_limit -> LJ::commafy( $msg_limit ) } )
                 unless ($msg_len_c <= $msg_limit);
+
+            # checks if the PM is empty (no text)
+            $force = $POST{'force'};
+            unless ( $msg_len_c > 0 || $force ) {
+               push @errors, $ML{'.warning.empty.message'};
+               $force = 1;
+            }
 
             # Get list of recipients
             my $to_field = $POST{'msg_to'};
@@ -225,6 +233,9 @@ body<=
                  });
     }
 
+    $body .= LJ::html_hidden( { name  => 'force',
+                                value => $force,
+                                id    => 'force' } );
     $body .= "</p>\n";
     # autocomplete To field with trusted and watched people
     my @flist = ();
diff -r 8669cb208a92 -r b19aa1d9e107 htdocs/inbox/compose.bml.text
--- a/htdocs/inbox/compose.bml.text	Sat Oct 17 00:24:32 2009 +0000
+++ b/htdocs/inbox/compose.bml.text	Fri Oct 16 23:48:00 2009 -0500
@@ -29,3 +29,5 @@
 .messaging.disabled=User messaging is currently disabled
 
 .suspended.cannot.send=Suspended accounts are not allowed to send private messages
+
+.warning.empty.message=Warning: You are trying to send a message with no text. Please resubmit if this is correct.
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org