Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

@@ -11,7 +11,7 @@
namespace IPS\nexus;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -123,9 +123,13 @@ class _Subscription extends \IPS\Patterns\ActiveRecord
*/
public function currentBlurb()
{
if ( $this->expire and $this->renews and ! $this->manually_added )
if ( !$this->active )
{
return \IPS\Member::loggedIn()->language()->addToStack( 'nexus_subs_subscribed_with_expire', NULL, array( 'sprintf' => array( $this->_expire->dayAndMonth() . ' ' . $this->_expire->format('Y') ) ) );
return \IPS\Member::loggedIn()->language()->addToStack( 'nexus_subs_subscribed_expired' );
}
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') ) ) );
}
return \IPS\Member::loggedIn()->language()->addToStack( 'nexus_subs_subscribed' );
@@ -134,22 +138,40 @@ class _Subscription extends \IPS\Patterns\ActiveRecord
/**
* Find and return the package this person is currently subscribed to, or NULL
*
* @param \IPS\Member|NULL $member Pass a member in if you like, no pressure really up to you
* @return \IPS\nexus\Subscription or NULL
* @param \IPS\Member $member The member
* @param bool $activeOnly If TRUE, returns only active subscription
* @return ?\IPS\nexus\Subscription
*/
public static function loadActiveByMember( $member=NULL )
{
$member = $member ? $member : \IPS\Member::loggedIn();
public static function loadByMember( \IPS\Member $member, bool $activeOnly )
{
try
{
return static::constructFromData( \IPS\Db::i()->select( '*', 'nexus_member_subscriptions', array( 'sub_active=1 and sub_member_id=?', $member->member_id ) )->first() );
$where = [];
$where[] = [ 'sub_member_id=?', $member->member_id ];
if ( $activeOnly )
{
$where[] = [ 'sub_active=1' ];
}
return static::constructFromData( \IPS\Db::i()->select( '*', 'nexus_member_subscriptions', $where, 'sub_active DESC, sub_start DESC' )->first() );
}
catch( \Exception $e )
{
return NULL;
}
}
/**
* Find and return the package this person is currently subscribed to, or NULL
*
* @param \IPS\Member|NULL $member Pass a member in if you like, no pressure really up to you
* @return \IPS\nexus\Subscription or NULL
* @deprecated Use loadByMember() instead
*/
public static function loadActiveByMember( $member=NULL )
{
return static::loadByMember( $member ? $member : \IPS\Member::loggedIn(), TRUE );
}
/**
* Load a subscription by member and package