News:

Please note these forums are mostly a testing ground for my SMF work and I don't really use them otherwise.

Main Menu

Paste-1242007270:v:use_geshi-1:v:type-text

Started by SleePy, May 11, 2009, 02:01 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

SleePy

Index: trunk/subscriptions.php
===================================================================
--- trunk/subscriptions.php   (revision 8394)
+++ trunk/subscriptions.php   (working copy)
@@ -121,7 +121,7 @@
 
 // We wish to check the pending payments to make sure we are expecting this.
 $request = $smcFunc['db_query']('', '
-   SELECT id_sublog, payments_pending, pending_details
+   SELECT id_sublog, payments_pending, pending_details, end_time
    FROM {db_prefix}log_subscribed
    WHERE id_subscribe = {int:current_subscription}
       AND id_member = {int:current_member}
@@ -142,6 +142,18 @@
    // Delete user subscription.
    removeSubscription($subscription_id, $member_id);
 
+   // If the end time subtracted by current time, is not greater than the duration (ie length of subscription), then we close it.
+   // !!! IE, Duration is 1 Year (31536000 seconds)
+   // !!! Subscription ends on 1273542875 (May 9th 2010 18:54 PDT)
+   // !!! Current time is 1242006935 (May 10th 2009 19:54 PDT)
+   // !!! So, 1273542875 - 1242006935 = 31535940
+   // !!! 31535940 is less than 31536000. So we would close it.
+   // !!! If the subscription was twice as long, We would just remove 1 subscription.
+   if ($subscription_info['end_time'] - time() < $subscription_info['length'])
+      $subscription_act = time();
+   else
+      $subscription_act = $subscription_info['end_time'] - $subscription_info['length'];
+
    // Mark it as complete so we have a record.
    $smcFunc['db_query']('', '
       UPDATE {db_prefix}log_subscribed
@@ -150,7 +162,7 @@
          AND id_member = {int:current_member}
          AND status = {int:not_active}',
       array(
-         'current_time' => time(),
+         'current_time' => $subscription_act,
          'current_subscription' => $subscription_id,
          'current_member' => $member_id,
          'not_active' => 0,
No siggy! :D