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\modules\front\clients;
/* 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;
@@ -64,17 +64,17 @@ class _credit extends \IPS\Dispatcher\Controller
/* Pending Withdrawls */
$perPage = 10;
$page = isset( \IPS\Request::i()->page ) ? intval( \IPS\Request::i()->page ) : 1;
$page = isset( \IPS\Request::i()->page ) ? \intval( \IPS\Request::i()->page ) : 1;
if( $page < 1 )
{
$page = 1;
}
$pastWithdrawalsSelect = \IPS\Db::i()->select( '*', 'nexus_payouts', array( 'po_member=?', \IPS\nexus\Customer::loggedIn()->member_id ), 'po_date DESC', array( ( $page - 1 ) * $perPage, $perPage ), NULL, NULL, \IPS\Db::SELECT_SQL_CALC_FOUND_ROWS );
$pastWithdrawalsSelect = \IPS\Db::i()->select( '*', 'nexus_payouts', array( 'po_member=?', \IPS\nexus\Customer::loggedIn()->member_id ), 'po_date DESC', array( ( $page - 1 ) * $perPage, $perPage ) );
$pastWithdrawalsPagination = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination(
\IPS\Http\Url::internal( 'app=nexus&module=clients&controller=credit', 'front', 'clientscredit' ),
ceil( $pastWithdrawalsSelect->count( TRUE ) / $perPage ),
ceil( \IPS\Db::i()->select( 'COUNT(*)', 'nexus_payouts', array( 'po_member=?', \IPS\nexus\Customer::loggedIn()->member_id ) )->first() / $perPage ),
$page,
$perPage
);
@@ -83,7 +83,7 @@ class _credit extends \IPS\Dispatcher\Controller
/* Can we withdraw? */
$canWithdraw = FALSE;
$withdrawOptions = json_decode( \IPS\Settings::i()->nexus_payout, TRUE );
if ( count( $withdrawOptions ) )
if ( \count( $withdrawOptions ) )
{
foreach ( \IPS\nexus\Money::currencies() as $currency )
{
@@ -136,7 +136,7 @@ class _credit extends \IPS\Dispatcher\Controller
{
unset( $withdrawOptions['Stripe'] );
}
if ( count( $withdrawOptions ) )
if ( \count( $withdrawOptions ) )
{
$withdrawForm = new \IPS\Helpers\Form( 'withdraw', 'withdraw_credit' );
@@ -149,7 +149,7 @@ class _credit extends \IPS\Dispatcher\Controller
} );
$currencyOptions = array();
if ( count( $balance ) > 1 )
if ( \count( $balance ) > 1 )
{
$currencyToggles = array();
foreach ( \IPS\nexus\Money::currencies() as $currency )
@@ -207,7 +207,7 @@ class _credit extends \IPS\Dispatcher\Controller
\IPS\Member::loggedIn()->language()->words[ 'withdraw_amount_' . $currency . '_desc' ] = \IPS\Member::loggedIn()->language()->addToStack( 'max_withdrawl_exceeded' );
}
$field = new \IPS\Helpers\Form\Number( 'withdraw_amount_' . $currency, (string) $max, count( $currencyOptions ) ? NULL : TRUE, array( 'min' => $min, 'max' => (string) $max, 'decimals' => \IPS\nexus\Money::numberOfDecimalsForCurrency( $currency ), 'disabled' => ( $max <= 0 ) ), count( $currencyOptions ) ? NULL : function( $val ) use ( $currency )
$field = new \IPS\Helpers\Form\Number( 'withdraw_amount_' . $currency, (string) $max, \count( $currencyOptions ) ? NULL : TRUE, array( 'min' => $min, 'max' => (string) $max, 'decimals' => \IPS\nexus\Money::numberOfDecimalsForCurrency( $currency ), 'disabled' => ( $max <= 0 ) ), \count( $currencyOptions ) ? NULL : function( $val ) use ( $currency )
{
if ( !$val and \IPS\Request::i()->withdraw_currency === $currency )
{
@@ -229,7 +229,7 @@ class _credit extends \IPS\Dispatcher\Controller
{
$options[ $k ] = $k === 'Manual' ? $settings['name'] : 'withdraw__' . $k;
$toggles[ $k ] = array();
$class = 'IPS\nexus\Gateway\\' . $k . '\Payout';
$class = \IPS\nexus\Gateway::payoutGateways()[ $k ];
foreach ( $class::form() as $field )
{
if ( !$field->htmlId )
@@ -241,7 +241,7 @@ class _credit extends \IPS\Dispatcher\Controller
}
}
if ( count( $withdrawOptions ) > 1 )
if ( \count( $withdrawOptions ) > 1 )
{
$withdrawForm->add( new \IPS\Helpers\Form\Radio( 'withdraw_method', NULL, TRUE, array( 'options' => $options, 'toggles' => $toggles ) ) );
}
@@ -253,17 +253,17 @@ class _credit extends \IPS\Dispatcher\Controller
if ( $values = $withdrawForm->values() )
{
$currencies = array_keys( $balance );
$currency = count( $currencyOptions ) ? $values['withdraw_currency'] : array_pop( $currencies );
$currency = \count( $currencyOptions ) ? $values['withdraw_currency'] : array_pop( $currencies );
$withdrawMethods = array_keys( $options );
if ( count( $withdrawMethods ) === 1 )
if ( \count( $withdrawMethods ) === 1 )
{
$key = array_pop( $withdrawMethods );
$class = 'IPS\nexus\Gateway\\' . $key . '\Payout';
$class = \IPS\nexus\Gateway::payoutGateways()[ $key ];
}
else
{
$class = 'IPS\nexus\Gateway\\' . $values['withdraw_method'] . '\Payout';
$class = \IPS\nexus\Gateway::payoutGateways()[ $values['withdraw_method'] ];
}
$payout = new $class;
@@ -295,6 +295,10 @@ class _credit extends \IPS\Dispatcher\Controller
}
catch ( \Exception $e ) {}
}
else
{
\IPS\core\AdminNotification::send( 'nexus', 'Withdrawal', NULL, TRUE, $payout );
}
\IPS\nexus\Customer::loggedIn()->log( 'payout', array( 'type' => 'request', 'amount' => $values[ 'withdraw_amount_' . $currency ], 'currency' => $currency, 'payout_id' => $payout->id ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=credit&withdraw=pending', 'front', 'clientscredit' ) );
@@ -311,7 +315,7 @@ class _credit extends \IPS\Dispatcher\Controller
\IPS\Output::i()->error( 'no_module_permission', '2X239/3', 403, '' );
}
\IPS\Output::i()->output = $withdrawForm->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'forms', 'core' ) ), 'popupTemplate' ) );
\IPS\Output::i()->output = $withdrawForm->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
}
/**
@@ -338,14 +342,14 @@ class _credit extends \IPS\Dispatcher\Controller
foreach ( $account->cm_credits as $value )
{
$max = $maximumBalanceAmounts ? ( ( new \IPS\Math\Number( number_format( $maximumBalanceAmounts[ $value->currency ]['amount'], \IPS\nexus\Money::numberOfDecimalsForCurrency( $value->currency ), '.', '' ) ) )->subtract( $value->amount ) ) : NULL;
if ( is_null( $max ) or $max->isGreaterThanZero() )
if ( \is_null( $max ) or $max->isGreaterThanZero() )
{
$maximums[ $account->member_id ][ $value->currency ] = is_null( $max ) ? NULL : (string) $max;
$maximums[ $account->member_id ][ $value->currency ] = \is_null( $max ) ? NULL : (string) $max;
}
}
}
if ( count( $maximums ) )
if ( \count( $maximums ) )
{
$topupForm = new \IPS\Helpers\Form( 'topup', 'checkout' );
@@ -353,20 +357,20 @@ class _credit extends \IPS\Dispatcher\Controller
foreach ( $maximums as $accountId => $data )
{
$currency = NULL;
if ( count( $data ) === 1 )
if ( \count( $data ) === 1 )
{
$currencies = array_keys( $data );
$currency = array_pop( $currencies );
}
$accountOptions[ $accountId ] = $accountId === \IPS\nexus\Customer::loggedIn()->id ? \IPS\nexus\Customer::loggedIn()->language()->addToStack( 'my_account', FALSE, array( 'sprintf' => array( \IPS\nexus\Customer::loggedIn()->cm_name ) ) ) : \IPS\nexus\Customer::load( $accountId )->cm_name;
$accountOptionToggles[ $accountId ] = ( count( $data ) > 1 ) ? array( 'topup_currency_' . $accountId ) : array( 'topup_amount_' . $accountId . '_' . $currency );
$accountOptionToggles[ $accountId ] = ( \count( $data ) > 1 ) ? array( 'topup_currency_' . $accountId ) : array( 'topup_amount_' . $accountId . '_' . $currency );
}
$topupForm->add( new \IPS\Helpers\Form\Radio( 'topup_account', NULL, TRUE, array( 'options' => $accountOptions, 'parse' => 'normal', 'toggles' => $accountOptionToggles ) ) );
foreach ( $maximums as $accountId => $data )
{
if ( count( $data ) > 1 )
if ( \count( $data ) > 1 )
{
$currencyToggles = array();
foreach ( $data as $currency => $maximum )
@@ -385,16 +389,16 @@ class _credit extends \IPS\Dispatcher\Controller
$field = new \IPS\Helpers\Form\Number( 'topup_amount_' . $accountId . '_' . $currency, NULL, NULL, array( 'decimals' => \IPS\nexus\Money::numberOfDecimalsForCurrency( $currency ) ), function( $val ) use ( $currency, $accountOptions, $accountId, $data, $min, $maximum )
{
if ( count( $accountOptions ) === 1 or \IPS\Request::i()->topup_account == $accountId )
if ( \count( $accountOptions ) === 1 or \IPS\Request::i()->topup_account == $accountId )
{
$key = "topup_currency_{$accountId}";
if ( count( $data ) === 1 or \IPS\Request::i()->$key == $currency )
if ( \count( $data ) === 1 or \IPS\Request::i()->$key == $currency )
{
if ( !$val )
{
throw new \DomainException('form_required');
}
elseif ( !is_null( $min ) and $val < $min )
elseif ( !\is_null( $min ) and $val < $min )
{
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'form_number_min', FALSE, array( 'sprintf' => array( $min ) ) ) );
}
@@ -439,7 +443,7 @@ class _credit extends \IPS\Dispatcher\Controller
\IPS\Output::i()->error( 'no_module_permission', '2X239/4', 403, '' );
}
\IPS\Output::i()->output = $topupForm->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'forms', 'core' ) ), 'popupTemplate' ) );
\IPS\Output::i()->output = $topupForm->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
}
/**