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

@@ -12,7 +12,7 @@
namespace IPS\nexus\extensions\core\MemberACPProfileBlocks;
/* 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;
@@ -36,14 +36,14 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
'count' => 0
)
);
if ( count( \IPS\nexus\Gateway::cardStorageGateways() ) )
if ( \count( \IPS\nexus\Gateway::cardStorageGateways() ) )
{
$tabs['cards'] = array(
'icon' => 'credit-card',
'count' => \IPS\Db::i()->select( 'COUNT(*)', 'nexus_customer_cards', array( 'card_member=?', $this->member->member_id ) )->first()
);
}
if ( count( \IPS\nexus\Gateway::billingAgreementGateways() ) )
if ( \count( \IPS\nexus\Gateway::billingAgreementGateways() ) )
{
$tabs['paypal'] = array(
'icon' => 'paypal',
@@ -54,10 +54,7 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
'icon' => 'user',
'count' => \IPS\Db::i()->select( 'COUNT(*)', 'nexus_alternate_contacts', array( 'main_id=?', $this->member->member_id ) )->first()
);
$tabs['referrers'] = array(
'icon' => 'retweet',
'count' => \IPS\Db::i()->select( 'COUNT(*)', 'nexus_referrals', array( 'referred_by=?', $this->member->member_id ) )->first()
);
return $tabs;
}
@@ -71,7 +68,7 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
/* Sparkline */
$sparkline = NULL;
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customer', 'customers_view_statistics' ) )
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customers_view_statistics' ) )
{
$rows = array();
$oneYearAgo = \IPS\DateTime::create()->sub( new \DateInterval( 'P1Y' ) );
@@ -142,32 +139,17 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
),
) );
}
/* Referrals */
try
{
$referredBy = \IPS\nexus\Customer::load( \IPS\Db::i()->select( 'referred_by', 'nexus_referrals', array( 'member_id=?', $this->member->member_id ) )->first() );
}
catch ( \UnderflowException $e )
{
$referredBy = NULL;
}
/* Primary Billing Address */
$primaryBillingAddress = NULL;
try
{
$primaryBillingAddress = \IPS\nexus\Customer\Address::constructFromData( \IPS\Db::i()->select( '*', 'nexus_customer_addresses', array( 'member=? AND primary_billing=1', $this->member->member_id ) )->first() )->address;
}
catch ( \UnderflowException $e ) { }
$addressCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_customer_addresses', array( 'member=?', $this->member->member_id ) )->first();
$primaryBillingAddress = $this->member->primaryBillingAddress();
$addressCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_customer_addresses', array( '`member`=?', $this->member->member_id ) )->first();
/* Display */
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->accountInformationOverview( $this->member, $sparkline, $referredBy, $primaryBillingAddress, $addressCount );
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->accountInformationOverview( $this->member, $sparkline, $primaryBillingAddress, $addressCount );
}
/**
* Get output: CARDS
* Get output: STORED PAYMENT METHODS
*
* @param bool $edit Edit view?
* @return string
@@ -184,21 +166,25 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
'id' => $card->id,
'card_type' => $cardData->type,
'card_member' => $card->member->member_id,
'card_number' => $cardData->lastFour,
'card_expire' => ( !is_null( $cardData->expMonth ) AND !is_null( $cardData->expYear ) ) ? str_pad( $cardData->expMonth , 2, '0', STR_PAD_LEFT ). '/' . $cardData->expYear : NULL
'card_number' => $cardData->lastFour ?: $cardData->number,
'card_expire' => ( !\is_null( $cardData->expMonth ) AND !\is_null( $cardData->expYear ) ) ? str_pad( $cardData->expMonth , 2, '0', STR_PAD_LEFT ). '/' . $cardData->expYear : NULL
);
}
catch ( \Exception $e ) { }
}
$cards = new \IPS\Helpers\Table\Custom( $cards, $this->member->acpUrl()->setQueryString( 'view', 'cards' ) );
$cards->rootButtons = array(
'add' => array(
'link' => \IPS\Http\Url::internal("app=nexus&module=customers&controller=view&id={$this->member->member_id}")->setQueryString( 'do', 'addCard' ),
'title' => 'add',
'icon' => 'plus',
'data' => array( 'ipsDialog' => true, 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('add_card') )
)
);
if ( \IPS\nexus\Gateway::cardStorageGateways( TRUE ) )
{
$cards->rootButtons = array(
'add' => array(
'link' => \IPS\Http\Url::internal("app=nexus&module=customers&controller=view&id={$this->member->member_id}")->setQueryString( 'do', 'addCard' ),
'title' => 'add',
'icon' => 'plus',
'data' => array( 'ipsDialog' => true, 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('add_card') )
)
);
}
$cards->rowButtons = function( $row )
{
return array(
@@ -368,76 +354,7 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->accountInformationTablePreview( $this->member, $alternativeContacts, \IPS\Member::loggedIn()->language()->addToStack( 'num_alternate_contacts', FALSE, array( 'pluralize' => array( $altContactCount ) ) ), 'alts' );
}
}
/**
* Get output: REFERRERS
*
* @param bool $edit Edit view?
* @return string
*/
protected function _referrers( $edit = FALSE )
{
$referCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_referrals', array( 'referred_by=?', $this->member->member_id ) )->first();
$referrals = new \IPS\Helpers\Table\Db( 'nexus_referrals', $this->member->acpUrl()->setQueryString( 'view', 'referrals' ), array( 'referred_by=?', $this->member->member_id ) );
$referrals->langPrefix = 'ref_';
$referrals->include = array( 'member_id', 'amount' );
$referrals->sortBy = $referrals->sortBy ?: 'member_id';
$referrals->parsers = array(
'member_id' => function( $v )
{
try
{
return \IPS\Theme::i()->getTemplate( 'global', 'nexus' )->userLink( \IPS\nexus\Customer::load( $v ) );
}
catch ( \OutOfRangeException $e )
{
return \IPS\Member::loggedIn()->language()->addToStack('deleted_member');
}
},
'email' => function( $v, $row )
{
try
{
return htmlspecialchars( \IPS\nexus\Customer::load( $row['member_id'] )->email, ENT_DISALLOWED, 'UTF-8', FALSE );
}
catch ( \OutOfRangeException $e )
{
return \IPS\Member::loggedIn()->language()->addToStack('deleted_member');
}
},
'amount' => function( $v )
{
$return = array();
if ( $v )
{
foreach ( json_decode( $v, TRUE ) as $currency => $amount )
{
$return[] = new \IPS\nexus\Money( $amount, $currency );
}
}
else
{
$return[] = new \IPS\nexus\Money( 0, \IPS\nexus\Customer::load( $this->member )->defaultCurrency() );
}
return implode( '<br>', $return );
}
);
if ( $edit )
{
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->customerPopup( $referrals );
}
else
{
$referrals->include[] = 'email';
$referrals->limit = 2;
$referrals->tableTemplate = array( \IPS\Theme::i()->getTemplate( 'customers', 'nexus' ), 'referralsOverview' );
$referrals->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'customers', 'nexus' ), 'referralsOverviewRows' );
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->accountInformationTablePreview( $this->member, $referrals, \IPS\Member::loggedIn()->language()->addToStack( 'num_refer_count', FALSE, array( 'pluralize' => array( $referCount ) ) ), 'referrers' );
}
}
/**
* Get output
*
@@ -472,7 +389,7 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
public function output()
{
$tabs = $this->tabs();
if ( !count( $tabs ) )
if ( !\count( $tabs ) )
{
return '';
}
@@ -11,7 +11,7 @@
namespace IPS\nexus\extensions\core\MemberACPProfileBlocks;
/* 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;
@@ -11,7 +11,7 @@
namespace IPS\nexus\extensions\core\MemberACPProfileBlocks;
/* 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;
@@ -92,7 +92,7 @@ class _Notes extends \IPS\core\MemberACPProfile\Block
'link' => \IPS\Http\Url::internal("app=nexus&module=customers&controller=view&id={$this->member->member_id}")->setQueryString( array( 'do' => 'deleteNote', 'note_id' => $row['note_id'], 'support' => isset( \IPS\Request::i()->support ) ? \IPS\Request::i()->support : 0 ) ),
'title' => 'delete',
'icon' => 'times-circle',
'data' => array( 'delete' => '' )
'data' => array( 'confirm' => '' )
);
}
return $return;
@@ -11,7 +11,7 @@
namespace IPS\nexus\extensions\core\MemberACPProfileBlocks;
/* 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;
@@ -35,7 +35,7 @@ class _ParentAccounts extends \IPS\core\MemberACPProfile\Block
$parents[] = \IPS\nexus\Customer::load( $row );
}
if ( count( $parents ) )
if ( \count( $parents ) )
{
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->parentAccounts( $parents );
}
@@ -11,7 +11,7 @@
namespace IPS\nexus\extensions\core\MemberACPProfileBlocks;
/* 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;
@@ -20,7 +20,7 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
/**
* @brief ACP Member Profile: Purchases
*/
class _Purchases extends \IPS\core\MemberACPProfile\Block
class _Purchases extends \IPS\core\MemberACPProfile\TabbedBlock
{
/**
* Purchase tree
@@ -28,22 +28,33 @@ class _Purchases extends \IPS\core\MemberACPProfile\Block
protected $_purchases = NULL;
/**
* Get purchase table
* Get Tab Names
*
* @return \IPS\Helpers\Tree\Tree
* @return string
*/
protected function purchases()
public function tabs()
{
if ( $this->_purchases === NULL )
{
$this->_purchases = \IPS\nexus\Purchase::tree( $this->member->acpUrl()->setQueryString( 'blockKey', 'nexus_Purchases' ), array( array( 'ps_member=?', $this->member->member_id ) ) );
$this->_purchases->rootsPerPage = 15;
$this->_purchases->getTotalRoots = function()
{
return NULL;
};
}
return $this->_purchases;
$tabs = array();
$activeCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_member=? AND ps_show=1 AND ps_active=1 AND ps_parent = 0', $this->member->member_id ) )->first();
$tabs['active'] = array(
'icon' => 'credit-card',
'count' => $activeCount,
);
$expiredCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_member=? AND ps_active = 0 AND ps_cancelled = 0 AND ps_parent = 0 AND ps_expire <?', $this->member->member_id, \IPS\DateTime::create()->getTimestamp() ) )->first();
$tabs['expired'] = array(
'icon' => 'credit-card',
'count' => $expiredCount,
);
$canceledCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_member=? AND ps_cancelled=1 AND ps_parent = 0', $this->member->member_id ) )->first();
$tabs['canceled'] = array(
'icon' => 'credit-card',
'count' => $canceledCount,
);
return $tabs;
}
/**
@@ -53,19 +64,48 @@ class _Purchases extends \IPS\core\MemberACPProfile\Block
*/
public function output()
{
$purchaseCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_member=? AND ps_show=1', $this->member->member_id ) )->first();
$purchaseRootCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_member=? AND ps_show=1 AND ps_parent=0', $this->member->member_id ) )->first();
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->purchases( $this->member, $this->purchases(), $purchaseCount, $purchaseRootCount );
$tabs = $this->tabs();
if ( !\count( $tabs ) )
{
return '';
}
$tabKeys = array_keys( $tabs );
$activeTabKey = ( isset( \IPS\Request::i()->block['nexus_Purchase'] ) and array_key_exists( \IPS\Request::i()->block['nexus_Purchases'], $tabs ) ) ? \IPS\Request::i()->block['nexus_Purchases'] : array_shift( $tabKeys );
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->purchases( $this->member, $tabs, $activeTabKey, $this->tabOutput( $activeTabKey ) );
}
/**
* Get output
*
* @return string
*/
public function tabOutput()
public function tabOutput( $activeTabKey )
{
return (string) $this->purchases();
if ( $this->_purchases === NULL )
{
$where = array();
$where[] = array( 'ps_member=?', $this->member->member_id );
switch ( $activeTabKey )
{
case 'active':
$where[] = array( 'ps_active=1' );
break;
case 'canceled':
$where[] = array( 'ps_cancelled=1' );
break;
case 'expired':
$where[] = array( 'ps_active = 0 and ps_cancelled = 0 and ps_expire <?', \IPS\DateTime::create()->getTimestamp() );
break;
}
$this->_purchases = \IPS\nexus\Purchase::tree( $this->member->acpUrl()->setQueryString( 'blockKey', 'nexus_Purchases' ), $where );
$this->_purchases->getTotalRoots = function()
{
return NULL;
};
}
return $this->_purchases;
}
}
@@ -11,7 +11,7 @@
namespace IPS\nexus\extensions\core\MemberACPProfileBlocks;
/* 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;
@@ -90,12 +90,12 @@ class _Statistics extends \IPS\core\MemberACPProfile\LazyLoadingBlock
'highval' => $comparisons['max'],
'avgval' => $comparisons['avg'],
'thisval' => $val,
'avgpct' => floatval( $comparisons['max'] ) ? round( ( ( $comparisons['avg'] - $comparisons['min'] ) / $comparisons['max'] ) * 100, 1 ) : 0,
'thispct' => floatval( $comparisons['max'] ) ? round( ( ( $val - $comparisons['min'] ) / $comparisons['max'] ) * 100, 1 ) : 0,
'avgpct' => \floatval( $comparisons['max'] ) ? round( ( ( $comparisons['avg'] - $comparisons['min'] ) / $comparisons['max'] ) * 100, 1 ) : 0,
'thispct' => \floatval( $comparisons['max'] ) ? round( ( ( $val - $comparisons['min'] ) / $comparisons['max'] ) * 100, 1 ) : 0,
'type' => 'timetopay'
);
$sum = "LEAST( ( COUNT(*) / ( ( {$time} - core_members.joined ) / 2592000 ) ), COUNT(*) )";
$sum = "LEAST( ( count(*) / ( ( {$time} - core_members.joined ) / 2592000 ) ), count(*) )";
try
{
$val = \IPS\Db::i()->select( "{$sum} as sum", 'nexus_support_requests', array( 'r_member=?', $this->member->member_id ), 'joined', NULL, 'joined' )->join( 'core_members', 'member_id=r_member' )->first();
@@ -11,7 +11,7 @@
namespace IPS\nexus\extensions\core\MemberACPProfileBlocks;
/* 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;
Whitespace-only changes.