Don't destroy the previous expiration date, so we can see how much paid 
time is transferrable.

        Patch by fu. 

diffs (50 lines):

diff -r 98cc7a5bf242 -r f86159d4bcfe cgi-bin/DW/Pay.pm
--- a/cgi-bin/DW/Pay.pm Thu Apr 28 12:46:55 2011 +0800
+++ b/cgi-bin/DW/Pay.pm Fri Apr 29 16:43:30 2011 +0800
@@ -381,8 +381,10 @@ sub add_paid_time {
         unless $months > 0 || $days > 0 ;
 
     # okay, let's see what the user is right now to decide what to do
+    my $permanent = $months == 99 ? 1 : 0;
+
     my ( $newtypeid, $amonths, $adays, $asecs ) = ( $typeid, $months, $days, 0 
);
-    my $permanent = $months == 99 ? 1 : 0;
+    $amonths = 0 if $permanent;
 
     # if they have a $ps hashref, they have or had paid time at some point
     if ( my $ps = DW::Pay::get_paid_status( $u ) ) {
@@ -400,7 +402,7 @@ sub add_paid_time {
 
             # but if they're going permanent...
             } elsif ( $permanent ) {
-                $amonths = 0;
+                $asecs = $ps->{expiresin};
 
             # but the types are different...
             } else {
diff -r 98cc7a5bf242 -r f86159d4bcfe htdocs/admin/pay/index.bml
--- a/htdocs/admin/pay/index.bml        Thu Apr 28 12:46:55 2011 +0800
+++ b/htdocs/admin/pay/index.bml        Fri Apr 29 16:43:30 2011 +0800
@@ -81,6 +81,10 @@
 
             if ( $ps->{permanent} ) {
                 $body .= '; <strong>Permanent Status</strong> will never 
expire.';
+
+                # but they may have transferrable paid time
+                $body .= " Has paid time up until " . LJ::mysql_time( 
$ps->{expiretime} )
+                    if $ps->{expiresin} > 0;
 
             } else {
                 if ( $ps->{expiresin} > 0 ) {
diff -r 98cc7a5bf242 -r f86159d4bcfe t/paid-time.t
--- a/t/paid-time.t     Thu Apr 28 12:46:55 2011 +0800
+++ b/t/paid-time.t     Fri Apr 29 16:43:30 2011 +0800
@@ -91,7 +91,7 @@ assert( $u1, 'premium', "paid +1 month =
 # seed account
 DW::Pay::add_paid_time( $u1, 'seed', 99 )
     or die DW::Pay::error_text();
-$paidmos = 0;  # never expires
+# no additional paid time, but store old value for reference
 
 assert( $u1, 'seed', "seed account" );
 
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog

Reply via email to