Version 4.7.0

This commit is contained in:
Neo committed 2025-12-19 16:00:35 -08:00
1 parent 517a5e1f70
commit 8ba7d43898
1933 files changed
+65613 -11332

No files matched your search

@@ -38,7 +38,14 @@ class _subscriptions extends \IPS\Dispatcher\Controller
$_SESSION['cart'] = array();
\IPS\Request::i()->setCookie( 'currency', \IPS\Request::i()->currency );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=subscriptions&controller=subscriptions', 'front', 'nexus_subscriptions' ) );
$url = \IPS\Http\Url::internal( 'app=nexus&module=subscriptions&controller=subscriptions', 'front', 'nexus_subscriptions' );
if( isset( \IPS\Request::i()->register ) )
{
$url = $url->setQueryString( 'register', (int) \IPS\Request::i()->register );
}
\IPS\Output::i()->redirect( $url );
}
}
@@ -57,11 +64,14 @@ class _subscriptions extends \IPS\Dispatcher\Controller
\IPS\Output::i()->error( 'nexus_no_subs', '2X379/1', 404, '' );
}
/* Send no-cache headers for this page, required for guest sign-ups */
\IPS\Output::i()->pageCaching = FALSE;
/* Create the table */
$table = new \IPS\nexus\Subscription\Table( \IPS\Http\Url::internal( 'app=nexus&module=subscriptions&controller=subscriptions', 'front', 'nexus_subscriptions' ) );
$current = \IPS\nexus\Subscription::loadByMember( \IPS\Member::loggedIn(), FALSE );
if ( $current AND ( !$current->purchase OR !$current->purchase->cancelled OR $current->purchase->can_reactivate ) )
if ( $current )
{
$table->activeSubscription = $current;
}
@@ -113,23 +123,22 @@ class _subscriptions extends \IPS\Dispatcher\Controller
\IPS\Output::i()->error( 'node_error', '2X379/7', 403, '' );
}
try
{
$subscription = \IPS\nexus\Subscription::loadActiveByMember( \IPS\Member::loggedIn() );
$subscription = \IPS\nexus\Subscription::loadByMember( \IPS\Member::loggedIn(), FALSE );
}
catch( \OutOfRangeException $e )
{
\IPS\Output::i()->error( 'nexus_no_subs_subs', '2X379/3', 404, '' );
}
/* Fetch purchase */
$purchase = NULL;
if( $subscription )
{
foreach ( \IPS\nexus\extensions\nexus\Item\Subscription::getPurchases( \IPS\nexus\Customer::loggedIn(), $subscription->package->id ) as $row )
foreach ( \IPS\nexus\extensions\nexus\Item\Subscription::getPurchases( \IPS\nexus\Customer::loggedIn(), $subscription->package->id, TRUE, TRUE ) as $row )
{
if ( $row->active and ! $row->cancelled )
if ( !$row->cancelled OR ( $row->cancelled AND $row->can_reactivate ) )
{
$purchase = $row;
break;
@@ -141,6 +150,12 @@ class _subscriptions extends \IPS\Dispatcher\Controller
{
\IPS\Output::i()->error( 'nexus_sub_no_purchase', '2X379/4', 404, '' );
}
/* We cannot process changes if an active Billing Agreement is in place */
if( $purchase->billing_agreement and !$purchase->billing_agreement->canceled )
{
\IPS\Output::i()->error( 'nexus_sub_no_change_ba', '2X379/B', 404, '' );
}
/* Right, that's all the "I'll tamper with the URLs for a laugh" stuff out of the way... */
$upgradeCost = $newPackage->costToUpgrade( $subscription->package, \IPS\nexus\Customer::loggedIn() );
@@ -171,9 +186,12 @@ class _subscriptions extends \IPS\Dispatcher\Controller
{
/* CSRF Check */
\IPS\Session::i()->csrfCheck();
/* Send no-cache headers for this page, required for guest sign-ups */
\IPS\Output::i()->pageCaching = FALSE;
/* Already purchased a subscription which was not cancelled? */
if ( $current = \IPS\nexus\Subscription::loadByMember( \IPS\nexus\Customer::loggedIn(), FALSE ) AND ( $current->purchase AND !$current->cancelled AND ( !$current->purchase->cancelled OR $current->purchase->can_reactivate ) ) )
/* Already purchased a subscription */
if ( $current = \IPS\nexus\Subscription::loadByMember( \IPS\nexus\Customer::loggedIn(), FALSE ) AND ( $current->purchase AND ( !$current->purchase->cancelled OR $current->purchase->can_reactivate ) ) )
{
\IPS\Output::i()->error( 'nexus_subs_already_got_package', '2X379/6', 403, '' );
}
@@ -276,46 +294,4 @@ class _subscriptions extends \IPS\Dispatcher\Controller
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=subscriptions&controller=subscriptions', 'front', 'nexus_subscriptions' ) );
}
}
/**
* Cancel an expired subscription so that we can purchase another subscription
*/
public function cancel()
{
/* CSRF Check */
\IPS\Session::i()->csrfCheck();
try
{
$purchase = \IPS\nexus\Purchase::load( \IPS\Request::i()->id );
}
catch( \OutOfRangeException $e )
{
\IPS\Output::i()->error( 'nexus_no_subs_package', '2X379/8', 404, '' );
}
try
{
$subscription = \IPS\nexus\Subscription::loadByMemberAndPurchase( \IPS\Member::loggedIn(), $purchase, FALSE );
}
catch( \OutOfRangeException $e )
{
\IPS\Output::i()->error( 'nexus_no_subs_subs', '2X379/9', 404, '' );
}
if( !$subscription->canCancel() )
{
\IPS\Output::i()->error( 'no_module_permission', '1X379/A', 403, '' );
}
foreach ( \IPS\nexus\extensions\nexus\Item\Subscription::getPurchases( \IPS\nexus\Customer::loggedIn(), $subscription->package->id, TRUE, TRUE ) as $row )
{
$row->cancelled = TRUE;
$row->save();
}
$subscription->cancelled = TRUE;
$subscription->save();
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=subscriptions&controller=subscriptions', 'front', 'nexus_subscriptions' ), 'cancelled' );
}
}