Add a checkbox to send posting instructions to your chosen email.

        Patch by kareila. 

diffs (240 lines):

diff -r 302e01ef42a1 -r 4c9e485ada83 bin/upgrading/en.dat
--- a/bin/upgrading/en.dat      Thu Jun 17 19:30:26 2010 +0800
+++ b/bin/upgrading/en.dat      Thu Jun 17 20:06:38 2010 +0800
@@ -2585,6 +2585,29 @@ setting.emailposting.error.pin.invalid=Y
 
 setting.emailposting.error.pin.invalidaccount=This PIN is invalid. You should 
change it to something that does not have anything to do with your [[sitename]] 
account.
 
+setting.emailposting.helpmessage.body<<
+PIN is required, embedded in one of: to address, subject or body.
+  To: [[email]]
+  Subject: +PIN <subject text>
+  Body: +PIN <body text>
+
+If posting to a community, include the community name in the to address.
+  To: [[comm]]
+
+Journal options are configured by using headers at the top of the message 
body, separated by a blank line from the rest of the message body.  Available 
headers:
+  post-icon (or post-userpic): icon keywords
+  post-tags: tag1, tag2, tag3
+  post-mood: mood name
+  post-music: song name
+  post-location: name of location
+  post-comments: "off" or "noemail"
+  post-security: public, private, access (or friends), or name of access group
+
+To edit your emailpost settings, visit [[url]]
+.
+
+setting.emailposting.helpmessage.subject=Summary of Email Posting Instructions 
for [[sitenameshort]]
+
 setting.emailposting.label=Email Posting
 
 setting.emailposting.notavailable=Your account level does not permit you to 
use this feature.
@@ -2596,6 +2619,8 @@ setting.emailposting.option.addr=Email A
 setting.emailposting.option.addr=Email Address:
 
 setting.emailposting.option.advanced=advanced setup options
+
+setting.emailposting.option.helpmessage=Email summary of posting instructions?
 
 setting.emailposting.option.pin=PIN:
 
diff -r 302e01ef42a1 -r 4c9e485ada83 cgi-bin/LJ/Setting/EmailPosting.pm
--- a/cgi-bin/LJ/Setting/EmailPosting.pm        Thu Jun 17 19:30:26 2010 +0800
+++ b/cgi-bin/LJ/Setting/EmailPosting.pm        Thu Jun 17 20:06:38 2010 +0800
@@ -46,13 +46,17 @@ sub option {
 
     my $pin = $class->get_arg($args, "emailposting_pin") || 
$u->prop("emailpost_pin");
 
-    my $ret .= "<p>" . $class->ml('setting.emailposting.option', { domain => 
$LJ::EMAIL_POST_DOMAIN, aopts => 
"href='$LJ::SITEROOT/manage/emailpost?mode=help'" }) . " $upgrade_link</p>";
+    my $ret = "<p>" . $class->ml( 'setting.emailposting.option',
+                                  { domain => $LJ::EMAIL_POST_DOMAIN,
+                                    aopts => 
"href='$LJ::SITEROOT/manage/emailpost?mode=help'" } );
+    $ret .= " $upgrade_link</p>";
 
     $ret .= "<table class='setting_table' cellspacing='5' cellpadding='0'>";
 
     if ( $can_emailpost ) {
         foreach my $i (0..2) {
-            $ret .= "<tr><td class='setting_label'><label 
for='${key}emailposting_addr$i'>" . 
$class->ml('setting.emailposting.option.addr') . "</label></td>";
+            $ret .= "<tr><td class='setting_label'><label 
for='${key}emailposting_addr$i'>";
+            $ret .= $class->ml( 'setting.emailposting.option.addr' ) . 
"</label></td>";
             $ret .= "<td>" . LJ::html_text({
                 name => "${key}emailposting_addr$i",
                 id => "${key}emailposting_addr$i",
@@ -60,19 +64,34 @@ sub option {
                 size => 40,
                 maxlength => 80,
             });
-            $ret .= " <label for='${key}emailposting_senderrors$i' 
style='color: #000;'>" . $class->ml('setting.emailposting.option.senderrors') . 
"</label>";
-            $ret .= " " . LJ::html_check({
+            $ret .= " <label for='${key}emailposting_senderrors$i' 
style='color: #000;'>";
+            $ret .= $class->ml( 'setting.emailposting.option.senderrors' ) . 
"</label>";
+            $ret .= " " . LJ::html_check( {
                 name => "${key}emailposting_senderrors$i",
                 id => "${key}emailposting_senderrors$i",
                 value => 1,
-                selected => $class->get_arg($args, 
"emailposting_senderrors$i") || ($addresses[$i] && $addrlist->{$addresses[$i]} 
&& $addrlist->{$addresses[$i]}->{get_errors}) ? 1 : 0,
-            });
+                selected => $class->get_arg( $args, 
"emailposting_senderrors$i" )
+                              || ( $addresses[$i] && 
$addrlist->{$addresses[$i]}
+                                   && 
$addrlist->{$addresses[$i]}->{get_errors} )
+                            ? 1 : 0,
+            } );
+            $ret .= "<br />";
+            $ret .= " <label for='${key}emailposting_helpmessage$i' 
style='color: #000;'>";
+            $ret .= $class->ml( 'setting.emailposting.option.helpmessage' ) . 
"</label>";
+            $ret .= " " . LJ::html_check( {
+                name => "${key}emailposting_helpmessage$i",
+                id => "${key}emailposting_helpmessage$i",
+                value => 1,
+                selected => 0,
+            } );
             my $addr_errdiv = $class->errdiv($errs, "emailposting_addr$i");
             $ret .= "<br />$addr_errdiv" if $addr_errdiv;
+            $ret .= "<br />&nbsp;";
             $ret .= "</td></tr>";
         }
 
-        $ret .= "<tr><td class='setting_label'><label 
for='${key}emailposting_pin'>" . $class->ml('setting.emailposting.option.pin') 
. "</label></td>";
+        $ret .= "<tr><td class='setting_label'><label 
for='${key}emailposting_pin'>";
+        $ret .= $class->ml( 'setting.emailposting.option.pin' ) . 
"</label></td>";
         $ret .= "<td>" . LJ::html_text({
             name => "${key}emailposting_pin",
             id => "${key}emailposting_pin",
@@ -86,7 +105,8 @@ sub option {
         $ret .= "</td></tr>";
 
         $ret .= "<tr><td>&nbsp;</td>";
-        $ret .= "<td><a href='$LJ::SITEROOT/manage/emailpost'>" . 
$class->ml('setting.emailposting.option.advanced') . "</a></td></tr>";
+        $ret .= "<td><a href='$LJ::SITEROOT/manage/emailpost'>";
+        $ret .= $class->ml( 'setting.emailposting.option.advanced' ) . 
"</a></td></tr>";
 
     } else {
         $ret .= $class->ml( 'setting.emailposting.notavailable' );
@@ -109,6 +129,7 @@ sub save {
 
     my %allowed;
     my $addrcount = 0;
+    my @send_helpmessage;
     foreach my $addr ($addr0_val, $addr1_val, $addr2_val) {
         $addr =~ s/\s+//g;
         next unless $addr;
@@ -119,11 +140,14 @@ sub save {
         $allowed{$addr} = {};
         $allowed{$addr}->{get_errors} = 1
             if $class->get_arg($args, "emailposting_senderrors$addrcount");
+        push @send_helpmessage, $addr
+            if $class->get_arg( $args, "emailposting_helpmessage$addrcount" );
 
         $addrcount++;
     }
 
     LJ::Emailpost::set_allowed_senders($u, \%allowed);
+    $class->email_helpmessage( $u, $_ ) foreach @send_helpmessage;
 
     $pin_val =~ s/\s+//g;
     $class->errors( emailposting_pin => 
$class->ml('setting.emailposting.error.pin.invalid', { num => 4 }) )
@@ -137,4 +161,22 @@ sub save {
     return 1;
 }
 
+sub email_helpmessage {
+    my ( $class, $u, $address ) = @_;
+    return unless $u && $address;
+    my $user = LJ::isu( $u ) ? $u->user : $u;  # allow object or string
+    my $postdomain = "\...@post.$lj::DOMAIN";
+    LJ::send_mail( {
+        to => $address,
+        from => $LJ::BOGUS_EMAIL,
+        fromname => $LJ::SITENAME,
+        subject => LJ::Lang::ml( 'setting.emailposting.helpmessage.subject',
+                   { sitenameshort => $LJ::SITENAMESHORT } ),
+        body => LJ::Lang::ml( 'setting.emailposting.helpmessage.body',
+                   { email => "$user+PIN$postdomain",
+                     comm => "$user.communityname$postdomain",
+                     url => "$LJ::SITEROOT/manage/emailpost" } ),
+    } );
+}
+
 1;
diff -r 302e01ef42a1 -r 4c9e485ada83 htdocs/manage/emailpost.bml
--- a/htdocs/manage/emailpost.bml       Thu Jun 17 19:30:26 2010 +0800
+++ b/htdocs/manage/emailpost.bml       Thu Jun 17 20:06:38 2010 +0800
@@ -316,6 +316,8 @@ body<=
         # Check email, add flags if needed.
         my %allowed;
         my $addrcount = 0;
+        my @send_helpmessage;
+
         foreach (split(/\0/, $addresses)) {
             s/\s+//g;
             next unless $_;
@@ -324,6 +326,7 @@ body<=
             push @errors, BML::ml('.error.invalidemail', {'email' => 
LJ::ehtml($_)}) unless /\@/;
             $allowed{$_} = {};
             $allowed{$_}->{'get_errors'} = 1 if $POST{"check_$addrcount"};
+            push @send_helpmessage, $_ if $POST{"help_$addrcount"};
             $addrcount++;
         }
 
@@ -342,11 +345,14 @@ body<=
             }
         }
         LJ::set_userprop($u, "emailpost_pin", $pin);
+        LJ::Setting::EmailPosting->email_helpmessage( $u, $_ )
+            foreach @send_helpmessage;
 
         my $ret;
         $ret .= "<?h1 $ML{'.success.header'} h1?>";
         $ret .= "<?p $ML{'.success.saved'} p?>";
         $ret .= "<?p " . BML::ml('.success.info', {'aopts' => 
"href='$LJ::SITEROOT/manage/emailpost?mode=help'"}) . " p?>";
+        $ret .= "<?p $ML{'.success.helpmessage'} p?>" if @send_helpmessage;
         if ($LJ::HELPURL{emailpost}) {
             $ret .= "<?h1 $ML{'.instructions.header'} h1?>";
             $ret .= "<?p FIXME: link to helpurl p?>";
@@ -390,7 +396,10 @@ body<=
     $ret .= "<form method='post' action='emailpost'>\n";
     $ret .= LJ::form_auth();
     $ret .= "<div style='margin-left:40px;'>";
-    $ret .= "<table 
border=\"0\"><tr><td>$ML{'.addresses.table.address'}</td><td>$ML{'.addresses.table.errors'}</td></tr>";
+    $ret .= "<table border=\"0\"><tr><td>$ML{'.addresses.table.address'}</td>";
+    $ret .= "<td>$ML{'setting.emailposting.option.senderrors'}</td>";
+    $ret .= "<td>&nbsp;</td>";
+    $ret .= "<td>$ML{'setting.emailposting.option.helpmessage'}</td></tr>";
     for(0..2) { # Limited to 3 addresses.
         $ret .= '<tr><td>';
         my $selected = 0;
@@ -400,6 +409,10 @@ body<=
         $selected = 1 if $addrlist->{$address[$_]}->{'get_errors'};
         $ret .= '<center>' . 
             LJ::html_check({name => "check_$_", selected => $selected})
+            . '</center>';
+        $ret .= '</td><td width="20"></td><td>';
+        $ret .= '<center>' . 
+            LJ::html_check( { name => "help_$_", selected => 0 } )
             . '</center>';
         $ret .= '</td></tr>';
     }
diff -r 302e01ef42a1 -r 4c9e485ada83 htdocs/manage/emailpost.bml.text
--- a/htdocs/manage/emailpost.bml.text  Thu Jun 17 19:30:26 2010 +0800
+++ b/htdocs/manage/emailpost.bml.text  Thu Jun 17 20:06:38 2010 +0800
@@ -2,8 +2,6 @@
 .addresses.header=Allowed sender addresses
 
 .addresses.table.address=Address:
-
-.addresses.table.errors=Send errors?
 
 .addresses.text=Only the addresses listed below are allowed to post to your 
account via the email gateway. If no addresses are listed, posting via the 
email gateway will be disabled for your account. Marked addresses will receive 
errors if there are any to send.
 
@@ -220,6 +218,8 @@
 
 .success.header=Success
 
+.success.helpmessage=If you requested a summary of posting instructions, it 
should arrive in your email inbox shortly.
+
 .success.info=Click <a [[aopts]]>here</a> for information on how to use this 
feature.
 
 .success.saved=Your email gateway settings have been saved.
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog

Reply via email to