madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[ljcom] r11732: LJSUP-11447: Need new parameter for user...

Committer: sbelyaev
LJSUP-11447: Need new parameter for userhead e-mail notification
U   trunk/bin/upgrading/en_LJ.dat
U   trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon.pm
Modified: trunk/bin/upgrading/en_LJ.dat
===================================================================
--- trunk/bin/upgrading/en_LJ.dat	2012-04-19 11:44:26 UTC (rev 11731)
+++ trunk/bin/upgrading/en_LJ.dat	2012-04-19 12:51:23 UTC (rev 11732)
@@ -8686,6 +8686,24 @@
 [[sitenameshort]] Team
 .
 
+subscription.expire.userhead.message_body|staleness=1
+subscription.expire.userhead.message_body<<
+Your [[acct_type]] account add-on of [[bonus_name]] <img src="[[userhead]]"/> for [[sitenameshort]] user
+[[user]] will expire in [[days]] days, at which time your paid account will revert to its standard features.
+
+You can renew your add-on of [[bonus_name]] in the [[sitenameshort]] Gift Shop here:
+
+[[uri]]
+
+[[acct_body]]
+
+If you have any questions or requests, please contact us by replying
+to this email.  We want to keep you happy.  :)
+
+Thanks,
+[[sitenameshort]] Team
+.
+
 subscription.expire.message_body_expired<<
 Your [[acct_type]] account add-on of Custom Userhead for [[sitenameshort]] user
 [[user]] will expire in [[days]] days, at which time your Custom Userhead will revert to standard.
@@ -8703,6 +8721,53 @@
 [[sitenameshort]] Team
 .
 
+subscription.expire.userhead.message_body_expired<<
+Your [[acct_type]] account add-on of Custom Userhead <img src="[[userhead]]"/> for [[sitenameshort]] user
+[[user]] will expire in [[days]] days, at which time your Custom Userhead will revert to standard.
+
+You can renew your add-on of Custom Userhead in the [[sitenameshort]] Gift Shop here:
+
+[[uri]]
+
+[[acct_body]]
+
+If you have any questions or requests, please contact us by replying
+to this email.  We want to keep you happy.  :)
+
+Thanks,
+[[sitenameshort]] Team
+.
+
+paidaddon.expire.message_body|staleness=1
+paidaddon.expire.message_body<<
+The following paid account add-on of your [[sitenameshort]] account [[user]] has expired.
+
+-[[addon]]
+
+If you'd like to renew this add-on, please visit:
+[[uri]]
+
+Thanks,
+[[sitenameshort]] Team
+.
+
+paidaddon.expire.html.message_body|staleness=1
+paidaddon.expire.html.message_body<<
+The following paid account add-on of your [[sitenameshort]] account [[user]] has expired.
+
+-[[addon]] [[ext_info]]
+
+If you'd like to renew this add-on, please visit:
+[[uri]]
+
+Thanks,
+[[sitenameshort]] Team
+.
+
+
+paidaddon.expire.subject|staleness=1
+paidaddon.expire.subject=Add-On Expired
+
 subscription.expire.soon|staleness=1
 subscription.expire.soon=Subscription Expiring Soon
 

Modified: trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon.pm	2012-04-19 11:44:26 UTC (rev 11731)
+++ trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon.pm	2012-04-19 12:51:23 UTC (rev 11732)
@@ -224,6 +224,7 @@
                 }
             }
 
+            my $html_body;
             my $body = "Your $acct_type account add-on of $bonus_name for $LJ::SITENAMESHORT user " .
                        "\"$u->{user}\" will expire in $days days, at which time your paid account will revert to its standard features.\n\n".
                        
@@ -242,7 +243,10 @@
 
             ## UserHead
             my $lang = $u->prop('browselang');
-            if ($item =~ m#^uh-\d+#) {
+            if ($item =~ m#^uh-(\d+)#) {
+                my $userhead_id = $1;
+                my $userhead = LJ::UserHead->get_userhead($userhead_id);
+
                 $acct_type = LJ::Lang::get_text ($lang, 'ljcom.acct.paid');
                 if (!$u->get_cap('paid') && !$u->in_class('plus')) {
                     $acct_type = LJ::Lang::get_text ($lang, 'ljcom.acct.free');
@@ -251,26 +255,62 @@
                     $acct_type = LJ::Lang::get_text ($lang, 'ljcom.acct.plus');
                 }
                 $subject = LJ::Lang::get_text ($lang, $level eq "soon" ? "subscription.expire.soon" : "subscription.expire.warning");
-                $body = LJ::Lang::get_text ($lang,  $level eq "soon" ? 'subscription.expire.message_body' : 'subscription.expire.message_body_expired', undef, {
+
+                my $acct_body =  $u->{journaltype} eq 'P' ? LJ::Lang::get_text ($lang, 'subscription.expire.acct_body', undef,
+                                                                                { siteroot => $LJ::SITEROOT } ) : "";
+
+                $body = LJ::Lang::get_text ($lang,  $level eq "soon" ? 'subscription.expire.message_body' :
+                                                                       'subscription.expire.message_body_expired', undef, {
                                 user            => $u->{user},
+                                userhead        => $userhead->get_uh_img, 
                                 acct_type       => $acct_type,
                                 bonus_name      => $bonus_name,
                                 sitenameshort   => $LJ::SITENAMESHORT,
                                 days            => $days,
                                 uri             => $uri,
-                                acct_body       => $u->{journaltype} eq 'P' ? LJ::Lang::get_text ($lang, 'subscription.expire.acct_body', undef, 
-                                                            { siteroot => $LJ::SITEROOT } ) : "",
+                                acct_body       => $acct_body });
+
+                if ($u->{opt_htmlemail} ne 'N') {
+                    my $body_variable =  $level eq "soon" ? 'subscription.expire.userhead.message_body' :
+                                                            'subscription.expire.userhead.message_body_expired';
+
+                    $html_body = LJ::Lang::get_text ($lang, $body_variable, undef, {
+                                    user            => $u->{user},
+                                    userhead        => $userhead->get_uh_img,
+                                    acct_type       => $acct_type,
+                                    bonus_name      => $bonus_name,
+                                    sitenameshort   => $LJ::SITENAMESHORT,
+                                    days            => $days,
+                                    uri             => $uri,
+                                    acct_body       => $acct_body });
+                } 
+            }
+
+            if ($u->{opt_htmlemail} eq 'N' || !$html_body) {
+                LJ::send_mail({
+                    to       => $u->email_raw,
+                    from     => $LJ::ACCOUNTS_EMAIL,,
+                    fromname => $LJ::SITENAMESHORT,
+                    wrap     => 1,
+                    charset  => $u->mailencoding || 'utf-8',
+                    subject  => $subject,
+                    body     => $body,
                 });
             }
+            else {
+                $html_body =~ s/\n/\n<br\/>/g unless $html_body =~ m!<br!i;
 
-            LJ::send_mail({ 'to' => $u->email_raw,
-                            'from' => $LJ::ACCOUNTS_EMAIL,
-                            'fromname' => $LJ::SITENAMESHORT,
-                            'wrap' => 1,
-                            'charset' => 'utf-8',
-                            'subject' => $subject,
-                            'body' => ($body),
-                        });
+                LJ::send_mail({
+                    to       => $u->email_raw,
+                    from     => $LJ::ACCOUNTS_EMAIL,
+                    fromname => $LJ::SITENAMESHORT,
+                    wrap     => 1,
+                    charset  => $u->mailencoding || 'utf-8',
+                    subject  => $subject,
+                    html     => $html_body,
+                    body     => $body,
+                });
+            }
         }
 }
 
@@ -287,7 +327,6 @@
     die $dbh->errstr if $dbh->err;
     while (my ($userid, $item, $size) = $sth->fetchrow_array)
     {
-
         # get a u object
         my $u = LJ::load_userid($userid, "force");
 
@@ -320,26 +359,69 @@
             my $item_obj = LJ::Pay::Payment::PayItem->new_memonly(item => $item, subitem => $size);
             my $name = $item_obj->product_name("short");
             my $uri = _get_item_uri($item);
+            my $item_ext_info = __additional_information($u, $item);
+            my $lang = $u->prop('browselang');
+            
+            my $subject = LJ::Lang::get_text ($lang, 'paidaddon.expire.subject');
 
-            LJ::send_mail({ 'to' => $u->email_raw,
-                            'from' => $LJ::ACCOUNTS_EMAIL,
-                            'fromname' => $LJ::SITENAMESHORT,
-                            'wrap' => 1,
-                            'charset' => 'utf-8',
-                            'subject' => 'Add-On Expired',
-                            'body' => ("$u->{'name'},\n\n".
-                                       "The following paid account add-on of your $LJ::SITENAMESHORT " .
-                                       "account \"$u->{'user'}\" has expired.\n\n" .
-                                       "   - $name\n\n" .
-                                       "If you'd like to renew this add-on, please visit:\n\n" .
-                                       "   $uri\n\n".
-                                       "Thanks,\n".
-                                       "$LJ::SITENAMESHORT Team\n"),
-                                   });
+            my $body = LJ::Lang::get_text ($lang,  'paidaddon.expire.message_body', undef, {                                
+                                user            => $u->user,
+                                addon           => $name,
+                                ext_info        => $item_ext_info,
+                                sitenameshort   => $LJ::SITENAMESHORT,
+                                uri             => $uri });
+
+            if ($u->{opt_htmlemail} ne 'N') {
+                my $html_body = LJ::Lang::get_text ($lang, 'paidaddon.expire.html.message_body', undef, {
+                                    user            => $u->user,
+                                    addon           => $name,
+                                    ext_info        => $item_ext_info,
+                                    sitenameshort   => $LJ::SITENAMESHORT,
+                                    uri             => $uri });
+
+                $html_body =~ s/\n/\n<br\/>/g unless $html_body =~ m!<br!i;
+
+                LJ::send_mail({
+                    to       => $u->email_raw,
+                    from     => $LJ::ACCOUNTS_EMAIL,
+                    fromname => $LJ::SITENAMESHORT,
+                    wrap     => 1,
+                    charset  => $u->mailencoding || 'utf-8',
+                    subject  => $subject,
+                    html     => $html_body,
+                    body     => $body,
+                });
+            } else {
+                LJ::send_mail({
+                    to       => $u->email_raw,
+                    from     => $LJ::ACCOUNTS_EMAIL,,
+                    fromname => $LJ::SITENAMESHORT,
+                    wrap     => 1,
+                    charset  => $u->mailencoding || 'utf-8',
+                    subject  => $subject,
+                    body     => $body,
+                });
+ 
+            }
         }
     }
 }
 
+sub __additional_information {
+    my ($u, $item) = @_;
+
+    if ($item =~ m#^uh-(\d+)#) {
+        my $userhead_id = $1;
+        my $userhead = LJ::UserHead->get_userhead($userhead_id);
+        if ($userhead) {
+            my $userhead_url = $userhead->get_uh_img;
+            return "<img src=\"$userhead_url\"/>";
+        }
+    }
+
+    return '';
+}
+
 sub apply_item {
     my $self = shift;
     my %args = @_;

Tags: dat, ljcom, madeon, pm, sbelyaev
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments