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

@@ -36,7 +36,12 @@ class _Subscription extends \IPS\Patterns\ActiveRecord
* @brief Multiton Store
*/
protected static $multitons;
/**
* @brief [ActiveRecord] Database ID Fields
*/
protected static $databaseIdFields = array( 'sub_purchase_id' );
/**
* Get the DateTime object for when this little subscription doth run out
*
@@ -67,16 +72,6 @@ class _Subscription extends \IPS\Patterns\ActiveRecord
return NULL;
}
/**
* Check if the subscription expired
*
* @return bool
*/
public function isExpired() : bool
{
return $this->expire AND $this->expire < \IPS\DateTime::create()->getTimestamp();
}
/**
* Get the package (ooh, very mysterious, sounds like something from Narcos)
*
@@ -133,10 +128,18 @@ class _Subscription extends \IPS\Patterns\ActiveRecord
*/
public function currentBlurb()
{
if ( !$this->active )
if ( !$this->active AND !$this->purchase->cancelled )
{
return \IPS\Member::loggedIn()->language()->addToStack( 'nexus_subs_subscribed_expired' );
}
elseif( $this->purchase->cancelled AND $this->purchase->can_reactivate )
{
return \IPS\Member::loggedIn()->language()->addToStack( 'nexus_subs_subscribed_cancelled' );
}
elseif( $this->purchase->cancelled )
{
return \IPS\Member::loggedIn()->language()->addToStack( 'nexus_subs_subscribed_cancelled_no_reactivate' );
}
if ( $this->expire and $this->renews and !$this->manually_added )
{
return \IPS\Member::loggedIn()->language()->addToStack( 'nexus_subs_subscribed_with_expire' . ( ( $this->purchase and $this->purchase->renewals ) ? '' : '_no_renewal' ), NULL, array( 'sprintf' => array( $this->_expire->dayAndMonth() . ' ' . $this->_expire->format('Y') ) ) );
@@ -210,28 +213,6 @@ class _Subscription extends \IPS\Patterns\ActiveRecord
throw new \OutOfRangeException;
}
}
/**
* Load a subscription by member and purchase
*
* @param \IPS\Member $member Take a guess
* @param \IPS\nexus\Purchase $purchase I mean it's really writing itself
* @return \IPS\nexus\Subscription
* @throws \OutOfRangeException
*/
public static function loadByMemberAndPurchase( \IPS\Member $member, \IPS\nexus\Purchase $purchase )
{
try
{
$where = array( array( 'sub_purchase_id=? and sub_member_id=?', $purchase->id, $member->member_id ) );
return static::constructFromData( \IPS\Db::i()->select( '*', 'nexus_member_subscriptions', $where )->first() );
}
catch( \Exception $ex )
{
throw new \OutOfRangeException;
}
}
/**
* Mark all subscriptions by this member as inactive
@@ -243,15 +224,4 @@ class _Subscription extends \IPS\Patterns\ActiveRecord
{
\IPS\Db::i()->update( 'nexus_member_subscriptions', array( 'sub_active' => 0 ), array( 'sub_member_id=?', $member->member_id ) );
}
/**
* Can we cancel this subscription?
*
* @return bool
*/
public function canCancel() : bool
{
return !$this->expire or $this->isExpired();
}
}