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;
@@ -56,7 +56,7 @@ class _addresses extends \IPS\Dispatcher\Controller
*/
protected function manage()
{
$addresses = new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_customer_addresses', array( 'member=?', \IPS\Member::loggedIn()->member_id ) ), 'IPS\nexus\Customer\Address' );
$addresses = new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_customer_addresses', array( '`member`=?', \IPS\Member::loggedIn()->member_id ) ), 'IPS\nexus\Customer\Address' );
$shippingAddress = NULL;
$billingAddress = NULL;
@@ -106,9 +106,25 @@ class _addresses extends \IPS\Dispatcher\Controller
$existing = NULL;
}
}
$needTaxStatus = NULL;
foreach ( \IPS\nexus\Tax::roots() as $tax )
{
if ( $tax->type === 'eu' )
{
$needTaxStatus = 'eu';
break;
}
if ( $tax->type === 'business' )
{
$needTaxStatus = 'business';
}
}
$addressHelperClass = $needTaxStatus ? 'IPS\nexus\Form\BusinessAddress' : 'IPS\Helpers\Form\Address';
$addressHelperOptions = ( $needTaxStatus === 'eu' ) ? array( 'vat' => TRUE ) : array();
$form = new \IPS\Helpers\Form;
$form->add( new \IPS\Helpers\Form\Address( 'address', $existing ? $existing->address : NULL, TRUE ) );
$form->add( new $addressHelperClass( 'address', $existing ? $existing->address : NULL, TRUE, $addressHelperOptions ) );
if ( $values = $form->values() )
{
@@ -116,8 +132,8 @@ class _addresses extends \IPS\Dispatcher\Controller
{
$existing = new \IPS\nexus\Customer\Address;
$existing->member = \IPS\Member::loggedIn();
$existing->primary_billing = !\IPS\Db::i()->select( 'count(*)', 'nexus_customer_addresses', array( 'member=? AND primary_billing=1', \IPS\Member::loggedIn()->member_id ) )->first();
$existing->primary_shipping = !\IPS\Db::i()->select( 'count(*)', 'nexus_customer_addresses', array( 'member=? AND primary_shipping=1', \IPS\Member::loggedIn()->member_id ) )->first();
$existing->primary_billing = !\IPS\Db::i()->select( 'count(*)', 'nexus_customer_addresses', array( '`member`=? AND primary_billing=1', \IPS\Member::loggedIn()->member_id ) )->first();
$existing->primary_shipping = !\IPS\Db::i()->select( 'count(*)', 'nexus_customer_addresses', array( '`member`=? AND primary_shipping=1', \IPS\Member::loggedIn()->member_id ) )->first();
\IPS\nexus\Customer::loggedIn()->log( 'address', array( 'type' => 'add', 'details' => json_encode( $values['address'] ) ) );
}
@@ -129,13 +145,15 @@ class _addresses extends \IPS\Dispatcher\Controller
$existing->address = $values['address'];
$existing->save();
\IPS\Request::i()->setCookie( 'location', NULL );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=addresses', 'front', 'clientsaddresses' ) );
}
if ( \IPS\Request::i()->isAjax() )
{
$form->class = 'ipsForm_vertical ipsForm_noLabels';
\IPS\Output::i()->sendOutput( $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'forms', 'core' ) ), 'popupTemplate' ) ) );
\IPS\Output::i()->sendOutput( $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) ) );
}
else
{
@@ -158,7 +176,7 @@ class _addresses extends \IPS\Dispatcher\Controller
if ( $address->member->member_id == \IPS\Member::loggedIn()->member_id )
{
$field = \IPS\Request::i()->primary === 'billing' ? 'primary_billing' : 'primary_shipping';
\IPS\Db::i()->update( 'nexus_customer_addresses', array( $field => 0 ), array( 'member=?', \IPS\Member::loggedIn()->member_id ) );
\IPS\Db::i()->update( 'nexus_customer_addresses', array( $field => 0 ), array( '`member`=?', \IPS\Member::loggedIn()->member_id ) );
$address->$field = TRUE;
$address->save();
@@ -166,6 +184,8 @@ class _addresses extends \IPS\Dispatcher\Controller
}
}
catch ( \OutOfRangeException $e ) {}
\IPS\Request::i()->setCookie( 'location', NULL );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=addresses', 'front', 'clientsaddresses' ) );
}
@@ -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;
@@ -87,6 +87,11 @@ class _alternatives extends \IPS\Dispatcher\Controller
{
$form->add( new \IPS\Helpers\Form\Email( 'altcontact_email', NULL, TRUE, array(), function( $val )
{
if( \IPS\Member::loggedIn()->email == $val )
{
throw new \DomainException('altcontact_email_self');
}
$member = \IPS\Member::load( $val, 'email' );
if ( !$member->member_id )
{
@@ -128,7 +133,7 @@ class _alternatives extends \IPS\Dispatcher\Controller
if( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->sendOutput( $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'forms', 'core' ) ), 'popupTemplate' ) ) );
\IPS\Output::i()->sendOutput( $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) ) );
}
else
{
@@ -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;
@@ -60,7 +60,7 @@ class _billingagreements extends \IPS\Dispatcher\Controller
$where = array( 'ba_member=?', \IPS\Member::loggedIn()->member_id );
$parentContacts = \IPS\nexus\Customer::loggedIn()->parentContacts( array( 'billing=1' ) );
if ( count( $parentContacts ) )
if ( \count( $parentContacts ) )
{
$or = array();
foreach ( array_keys( iterator_to_array( $parentContacts ) ) as $id )
@@ -131,7 +131,7 @@ class _billingagreements extends \IPS\Dispatcher\Controller
}
/* Transactions */
$currentPage = isset( \IPS\Request::i()->page ) ? intval( \IPS\Request::i()->page ) : 1;
$currentPage = isset( \IPS\Request::i()->page ) ? \intval( \IPS\Request::i()->page ) : 1;
$perPage = 25;
$invoices = new \IPS\Patterns\ActiveRecordIterator(
\IPS\Db::i()->select(
@@ -139,14 +139,12 @@ class _billingagreements extends \IPS\Dispatcher\Controller
'nexus_invoices',
array( 'i_id IN(?)', \IPS\Db::i()->select( 't_invoice', 'nexus_transactions', array( 't_billing_agreement=?', $billingAgreement->id ) ) ),
'i_date DESC',
array( ( $currentPage - 1 ) * $perPage, $perPage ),
NULL,
NULL,
\IPS\Db::SELECT_SQL_CALC_FOUND_ROWS
array( ( $currentPage - 1 ) * $perPage, $perPage )
),
'IPS\nexus\Invoice'
);
$pagination = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination( $billingAgreement->url(), ceil( $invoices->count( TRUE ) / $perPage ), $currentPage, $perPage );
$invoicesCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_invoices', array( 'i_id IN(?)', \IPS\Db::i()->select( 't_invoice', 'nexus_transactions', array( 't_billing_agreement=?', $billingAgreement->id ) ) ) )->first();
$pagination = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination( $billingAgreement->url(), ceil( $invoicesCount / $perPage ), $currentPage, $perPage );
\IPS\Output::i()->breadcrumb[] = array( $billingAgreement->url(), $billingAgreement->gw_id );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->billingAgreement( $billingAgreement, $purchases, $invoices, $pagination );
@@ -163,7 +161,7 @@ class _billingagreements extends \IPS\Dispatcher\Controller
/* Check act */
$act = \IPS\Request::i()->act;
if ( !in_array( $act, array( 'suspend', 'reactivate', 'cancel' ) ) )
if ( !\in_array( $act, array( 'suspend', 'reactivate', 'cancel' ) ) )
{
\IPS\Output::i()->error( 'node_error', '3X321/3', 403, '' );
}
@@ -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;
@@ -63,10 +63,10 @@ class _cards extends \IPS\Dispatcher\Controller
{
$cardData = $card->card;
$cards[ $card->id ] = array(
'id' => $card->id,
'card_type' => $cardData->type,
'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
'id' => $card->id,
'card_type' => $cardData->type,
'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 ) { }
@@ -82,8 +82,9 @@ class _cards extends \IPS\Dispatcher\Controller
*/
public function add()
{
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'checkout.css', 'nexus' ) );
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'global_gateways.js', 'nexus', 'global' ) );
$form = \IPS\nexus\Customer\CreditCard::create( \IPS\nexus\Customer::loggedIn() );
$form = \IPS\nexus\Customer\CreditCard::create( \IPS\nexus\Customer::loggedIn(), FALSE );
if ( $form instanceof \IPS\nexus\Customer\CreditCard )
{
\IPS\nexus\Customer::loggedIn()->log( 'card', array( 'type' => 'add', 'number' => $form->card->lastFour ) );
@@ -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' ) );
}
/**
@@ -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;
@@ -90,6 +90,6 @@ class _donations extends \IPS\Dispatcher\Controller
}
\IPS\Output::i()->title = $goal->_title;
\IPS\Output::i()->output = $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'forms', 'core' ) ), 'popupTemplate' ) );
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
}
}
@@ -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;
@@ -134,6 +134,10 @@ class _info extends \IPS\Dispatcher\Controller
foreach ( \IPS\nexus\Customer\CustomField::roots() as $field )
{
$column = $field->column;
if ( $field->type === 'Editor' )
{
$field::$editorOptions = array_merge( $field::$editorOptions, array( 'attachIds' => array( \IPS\nexus\Customer::loggedIn()->member_id ) ) );
}
$formElements[ $column ] = $field->buildHelper( $protected ? NULL : \IPS\nexus\Customer::loggedIn()->$column );
}
@@ -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;
@@ -49,29 +49,18 @@ class _invoices extends \IPS\Dispatcher\Controller
\IPS\Output::i()->error( 'node_error', '2X215/1', 404, '' );
}
}
else if ( isset( \IPS\Request::i()->do ) and \IPS\Request::i()->do == 'printout' and isset( $_SESSION['nexusMember'] ) )
{
$this->invoice = \IPS\nexus\Invoice::load( \IPS\Request::i()->id );
$guest = $this->invoice->guest_data;
if ( $guest['member']['email'] != $_SESSION['nexusMember']['email'] )
{
\IPS\Output::i()->error( 'node_error', '2X215/5', 404, '' );
}
}
else if ( isset( \IPS\Request::i()->do ) and \IPS\Request::i()->do == 'printout' and isset( \IPS\Request::i()->key ) )
{
$this->invoice = \IPS\nexus\Invoice::load( \IPS\Request::i()->id );
$guest = $this->invoice->guest_data;
if ( md5( $guest['member']['email'] . ';' . $guest['member']['joined'] ) != \IPS\Request::i()->key )
{
\IPS\Output::i()->error( 'node_error', '2X215/7', 404, '' );
}
}
else
{
\IPS\Output::i()->error( 'no_module_permission_guest', '2X215/6', 404, '' );
/* Prevent the vid key from being exposed in referrers */
\IPS\Output::i()->sendHeader( "Referrer-Policy: origin" );
$key = isset( \IPS\Request::i()->key ) ? \IPS\Request::i()->key : ( isset( \IPS\Request::i()->cookie['guestTransactionKey'] ) ? \IPS\Request::i()->cookie['guestTransactionKey'] : NULL );
$this->invoice = \IPS\nexus\Invoice::load( \IPS\Request::i()->id );
if( $this->invoice->member->member_id or !$key or !isset( $this->invoice->guest_data['guestTransactionKey'] ) or !\IPS\Login::compareHashes( $key, $this->invoice->guest_data['guestTransactionKey'] ) )
{
\IPS\Output::i()->error( 'no_module_permission_guest', '2X215/6', 404, '' );
}
}
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=invoices', 'front', 'clientsinvoices' ), \IPS\Member::loggedIn()->language()->addToStack('client_invoices') );
@@ -112,7 +101,7 @@ class _invoices extends \IPS\Dispatcher\Controller
{
$where = array( 'i_member=?', \IPS\Member::loggedIn()->member_id );
$parentContacts = \IPS\nexus\Customer::loggedIn()->parentContacts( array( 'billing=1' ) );
if ( count( $parentContacts ) )
if ( \count( $parentContacts ) )
{
$or = array();
foreach ( array_keys( iterator_to_array( $parentContacts ) ) as $id )
@@ -170,7 +159,7 @@ class _invoices extends \IPS\Dispatcher\Controller
$this->invoice->save();
\IPS\Output::i()->redirect( $this->invoice->url() );
}
\IPS\Output::i()->output = $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'forms', 'core' ) ), 'popupTemplate' ) );;
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );;
}
/**
@@ -190,7 +179,7 @@ class _invoices extends \IPS\Dispatcher\Controller
$this->invoice->save();
\IPS\Output::i()->redirect( $this->invoice->url() );
}
\IPS\Output::i()->output = $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'forms', 'core' ) ), 'popupTemplate' ) );;
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );;
}
/**
@@ -200,21 +189,7 @@ class _invoices extends \IPS\Dispatcher\Controller
*/
public function printout()
{
$address = NULL;
if ( $this->invoice->billaddress )
{
$address = $this->invoice->billaddress;
}
else
{
try
{
$address = \IPS\nexus\Customer\Address::constructFromData( \IPS\Db::i()->select( '*', 'nexus_customer_addresses', array( "member=? AND primary_billing=?", $this->invoice->member->member_id, 1 ) )->first() )->address;
}
catch( \UnderflowException $e ) {}
}
$output = \IPS\Theme::i()->getTemplate( 'invoices', 'nexus', 'global' )->printInvoice( $this->invoice, $this->invoice->summary(), $address );
$output = \IPS\Theme::i()->getTemplate( 'invoices', 'nexus', 'global' )->printInvoice( $this->invoice, $this->invoice->summary(), $this->invoice->billaddress ?: $this->invoice->member->primaryBillingAddress() );
\IPS\Output::i()->title = 'I' . $this->invoice->id;
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'global', 'core' )->blankTemplate( $output ) );
}
@@ -229,12 +204,12 @@ class _invoices extends \IPS\Dispatcher\Controller
/* CSRF check */
\IPS\Session::i()->csrfCheck();
/* Can only cancel the invoice if it's pending */
if ( $this->invoice->status !== \IPS\nexus\Invoice::STATUS_PENDING )
/* Can only cancel the invoice if it's pending and there are no processing transactions */
if ( $this->invoice->status !== \IPS\nexus\Invoice::STATUS_PENDING or \count( $this->invoice->transactions( [ \IPS\nexus\Transaction::STATUS_HELD, \IPS\nexus\Transaction::STATUS_REVIEW, \IPS\nexus\Transaction::STATUS_GATEWAY_PENDING, \IPS\nexus\Transaction::STATUS_DISPUTED ] ) ) )
{
\IPS\Output::i()->error( 'order_already_paid', '2X215/4', 403, '' );
}
/* If they have already made a partial payment, refund it to their account credit */
foreach ( $this->invoice->transactions( array( \IPS\nexus\Transaction::STATUS_PAID, \IPS\nexus\Transaction::STATUS_PART_REFUNDED ) ) as $transaction )
{
@@ -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;
@@ -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;
@@ -80,8 +80,9 @@ class _purchases extends \IPS\Dispatcher\Controller
protected function manage()
{
$where = array( array( 'ps_member=?', \IPS\Member::loggedIn()->member_id ) );
$parentContacts = \IPS\nexus\Customer::loggedIn()->parentContacts();
if ( count( $parentContacts ) )
if ( \count( $parentContacts ) )
{
$or = array();
foreach ( $parentContacts as $contact )
@@ -90,9 +91,12 @@ class _purchases extends \IPS\Dispatcher\Controller
}
}
$where[] = array( 'ps_show=1' );
/* Get only the purchases from active applications */
$where[] = array( "ps_app IN('" . implode( "','", array_keys( \IPS\Application::enabledApplications() ) ) . "')" );
$purchases = array();
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_purchases', $where ), 'IPS\nexus\Purchase' ) as $purchase )
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_purchases', $where, 'ps_active DESC, ps_expire DESC, ps_start DESC' ), 'IPS\nexus\Purchase' ) as $purchase )
{
$purchases[ $purchase->parent ][ $purchase->id ] = $purchase;
}
@@ -151,7 +155,7 @@ class _purchases extends \IPS\Dispatcher\Controller
}
elseif ( isset( \IPS\Request::i()->cycles ) and \IPS\Login::compareHashes( (string) \IPS\Session::i()->csrfKey, (string) \IPS\Request::i()->csrfKey ) )
{
$_cycles = intval( \IPS\Request::i()->cycles );
$_cycles = \intval( \IPS\Request::i()->cycles );
if ( $_cycles >= 1 and ( $cycles === TRUE or $_cycles <= $cycles ) )
{
$cycles = $_cycles;
@@ -179,14 +183,14 @@ class _purchases extends \IPS\Dispatcher\Controller
}
}
$form = new \IPS\Helpers\Form;
$form = new \IPS\Helpers\Form( 'form', 'continue' );
$form->class = 'ipsForm_vertical';
$form->add( new \IPS\Helpers\Form\Number( 'renew_for', 1, TRUE, array( 'min' => 1, 'max' => $cycles === TRUE ? NULL : $cycles ), NULL, NULL, $suffix ) );
if( $values = $form->values() or $cycles === 1 )
{
if ( $pendingInvoice = $this->purchase->invoice_pending and $pendingInvoice->status === $pendingInvoice::STATUS_PENDING )
{
if ( count( $pendingInvoice->items ) === 1 )
if ( \count( $pendingInvoice->items ) === 1 )
{
foreach ( $pendingInvoice->items as $item )
{
@@ -214,7 +218,7 @@ class _purchases extends \IPS\Dispatcher\Controller
\IPS\Output::i()->redirect( $invoice->checkoutUrl() );
}
\IPS\Output::i()->output = $form;
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
}
/**
@@ -225,7 +229,7 @@ class _purchases extends \IPS\Dispatcher\Controller
protected function cancel()
{
\IPS\Session::i()->csrfCheck();
if ( !$this->purchase->canCancel() )
{
\IPS\Output::i()->error( 'you_cannot_cancel', '2X212/5', 403, '' );
@@ -246,6 +250,10 @@ class _purchases extends \IPS\Dispatcher\Controller
$this->purchase->can_reactivate = TRUE;
$this->purchase->save();
if ( $ref = \IPS\Request::i()->referrer( FALSE, TRUE ) )
{
\IPS\Output::i()->redirect( $ref );
}
\IPS\Output::i()->redirect( $this->purchase->url() );
}
}
@@ -1,60 +0,0 @@
<?php
/**
* @brief Referrals
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Nexus
* @since 15 Aug 2014
*/
namespace IPS\nexus\modules\front\clients;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Referrals
*/
class _referrals extends \IPS\Dispatcher\Controller
{
/**
* Execute
*
* @return void
*/
public function execute()
{
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'clients.css', 'nexus' ) );
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_clients.js', 'nexus', 'front' ) );
\IPS\Output::i()->sidebar['enabled'] = FALSE;
parent::execute();
}
/**
* View List
*
* @return void
*/
protected function manage()
{
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=referrals', 'front', 'clientsreferrals' ), \IPS\Member::loggedIn()->language()->addToStack('client_referrals') );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('client_referrals');
\IPS\Output::i()->sidebar['enabled'] = FALSE;
$url = \IPS\Http\Url::internal( 'app=nexus&module=promotion&controller=referral&id=' . \IPS\Member::loggedIn()->member_id, 'front', 'referral' );
if ( isset( \IPS\Request::i()->target ) )
{
$url = $url->setQueryString( 'direct', base64_encode( \IPS\Request::i()->target ) );
}
$rules = new \IPS\nexus\CommissionRule\Iterator( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_referral_rules' ), 'IPS\nexus\CommissionRule' ), \IPS\Member::loggedIn() );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->referrals( $url, $rules );
}
}
@@ -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;
@@ -34,7 +34,7 @@ class _splash extends \IPS\Dispatcher\Controller
{
$where = array( array( 'ps_member=?', \IPS\Member::loggedIn()->member_id ) );
$parentContacts = \IPS\nexus\Customer::loggedIn()->parentContacts();
if ( count( $parentContacts ) )
if ( \count( $parentContacts ) )
{
$or = array();
foreach ( $parentContacts as $contact )