Add a reason field, and refactor the strings to be less painful to
update.
Patch by kareila.
diffs (527 lines):
diff -r 197be79b14e5 -r 3b5231ceae25 bin/upgrading/en.dat
--- a/bin/upgrading/en.dat Tue Apr 05 12:05:21 2011 +0800
+++ b/bin/upgrading/en.dat Fri Apr 08 16:38:09 2011 +0800
@@ -3254,73 +3254,58 @@ 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:
+shop.email.acct.body.create<<
+
+
+You can use the following link to create your account:
+
+ [[createurl]]
+
+.
+
+shop.email.acct.body.end<<
+
+
+Regards,
+The [[sitename]] Team
+.
+
+shop.email.acct.body.note<<
+
+
+The following note was authored by the sender:
+
+ [[reason]]
+
+--
+
+.
+
+shop.email.acct.body.start<<
+Dear [[touser]],
+
+.
+
+shop.email.acct.body.type<<
+
+
+The account type 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.explicit.body<<
-Dear [[touser]],
-
-Your [[sitename]] community [[commname]] has been upgraded by [[fromname]].
-The account that was given is:
-
- [[accounttype]]
-
-Congratulations on your community's paid time!
-
-
-Regards,
-The [[sitename]] Team
-.
-
-shop.email.comm.explicit.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.acct.subject=[[sitename]] Account Purchase
+
+shop.email.comm.anon=Someone has chosen to upgrade your [[sitename]] community
[[commname]].
+
+shop.email.comm.close=Congratulations on your community's paid time!
+
+shop.email.comm.explicit=Your [[sitename]] community [[commname]] has been
upgraded by [[fromname]].
+
+shop.email.comm.other=[[fromuser]] has chosen to upgrade your [[sitename]]
community [[commname]].
+
+shop.email.comm.self=Your [[sitename]] community [[commname]] has been
upgraded.
shop.email.confirm.checkmoneyorder.body<<
Dear [[touser]],
@@ -3374,47 +3359,11 @@ shop.email.confirm.paypal.body.status.pr
shop.email.confirm.paypal.subject=[[sitename]] Purchase Confirmation
-shop.email.email.anon.body<<
-Dear [[email]],
-
-Someone has chosen to purchase a [[sitename]] account for you. The account
type
-that was purchased is:
-
- [[accounttype]]
-
-You can use the following link to create your account:
-
- [[createurl]]
-
-We look forward to having you on the site!
-
-
-Regards,
-The [[sitename]] Team
-.
-
-shop.email.email.anon.subject=[[sitename]] Account Purchase
-
-shop.email.email.other.body<<
-Dear [[email]],
-
-[[fromuser]] has chosen to purchase a [[sitename]] account for you. The
account
-that was purchased is:
-
- [[accounttype]]
-
-You can use the following link to create your account:
-
- [[createurl]]
-
-We look forward to having you on the site!
-
-
-Regards,
-The [[sitename]] Team
-.
-
-shop.email.email.other.subject=[[sitename]] Account Purchase
+shop.email.email.anon=Someone has chosen to purchase a [[sitename]] account
for you.
+
+shop.email.email.close=We look forward to having you on the site!
+
+shop.email.email.other=[[fromuser]] has chosen to purchase a [[sitename]]
account for you.
shop.email.gift.other.body<<
Dear [[touser]],
@@ -3499,107 +3448,25 @@ The [[sitename]] Team
The [[sitename]] Team
.
-shop.email.user.anon.body<<
-Dear [[touser]],
-
-Someone has chosen to upgrade your [[sitename]] account. The account that was
-purchased is:
-
- [[accounttype]]
-
-Congratulations on your paid time!
-
-
-Regards,
-The [[sitename]] Team
-.
-
-shop.email.user.anon.subject=[[sitename]] Account Purchase
-
-shop.email.user.explicit.body<<
-Dear [[touser]],
-
-Your [[sitename]] account has been upgraded by [[fromname]]. The account that
-was given is:
-
- [[accounttype]]
-
-Congratulations on your paid time!
-
-
-Regards,
-The [[sitename]] Team
-.
-
-shop.email.user.explicit.subject=[[sitename]] Account Purchase
-
-shop.email.user.other.body<<
-Dear [[touser]],
-
-[[fromuser]] has chosen to upgrade your [[sitename]] account. The account that
-was purchased is:
-
- [[accounttype]]
-
-Congratulations on your paid time!
-
-
-Regards,
-The [[sitename]] Team
-.
-
-shop.email.user.other.subject=[[sitename]] Account Purchase
-
-shop.email.user.random.body<<
-Dear [[touser]],
-
+shop.email.user.anon=Someone has chosen to upgrade your [[sitename]] account.
+
+shop.email.user.close=Congratulations on your paid time!
+
+shop.email.user.explicit=Your [[sitename]] account has been upgraded by
[[fromname]].
+
+shop.email.user.other=[[fromuser]] has chosen to upgrade your [[sitename]]
account.
+
+shop.email.user.random<<
Your account has been randomly selected to receive [[fromuser]]'s payment
-through our sponsor-a-free-user program. The account that was purchased is:
-
- [[accounttype]]
-
-Congratulations on your paid time!
-
-
-Regards,
-The [[sitename]] Team
-.
-
-shop.email.user.random.subject=[[sitename]] Account Purchase
-
-shop.email.user.random_anon.body<<
-Dear [[touser]],
-
+through our sponsor-a-free-user program.
+.
+
+shop.email.user.random_anon<<
Your account has been randomly selected to receive someone's payment through
our
-sponsor-a-free-user program. The account that was purchased is:
-
- [[accounttype]]
-
-Congratulations on your paid time!
-
-
-Regards,
-The [[sitename]] Team
-.
-
-shop.email.user.random_anon.subject=[[sitename]] Account Purchase
-
-shop.email.user.self.body<<
-Dear [[touser]],
-
-Your [[sitename]] account has been upgraded. The account that was purchased
-is:
-
- [[accounttype]]
-
-Congratulations on your paid time!
-
-
-Regards,
-The [[sitename]] Team
-.
-
-shop.email.user.self.subject=[[sitename]] Account Purchase
+sponsor-a-free-user program.
+.
+
+shop.email.user.self=Your [[sitename]] account has been upgraded.
shop.expiration.comm.0.body<<
Dear [[touser]],
@@ -5088,6 +4955,8 @@ widget.shopitemoptions.error.invaliduser
widget.shopitemoptions.error.nocart=Unable to get a shopping cart for you.
Please try again later.
+widget.shopitemoptions.error.notforsale=This purchase type is currently not
for sale.
+
widget.shopitemoptions.error.notloggedin=You must be logged in as a personal
account in order to purchase paid time for yourself.
widget.shopitemoptions.error.nousers=There are currently no active free users.
diff -r 197be79b14e5 -r 3b5231ceae25 cgi-bin/DW/Shop/Item.pm
--- a/cgi-bin/DW/Shop/Item.pm Tue Apr 05 12:05:21 2011 +0800
+++ b/cgi-bin/DW/Shop/Item.pm Fri Apr 08 16:38:09 2011 +0800
@@ -47,6 +47,7 @@ Arguments:
=item cannot_conflict => 1,
=item noremove => 1,
=item from_name => sender name,
+=item reason => personal note from sender to target
The type is required. Also, one target_* argument is required; it may be either
a target_userid or a target_email. All other arguments are optional.
@@ -209,6 +210,21 @@ sub can_be_added {
return 1;
}
+
+=head2 C<< $self->can_have_reason( [ %opts ] ) >>
+
+Returns 1 if this item is allowed to have a personal note from the
+sender explaining the reason for the gift.
+
+Subclasses must override this in order to disallow.
+
+=cut
+
+sub can_have_reason {
+ my ( $self, %opts ) = @_;
+
+ return 1;
+}
=head2 C<< $self->conflicts( $item ) >>
@@ -479,6 +495,10 @@ Name of the sender in special cases. For
Name of the sender in special cases. For example, can be the site name for
promotions. Not exposed/settable via the shop.
+=head2 C<< $self->reason >>
+
+Optional note from the sender explaining the reason for the gift.
+
=cut
sub display_paid_cash { sprintf( '$%0.2f USD', $_[0]->paid_cash ) }
@@ -491,6 +511,7 @@ sub anonymous { return $_[0]->{anonym
sub anonymous { return $_[0]->{anonymous}; }
sub noremove { return $_[0]->{noremove}; }
sub from_name { return $_[0]->{from_name}; }
+sub reason { return $_[0]->{reason}; }
# this has to work with old items (pre-points) too
sub cost_cash {
diff -r 197be79b14e5 -r 3b5231ceae25 cgi-bin/DW/Shop/Item/Account.pm
--- a/cgi-bin/DW/Shop/Item/Account.pm Tue Apr 05 12:05:21 2011 +0800
+++ b/cgi-bin/DW/Shop/Item/Account.pm Fri Apr 08 16:38:09 2011 +0800
@@ -108,6 +108,7 @@ sub _apply_userid {
my $accounttype_string = $self->permanent ?
LJ::Lang::ml( 'shop.email.accounttype.permanent', { type =>
$self->class_name } ) :
LJ::Lang::ml( 'shop.email.accounttype', { type => $self->class_name,
nummonths => $self->months } );
+ $subj = LJ::Lang::ml( "shop.email.acct.subject", { sitename =>
$LJ::SITENAME } );
if ( $u->is_community ) {
my $maintus = LJ::load_userids( $u->maintainer_userids );
@@ -116,17 +117,23 @@ sub _apply_userid {
$emailtype = 'anon' if $self->anonymous;
$emailtype = 'explicit' if $self->from_name;
- $subj = LJ::Lang::ml( "shop.email.comm.$emailtype.subject", {
sitename => $LJ::SITENAME } );
- $body = LJ::Lang::ml( "shop.email.comm.$emailtype.body",
+ $body = LJ::Lang::ml( "shop.email.acct.body.start", { touser =>
$maintu->display_name } );
+ $body .= "\n";
+ $body .= LJ::Lang::ml( "shop.email.comm.$emailtype",
{
- touser => $maintu->display_name,
fromuser => $fu ? $fu->display_name : '',
commname => $u->display_name,
- accounttype => $accounttype_string,
sitename => $LJ::SITENAME,
fromname => $self->from_name,
}
);
+
+ $body .= LJ::Lang::ml( "shop.email.acct.body.type", { accounttype
=> $accounttype_string } );
+ $body .= LJ::Lang::ml( "shop.email.acct.body.note", { reason =>
$self->reason } )
+ if $self->reason;
+
+ $body .= LJ::Lang::ml( "shop.email.comm.close" );
+ $body .= LJ::Lang::ml( "shop.email.acct.body.end", { sitename =>
$LJ::SITENAME } );
# send the email to the maintainer
LJ::send_mail( {
@@ -147,16 +154,22 @@ sub _apply_userid {
$emailtype = 'explicit' if $self->from_name;
}
- $subj = LJ::Lang::ml( "shop.email.user.$emailtype.subject", { sitename
=> $LJ::SITENAME } );
- $body = LJ::Lang::ml( "shop.email.user.$emailtype.body",
+ $body = LJ::Lang::ml( "shop.email.acct.body.start", { touser =>
$u->display_name } );
+ $body .= "\n";
+ $body .= LJ::Lang::ml( "shop.email.user.$emailtype",
{
- touser => $u->display_name,
fromuser => $fu ? $fu->display_name : '',
- accounttype => $accounttype_string,
sitename => $LJ::SITENAME,
fromname => $self->from_name,
}
);
+
+ $body .= LJ::Lang::ml( "shop.email.acct.body.type", { accounttype =>
$accounttype_string } );
+ $body .= LJ::Lang::ml( "shop.email.acct.body.note", { reason =>
$self->reason } )
+ if $self->reason;
+
+ $body .= LJ::Lang::ml( "shop.email.user.close" );
+ $body .= LJ::Lang::ml( "shop.email.acct.body.end", { sitename =>
$LJ::SITENAME } );
# send the email to the user
LJ::send_mail( {
@@ -205,16 +218,24 @@ sub _apply_email {
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",
+ $subj = LJ::Lang::ml( "shop.email.acct.subject", { sitename =>
$LJ::SITENAME } );
+
+ $body = LJ::Lang::ml( "shop.email.acct.body.start", { touser =>
$self->t_email } );
+ $body .= "\n";
+ $body .= LJ::Lang::ml( "shop.email.email.$emailtype",
{
- email => $self->t_email,
fromuser => $fu ? $fu->display_name : '',
- accounttype => $accounttype_string,
- createurl => "$LJ::SITEROOT/create?code=$code",
sitename => $LJ::SITENAME,
}
);
+
+ $body .= LJ::Lang::ml( "shop.email.acct.body.type", { accounttype =>
$accounttype_string } );
+ $body .= LJ::Lang::ml( "shop.email.acct.body.create", { createurl =>
"$LJ::SITEROOT/create?code=$code" } );
+ $body .= LJ::Lang::ml( "shop.email.acct.body.note", { reason =>
$self->reason } )
+ if $self->reason;
+
+ $body .= LJ::Lang::ml( "shop.email.email.close" );
+ $body .= LJ::Lang::ml( "shop.email.acct.body.end", { sitename =>
$LJ::SITENAME } );
# send the email to the user
my $rv = LJ::send_mail( {
diff -r 197be79b14e5 -r 3b5231ceae25 cgi-bin/LJ/Widget/ShopItemOptions.pm
--- a/cgi-bin/LJ/Widget/ShopItemOptions.pm Tue Apr 05 12:05:21 2011 +0800
+++ b/cgi-bin/LJ/Widget/ShopItemOptions.pm Fri Apr 08 16:38:09 2011 +0800
@@ -53,6 +53,9 @@ sub render_body {
}
$ret .= "<br />";
+
+ $ret .= $class->ml( "widget.shopitemoptions.error.notforsale" )
+ unless @month_values; # no matching keys in SHOP hash
foreach my $month_value ( sort { $b <=> $a } @month_values ) {
my $full_item = $given_item . $month_value;
@@ -145,6 +148,8 @@ sub handle_post {
$item_data{anonymous} = 1
if $post->{anonymous} || !$remote;
+ $item_data{reason} = LJ::strip_html( $post->{reason} ); # plain text
+
# build a new item and try to toss it in the cart. this fails if there's a
# conflict or something
if ( $post->{accttype} ) {
diff -r 197be79b14e5 -r 3b5231ceae25 htdocs/shop/account.bml
--- a/htdocs/shop/account.bml Tue Apr 05 12:05:21 2011 +0800
+++ b/htdocs/shop/account.bml Fri Apr 08 16:38:09 2011 +0800
@@ -75,7 +75,9 @@ body<=
my $post_fields = LJ::Widget::ShopItemOptions->post_fields( \%POST );
if ( keys %$post_fields ) { # make sure the user selected an account
type
# need to do this because all of these form fields are in the BML
page instead of in the widget
- LJ::Widget->use_specific_form_fields( post => \%POST, widget =>
"ShopItemOptions", fields => [ qw( for username email deliverydate_mm
deliverydate_dd deliverydate_yyyy anonymous ) ] );
+ LJ::Widget->use_specific_form_fields( post => \%POST,
+ widget => "ShopItemOptions",
+ fields => [ qw( for username
email deliverydate_mm deliverydate_dd deliverydate_yyyy anonymous reason ) ] );
my %from_post = LJ::Widget->handle_post( \%POST, (
'ShopItemOptions' ) );
$error = $from_post{error} if $from_post{error};
} else {
@@ -142,6 +144,17 @@ body<=
disabled => $remote ? 0 : 1,
} ) . "</td></tr>";
+ if ( DW::Shop::Item::Account->can_have_reason ) {
+ $ret .= "<tr><td>$ML{'.giftfor.reason'}</td><td>";
+ $ret .= LJ::html_textarea( {
+ name => 'reason',
+ rows => 6,
+ cols => 60,
+ wrap => 'soft'
+ } );
+ $ret .= "</td></tr>";
+ }
+
$ret .= "</table>";
}
diff -r 197be79b14e5 -r 3b5231ceae25 htdocs/shop/account.bml.text
--- a/htdocs/shop/account.bml.text Tue Apr 05 12:05:21 2011 +0800
+++ b/htdocs/shop/account.bml.text Fri Apr 08 16:38:09 2011 +0800
@@ -16,6 +16,8 @@
.giftfor.email=Email address to receive the account creation code for this
account:
+.giftfor.reason=Optional note for recipient (plain text):
+
.giftfor.username=Username to receive this account:
.giftfor.username.random=Random active free user
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog