fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2012-03-29 06:35 am

[dw-free] remember "send me a copy of my own message" selection for next time

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

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

Save the "Send me a copy of my own message" when you compose a message, for
convenience.

(Welcome to purplecat whose first patch it is!)

Patch by [personal profile] purplecat.

Files modified:
  • bin/upgrading/proplists.dat
  • cgi-bin/LJ/User.pm
  • htdocs/inbox/compose.bml
--------------------------------------------------------------------------------
diff -r fc4a5b0cc19b -r fc8e704f0211 bin/upgrading/proplists.dat
--- a/bin/upgrading/proplists.dat	Sat Mar 24 13:11:22 2012 +0800
+++ b/bin/upgrading/proplists.dat	Thu Mar 29 14:33:56 2012 +0800
@@ -62,6 +62,14 @@
   multihomed: 0
   prettyname: CAPTCHA type
 
+userproplist.cc_msg:
+  cldversion: 4
+  datatype: bool
+  des: options to CC pms to the user
+  indexed: 0
+  multihomed: 0
+  prettyname: CC pms to the user
+
 userproplist.city:
   cldversion: 4
   datatype: char
diff -r fc4a5b0cc19b -r fc8e704f0211 cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm	Sat Mar 24 13:11:22 2012 +0800
+++ b/cgi-bin/LJ/User.pm	Thu Mar 29 14:33:56 2012 +0800
@@ -2197,6 +2197,16 @@
     return $_[1] || $u->prop( 'captcha' ) || $LJ::DEFAULT_CAPTCHA_TYPE;
 }
 
+sub cc_msg {
+    my ( $u, $value ) = @_;
+    if ( defined $value && $value=~ /[01]/ ) {
+       $u->set_prop( cc_msg => $value );
+       return $value;
+    }
+
+    return $u->prop( 'cc_msg' ) ? 1 : 0;
+}
+
 sub clear_prop {
     my ($u, $prop) = @_;
     $u->set_prop($prop, undef);
diff -r fc4a5b0cc19b -r fc8e704f0211 htdocs/inbox/compose.bml
--- a/htdocs/inbox/compose.bml	Sat Mar 24 13:11:22 2012 +0800
+++ b/htdocs/inbox/compose.bml	Thu Mar 29 14:33:56 2012 +0800
@@ -98,6 +98,9 @@
             push @to_list, $remote->username if $POST{'cc_msg'};
             my @msg_list;
 
+            # persist the default value of the cc_msg option
+            $remote->cc_msg( $POST{'cc_msg'} ? 1 : 0 );
+
             # must be at least one username
             push @errors, $ML{'.error.no.username'} unless ( scalar( @to_list ) > 0 );
 
@@ -271,11 +274,13 @@
     $body .= $picform;
 
     # Are we sending a copy of the message to the user?
+    my $cc_msg_option = $remote->cc_msg;
+
     $body .= LJ::html_check( {
         name     => 'cc_msg',
         id       => 'cc_msg',
         value    => 1,
-        selected => 0,
+        selected => $cc_msg_option,
     } );
     $body .= " <label for='cc_msg' style='font-weight: normal; font-size: smaller; font-style:italic;'>" . BML::ml( '.form.label.cc' ) . "</label></div>";
 
--------------------------------------------------------------------------------