janinedog: (Default)
Janine ([personal profile] janinedog) wrote in [site community profile] changelog2009-05-01 01:44 am

[dw-free] Fix sending a payment to an email address.

[commit: http://hg.dwscoalition.org/dw-free/rev/d044a86a82b9]

Fix sending a payment to an email address.

Patch by [personal profile] janinedog.

Files modified:
  • bin/upgrading/en.dat
  • cgi-bin/DW/Shop/Item/Account.pm
--------------------------------------------------------------------------------
diff -r bab587a837ad -r d044a86a82b9 bin/upgrading/en.dat
--- a/bin/upgrading/en.dat	Fri May 01 01:22:24 2009 +0000
+++ b/bin/upgrading/en.dat	Fri May 01 01:44:15 2009 +0000
@@ -3258,8 +3258,6 @@ shop.item.account.canbeadded.alreadyperm
 
 shop.item.account.canbeadded.invalidjournaltype=You can only send paid time to a personal journal or community account.
 
-shop.item.account.canbeadded.invaliduser=The username that you entered is invalid or does not exist.
-
 shop.item.account.canbeadded.nopaidforpremium=[[user]] has a Premium Paid Account, so they cannot receive a Paid Account.
 
 shop.item.account.canbeadded.noperms=There are no more seed accounts available for purchase at this time.
diff -r bab587a837ad -r d044a86a82b9 cgi-bin/DW/Shop/Item/Account.pm
--- a/cgi-bin/DW/Shop/Item/Account.pm	Fri May 01 01:22:24 2009 +0000
+++ b/cgi-bin/DW/Shop/Item/Account.pm	Fri May 01 01:44:15 2009 +0000
@@ -263,13 +263,9 @@ sub can_be_added {
 
     my $errref = $opts{errref};
     my $target_u = LJ::load_userid( $self->t_userid );
-    unless ( LJ::isu( $target_u ) ) {
-        $$errref = LJ::Lang::ml( 'shop.item.account.canbeadded.invaliduser' );
-        return 0;
-    }
 
     # the receiving user must be a personal or community account
-    unless ( $target_u->is_personal || $target_u->is_community ) {
+    if ( LJ::isu( $target_u ) && !$target_u->is_personal && !$target_u->is_community ) {
         $$errref = LJ::Lang::ml( 'shop.item.account.canbeadded.invalidjournaltype' );
         return 0;
     }
@@ -281,15 +277,17 @@ sub can_be_added {
     }
 
     # check to make sure the target user's current account type doesn't conflict with the item
-    my $account_type = DW::Pay::get_account_type( $target_u );
-    if ( $account_type eq 'seed' ) {
-        # no paid time can be purchased for seed accounts
-        $$errref = LJ::Lang::ml( 'shop.item.account.canbeadded.alreadyperm', { user => $target_u->ljuser_display } );
-        return 0;
-    } elsif ( $account_type eq 'premium' && $self->class eq 'paid' ) {
-        # premium accounts can't get normal paid time
-        $$errref = LJ::Lang::ml( 'shop.item.account.canbeadded.nopaidforpremium', { user => $target_u->ljuser_display } );
-        return 0;
+    if ( LJ::isu( $target_u ) ) {
+        my $account_type = DW::Pay::get_account_type( $target_u );
+        if ( $account_type eq 'seed' ) {
+            # no paid time can be purchased for seed accounts
+            $$errref = LJ::Lang::ml( 'shop.item.account.canbeadded.alreadyperm', { user => $target_u->ljuser_display } );
+            return 0;
+        } elsif ( $account_type eq 'premium' && $self->class eq 'paid' ) {
+            # premium accounts can't get normal paid time
+            $$errref = LJ::Lang::ml( 'shop.item.account.canbeadded.nopaidforpremium', { user => $target_u->ljuser_display } );
+            return 0;
+        }
     }
 
     return 1;
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org