Committer: azateev
LJSV-2186 Incorrect subject in notification about add-on expirationU trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon.pm
Modified: trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon.pm =================================================================== --- trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon.pm 2012-04-24 12:33:43 UTC (rev 11773) +++ trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon.pm 2012-04-24 12:43:48 UTC (rev 11774) @@ -159,12 +159,10 @@ return $uri; } +# expiring bonus feature reminders sub mail_reminders { my ($rlo, $rhi, $level) = @_; - # expiring bonus feature reminders - my $subject = $level eq "soon" ? "Subscription Expiring Soon" : "Subscription Expiration Warning"; - my $dbh = _get_dbh(); # what time is it on the database? my $nowu = $dbh->selectrow_array("SELECT UNIX_TIMESTAMP()"); @@ -185,8 +183,8 @@ next unless $u; next unless $u->{statusvis} eq 'V'; - next if $u->get_cap('perm'); + my $lang = $u->prop('browselang') || $LJ::DEFAULT_LANG; my $exptime = LJ::TimeUtil->mysqldate_to_time($expdate); my $days = int(($exptime - $nowu) / 86400 + 0.5); $dbh->do("UPDATE paidexp SET lastmailed=NOW() WHERE userid=? AND item=?", @@ -205,60 +203,54 @@ my $uri = _get_item_uri($item, $u->{journaltype} ne 'P'); - my $acct_body = ''; - if ($u->{journaltype} eq 'P') { + my $acct_body = $u->is_personal() ? LJ::Lang::get_text ($lang, + 'subscription.expire.acct_body', + undef, + { siteroot => $LJ::SITEROOT } + ) : + ""; - $acct_body = - "Avoid the hassle of renewing manually and set up automatic payments here:\n\n" . - - " $LJ::SITEROOT/manage/payments/\n\n"; + my $acct_type = LJ::Lang::get_text ($lang, 'ljcom.acct.paid'); + if (!$u->get_cap('paid')) { + $acct_type = $u->in_class('plus') ? LJ::Lang::get_text ($lang, 'ljcom.acct.plus') + : LJ::Lang::get_text ($lang, 'ljcom.acct.free'); } - my $acct_type = "Paid"; - if ($item eq 'userpic_small') { - if (!$u->get_cap('paid') && !$u->in_class('plus')) { - $acct_type = "Basic"; - } - if (!$u->get_cap('paid') && $u->in_class('plus')) { - $acct_type = "Plus"; - } - } + my $subject = LJ::Lang::get_text ($lang, $level eq "soon" ? 'subscription.addon.expire.soon.message.subject' : + 'subscription.addon.expire.warning.message.subject'); - 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". - - "You can renew your add-on of $bonus_name in the $LJ::SITENAMESHORT " . - "Gift Shop here: \n\n" . + my $body = LJ::Lang::get_text ($lang, 'subscription.addon.expire.message.body.plain', undef, { + user => $u->{user}, + acct_type => $acct_type, + bonus_name => $bonus_name, + sitenameshort => $LJ::SITENAMESHORT, + days => $days, + uri => $uri, + acct_body => $acct_body } + ); - " $uri\n\n" . - - $acct_body . - - "If you have any questions or requests, please contact us by replying " . - "to this email. We want to keep you happy. :)\n\n" . - - "Thanks,\n". - "$LJ::SITENAMESHORT Team\n"; - + my $html_body = ''; + if ($u->{opt_htmlemail} ne 'N') { + $html_body = LJ::Lang::get_text ($lang, 'subscription.addon.expire.message.body.html', undef, { + user => $u->ljuser_display, + acct_type => $acct_type, + bonus_name => $bonus_name, + sitenameshort => $LJ::SITENAMESHORT, + days => $days, + uri => $uri, + acct_body => $acct_body } + ); + } + ## UserHead - my $lang = $u->prop('browselang'); 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'); - } - if (!$u->get_cap('paid') && $u->in_class('plus')) { - $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"); + $subject = LJ::Lang::get_text ($lang, $level eq "soon" ? + "subscription.userhead.expire.soon.message.subject" : + "subscription.userhead.expire.warning.message.subject"); - 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}, @@ -298,7 +290,6 @@ }); } else { - $html_body =~ s/\n/\n<br\/>/g unless $html_body =~ m!<br!i; LJ::send_mail({ to => $u->email_raw,