Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Consumer/business address input class for Form Builder
|
||||
* @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 8 Oct 2019
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\Form;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Consumer/business address input class for Form Builder
|
||||
*/
|
||||
class _BusinessAddress extends \IPS\Helpers\Form\Address
|
||||
{
|
||||
/**
|
||||
* @brief Default Options
|
||||
* @code
|
||||
$defaultOptions = array(
|
||||
'minimize' => FALSE, // Minimize the address field until the user focuses?
|
||||
'requireFullAddress'=> TRUE, // Does this have to be a full address? Default is TRUE, may set to FALSE if a more generic location is acceptable
|
||||
'vat' => FALSE, // In addition if asking if this is a business address, should we prompt for the VAT number?
|
||||
);
|
||||
* @endcode
|
||||
*/
|
||||
protected $defaultOptions = array(
|
||||
'minimize' => FALSE,
|
||||
'requireFullAddress' => TRUE,
|
||||
'vat' => FALSE
|
||||
);
|
||||
|
||||
/**
|
||||
* Get HTML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function html()
|
||||
{
|
||||
/* If we don't have a value, set their country based on the HTTP headers */
|
||||
if ( !$this->value OR ( $this->value instanceof \IPS\GeoLocation AND !$this->value->country ) )
|
||||
{
|
||||
$this->value = ( $this->value instanceof \IPS\GeoLocation ) ? $this->value : new \IPS\GeoLocation;
|
||||
if ( $defaultCountry = static::calculateDefaultCountry() )
|
||||
{
|
||||
$this->value->country = $defaultCountry;
|
||||
}
|
||||
}
|
||||
|
||||
/* We need a HTML id */
|
||||
if ( !$this->htmlId )
|
||||
{
|
||||
$this->htmlId = md5( 'ips_checkbox_' . $this->name );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
return \IPS\Theme::i()->getTemplate( 'forms', 'nexus', 'global' )->businessAddress( $this->name, $this->value, \IPS\Settings::i()->googleplacesautocomplete ? \IPS\Settings::i()->google_maps_api_key : NULL, $this->options['minimize'], $this->options['requireFullAddress'], $this->htmlId, $this->options['vat'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Value
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
/* Get the normal address stuff */
|
||||
$value = parent::getValue();
|
||||
|
||||
/* Add in business stuff */
|
||||
if ( $value )
|
||||
{
|
||||
$name = $this->name;
|
||||
if( \IPS\Request::i()->$name['type'] === 'business' )
|
||||
{
|
||||
$value->business = \IPS\Request::i()->$name['business'];
|
||||
|
||||
if ( $this->options['vat'] and \in_array( $value->country, array('AT','BE','BG','HR','CY','CZ','DK','EE','FI','FR','DE','GR','HU','IE','IT','LV','LT','LU','MT','NL','PL','PT','RO','SK','SI','ES','SE','GB') ) and \IPS\Request::i()->$name['vat'] )
|
||||
{
|
||||
$value->vat = \IPS\Request::i()->$name['vat'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$value->vat = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$value->business = NULL;
|
||||
$value->vat = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return */
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @return TRUE
|
||||
*/
|
||||
public function validate()
|
||||
{
|
||||
parent::validate();
|
||||
|
||||
if( $this->value )
|
||||
{
|
||||
if ( $this->value->business === '' )
|
||||
{
|
||||
throw new \DomainException('cm_business_name_required');
|
||||
}
|
||||
|
||||
if ( $this->value->vat )
|
||||
{
|
||||
try
|
||||
{
|
||||
$response = \IPS\nexus\Tax::validateVAT( $this->value->vat );
|
||||
if ( !$response )
|
||||
{
|
||||
throw new \DomainException('cm_checkout_vat_invalid');
|
||||
}
|
||||
elseif ( $response['countryCode'] !== $this->value->country )
|
||||
{
|
||||
throw new \DomainException('cm_checkout_vat_wrong_country');
|
||||
}
|
||||
}
|
||||
catch ( \IPS\Http\Request\Exception $e )
|
||||
{
|
||||
\IPS\Log::log( $e, 'vat-validation' );
|
||||
throw new \DomainException('cm_checkout_vat_error');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\Form;
|
||||
|
||||
/* 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;
|
||||
@@ -33,6 +33,8 @@ class _CreditCard extends \IPS\Helpers\Form\FormAbstract
|
||||
'attr' => array(...), // Will wrap fields in a div with the specified attributes
|
||||
'jsRequired'=> FALSE, // If true, will add an error in <noscript> tags
|
||||
'names' => TRUE, // Sets if name="" attributes should be on the fields (for gateways that use JS, this avoids details hitting the server)
|
||||
'dummy' => TRUE, // If TRUE, will create <div>s rather than actual input boxes which is needed for some gateways
|
||||
'loading' => TRUE, // If TRUE, will apply a loading filter over the new card input area in case you have any extra JS that needs to be set up
|
||||
);
|
||||
* @endcode
|
||||
*/
|
||||
@@ -44,6 +46,8 @@ class _CreditCard extends \IPS\Helpers\Form\FormAbstract
|
||||
'jsRequired'=> FALSE,
|
||||
'names' => TRUE,
|
||||
'dummy' => FALSE,
|
||||
'disabled' => FALSE,
|
||||
'loading' => FALSE
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -59,7 +63,7 @@ class _CreditCard extends \IPS\Helpers\Form\FormAbstract
|
||||
$expMonth = NULL;
|
||||
$expYear = NULL;
|
||||
$ccv = '';
|
||||
if ( is_array( $this->value ) )
|
||||
if ( \is_array( $this->value ) )
|
||||
{
|
||||
$number = $this->value['number'];
|
||||
$expMonth = $this->value['exp_month'];
|
||||
@@ -95,12 +99,13 @@ class _CreditCard extends \IPS\Helpers\Form\FormAbstract
|
||||
}
|
||||
}
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'forms', 'nexus', 'global' )->creditCard( $this, $types, $number, intval( $expMonth ), intval( $expYear ), $ccv, $storedCards );
|
||||
return \IPS\Theme::i()->getTemplate( 'forms', 'nexus', 'global' )->creditCard( $this, $types, $number, \intval( $expMonth ), \intval( $expYear ), $ccv, $storedCards );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get HTML
|
||||
*
|
||||
* @param \IPS\Helpers\Form|null $form Form helper object
|
||||
* @return string
|
||||
*/
|
||||
public function rowHtml( $form=NULL )
|
||||
@@ -183,7 +188,7 @@ class _CreditCard extends \IPS\Helpers\Form\FormAbstract
|
||||
{
|
||||
if ( $this->value instanceof \IPS\nexus\CreditCard )
|
||||
{
|
||||
if ( $this->value->type and !in_array( $this->value->type, $this->options['types'] ) )
|
||||
if ( $this->value->type and !\in_array( $this->value->type, $this->options['types'] ) )
|
||||
{
|
||||
throw new \LogicException( \IPS\Member::loggedIn()->language()->addToStack( 'card_bad_type', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( "card_type_" . $this->value->type ) ) ) ) );
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\Form;
|
||||
|
||||
/* 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;
|
||||
@@ -33,7 +33,7 @@ class _DiscountBulk extends \IPS\Helpers\Form\FormAbstract
|
||||
$selectedPackage = NULL;
|
||||
try
|
||||
{
|
||||
$selectedPackage = $this->value['package'] ? \IPS\nexus\Package::load( $this->value['package'] ) : array();
|
||||
$selectedPackage = ( \is_array( $this->value ) AND isset( $this->value['package'] ) ) ? \IPS\nexus\Package::load( $this->value['package'] ) : array();
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) {}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\Form;
|
||||
|
||||
/* 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;
|
||||
@@ -33,7 +33,7 @@ class _DiscountLoyalty extends \IPS\Helpers\Form\FormAbstract
|
||||
$selectedPackage = NULL;
|
||||
try
|
||||
{
|
||||
$selectedPackage = $this->value['package'] ? \IPS\nexus\Package::load( $this->value['package'] ) : NULL;
|
||||
$selectedPackage = ( \is_array( $this->value ) AND isset( $this->value['package'] ) ) ? \IPS\nexus\Package::load( $this->value['package'] ) : NULL;
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) {}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\Form;
|
||||
|
||||
/* 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\Form;
|
||||
|
||||
/* 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\Form;
|
||||
|
||||
/* 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\Form;
|
||||
|
||||
/* 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;
|
||||
@@ -61,9 +61,9 @@ class _Money extends \IPS\Helpers\Form\FormAbstract
|
||||
return '*';
|
||||
}
|
||||
|
||||
$_value = is_array( $this->value ) ? $this->value : @json_decode( $this->value, TRUE );
|
||||
$_value = \is_array( $this->value ) ? $this->value : @json_decode( $this->value, TRUE );
|
||||
$value = array();
|
||||
if ( is_array( $_value ) )
|
||||
if ( \is_array( $_value ) )
|
||||
{
|
||||
foreach ( $_value as $currency => $amount )
|
||||
{
|
||||
@@ -73,11 +73,11 @@ class _Money extends \IPS\Helpers\Form\FormAbstract
|
||||
{
|
||||
$value[ $currency ] = $amount;
|
||||
}
|
||||
elseif ( is_array( $amount ) and isset( $amount['amount'] ) )
|
||||
elseif ( \is_array( $amount ) and isset( $amount['amount'] ) )
|
||||
{
|
||||
$value[ $currency ] = new \IPS\nexus\Money( $amount['amount'], $currency );
|
||||
}
|
||||
elseif ( is_numeric( $amount ) )
|
||||
elseif ( \is_numeric( $amount ) )
|
||||
{
|
||||
$value[ $currency ] = new \IPS\nexus\Money( $amount, $currency );
|
||||
}
|
||||
@@ -97,7 +97,7 @@ class _Money extends \IPS\Helpers\Form\FormAbstract
|
||||
{
|
||||
if ( $this->required )
|
||||
{
|
||||
if ( ( $this->options['unlimitedLang'] and $this->value === '*' ) or count( $this->value ) )
|
||||
if ( ( $this->options['unlimitedLang'] and $this->value === '*' ) or \count( $this->value ) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\Form;
|
||||
|
||||
/* 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;
|
||||
@@ -27,20 +27,32 @@ class _RenewalTerm extends \IPS\Helpers\Form\FormAbstract
|
||||
* @brief Default Options
|
||||
* @code
|
||||
$defaultOptions = array(
|
||||
'customer' => \IPS\nexus\Customer, // Customer this is for (sets appropriate default currency)
|
||||
'currency' => 'USD', // Alternatively to specifying customer, can manually specify currency (defaults to NULL)
|
||||
'allCurrencies' => FALSE, // If TRUE, will ask for a price in all currencies (defaults to FALSE)
|
||||
'addToBase' => FALSE, // If TRUE, a checkbox will be added asking if the price should be added to the base price
|
||||
'lockTerm' => FALSE, // If TRUE, only the price (not the term) will be editable
|
||||
'customer' => \IPS\nexus\Customer, // Customer this is for (sets appropriate default currency)
|
||||
'currency' => 'USD', // Alternatively to specifying customer, can manually specify currency (defaults to NULL)
|
||||
'allCurrencies' => FALSE, // If TRUE, will ask for a price in all currencies (defaults to FALSE)
|
||||
'addToBase' => FALSE, // If TRUE, a checkbox will be added asking if the price should be added to the base price
|
||||
'lockTerm' => FALSE, // If TRUE, only the price (not the term) will be editable
|
||||
'lockPrice' => FALSE, // If TRUE, only the term (not the price) will be editable
|
||||
'nullLang' => FALSE, // If a value is provided, an "unlimited" checkbox will show with this label which, if checked, will cause the return value to be null
|
||||
'initialTerm' => FALSE, // Set to TRUE if this is to fetermine the initial term for a package. Will show a "[] or lifetime" checkbox and change some wording
|
||||
'initialTermLang' => 'term_no_renewals', // The label to use for the "[] or lifetime" checkbox
|
||||
'unlimitedTogglesOn' => [...], // Toggles for if the "[] or lifetime" checkbox is checked
|
||||
'unlimitedTogglesOff' => [...], // Toggles for if the "[] or lifetime" checkbox is unchecked
|
||||
);
|
||||
* @endcode
|
||||
*/
|
||||
protected $defaultOptions = array(
|
||||
'customer' => NULL,
|
||||
'currency' => NULL,
|
||||
'allCurrencies' => FALSE,
|
||||
'addToBase' => NULL,
|
||||
'lockTerm' => FALSE,
|
||||
'customer' => NULL,
|
||||
'currency' => NULL,
|
||||
'allCurrencies' => FALSE,
|
||||
'addToBase' => NULL,
|
||||
'lockTerm' => FALSE,
|
||||
'lockPrice' => FALSE,
|
||||
'nullLang' => NULL,
|
||||
'initialTerm' => FALSE,
|
||||
'initialTermLang' => 'term_no_renewals',
|
||||
'unlimitedTogglesOn' => [],
|
||||
'unlimitedTogglesOff' => []
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -50,39 +62,7 @@ class _RenewalTerm extends \IPS\Helpers\Form\FormAbstract
|
||||
*/
|
||||
public function html()
|
||||
{
|
||||
$value = $this->value;
|
||||
if ( !$this->value )
|
||||
{
|
||||
if ( $this->options['customer'] )
|
||||
{
|
||||
$defaultCurrency = $this->options['customer']->defaultCurrency();
|
||||
}
|
||||
elseif ( $this->options['currency'] )
|
||||
{
|
||||
$defaultCurrency = $this->options['currency'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$currencies = \IPS\nexus\Money::currencies();
|
||||
$defaultCurrency = array_shift( $currencies );
|
||||
}
|
||||
|
||||
if ( $this->options['allCurrencies'] )
|
||||
{
|
||||
$costs = array();
|
||||
foreach ( \IPS\nexus\Money::currencies() as $currency )
|
||||
{
|
||||
$costs[ $currency ] = new \IPS\nexus\Money( 0, $currency );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$costs = new \IPS\nexus\Money( 0, $defaultCurrency );
|
||||
}
|
||||
$value = new \IPS\nexus\Purchase\RenewalTerm( $costs, new \DateInterval( 'P0M' ) );
|
||||
}
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'forms', 'nexus', 'global' )->renewalTerm( $this->name, $value, $this->options );
|
||||
return \IPS\Theme::i()->getTemplate( 'forms', 'nexus', 'global' )->renewalTerm( $this->name, $this->value, $this->options );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,14 +72,15 @@ class _RenewalTerm extends \IPS\Helpers\Form\FormAbstract
|
||||
*/
|
||||
public function formatValue()
|
||||
{
|
||||
if ( is_array( $this->value ) )
|
||||
if ( \is_array( $this->value ) )
|
||||
{
|
||||
if ( !isset( $this->value['term'] ) or !$this->value['term'] or !isset( $this->value['unit'] ) or !$this->value['unit'] )
|
||||
if ( isset( $this->value['null'] ) /* or !isset( $this->value['term'] ) or !$this->value['term'] or !isset( $this->value['unit'] ) or !$this->value['unit'] */ )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Work out prices */
|
||||
if ( $this->options['allCurrencies'] )
|
||||
{
|
||||
$costs = array();
|
||||
@@ -126,23 +107,37 @@ class _RenewalTerm extends \IPS\Helpers\Form\FormAbstract
|
||||
$currencies = \IPS\nexus\Money::currencies();
|
||||
$currency = array_shift( $currencies );
|
||||
}
|
||||
$costs = new \IPS\nexus\Money( $this->value['amount'], $currency );
|
||||
}
|
||||
|
||||
/* Perform some sanity checks */
|
||||
if ( $this->value['term'] < 1 )
|
||||
{
|
||||
$this->value = new \IPS\nexus\Purchase\RenewalTerm( $costs, new \DateInterval( 'P' . 1 . mb_strtoupper( $this->value['unit'] ) ), NULL, $this->options['addToBase'] ? isset( $this->value['add'] ) : FALSE );
|
||||
throw new \LengthException( \IPS\Member::loggedIn()->language()->addToStack('form_number_min', FALSE, array( 'sprintf' => array( 0 ) ) ) );
|
||||
}
|
||||
|
||||
if ( !in_array( $this->value['unit'], array( 'd', 'm', 'y' ) ) )
|
||||
{
|
||||
$this->value = new \IPS\nexus\Purchase\RenewalTerm( $costs, new \DateInterval( 'P' . $this->value['term'] . 'D' ), NULL, $this->options['addToBase'] ? isset( $this->value['add'] ) : FALSE );
|
||||
throw new \OutOfRangeException( 'form_bad_value' );
|
||||
$costs = isset( $this->value['amount'] ) ? new \IPS\nexus\Money( $this->value['amount'], $currency ) : NULL;
|
||||
}
|
||||
|
||||
return new \IPS\nexus\Purchase\RenewalTerm( $costs, new \DateInterval( 'P' . $this->value['term'] . mb_strtoupper( $this->value['unit'] ) ), NULL, $this->options['addToBase'] ? isset( $this->value['add'] ) : FALSE );
|
||||
/* Work out term */
|
||||
if ( isset( $this->value['unlimited'] ) )
|
||||
{
|
||||
$term = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !isset( $this->value['term'] ) or !$this->value['term'] or !isset( $this->value['unit'] ) or !$this->value['unit'] )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( $this->value['term'] < 1 )
|
||||
{
|
||||
$this->value = new \IPS\nexus\Purchase\RenewalTerm( $costs, new \DateInterval( 'P' . 1 . mb_strtoupper( $this->value['unit'] ) ), NULL, $this->options['addToBase'] ? isset( $this->value['add'] ) : FALSE );
|
||||
throw new \LengthException( \IPS\Member::loggedIn()->language()->addToStack('form_number_min', FALSE, array( 'sprintf' => array( 0 ) ) ) );
|
||||
}
|
||||
if ( !\in_array( $this->value['unit'], array( 'd', 'm', 'y' ) ) )
|
||||
{
|
||||
$this->value = new \IPS\nexus\Purchase\RenewalTerm( $costs, new \DateInterval( 'P' . $this->value['term'] . 'D' ), NULL, $this->options['addToBase'] ? isset( $this->value['add'] ) : FALSE );
|
||||
throw new \OutOfRangeException( 'form_bad_value' );
|
||||
}
|
||||
|
||||
$term = new \DateInterval( 'P' . $this->value['term'] . mb_strtoupper( $this->value['unit'] ) );
|
||||
}
|
||||
|
||||
/* Return */
|
||||
return new \IPS\nexus\Purchase\RenewalTerm( $costs, $term, NULL, $this->options['addToBase'] ? isset( $this->value['add'] ) : FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\Form;
|
||||
|
||||
/* 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;
|
||||
@@ -77,7 +77,7 @@ class _Shipping extends \IPS\Helpers\Form\FormAbstract
|
||||
throw new \InvalidArgumentException('form_required');
|
||||
}
|
||||
}
|
||||
elseif ( !in_array( $this->value[ $group ], array_keys( $options['methods'] ) ) )
|
||||
elseif ( !\in_array( $this->value[ $group ], array_keys( $options['methods'] ) ) )
|
||||
{
|
||||
throw new \OutOfRangeException( 'form_bad_value' );
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\Form;
|
||||
|
||||
/* 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;
|
||||
@@ -71,12 +71,12 @@ class _StateSelect extends \IPS\Helpers\Form\FormAbstract
|
||||
*/
|
||||
public function formatValue()
|
||||
{
|
||||
if ( is_array( $this->value ) )
|
||||
if ( \is_array( $this->value ) )
|
||||
{
|
||||
$value = array();
|
||||
foreach ( $this->value as $k => $v )
|
||||
{
|
||||
if ( in_array( (string) $k, \IPS\GeoLocation::$countries ) )
|
||||
if ( \in_array( (string) $k, \IPS\GeoLocation::$countries ) )
|
||||
{
|
||||
$value[ $k ] = $v;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\Form;
|
||||
|
||||
/* 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;
|
||||
@@ -30,8 +30,8 @@ class _UserPass extends \IPS\Helpers\Form\FormAbstract
|
||||
*/
|
||||
public function html()
|
||||
{
|
||||
$value = is_array( $this->value ) ? $this->value : json_decode( \IPS\Text\Encrypt::fromTag( $this->value )->decrypt(), TRUE );
|
||||
$defaultValue = is_array( $this->defaultValue ) ? $this->defaultValue : json_decode( \IPS\Text\Encrypt::fromTag( $this->defaultValue )->decrypt(), TRUE );
|
||||
$value = \is_array( $this->value ) ? $this->value : json_decode( \IPS\Text\Encrypt::fromTag( $this->value )->decrypt(), TRUE );
|
||||
$defaultValue = \is_array( $this->defaultValue ) ? $this->defaultValue : json_decode( \IPS\Text\Encrypt::fromTag( $this->defaultValue )->decrypt(), TRUE );
|
||||
if ( isset( $value['pw'] ) and isset( $defaultValue['pw'] ) and $value['pw'] and $value['pw'] === $defaultValue['pw'] and !$this->error )
|
||||
{
|
||||
$value['pw'] = '********';
|
||||
@@ -51,7 +51,7 @@ class _UserPass extends \IPS\Helpers\Form\FormAbstract
|
||||
|
||||
if ( isset( $value['pw'] ) and $value['pw'] === '********' )
|
||||
{
|
||||
$defaultValue = is_array( $this->defaultValue ) ? $this->defaultValue : json_decode( \IPS\Text\Encrypt::fromTag( $this->defaultValue )->decrypt(), TRUE );
|
||||
$defaultValue = \is_array( $this->defaultValue ) ? $this->defaultValue : json_decode( \IPS\Text\Encrypt::fromTag( $this->defaultValue )->decrypt(), TRUE );
|
||||
$value['pw'] = $defaultValue['pw'];
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\Form;
|
||||
|
||||
/* 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;
|
||||
|
||||
Reference in new issue
Block a user