Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -11,44 +11,55 @@
|
||||
namespace IPS\nexus\extensions\core\MemberACPProfileBlocks;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\core\MemberACPProfile\TabbedBlock;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Helpers\Tree\Tree;
|
||||
use IPS\nexus\Purchase;
|
||||
use IPS\Request;
|
||||
use IPS\Theme;
|
||||
use function count;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ACP Member Profile: Purchases
|
||||
*/
|
||||
class _Purchases extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
class Purchases extends TabbedBlock
|
||||
{
|
||||
/**
|
||||
* Purchase tree
|
||||
*/
|
||||
protected $_purchases = NULL;
|
||||
protected ?Tree $_purchases = NULL;
|
||||
|
||||
/**
|
||||
* Get Tab Names
|
||||
*
|
||||
* @return string
|
||||
* @return array
|
||||
*/
|
||||
public function tabs()
|
||||
public function tabs(): array
|
||||
{
|
||||
$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();
|
||||
$activeCount = 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();
|
||||
$expiredCount = 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, 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();
|
||||
$canceledCount = 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,
|
||||
@@ -62,32 +73,33 @@ class _Purchases extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function output()
|
||||
public function output(): string
|
||||
{
|
||||
$tabs = $this->tabs();
|
||||
if ( !\count( $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 );
|
||||
$activeTabKey = ( isset( Request::i()->block['nexus_Purchase'] ) and array_key_exists( Request::i()->block['nexus_Purchases'], $tabs ) ) ? Request::i()->block['nexus_Purchases'] : array_shift( $tabKeys );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->purchases( $this->member, $tabs, $activeTabKey, $this->tabOutput( $activeTabKey ) );
|
||||
return (string) Theme::i()->getTemplate( 'customers', 'nexus' )->purchases( $this->member, $tabs, $activeTabKey, $this->tabOutput( $activeTabKey ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get output
|
||||
*
|
||||
* @return string
|
||||
* @param string $tab
|
||||
* @return mixed
|
||||
*/
|
||||
public function tabOutput( $activeTabKey )
|
||||
public function tabOutput(string $tab ): mixed
|
||||
{
|
||||
if ( $this->_purchases === NULL )
|
||||
{
|
||||
$where = array();
|
||||
$where[] = array( 'ps_member=?', $this->member->member_id );
|
||||
|
||||
switch ( $activeTabKey )
|
||||
switch ( $tab )
|
||||
{
|
||||
case 'active':
|
||||
$where[] = array( 'ps_active=1' );
|
||||
@@ -96,11 +108,11 @@ class _Purchases extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
$where[] = array( 'ps_cancelled=1' );
|
||||
break;
|
||||
case 'expired':
|
||||
$where[] = array( 'ps_active = 0 and ps_cancelled = 0 and ps_expire <?', \IPS\DateTime::create()->getTimestamp() );
|
||||
$where[] = array( 'ps_active = 0 and ps_cancelled = 0 and ps_expire <?', DateTime::create()->getTimestamp() );
|
||||
break;
|
||||
}
|
||||
|
||||
$this->_purchases = \IPS\nexus\Purchase::tree( $this->member->acpUrl()->setQueryString( 'blockKey', 'nexus_Purchases' ), $where );
|
||||
$this->_purchases = Purchase::tree( $this->member->acpUrl()->setQueryString( 'blockKey', 'nexus_Purchases' ), $where );
|
||||
$this->_purchases->getTotalRoots = function()
|
||||
{
|
||||
return NULL;
|
||||
|
||||
Reference in new issue
Block a user