[dw-free] Finishing up payment system
[commit: http://hg.dwscoalition.org/dw-free/rev/c5a0b5cd0417]
http://bugs.dwscoalition.org/show_bug.cgi?id=116
Clean up emails, split them into personal vs community, and generally make
them more useful.
Patch by
janinedog.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=116
Clean up emails, split them into personal vs community, and generally make
them more useful.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- bin/upgrading/en.dat
- bin/worker/paidstatus
- cgi-bin/DW/Shop/Item/Account.pm
- htdocs/shop/account.bml
-------------------------------------------------------------------------------- diff -r e8217b20c96a -r c5a0b5cd0417 bin/upgrading/en.dat --- a/bin/upgrading/en.dat Wed Apr 29 06:16:06 2009 +0000 +++ b/bin/upgrading/en.dat Wed Apr 29 06:18:18 2009 +0000 @@ -2952,6 +2952,57 @@ shop.email.accounttype=[[type]] for [[nu shop.email.accounttype.permanent=[[type]] +shop.email.comm.anon.body<< +Dear [[touser]], + +Someone has chosen to upgrade your [[sitename]] community [[commname]]. The +account that was purchased is: + + [[accounttype]] + +Congratulations on your community's paid time! + + +Regards, +The [[sitename]] Team +. + +shop.email.comm.anon.subject=[[sitename]] Account Purchase + +shop.email.comm.other.body<< +Dear [[touser]], + +[[fromuser]] has chosen to upgrade your [[sitename]] community [[commname]]. +The account that was purchased is: + + [[accounttype]] + +Congratulations on your community's paid time! + + +Regards, +The [[sitename]] Team +. + +shop.email.comm.other.subject=[[sitename]] Account Purchase + +shop.email.comm.self.body<< +Dear [[touser]], + +Your [[sitename]] community [[commname]] has been upgraded. The account that +was purchased is: + + [[accounttype]] + +Congratulations on your community's paid time! + + +Regards, +The [[sitename]] Team +. + +shop.email.comm.self.subject=[[sitename]] Account Purchase + shop.email.email.anon.body<< Dear [[email]], @@ -2973,7 +3024,7 @@ The [[sitename]] Team shop.email.email.anon.subject=[[sitename]] Account Purchase -shop.email.email.body<< +shop.email.email.other.body<< Dear [[email]], [[fromuser]] has chosen to purchase a [[sitename]] account for you. The account @@ -2992,7 +3043,7 @@ The [[sitename]] Team The [[sitename]] Team . -shop.email.email.subject=[[sitename]] Account Purchase +shop.email.email.other.subject=[[sitename]] Account Purchase shop.email.user.anon.body<< Dear [[touser]], @@ -3045,8 +3096,61 @@ The [[sitename]] Team shop.email.user.self.subject=[[sitename]] Account Purchase -shop.expiration.0.body<< -Dear [[account]], +shop.expiration.comm.0.body<< +Dear [[touser]], + +Your community [[commname]]'s paid account has expired. + +If you wish, you can purchase more paid time here: + + [[shopurl]] + + +Regards, +The [[sitename]] Team +. + +shop.expiration.comm.0.subject=[[sitename]] Account Expired + +shop.expiration.comm.14.body<< +Dear [[touser]], + +This is a friendly notice letting you know that your community [[commname]]'s +paid account is set to expire in approximately two weeks. + +If you wish, you can add more paid time to your community here: + + [[shopurl]] + + +Regards, +The [[sitename]] Team +. + +shop.expiration.comm.14.subject=[[sitename]] Account Expiration + +shop.expiration.comm.3.body<< +Dear [[touser]], + +This is a friendly notice letting you know that your community [[commname]]'s +paid account is set to expire in approximately three days. + +This is the last notice you will get. Your community will automatically revert +to free status three days from now. + +If you wish, you can add more paid time to your community here: + + [[shopurl]] + + +Regards, +The [[sitename]] Team +. + +shop.expiration.comm.3.subject=[[sitename]] Account Expiration + +shop.expiration.user.0.body<< +Dear [[touser]], Your paid account has expired. @@ -3059,10 +3163,10 @@ The [[sitename]] Team The [[sitename]] Team . -shop.expiration.0.subject=[[sitename]] Account Expired - -shop.expiration.14.body<< -Dear [[account]], +shop.expiration.user.0.subject=[[sitename]] Account Expired + +shop.expiration.user.14.body<< +Dear [[touser]], This is a friendly notice letting you know that your paid account is set to expire in approximately two weeks. @@ -3076,13 +3180,13 @@ The [[sitename]] Team The [[sitename]] Team . -shop.expiration.14.subject=[[sitename]] Account Expiration - -shop.expiration.3.body<< -Dear [[account]], - -This is a friendly notice letting you know that your account is set to expire in -approximately three days. +shop.expiration.user.14.subject=[[sitename]] Account Expiration + +shop.expiration.user.3.body<< +Dear [[touser]], + +This is a friendly notice letting you know that your paid account is set to +expire in approximately three days. This is the last notice you will get. Your account will automatically revert to free status three days from now. @@ -3096,7 +3200,7 @@ The [[sitename]] Team The [[sitename]] Team . -shop.expiration.3.subject=[[sitename]] Account Expiration +shop.expiration.user.3.subject=[[sitename]] Account Expiration shop.item.account.canbeadded.alreadyperm=The person that you are trying to purchase an account for has a Seed Account, so they cannot receive any additional paid time. diff -r e8217b20c96a -r c5a0b5cd0417 bin/worker/paidstatus --- a/bin/worker/paidstatus Wed Apr 29 06:16:06 2009 +0000 +++ b/bin/worker/paidstatus Wed Apr 29 06:18:18 2009 +0000 @@ -150,7 +150,7 @@ sub main_loop { $log->( 'Found %d users expiring soon.', scalar( @$rows ) ); - # now expire the user + # now warn the user warn_user( $dbh, $_ ) foreach @$rows; } @@ -164,14 +164,36 @@ sub expire_user { $log->( 'Expiring %s(%d).', $u->user, $u->id ); - # aw, send them a mail :( - LJ::send_mail( { - to => $u->email_raw, - fromname => $LJ::SITENAME, - from => $LJ::ACCOUNTS_EMAIL, - subject => LJ::Lang::ml( "shop.expiration.0.subject", { sitename => $LJ::SITENAME } ), - body => LJ::Lang::ml( "shop.expiration.0.body", { sitename => $LJ::SITENAME, account => $u->user, shopurl => "$LJ::SITEROOT/shop/account?for=self" } ), - } ); + if ( $u->is_community ) { + # send an email to every maintainer + my $maintus = LJ::load_userids( $u->maintainer_userids ); + foreach my $maintu ( values %$maintus ) { + LJ::send_mail( { + to => $maintu->email_raw, + fromname => $LJ::SITENAME, + from => $LJ::ACCOUNTS_EMAIL, + subject => LJ::Lang::ml( "shop.expiration.comm.0.subject", { sitename => $LJ::SITENAME } ), + body => LJ::Lang::ml( "shop.expiration.comm.0.body", { + touser => $maintu->display_name, + commname => $u->display_name, + shopurl => "$LJ::SITEROOT/shop/account?for=gift&user=" . $u->user, + sitename => $LJ::SITENAME, + } ), + } ); + } + } else { + LJ::send_mail( { + to => $u->email_raw, + fromname => $LJ::SITENAME, + from => $LJ::ACCOUNTS_EMAIL, + subject => LJ::Lang::ml( "shop.expiration.user.0.subject", { sitename => $LJ::SITENAME } ), + body => LJ::Lang::ml( "shop.expiration.user.0.body", { + touser => $u->display_name, + shopurl => "$LJ::SITEROOT/shop/account?for=self", + sitename => $LJ::SITENAME, + } ), + } ); + } # this is pretty easy, we just tell DW::Pay to do it return DW::Pay::expire_user( $uid ); @@ -197,13 +219,36 @@ sub warn_user { return 1 unless defined $mail; - LJ::send_mail( { - to => $u->email_raw, - fromname => $LJ::SITENAME, - from => $LJ::ACCOUNTS_EMAIL, - subject => LJ::Lang::ml( "shop.expiration.$mail.subject", { sitename => $LJ::SITENAME } ), - body => LJ::Lang::ml( "shop.expiration.$mail.body", { sitename => $LJ::SITENAME, account => $u->user, shopurl => "$LJ::SITEROOT/shop/account?for=self" } ), - } ); + if ( $u->is_community ) { + # send an email to every maintainer + my $maintus = LJ::load_userids( $u->maintainer_userids ); + foreach my $maintu ( values %$maintus ) { + LJ::send_mail( { + to => $maintu->email_raw, + fromname => $LJ::SITENAME, + from => $LJ::ACCOUNTS_EMAIL, + subject => LJ::Lang::ml( "shop.expiration.comm.$mail.subject", { sitename => $LJ::SITENAME } ), + body => LJ::Lang::ml( "shop.expiration.comm.$mail.body", { + touser => $maintu->display_name, + commname => $u->display_name, + shopurl => "$LJ::SITEROOT/shop/account?for=gift&user=" . $u->user, + sitename => $LJ::SITENAME, + } ), + } ); + } + } else { + LJ::send_mail( { + to => $u->email_raw, + fromname => $LJ::SITENAME, + from => $LJ::ACCOUNTS_EMAIL, + subject => LJ::Lang::ml( "shop.expiration.user.$mail.subject", { sitename => $LJ::SITENAME } ), + body => LJ::Lang::ml( "shop.expiration.user.$mail.body", { + touser => $u->display_name, + shopurl => "$LJ::SITEROOT/shop/account?for=self", + sitename => $LJ::SITENAME, + } ), + } ); + } # now update the db $dbh->do( 'UPDATE dw_paidstatus SET lastemail = ? WHERE userid = ?', diff -r e8217b20c96a -r c5a0b5cd0417 cgi-bin/DW/Shop/Item/Account.pm --- a/cgi-bin/DW/Shop/Item/Account.pm Wed Apr 29 06:16:06 2009 +0000 +++ b/cgi-bin/DW/Shop/Item/Account.pm Wed Apr 29 06:18:18 2009 +0000 @@ -125,39 +125,55 @@ sub _apply_userid { LJ::Lang::ml( 'shop.email.accounttype.permanent', { type => $self->class_name } ) : LJ::Lang::ml( 'shop.email.accounttype', { type => $self->class_name, nummonths => $self->months } ); - if ( $self->anonymous ) { - $subj = LJ::Lang::ml( 'shop.email.user.anon.subject', { sitename => $LJ::SITENAME } ); - $body = LJ::Lang::ml( 'shop.email.user.anon.body', + if ( $u->is_community ) { + my $maintus = LJ::load_userids( $u->maintainer_userids ); + foreach my $maintu ( values %$maintus ) { + my $emailtype = $maintu->equals( $fu ) ? 'self' : 'other'; + $emailtype = 'anon' if $self->anonymous; + + $subj = LJ::Lang::ml( "shop.email.comm.$emailtype.subject", { sitename => $LJ::SITENAME } ); + $body = LJ::Lang::ml( "shop.email.comm.$emailtype.body", + { + touser => $maintu->display_name, + fromuser => $fu->display_name, + commname => $u->display_name, + accounttype => $accounttype_string, + sitename => $LJ::SITENAME, + } + ); + + # send the email to the maintainer + LJ::send_mail( { + to => $maintu->email_raw, + from => $LJ::ACCOUNTS_EMAIL, + fromname => $LJ::SITENAME, + subject => $subj, + body => $body + } ); + } + } else { + my $emailtype = $u->equals( $fu ) ? 'self' : 'other'; + $emailtype = 'anon' if $self->anonymous; + + $subj = LJ::Lang::ml( "shop.email.user.$emailtype.subject", { sitename => $LJ::SITENAME } ); + $body = LJ::Lang::ml( "shop.email.user.$emailtype.body", { - touser => $u->user, - email => $self->t_email, - sitename => $LJ::SITENAME, + touser => $u->display_name, + fromuser => $fu->display_name, accounttype => $accounttype_string, + sitename => $LJ::SITENAME, } ); - } else { - my $string_insert = $u->equals( $fu ) ? 'self' : 'other'; - $subj = LJ::Lang::ml( "shop.email.user.$string_insert.subject", { sitename => $LJ::SITENAME } ); - $body = LJ::Lang::ml( "shop.email.user.$string_insert.body", - { - touser => $u->display_name, - email => $self->t_email, - sitename => $LJ::SITENAME, - fromuser => $fu->display_name, - accounttype => $accounttype_string, - } - ); + # send the email to the user + LJ::send_mail( { + to => $u->email_raw, + from => $LJ::ACCOUNTS_EMAIL, + fromname => $LJ::SITENAME, + subject => $subj, + body => $body + } ); } - - # send the email to the user - LJ::send_mail( { - to => $u->email_raw, - from => $LJ::ACCOUNTS_EMAIL, - fromname => $LJ::SITENAME, - subject => $subj, - body => $body - } ); # tell the caller we're happy return 1; @@ -194,28 +210,18 @@ sub _apply_email { LJ::Lang::ml( 'shop.email.accounttype.permanent', { type => $self->class_name } ) : LJ::Lang::ml( 'shop.email.accounttype', { type => $self->class_name, nummonths => $self->months } ); - if ( $self->anonymous ) { - $subj = LJ::Lang::ml( 'shop.email.email.anon.subject', { sitename => $LJ::SITENAME } ); - $body = LJ::Lang::ml( 'shop.email.email.anon.body', - { - email => $self->t_email, - sitename => $LJ::SITENAME, - createurl => "$LJ::SITEROOT/create?code=$code", - accounttype => $accounttype_string, - } - ); - } else { - $subj = LJ::Lang::ml( 'shop.email.email.subject', { sitename => $LJ::SITENAME } ); - $body = LJ::Lang::ml( 'shop.email.email.body', - { - email => $self->t_email, - sitename => $LJ::SITENAME, - createurl => "$LJ::SITEROOT/create?code=$code&from=" . $fu->user, - fromuser => $fu->display_name, - accounttype => $accounttype_string, - } - ); - } + my $emailtype = $self->anonymous ? 'anon' : 'other'; + + $subj = LJ::Lang::ml( "shop.email.email.$emailtype.subject", { sitename => $LJ::SITENAME } ); + $body = LJ::Lang::ml( "shop.email.email.$emailtype.body", + { + email => $self->t_email, + fromuser => $fu->display_name, + accounttype => $accounttype_string, + createurl => "$LJ::SITEROOT/create?code=$code", + sitename => $LJ::SITENAME, + } + ); # send the email to the user my $rv = LJ::send_mail( { diff -r e8217b20c96a -r c5a0b5cd0417 htdocs/shop/account.bml --- a/htdocs/shop/account.bml Wed Apr 29 06:16:06 2009 +0000 +++ b/htdocs/shop/account.bml Wed Apr 29 06:18:18 2009 +0000 @@ -101,7 +101,7 @@ body<= $ret .= "<table class='shop-table-gift'>"; if ( $for eq 'gift' ) { - $ret .= "<tr><td>$ML{'.giftfor.username'}</td><td>" . LJ::html_text( { name => 'username' } ) . "</td></tr>"; + $ret .= "<tr><td>$ML{'.giftfor.username'}</td><td>" . LJ::html_text( { name => 'username', value => LJ::ehtml( $GET{user} ) } ) . "</td></tr>"; } else { # $for eq 'new' $ret .= "<tr><td>$ML{'.giftfor.email'}</td><td>" . LJ::html_text( { name => 'email' } ) . "</td></tr>"; } --------------------------------------------------------------------------------