Version 4.3.0

This commit is contained in:
Neo committed 2025-12-19 05:47:12 -08:00
1 parent 96997ddd8e
commit fe1acf984a
1349 files changed
+116159 -67711

No files matched your search

@@ -40,11 +40,6 @@ class _checkout extends \IPS\Dispatcher\Controller
*/
public function execute()
{
if ( mb_strtolower( $_SERVER['REQUEST_METHOD'] ) == 'get' and \IPS\Settings::i()->nexus_https and \IPS\Request::i()->url()->data['scheme'] !== 'https' )
{
\IPS\Output::i()->redirect( \IPS\Request::i()->url()->setScheme('https') );
}
\IPS\Output::i()->sidebar['enabled'] = FALSE;
\IPS\Output::i()->bodyClasses[] = 'ipsLayout_minimal';
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'checkout.css', 'nexus' ) );
@@ -56,6 +51,7 @@ class _checkout extends \IPS\Dispatcher\Controller
}
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_checkout.js', 'nexus', 'front' ) );
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'global_gateways.js', 'nexus', 'global' ) );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'module__nexus_checkout' );
parent::execute();
@@ -75,11 +71,6 @@ class _checkout extends \IPS\Dispatcher\Controller
if ( !$this->invoice->canView() )
{
if ( !$this->invoice->member->member_id and \IPS\Member::loggedIn()->member_id and isset( \IPS\Request::i()->loginKey ) and \IPS\Request::i()->loginKey === md5( json_encode( $this->invoice->items ) . session_id() . \IPS\SUITE_UNIQUE_KEY ) )
{
$this->_assignInvoiceToMember( \IPS\Member::loggedIn() );
}
throw new \OutOfRangeException;
}
}
@@ -168,7 +159,10 @@ class _checkout extends \IPS\Dispatcher\Controller
/* Do we need to log in? */
$this->needsToLogin = ( !\IPS\Member::loggedIn()->member_id and ( $this->invoice->requiresLogin() or \IPS\Settings::i()->nexus_donate_loggedin ) );
/* Facebook Pixel */
\IPS\core\Facebook\Pixel::i()->InitiateCheckout = true;
/* Do the wizard */
\IPS\Output::i()->sidebar['enabled'] = FALSE;
if ( isset( \IPS\Output::i()->breadcrumb['module'][0] ) )
@@ -198,7 +192,7 @@ class _checkout extends \IPS\Dispatcher\Controller
$form = new \IPS\Helpers\Form( 'customer', $buttonLang, $this->invoice->checkoutUrl()->setQueryString( '_step', 'checkout_customer' ) );
/* Account Information */
if ( $this->needsToLogin and \IPS\Settings::i()->allow_reg )
if ( $this->needsToLogin and !in_array( \IPS\Login::registrationType(), array( 'disabled', 'redirect' ) ) )
{
$guestData = $this->invoice->guest_data;
@@ -240,7 +234,7 @@ class _checkout extends \IPS\Dispatcher\Controller
}
/* Billing Information */
if ( $needBillingInfo or ( $this->needsToLogin and \IPS\Settings::i()->allow_reg and !\IPS\Settings::i()->nexus_checkreg_usernames ) )
if ( $needBillingInfo or ( $this->needsToLogin and !in_array( \IPS\Login::registrationType(), array( 'disabled', 'redirect' ) ) and !\IPS\Settings::i()->nexus_checkreg_usernames ) )
{
$form->add( new \IPS\Helpers\Form\Text( 'cm_first_name', $this->invoice->member->cm_first_name, TRUE ) );
$form->add( new \IPS\Helpers\Form\Text( 'cm_last_name', $this->invoice->member->cm_last_name, TRUE ) );
@@ -288,7 +282,7 @@ class _checkout extends \IPS\Dispatcher\Controller
}
/* Additional Information */
if ( $this->needsToLogin and \IPS\Settings::i()->allow_reg )
if ( $this->needsToLogin and !in_array( \IPS\Login::registrationType(), array( 'disabled', 'redirect' ) ) )
{
$form->addHeader('additional_information');
@@ -423,7 +417,7 @@ class _checkout extends \IPS\Dispatcher\Controller
}
/* Misc */
$form->add( new \IPS\Helpers\Form\Checkbox( 'reg_admin_mails', $guestData ? $guestData['member']['allow_admin_mails'] : TRUE, FALSE ) );
$form->add( new \IPS\Helpers\Form\Checkbox( 'reg_admin_mails', $guestData ? $guestData['member']['allow_admin_mails'] : \IPS\Settings::i()->updates_consent_default == 'enabled' ? TRUE : FALSE, FALSE ) );
\IPS\Member::loggedIn()->language()->words[ "reg_agreed_terms" ] = sprintf( \IPS\Member::loggedIn()->language()->get("reg_agreed_terms"), \IPS\Http\Url::internal( 'app=core&module=system&controller=terms', 'front', 'terms', array(), \IPS\Http\Url::PROTOCOL_RELATIVE ) );
/* Build the appropriate links for registration terms & privacy policy */
@@ -452,7 +446,7 @@ class _checkout extends \IPS\Dispatcher\Controller
if ( $this->needsToLogin )
{
/* It shouldn't be possible to get here */
if ( !\IPS\Settings::i()->allow_reg )
if ( in_array( \IPS\Login::registrationType(), array( 'disabled', 'redirect' ) ) )
{
\IPS\Output::i()->error( 'reg_disabled', '3X196/A', 403, '' );
}
@@ -477,7 +471,7 @@ class _checkout extends \IPS\Dispatcher\Controller
/* Security questions */
$securityQuestionAnswers = array();
if ( \IPS\Settings::i()->security_questions_enabled and in_array( \IPS\Settings::i()->security_questions_prompt, array( 'register', 'optional' ) ) )
if ( \IPS\Settings::i()->security_questions_enabled and ( \IPS\Settings::i()->security_questions_prompt === 'register' or ( \IPS\Settings::i()->security_questions_prompt === 'optional' and !$values['security_questions_optout_title'] ) ) )
{
foreach ( $values as $k => $v )
{
@@ -517,8 +511,7 @@ class _checkout extends \IPS\Dispatcher\Controller
$member->name = "{$values['cm_first_name']} {$values['cm_last_name']}";
}
$member->email = $values['email_address'];
$member->members_pass_salt = $member->generateSalt();
$member->members_pass_hash = $member->encryptedPassword( $values['password'] );
$member->setLocalPassword( $values['password'] );
$member->allow_admin_mails = $values['reg_admin_mails'];
$member->member_group_id = \IPS\Settings::i()->member_group;
@@ -554,16 +547,22 @@ class _checkout extends \IPS\Dispatcher\Controller
}
/* Run it through the spam service */
$spamCode = NULL;
$spamAction = NULL;
if( \IPS\Settings::i()->spam_service_enabled )
{
if( $member->spamService() == 4 )
$spamAction = $member->spamService( 'register', NULL, $spamCode );
if( $spamAction == 4 )
{
\IPS\Output::i()->error( 'spam_denied_account', '2S129/1', 403, '' );
}
}
/* Save a copy of the member in SESSIONS so the user can print off an invoice */
$_SESSION['nexusMember'] = $member->changed;
/* Save on invoice */
$this->invoice->guest_data = array( 'member' => $member->changed, 'profileFields' => $profileFields, 'securityAnswers' => $securityQuestionAnswers );
$this->invoice->guest_data = array( 'member' => $member->changed, 'profileFields' => $profileFields, 'securityAnswers' => $securityQuestionAnswers, 'spamData' => array( 'code' => $spamCode, 'action' => $spamAction ) );
}
}
/* Otherwise just update the name and details */
@@ -655,16 +654,72 @@ class _checkout extends \IPS\Dispatcher\Controller
/* If we're not logged in, and we need an account for this purchase, show the login form */
$loginForms = NULL;
$loginError = NULL;
$mfaOutput = NULL;
if ( $this->needsToLogin )
{
$login = new \IPS\Login( $this->invoice->checkoutUrl()->setQueryString( 'loginKey', md5( json_encode( $this->invoice->items ) . session_id() . \IPS\SUITE_UNIQUE_KEY ) ) );
$loginForms = $login->forms( FALSE, TRUE ); // This has to be before authenticate() as the result gets cached and we need to specify the destination is the same page
/* Two-Factor Authentication */
if ( isset( \IPS\Request::i()->mfa ) and isset( $_SESSION['processing2FACheckout'] ) and $_SESSION['processing2FACheckout']['invoice'] === $this->invoice->id )
{
$member = \IPS\Member::load( $_SESSION['processing2FACheckout']['memberId'] );
if ( !$member->member_id )
{
unset( $_SESSION['processing2FACheckout'] );
\IPS\Output::i()->redirect( $this->invoice->checkoutUrl() );
}
$device = \IPS\Member\Device::loadOrCreate( $member );
$mfaOutput = \IPS\MFA\MFAHandler::accessToArea( 'core', $device->known ? 'AuthenticateFrontKnown' : 'AuthenticateFront', $this->invoice->checkoutUrl()->setQueryString( 'mfa', 1 ), $member );
if ( !$mfaOutput )
{
/* Set the invoice owner */
$this->invoice->member = $member;
$this->invoice->save();
/* Process the login */
( new \IPS\Login\Success( $member, \IPS\Login\Handler::load( $_SESSION['processing2FACheckout']['handler'] ), $_SESSION['processing2FACheckout']['remember'], $_SESSION['processing2FACheckout']['anonymous'] ) )->process();
/* Redirect */
\IPS\Output::i()->redirect( $this->invoice->checkoutUrl() );
}
}
/* Login */
$login = new \IPS\Login( $this->invoice->checkoutUrl() );
try
{
$member = $login->authenticate();
if ( $member !== NULL )
if ( $success = $login->authenticate() )
{
$this->_assignInvoiceToMember( $member, $login->flags['remember_me'], $login->flags['signin_anonymous'] );
/* Verify it's okay for this member to be buying those items */
try
{
foreach ( $this->invoice->items as $item )
{
$item->memberCanPurchase( $success->member );
}
}
catch ( \DomainException $e )
{
\IPS\Output::i()->error( $e->getMessage(), '1X196/B', 403, '' );
}
/* Process the login */
if ( $success->mfa() )
{
$_SESSION['processing2FACheckout'] = array( 'memberId' => $success->member->member_id, 'invoice' => $this->invoice->id, 'anonymous' => $success->anonymous, 'remember' => $success->rememberMe, 'handler' => $success->handler->id );
\IPS\Output::i()->redirect( $this->invoice->checkoutUrl()->setQueryString( 'mfa', 1 ) );
}
else
{
/* Set the invoice owner */
$this->invoice->member = $success->member;
$this->invoice->save();
/* Process the login */
$success->process();
/* Redirect */
\IPS\Output::i()->redirect( $this->invoice->checkoutUrl() );
}
}
}
catch ( \IPS\Login\Exception $e )
@@ -672,57 +727,12 @@ class _checkout extends \IPS\Dispatcher\Controller
$loginError = $e->getMessage();
}
}
/* Display */
return \IPS\Theme::i()->getTemplate('checkout')->customerInformation( $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'checkout', 'nexus' ) ), 'customerInformationForm' ) ), $loginForms, $loginError, $this->invoice );
}
/**
* Assign invoice to user
*
* @param \IPS\Member $member The member
* @param bool $rememberMe Set "Remember me" flag?
* @param bool $anonymous Login is anonymous?
* @return void
*/
protected function _assignInvoiceToMember( \IPS\Member $member, $rememberMe=TRUE, $anonymous=FALSE )
{
/* Verify it's okay for this member to be buying those items */
try
{
foreach ( $this->invoice->items as $item )
{
$item->memberCanPurchase( $member );
}
}
catch ( \DomainException $e )
{
\IPS\Output::i()->error( $e->getMessage(), '1X196/B', 403, '' );
}
/* Log in */
\IPS\Session::i()->setMember( $member );
if ( $anonymous and !\IPS\Settings::i()->disable_anonymous )
{
\IPS\Session::i()->setAnon();
}
/* Log device */
$device = \IPS\Member\Device::loadOrCreate( $member, FALSE );
$device->anonymous = $anonymous and !\IPS\Settings::i()->disable_anonymous;
$device->updateAfterAuthentication( $rememberMe );
/* Member Sync */
$member->memberSync( 'onLogin', array( $this->invoice->checkoutUrl() ) );
/* Set the invoice owner */
$this->invoice->member = $member;
$this->invoice->save();
/* Redirect */
\IPS\Output::i()->redirect( $this->invoice->checkoutUrl() );
}
/**
* Step: Select Shipping
*
@@ -1145,7 +1155,7 @@ class _checkout extends \IPS\Dispatcher\Controller
if ( $item->groupWithParent and is_int( $item->parent ) and isset( $item->renewalTerm ) and $item->renewalTerm )
{
$parent = $this->invoice->items[ $item->parent ];
if ( isset( $parent->renewalTerm ) and $parent->renewalTerm )
if ( ( isset( $parent->renewalTerm ) and $parent->renewalTerm ) or isset( $overriddenRenewalTerms[ $item->parent ] ) )
{
if ( isset( $overriddenRenewalTerms[ $item->parent ] ) )
{
@@ -1255,6 +1265,7 @@ class _checkout extends \IPS\Dispatcher\Controller
/* Build form */
$elements = array();
$paymentMethodsToggles = array();
$showSubmitButton = FALSE;
foreach ( $paymentMethods as $gateway )
{
foreach ( $gateway->paymentScreen( $this->invoice, $amountToPay, NULL, $recurrings ) as $element )
@@ -1266,16 +1277,23 @@ class _checkout extends \IPS\Dispatcher\Controller
$elements[] = $element;
$paymentMethodsToggles[ $gateway->id ][] = $element->htmlId;
}
if ( $gateway->showSubmitButton() )
{
$showSubmitButton = TRUE;
$paymentMethodsToggles[ $gateway->id ][] = 'paymentMethodSubmit';
}
}
$paymentMethodOptions = array();
foreach ( $paymentMethods as $k => $v )
{
$paymentMethodOptions[ $k ] = $v->_title;
}
if ( $canUseAccountCredit and \IPS\nexus\Customer::loggedIn()->cm_credits[ $this->invoice->currency ]->amount->isGreaterThanZero() )
if ( $canUseAccountCredit and isset( \IPS\nexus\Customer::loggedIn()->cm_credits[ $this->invoice->currency ] ) and \IPS\nexus\Customer::loggedIn()->cm_credits[ $this->invoice->currency ]->amount->isGreaterThanZero() )
{
$paymentMethodOptions[0] = \IPS\Member::loggedIn()->language()->addToStack( 'account_credit_with_amount', FALSE, array( 'sprintf' => array( \IPS\nexus\Customer::loggedIn()->cm_credits[ $this->invoice->currency ] ) ) );
$paymentMethodsToggles[0][] = 'paymentMethodSubmit';
}
$form = new \IPS\Helpers\Form( 'select_method', 'checkout_pay', $this->invoice->checkoutUrl()->setQueryString( '_step', 'checkout_pay' ) );
@@ -1294,7 +1312,7 @@ class _checkout extends \IPS\Dispatcher\Controller
}
if ( \IPS\Settings::i()->nexus_tac === 'checkbox' )
{
$form->add( new \IPS\Helpers\Form\Checkbox( 'i_agree_to_tac', FALSE, TRUE, array( 'labelHtmlSprintf' => array( "<a href='" . htmlspecialchars( \IPS\Settings::i()->nexus_tac_link, \IPS\HTMLENTITIES, 'UTF-8', FALSE ) . "' target='_blank'>" . \IPS\Member::loggedIn()->language()->addToStack( 'terms_and_conditions' ) . '</a>' ) ), function( $val )
$form->add( new \IPS\Helpers\Form\Checkbox( 'i_agree_to_tac', FALSE, TRUE, array( 'labelHtmlSprintf' => array( "<a href='" . htmlspecialchars( \IPS\Settings::i()->nexus_tac_link, ENT_DISALLOWED, 'UTF-8', FALSE ) . "' target='_blank'>" . \IPS\Member::loggedIn()->language()->addToStack( 'terms_and_conditions' ) . '</a>' ) ), function( $val )
{
if ( !$val )
{
@@ -1407,7 +1425,7 @@ class _checkout extends \IPS\Dispatcher\Controller
$transaction->auth = $gateway->auth( $transaction, $values, $maxMind, $recurrings );
}
catch ( \LogicException $e )
{
{
$form->error = $e->getMessage();
return $form;
}
@@ -1487,6 +1505,7 @@ class _checkout extends \IPS\Dispatcher\Controller
throw new \DomainException('coupon_code_invalid');
}
}
return '';
}
) ) );
if ( $values = $couponForm->values() )
@@ -1499,7 +1518,7 @@ class _checkout extends \IPS\Dispatcher\Controller
}
/* Display */
return \IPS\Theme::i()->getTemplate('checkout')->confirmAndPay( $this->invoice, $this->invoice->summary(), $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'checkout', 'nexus' ) ), 'paymentForm' ), $this->invoice, $amountToPay ), $amountToPay, $couponForm ? $couponForm->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'checkout', 'nexus' ) ), 'couponForm' ) ) : NULL, $recurrings, $overriddenRenewalTerms );
return \IPS\Theme::i()->getTemplate('checkout')->confirmAndPay( $this->invoice, $this->invoice->summary(), $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'checkout', 'nexus' ) ), 'paymentForm' ), $this->invoice, $amountToPay, $showSubmitButton ), $amountToPay, $couponForm ? $couponForm->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'checkout', 'nexus' ) ), 'couponForm' ) ) : NULL, $recurrings, $overriddenRenewalTerms );
}
/**
@@ -1560,7 +1579,7 @@ class _checkout extends \IPS\Dispatcher\Controller
$output = '';
$checkoutStatus = '';
switch ( $transaction->status )
{
case \IPS\nexus\Transaction::STATUS_PAID:
@@ -1606,12 +1625,23 @@ class _checkout extends \IPS\Dispatcher\Controller
$checkoutStatus = 'pending';
$output = \IPS\Theme::i()->getTemplate('checkout')->transactionGatewayPending( $transaction );
break;
case \IPS\nexus\Transaction::STATUS_PENDING:
if ( isset( \IPS\Request::i()->pending ) )
{
$checkoutStatus = 'pending';
$output = \IPS\Theme::i()->getTemplate('checkout')->transactionGatewayPending( $transaction );
break;
}
default:
\IPS\Output::i()->redirect( $transaction->invoice->checkoutUrl() );
break;
}
/* Facebook Pixel */
\IPS\core\Facebook\Pixel::i()->Purchase = true;
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('checkout')->checkoutWrapper( $output, $checkoutStatus );
}
}
}
@@ -35,17 +35,12 @@ class _addresses extends \IPS\Dispatcher\Controller
\IPS\Output::i()->error( 'no_module_permission_guest', '2X235/1', 403, '' );
}
if ( mb_strtolower( $_SERVER['REQUEST_METHOD'] ) == 'get' and \IPS\Settings::i()->nexus_https and \IPS\Request::i()->url()->data['scheme'] !== 'https' )
{
\IPS\Output::i()->redirect( \IPS\Request::i()->url()->setScheme('https') );
}
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'clients.css', 'nexus' ) );
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=addresses', 'front', 'clientsaddresses', array(), \IPS\Settings::i()->nexus_https ), \IPS\Member::loggedIn()->language()->addToStack('client_addresses') );
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=addresses', 'front', 'clientsaddresses' ), \IPS\Member::loggedIn()->language()->addToStack('client_addresses') );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('client_addresses');
\IPS\Output::i()->sidebar['enabled'] = FALSE;
if ( $output = \IPS\MFA\MFAHandler::accessToArea( 'nexus', 'Addresses', \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=addresses', 'front', 'clientsaddresses', array(), \IPS\Settings::i()->nexus_https ) ) )
if ( $output = \IPS\MFA\MFAHandler::accessToArea( 'nexus', 'Addresses', \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=addresses', 'front', 'clientsaddresses' ) ) )
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->addresses( NULL, NULL, array() ) . $output;
return;
@@ -134,7 +129,7 @@ class _addresses extends \IPS\Dispatcher\Controller
$existing->address = $values['address'];
$existing->save();
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=addresses', 'front', 'clientsaddresses', array(), \IPS\Settings::i()->nexus_https ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=addresses', 'front', 'clientsaddresses' ) );
}
if ( \IPS\Request::i()->isAjax() )
@@ -172,7 +167,7 @@ class _addresses extends \IPS\Dispatcher\Controller
}
catch ( \OutOfRangeException $e ) {}
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=addresses', 'front', 'clientsaddresses', array(), \IPS\Settings::i()->nexus_https ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=addresses', 'front', 'clientsaddresses' ) );
}
/**
@@ -198,6 +193,6 @@ class _addresses extends \IPS\Dispatcher\Controller
}
catch ( \OutOfRangeException $e ) {}
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=addresses', 'front', 'clientsaddresses', array(), \IPS\Settings::i()->nexus_https ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=addresses', 'front', 'clientsaddresses' ) );
}
}
@@ -35,17 +35,12 @@ class _alternatives extends \IPS\Dispatcher\Controller
\IPS\Output::i()->error( 'no_module_permission_guest', '2X237/1', 403, '' );
}
if ( mb_strtolower( $_SERVER['REQUEST_METHOD'] ) == 'get' and \IPS\Settings::i()->nexus_https and \IPS\Request::i()->url()->data['scheme'] !== 'https' )
{
\IPS\Output::i()->redirect( \IPS\Request::i()->url()->setScheme('https') );
}
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'clients.css', 'nexus' ) );
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=alternatives', 'front', 'clientsalternatives', array(), \IPS\Settings::i()->nexus_https ), \IPS\Member::loggedIn()->language()->addToStack('client_alternatives') );
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=alternatives', 'front', 'clientsalternatives' ), \IPS\Member::loggedIn()->language()->addToStack('client_alternatives') );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('client_alternatives');
\IPS\Output::i()->sidebar['enabled'] = FALSE;
if ( $output = \IPS\MFA\MFAHandler::accessToArea( 'nexus', 'Alternatives', \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=alternatives', 'front', 'clientsalternatives', array(), \IPS\Settings::i()->nexus_https ) ) )
if ( $output = \IPS\MFA\MFAHandler::accessToArea( 'nexus', 'Alternatives', \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=alternatives', 'front', 'clientsalternatives' ) ) )
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->alternatives( TRUE ) . $output;
return;
@@ -128,7 +123,7 @@ class _alternatives extends \IPS\Dispatcher\Controller
$altContact->support = $values['altcontact_support'];
$altContact->save();
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=alternatives', 'front', 'clientsalternatives', array(), \IPS\Settings::i()->nexus_https ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=alternatives', 'front', 'clientsalternatives' ) );
}
if( \IPS\Request::i()->isAjax() )
@@ -161,6 +156,6 @@ class _alternatives extends \IPS\Dispatcher\Controller
}
catch ( \UnderflowException $e ) {}
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=alternatives', 'front', 'clientsalternatives', array(), \IPS\Settings::i()->nexus_https ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=alternatives', 'front', 'clientsalternatives' ) );
}
}
@@ -35,17 +35,12 @@ class _billingagreements extends \IPS\Dispatcher\Controller
\IPS\Output::i()->error( 'no_module_permission_guest', '2X321/1', 403, '' );
}
if ( mb_strtolower( $_SERVER['REQUEST_METHOD'] ) == 'get' and \IPS\Settings::i()->nexus_https and \IPS\Request::i()->url()->data['scheme'] !== 'https' )
{
\IPS\Output::i()->redirect( \IPS\Request::i()->url()->setScheme('https') );
}
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'clients.css', 'nexus' ) );
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=billingagreements', 'front', 'clientsbillingagreements', array(), \IPS\Settings::i()->nexus_https ), \IPS\Member::loggedIn()->language()->addToStack('client_billing_agreements') );
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=billingagreements', 'front', 'clientsbillingagreements' ), \IPS\Member::loggedIn()->language()->addToStack('client_billing_agreements') );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('client_billing_agreements');
\IPS\Output::i()->sidebar['enabled'] = FALSE;
if ( $output = \IPS\MFA\MFAHandler::accessToArea( 'nexus', 'BillingAgreements', \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=billingagreements', 'front', 'clientsbillingagreements', array(), \IPS\Settings::i()->nexus_https ) ) )
if ( $output = \IPS\MFA\MFAHandler::accessToArea( 'nexus', 'BillingAgreements', \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=billingagreements', 'front', 'clientsbillingagreements' ) ) )
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->billingAgreements( array() ) . $output;
return;
@@ -35,17 +35,12 @@ class _cards extends \IPS\Dispatcher\Controller
\IPS\Output::i()->error( 'no_module_permission_guest', '2X236/1', 403, '' );
}
if ( mb_strtolower( $_SERVER['REQUEST_METHOD'] ) == 'get' and \IPS\Settings::i()->nexus_https and \IPS\Request::i()->url()->data['scheme'] !== 'https' )
{
\IPS\Output::i()->redirect( \IPS\Request::i()->url()->setScheme('https') );
}
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'clients.css', 'nexus' ) );
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=cards', 'front', 'clientscards', array(), \IPS\Settings::i()->nexus_https ), \IPS\Member::loggedIn()->language()->addToStack('client_cards') );
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=cards', 'front', 'clientscards' ), \IPS\Member::loggedIn()->language()->addToStack('client_cards') );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('client_cards');
\IPS\Output::i()->sidebar['enabled'] = FALSE;
if ( $output = \IPS\MFA\MFAHandler::accessToArea( 'nexus', 'Cards', \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=cards', 'front', 'clientscards', array(), \IPS\Settings::i()->nexus_https ) ) )
if ( $output = \IPS\MFA\MFAHandler::accessToArea( 'nexus', 'Cards', \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=cards', 'front', 'clientscards' ) ) )
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->cards( array() ) . $output;
return;
@@ -91,7 +86,7 @@ class _cards extends \IPS\Dispatcher\Controller
if ( $form instanceof \IPS\nexus\Customer\CreditCard )
{
\IPS\nexus\Customer::loggedIn()->log( 'card', array( 'type' => 'add', 'number' => $form->card->lastFour ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=cards', 'front', 'clientscards', array(), \IPS\Settings::i()->nexus_https ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=cards', 'front', 'clientscards' ) );
}
else
{
@@ -122,6 +117,6 @@ class _cards extends \IPS\Dispatcher\Controller
}
catch ( \Exception $e ) { }
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=cards', 'front', 'clientscards', array(), \IPS\Settings::i()->nexus_https ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=cards', 'front', 'clientscards' ) );
}
}
@@ -34,18 +34,13 @@ class _credit extends \IPS\Dispatcher\Controller
{
\IPS\Output::i()->error( 'no_module_permission_guest', '2X239/1', 403, '' );
}
if ( mb_strtolower( $_SERVER['REQUEST_METHOD'] ) == 'get' and \IPS\Settings::i()->nexus_https and \IPS\Request::i()->url()->data['scheme'] !== 'https' )
{
\IPS\Output::i()->redirect( \IPS\Request::i()->url()->setScheme('https') );
}
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'clients.css', 'nexus' ) );
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=credit', 'front', 'clientscredit', array(), \IPS\Settings::i()->nexus_https ), \IPS\Member::loggedIn()->language()->addToStack('client_credit') );
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=credit', 'front', 'clientscredit' ), \IPS\Member::loggedIn()->language()->addToStack('client_credit') );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('client_credit');
\IPS\Output::i()->sidebar['enabled'] = FALSE;
if ( $output = \IPS\MFA\MFAHandler::accessToArea( 'nexus', 'AccountCredit', \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=credit', 'front', 'clientscredit', array(), \IPS\Settings::i()->nexus_https ) ) )
if ( $output = \IPS\MFA\MFAHandler::accessToArea( 'nexus', 'AccountCredit', \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=credit', 'front', 'clientscredit' ) ) )
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->credit( NULL, array(), NULL, FALSE, FALSE ) . $output;
return;
@@ -78,7 +73,7 @@ class _credit extends \IPS\Dispatcher\Controller
$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 );
$pastWithdrawalsPagination = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination(
\IPS\Http\Url::internal( 'app=nexus&module=clients&controller=credit', 'front', 'clientscredit', array(), \IPS\Settings::i()->nexus_https ),
\IPS\Http\Url::internal( 'app=nexus&module=clients&controller=credit', 'front', 'clientscredit' ),
ceil( $pastWithdrawalsSelect->count( TRUE ) / $perPage ),
$page,
$perPage
@@ -296,13 +291,13 @@ class _credit extends \IPS\Dispatcher\Controller
{
$payout->process();
\IPS\nexus\Customer::loggedIn()->log( 'payout', array( 'type' => 'autoprocess', '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=success', 'front', 'clientscredit', array(), \IPS\Settings::i()->nexus_https ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=credit&withdraw=success', 'front', 'clientscredit' ) );
}
catch ( \Exception $e ) {}
}
\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', array(), \IPS\Settings::i()->nexus_https ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=credit&withdraw=pending', 'front', 'clientscredit' ) );
}
}
else
@@ -367,7 +362,7 @@ class _credit extends \IPS\Dispatcher\Controller
$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 );
}
$topupForm->add( new \IPS\Helpers\Form\Radio( 'topup_account', NULL, TRUE, array( 'options' => $accountOptions, 'parse' => 'none', 'toggles' => $accountOptionToggles ) ) );
$topupForm->add( new \IPS\Helpers\Form\Radio( 'topup_account', NULL, TRUE, array( 'options' => $accountOptions, 'parse' => 'normal', 'toggles' => $accountOptionToggles ) ) );
foreach ( $maximums as $accountId => $data )
{
@@ -474,6 +469,6 @@ class _credit extends \IPS\Dispatcher\Controller
}
catch ( \OutOfRangeException $e ) { }
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=credit', 'front', 'clientscredit', array(), \IPS\Settings::i()->nexus_https ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=credit', 'front', 'clientscredit' ) );
}
}
@@ -22,22 +22,7 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
* Donations
*/
class _donations extends \IPS\Dispatcher\Controller
{
/**
* Execute
*
* @return void
*/
public function execute()
{
if ( mb_strtolower( $_SERVER['REQUEST_METHOD'] ) == 'get' and \IPS\Settings::i()->nexus_https and \IPS\Request::i()->url()->data['scheme'] !== 'https' )
{
\IPS\Output::i()->redirect( \IPS\Request::i()->url()->setScheme('https') );
}
parent::execute();
}
{
/**
* View List
*
@@ -53,11 +38,11 @@ class _donations extends \IPS\Dispatcher\Controller
}
else
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=donations', 'front', 'clientsdonations', array(), \IPS\Settings::i()->nexus_https ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=donations', 'front', 'clientsdonations' ) );
}
}
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=donations', 'front', 'clientsdonations', array(), \IPS\Settings::i()->nexus_https ), \IPS\Member::loggedIn()->language()->addToStack('client_donations') );
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=donations', 'front', 'clientsdonations' ), \IPS\Member::loggedIn()->language()->addToStack('client_donations') );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('client_donations');
\IPS\Output::i()->sidebar['enabled'] = FALSE;
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'donations.css' ) );
@@ -35,16 +35,11 @@ class _info extends \IPS\Dispatcher\Controller
\IPS\Output::i()->error( 'no_module_permission_guest', '2X242/1', 403, '' );
}
if ( mb_strtolower( $_SERVER['REQUEST_METHOD'] ) == 'get' and \IPS\Settings::i()->nexus_https and \IPS\Request::i()->url()->data['scheme'] !== 'https' )
{
\IPS\Output::i()->redirect( \IPS\Request::i()->url()->setScheme('https') );
}
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=info', 'front', 'clientsinfo', array(), \IPS\Settings::i()->nexus_https ), \IPS\Member::loggedIn()->language()->addToStack('client_info') );
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=info', 'front', 'clientsinfo' ), \IPS\Member::loggedIn()->language()->addToStack('client_info') );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('client_info');
\IPS\Output::i()->sidebar['enabled'] = FALSE;
if ( $output = \IPS\MFA\MFAHandler::accessToArea( 'nexus', 'BillingInfo', \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=info', 'front', 'clientsinfo', array(), \IPS\Settings::i()->nexus_https ) ) )
if ( $output = \IPS\MFA\MFAHandler::accessToArea( 'nexus', 'BillingInfo', \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=info', 'front', 'clientsinfo' ) ) )
{
$form = new \IPS\Helpers\Form;
foreach( $this->_buildInfoForm( TRUE ) AS $formElement )
@@ -71,7 +66,7 @@ class _info extends \IPS\Dispatcher\Controller
$form->add( $formElement );
}
if ( $values = $form->values( TRUE ) )
if ( $values = $form->values() )
{
$changes = array();
foreach( array( 'cm_first_name', 'cm_last_name' ) AS $nameField )
@@ -95,7 +90,14 @@ class _info extends \IPS\Dispatcher\Controller
{
$column = $field->column;
$helper = $field->buildHelper();
$valueToSave = $helper::stringValue( $values["nexus_ccfield_{$field->id}"] );
if ( $helper instanceof \IPS\Helpers\Form\Upload )
{
$valueToSave = (string) $values["nexus_ccfield_{$field->id}"];
}
else
{
$valueToSave = $helper::stringValue( $values["nexus_ccfield_{$field->id}"] );
}
if ( \IPS\nexus\Customer::loggedIn()->$column != $valueToSave )
{
$changes['other'][] = array( 'name' => 'nexus_ccfield_' . $field->id, 'value' => $field->displayValue( $valueToSave ), 'old' => $field->displayValue( \IPS\nexus\Customer::loggedIn()->$column ) );
@@ -112,7 +114,7 @@ class _info extends \IPS\Dispatcher\Controller
\IPS\nexus\Customer::loggedIn()->log( 'info', $changes );
}
\IPS\nexus\Customer::loggedIn()->save();
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=info', 'front', 'clientsinfo', array(), \IPS\Settings::i()->nexus_https ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=info', 'front', 'clientsinfo' ) );
}
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->info( $form );
@@ -30,16 +30,6 @@ class _invoices extends \IPS\Dispatcher\Controller
*/
public function execute()
{
if ( !\IPS\Member::loggedIn()->member_id )
{
\IPS\Output::i()->error( 'no_module_permission_guest', '2X215/3', 403, '' );
}
if ( mb_strtolower( $_SERVER['REQUEST_METHOD'] ) == 'get' and \IPS\Settings::i()->nexus_https and \IPS\Request::i()->url()->data['scheme'] !== 'https' )
{
\IPS\Output::i()->redirect( \IPS\Request::i()->url()->setScheme('https') );
}
/* Load Invoice */
if ( isset( \IPS\Request::i()->id ) )
{
@@ -48,21 +38,43 @@ class _invoices extends \IPS\Dispatcher\Controller
\IPS\Request::i()->do = 'printout';
}
try
if ( \IPS\Member::loggedIn()->member_id )
{
$this->invoice = \IPS\nexus\Invoice::loadAndCheckPerms( \IPS\Request::i()->id );
try
{
$this->invoice = \IPS\nexus\Invoice::loadAndCheckPerms( \IPS\Request::i()->id );
}
catch ( \OutOfRangeException $e )
{
\IPS\Output::i()->error( 'node_error', '2X215/1', 404, '' );
}
}
catch ( \OutOfRangeException $e )
else if ( isset( \IPS\Request::i()->do ) and \IPS\Request::i()->do == 'printout' and isset( $_SESSION['nexusMember'] ) )
{
\IPS\Output::i()->error( 'node_error', '2X215/1', 404, '' );
$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, '' );
}
}
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=invoices', 'front', 'clientsinvoices', array(), \IPS\Settings::i()->nexus_https ), \IPS\Member::loggedIn()->language()->addToStack('client_invoices') );
else
{
\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') );
\IPS\Output::i()->breadcrumb[] = array( $this->invoice->url(), $this->invoice->title );
\IPS\Output::i()->title = $this->invoice->title;
}
else
{
if ( !\IPS\Member::loggedIn()->member_id )
{
\IPS\Output::i()->error( 'no_module_permission_guest', '2X215/3', 403, '' );
}
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('client_invoices');
if ( isset( \IPS\Request::i()->do ) )
{
@@ -35,13 +35,8 @@ class _purchases extends \IPS\Dispatcher\Controller
\IPS\Output::i()->error( 'no_module_permission_guest', '2X212/6', 403, '' );
}
if ( mb_strtolower( $_SERVER['REQUEST_METHOD'] ) == 'get' and \IPS\Settings::i()->nexus_https and \IPS\Request::i()->url()->data['scheme'] !== 'https' )
{
\IPS\Output::i()->redirect( \IPS\Request::i()->url()->setScheme('https') );
}
/* Purchases breadcrumb */
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=purchases', 'front', 'clientspurchases', array(), \IPS\Settings::i()->nexus_https ), \IPS\Member::loggedIn()->language()->addToStack('client_purchases') );
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=purchases', 'front', 'clientspurchases' ), \IPS\Member::loggedIn()->language()->addToStack('client_purchases') );
/* Load Purchase */
if ( isset( \IPS\Request::i()->id ) )
@@ -154,6 +149,14 @@ class _purchases extends \IPS\Dispatcher\Controller
{
\IPS\Session::i()->csrfCheck();
}
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 );
if ( $_cycles >= 1 and ( $cycles === TRUE or $_cycles <= $cycles ) )
{
$cycles = $_cycles;
}
}
$term = $this->purchase->renewals->getTerm();
if ( $term['term'] > 1 )
@@ -29,12 +29,7 @@ class _referrals extends \IPS\Dispatcher\Controller
* @return void
*/
public function execute()
{
if ( mb_strtolower( $_SERVER['REQUEST_METHOD'] ) == 'get' and \IPS\Settings::i()->nexus_https and \IPS\Request::i()->url()->data['scheme'] !== 'https' )
{
\IPS\Output::i()->redirect( \IPS\Request::i()->url()->setScheme('https') );
}
{
\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;
@@ -48,7 +43,7 @@ class _referrals extends \IPS\Dispatcher\Controller
*/
protected function manage()
{
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=referrals', 'front', 'clientsreferrals', array(), \IPS\Settings::i()->nexus_https ), \IPS\Member::loggedIn()->language()->addToStack('client_referrals') );
\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;
@@ -32,7 +32,15 @@ class _referral extends \IPS\Dispatcher\Controller
{
\IPS\Request::i()->setCookie( 'referred_by', intval( \IPS\Request::i()->id ), \IPS\DateTime::create()->add( new \DateInterval( 'P1Y' ) ) );
$target = \IPS\Request::i()->direct ? \IPS\Http\Url::createFromString( base64_decode( \IPS\Request::i()->direct ) ) : \IPS\Http\Url::baseUrl();
try
{
$target = \IPS\Request::i()->direct ? \IPS\Http\Url::createFromString( base64_decode( \IPS\Request::i()->direct ) ) : \IPS\Http\Url::baseUrl();
}
catch( \IPS\Http\Url\Exception $e )
{
$target = NULL;
}
if ( $target instanceof \IPS\Http\Url\Internal )
{
\IPS\Output::i()->redirect( $target );
@@ -199,7 +199,7 @@ class _cart extends \IPS\Dispatcher\Controller
$canRegister = ( !\IPS\Settings::i()->nexus_reg_force or \IPS\Member::loggedIn()->member_id );
$tempInvoiceKey = md5( uniqid() );
$tempInvoiceKey = md5( mt_rand() );
$invoice = new \IPS\nexus\Invoice;
$invoice->member = \IPS\nexus\Customer::loggedIn();
@@ -71,7 +71,7 @@ class _gifts extends \IPS\Dispatcher\Controller
$form = new \IPS\Helpers\Form( 'form', 'buy_gift_voucher' );
$form->class = 'ipsForm_vertical';
$form->add( new \IPS\Helpers\Form\Color( 'gift_voucher_color', '3b3b3b', FALSE ) );
$form->add( new \IPS\Helpers\Form\Radio( 'gift_voucher_amount', NULL, TRUE, array( 'options' => $options, 'parse' => 'none', 'userSuppliedInput' => 'x' ) ) );
$form->add( new \IPS\Helpers\Form\Radio( 'gift_voucher_amount', NULL, TRUE, array( 'options' => $options, 'parse' => 'normal', 'userSuppliedInput' => 'x' ) ) );
$form->add( new \IPS\Helpers\Form\Radio( 'gift_voucher_method', NULL, TRUE, array( 'options' => array( 'email' => 'email', 'print' => 'gift_voucher_print' ), 'toggles' => array( 'email' => array( 'gift_voucher_email' ) ) ) ) );
$form->add( new \IPS\Helpers\Form\Email( 'gift_voucher_email', NULL, NULL, array(), function( $val )
{
@@ -200,48 +200,65 @@ class _product extends \IPS\Content\Controller
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('store')->package( $package, $item, $this->_getForm( $package, $inCart, TRUE ), array_sum( $inCart ), $shippingMethods, $itemDataForShipping, $locationType, $renewalTerm );
}
$price = $package->price();
try
{
$price = $package->price();
}
catch( \OutOfBoundsException $e )
{
$price = NULL;
}
\IPS\Output::i()->jsonLd['package'] = array(
'@context' => "http://schema.org",
'@type' => "Product",
'name' => $package->_title,
'description' => strip_tags( $item->truncated() ),
'category' => $item->container()->_title,
'url' => (string) $package->url(),
'sku' => $package->id,
'offers' => array(
'@type' => 'Offer',
'availability' => ( $package->stock > 0 OR $package->stock == -1 ) ? 'http://schema.org/InStock' : 'http://schema.org/OutOfStock',
'price' => $price->amountAsString(),
'priceCurrency' => $price->currency,
'seller' => array(
'@type' => 'Organization',
'name' => \IPS\Settings::i()->board_name
),
),
/* Facebook Pixel */
\IPS\core\Facebook\Pixel::i()->ViewContent = array(
'content_ids' => array( $package->id ),
'content_type' => 'product'
);
if( $package->image )
/* A product MUST have an offer, so if there's no price (i.e. due to currency configuration) don't even output */
if( $price !== NULL )
{
\IPS\Output::i()->jsonLd['package']['image'] = (string) $package->image;
}
if( $package->reviewable )
{
\IPS\Output::i()->jsonLd['package']['aggregateRating'] = array(
'@type' => 'AggregateRating',
'ratingValue' => $item->averageReviewRating(),
'ratingCount' => $item->reviews
\IPS\Output::i()->jsonLd['package'] = array(
'@context' => "http://schema.org",
'@type' => "Product",
'name' => $package->_title,
'description' => strip_tags( $item->truncated() ),
'category' => $item->container()->_title,
'url' => (string) $package->url(),
'sku' => $package->id,
'offers' => array(
'@type' => 'Offer',
'availability' => ( $package->stock > 0 OR $package->stock == -1 ) ? 'http://schema.org/InStock' : 'http://schema.org/OutOfStock',
'price' => $price->amountAsString(),
'priceCurrency' => $price->currency,
'seller' => array(
'@type' => 'Organization',
'name' => \IPS\Settings::i()->board_name
),
),
);
}
if( isset( $length ) )
{
\IPS\Output::i()->jsonLd['package']['depth'] = array( '@type' => 'Distance', 'name' => $length->string() );
\IPS\Output::i()->jsonLd['package']['width'] = array( '@type' => 'Distance', 'name' => $width->string() );
\IPS\Output::i()->jsonLd['package']['height'] = array( '@type' => 'Distance', 'name' => $height->string() );
\IPS\Output::i()->jsonLd['package']['weight'] = array( '@type' => 'QuantitativeValue', 'name' => $weight->string() );
if( $package->image )
{
\IPS\Output::i()->jsonLd['package']['image'] = (string) $package->image;
}
if( $package->reviewable )
{
\IPS\Output::i()->jsonLd['package']['aggregateRating'] = array(
'@type' => 'AggregateRating',
'ratingValue' => $item->averageReviewRating(),
'ratingCount' => $item->reviews
);
}
if( isset( $length ) )
{
\IPS\Output::i()->jsonLd['package']['depth'] = array( '@type' => 'Distance', 'name' => $length->string() );
\IPS\Output::i()->jsonLd['package']['width'] = array( '@type' => 'Distance', 'name' => $width->string() );
\IPS\Output::i()->jsonLd['package']['height'] = array( '@type' => 'Distance', 'name' => $height->string() );
\IPS\Output::i()->jsonLd['package']['weight'] = array( '@type' => 'QuantitativeValue', 'name' => $weight->string() );
}
}
}
}
@@ -158,40 +158,52 @@ class _store extends \IPS\Dispatcher\Controller
foreach( $packages as $package )
{
$item = \IPS\nexus\Package\Item::load( $package->id );
$price = $package->price();
\IPS\Output::i()->jsonLd['package' . $package->id ] = array(
'@context' => "http://schema.org",
'@type' => "Product",
'name' => $package->_title,
'description' => strip_tags( $item->truncated() ),
'category' => $category->_title,
'url' => (string) $package->url(),
'sku' => $package->id,
'offers' => array(
'@type' => 'Offer',
'availability' => ( $package->stock > 0 OR $package->stock == -1 ) ? 'http://schema.org/InStock' : 'http://schema.org/OutOfStock',
'price' => $price->amountAsString(),
'priceCurrency' => $price->currency,
'seller' => array(
'@type' => 'Organization',
'name' => \IPS\Settings::i()->board_name
),
),
);
if( $package->image )
try
{
\IPS\Output::i()->jsonLd['package' . $package->id ]['image'] = (string) $package->image;
$price = $package->price();
}
catch( \OutOfBoundsException $e )
{
$price = NULL;
}
if( $package->reviewable )
/* A product MUST have an offer, so if there's no price (i.e. due to currency configuration) don't even output */
if( $price !== NULL )
{
\IPS\Output::i()->jsonLd['package' . $package->id ]['aggregateRating'] = array(
'@type' => 'AggregateRating',
'ratingValue' => $item->averageReviewRating(),
'ratingCount' => $item->reviews
\IPS\Output::i()->jsonLd['package' . $package->id ] = array(
'@context' => "http://schema.org",
'@type' => "Product",
'name' => $package->_title,
'description' => strip_tags( $item->truncated() ),
'category' => $category->_title,
'url' => (string) $package->url(),
'sku' => $package->id,
'offers' => array(
'@type' => 'Offer',
'availability' => ( $package->stock > 0 OR $package->stock == -1 ) ? 'http://schema.org/InStock' : 'http://schema.org/OutOfStock',
'price' => $price->amountAsString(),
'priceCurrency' => $price->currency,
'seller' => array(
'@type' => 'Organization',
'name' => \IPS\Settings::i()->board_name
),
),
);
if( $package->image )
{
\IPS\Output::i()->jsonLd['package' . $package->id ]['image'] = (string) $package->image;
}
if( $package->reviewable )
{
\IPS\Output::i()->jsonLd['package' . $package->id ]['aggregateRating'] = array(
'@type' => 'AggregateRating',
'ratingValue' => $item->averageReviewRating(),
'ratingCount' => $item->reviews
);
}
}
}
@@ -0,0 +1,227 @@
<?php
/**
* @brief subscriptions
* @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 Commerce
* @since 09 Feb 2018
*/
namespace IPS\nexus\modules\front\subscriptions;
/* 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;
}
/**
* subscriptions
*/
class _subscriptions extends \IPS\Dispatcher\Controller
{
/**
* Show the subscription packages
*
* @return void
*/
protected function manage()
{
if ( ! \IPS\Settings::i()->nexus_subs_enabled )
{
\IPS\Output::i()->error( 'nexus_no_subs', '2X379/1', 404, '' );
}
/* Create the table */
$table = new \IPS\nexus\Subscription\Table( \IPS\Http\Url::internal( 'app=nexus&module=subscriptions&controller=subscriptions', 'front', 'nexus_subscriptions' ) );
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_subscriptions.js', 'nexus', 'front' ) );
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'subscriptions.css', 'nexus' ) );
\IPS\Output::i()->breadcrumb['module'] = array( \IPS\Http\Url::internal( 'app=nexus&module=subscriptions&controller=subscriptions', 'front', 'nexus_subscriptions' ), \IPS\Member::loggedIn()->language()->addToStack('nexus_front_subscriptions') );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('nexus_front_subscriptions');
\IPS\Output::i()->output = $table;
}
/**
* Change packages. It allows you to change packages. I mean again, the whole concept of PHPDoc seems to point out the obvious. A bit like GPS navigation for your front room. There's the sofa. There's the cat.
*
* @return void just like life, it is meaningless and temporary so live in the moment, enjoy each day and eat chocolate unless you have an allergy in which case don't. See your GP before starting any new diet.
*/
protected function change()
{
/* CSRF Check */
\IPS\Session::i()->csrfCheck();
try
{
$newPackage = \IPS\nexus\Subscription\Package::load( \IPS\Request::i()->id );
}
catch( \OutOfRangeException $e )
{
\IPS\Output::i()->error( 'nexus_no_subs_package', '2X379/2', 404, '' );
}
try
{
$subscription = \IPS\nexus\Subscription::loadActiveByMember( \IPS\Member::loggedIn() );
}
catch( \OutOfRangeException $e )
{
\IPS\Output::i()->error( 'nexus_no_subs_subs', '2X379/3', 404, '' );
}
/* Fetch purchase */
$purchase = NULL;
foreach ( \IPS\nexus\extensions\nexus\Item\Subscription::getPurchases( \IPS\nexus\Customer::loggedIn(), $subscription->package->id ) as $row )
{
if ( $row->active and ! $row->cancelled )
{
$purchase = $row;
break;
}
}
if ( $purchase === NULL )
{
\IPS\Output::i()->error( 'nexus_sub_no_purchase', '2X379/4', 404, '' );
}
/* Right, that's all the "I'll tamper with the URLs for a laugh" stuff out of the way... */
$upgradeCost = $newPackage->costToUpgrade( $subscription->package, \IPS\nexus\Customer::loggedIn() );
if ( $upgradeCost === NULL )
{
\IPS\Output::i()->error( 'nexus_no_subs_nocost', '2X379/5', 404, '' );
}
$invoice = $subscription->package->upgradeDowngrade( $purchase, $newPackage );
if ( $invoice )
{
\IPS\Output::i()->redirect( $invoice->checkoutUrl() );
}
$purchase->member->log( 'subscription', array( 'type' => 'change', 'id' => $purchase->id, 'old' => $purchase->name, 'name' => $newPackage->titleForLog(), 'system' => FALSE ) );
\IPS\Output::i()->redirect( $purchase->url() );
}
/**
* Cancels a subscription doens't it? Yes it does.
*
* @return void
*/
protected function cancel()
{
/* CSRF Check */
\IPS\Session::i()->csrfCheck();
$package = \IPS\nexus\Subscription\Package::load( \IPS\Request::i()->id );
$subscription = \IPS\nexus\Subscription::loadActiveByMember( \IPS\Member::loggedIn() );
/* Build Form */
$form = new \IPS\Helpers\Form;
$form->class = 'ipsForm_vertical';
if ( $subscription->renews )
{
$form->add( new \IPS\Helpers\Form\Radio( 'nexus_sub_cancel_type', 0, TRUE, array(
'options' => array( 0 => 'nexus_sub_cancel_type_renewal', 1 => 'nexus_sub_cancel_type_immediate' )
), NULL, NULL, NULL, 'nexus_sub_cancel_type' ) );
}
else
{
$form->add( new \IPS\Helpers\Form\YesNo( 'nexus_sub_cancel_now', 0, TRUE, array(), NULL, NULL, NULL, 'nexus_sub_cancel_now' ) );
}
if( $subscription->_expire )
{
\IPS\Member::loggedIn()->language()->words['nexus_sub_cancel_type_renewal_desc'] = \IPS\Member::loggedIn()->language()->addToStack( 'nexus_sub_cancel_type_renewal__desc', NULL, array( 'sprintf' => array( $subscription->_expire->dayAndMonth() . ' ' . $subscription->_expire->format('Y') ) ) );
}
if ( $values = $form->values() )
{
if ( ( isset( $values['nexus_sub_cancel_now'] ) and $values['nexus_sub_cancel_now'] ) or ( isset( $values['nexus_sub_cancel_type'] ) and $values['nexus_sub_cancel_type'] == 1 ) )
{
/* Cancel purchase */
foreach ( \IPS\nexus\extensions\nexus\Item\Subscription::getPurchases( \IPS\nexus\Customer::loggedIn(), $package->id ) as $purchase )
{
$purchase->cancelled = TRUE;
$purchase->member->log( 'purchase', array( 'type' => 'cancel', 'id' => $purchase->id, 'name' => $purchase->name ) );
$purchase->can_reactivate = FALSE;
$purchase->save();
}
/* Cancel the subscription */
$package->cancelMember( \IPS\nexus\Customer::loggedIn() );
}
else if ( isset( $values['nexus_sub_cancel_type'] ) and $values['nexus_sub_cancel_type'] == 0 )
{
/* Just stop the renewal bud */
$subscription->renews = 0;
$subscription->save();
/* Cancel renewals */
foreach ( \IPS\nexus\extensions\nexus\Item\Subscription::getPurchases( \IPS\nexus\Customer::loggedIn(), $package->id ) as $purchase )
{
$purchase->renewals = NULL;
$purchase->save();
}
$purchase->member->log( 'subscription', array( 'type' => 'cancelrenewals', 'id' => $package->id ) );
}
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=subscriptions&controller=subscriptions', 'front', 'nexus_subscriptions' ) );
}
/* Display */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('nexus_subs_cancel');
\IPS\Output::i()->output = \IPS\Request::i()->isAjax() ? $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'forms', 'core' ) ), 'popupTemplate' ) ) : $form;
}
/**
* Purchase
*
* @return void
*/
protected function purchase()
{
/* CSRF Check */
\IPS\Session::i()->csrfCheck();
$package = \IPS\nexus\Subscription\Package::load( \IPS\Request::i()->id );
$price = $package->price();
$item = new \IPS\nexus\extensions\nexus\Item\Subscription( \IPS\nexus\Customer::loggedIn()->language()->get( $package->_titleLanguageKey ), $price );
$item->id = $package->id;
try
{
$item->tax = \IPS\nexus\Tax::load( $package->tax );
}
catch ( \OutOfRangeException $e ) { }
if ( $package->gateways !== '*' )
{
$item->paymentMethodIds = explode( ',', $package->gateways );
}
$item->renewalTerm = $package->renewalTerm( $price->currency );
/* Generate the invoice */
$invoice = new \IPS\nexus\Invoice;
$invoice->currency = $price->currency;
$invoice->member = \IPS\nexus\Customer::loggedIn();
$invoice->addItem( $item );
$invoice->return_uri = "app=nexus&module=subscriptions&controller=subscriptions";
$invoice->save();
/* Take them to it */
\IPS\Output::i()->redirect( $invoice->checkoutUrl() );
}
}
@@ -75,7 +75,7 @@ class _home extends \IPS\Dispatcher\Controller
$form = new \IPS\Helpers\Form( 'account', 'continue' );
$form->class = 'ipsForm_vertical';
$form->add( new \IPS\Helpers\Form\Radio( 'support_account', \IPS\nexus\Customer::loggedIn()->member_id, TRUE, array( 'options' => $options, 'parse' => 'none' ) ) );
$form->add( new \IPS\Helpers\Form\Radio( 'support_account', \IPS\nexus\Customer::loggedIn()->member_id, TRUE, array( 'options' => $options, 'parse' => 'normal' ) ) );
if ( $values = $form->values() )
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=nexus&module=support&controller=home&do=create&account={$values['support_account']}", 'front', 'support_create' ) );
@@ -98,17 +98,19 @@ class _view extends \IPS\Content\Controller
\IPS\Output::i()->error( 'node_error', '2X209/1', 404, '' );
}
$existingRating = NULL;
/* If we've rated, do not allow us to rate again */
try
{
$existingRating = \IPS\Db::i()->select( '*', 'nexus_support_ratings', array( 'rating_reply=?', $reply->id ) )->first();
\IPS\Db::i()->select( '*', 'nexus_support_ratings', array( 'rating_reply=?', $reply->id ) )->first();
\IPS\Output::i()->error( 'already_rated', '2X204/2', 403, '' );
}
catch ( \UnderflowException $e ) {}
$form = new \IPS\Helpers\Form( 'feedback', 'send_feedback' );
$form->class = 'ipsForm_vertical';
$form->add( new \IPS\Helpers\Form\Rating( 'support_rating_rating', \IPS\Request::i()->rating, TRUE ) );
$form->add( new \IPS\Helpers\Form\TextArea( 'support_rating_feedback', $existingRating ? $existingRating['rating_note'] : NULL, FALSE ) );
$form->add( new \IPS\Helpers\Form\TextArea( 'support_rating_feedback', NULL, FALSE ) );
if ( $values = $form->values() )
{
$save = array(
@@ -119,16 +121,9 @@ class _view extends \IPS\Content\Controller
'rating_note' => $values['support_rating_feedback'],
'rating_date' => time()
);
if ( $existingRating )
{
\IPS\Db::i()->update( 'nexus_support_ratings', $save, array( 'rating_reply=?', $reply->id ) );
}
else
{
\IPS\Db::i()->insert( 'nexus_support_ratings', $save );
}
\IPS\Db::i()->insert( 'nexus_support_ratings', $save );
if ( \IPS\Request::i()->isAjax() )
{
$reply->ratingData = $save;