Version 4.6.0

This commit is contained in:
Neo committed 2025-12-19 05:55:31 -08:00
1 parent f79dcf067a
commit 517a5e1f70
2036 files changed
+110041 -26162

No files matched your search

@@ -67,6 +67,16 @@ 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)
*
@@ -192,7 +202,29 @@ class _Subscription extends \IPS\Patterns\ActiveRecord
{
$where[] = array( 'sub_active=1' );
}
return static::constructFromData( \IPS\Db::i()->select( '*', 'nexus_member_subscriptions', $where )->first() );
}
catch( \Exception $ex )
{
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 )
@@ -212,4 +244,14 @@ 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();
}
}