Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\Package;
|
||||
|
||||
/* 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;
|
||||
@@ -48,11 +48,11 @@ class _Product extends \IPS\nexus\Package
|
||||
|
||||
if ( !$customEdit ) // After the package has been created, these are unimportant
|
||||
{
|
||||
$return['package_settings']['physical'] = new \IPS\Helpers\Form\YesNo( 'p_physical', $package->type === 'product' ? $package->physical : FALSE, FALSE, array( 'togglesOn' => array( 'p_weight', 'p_length', 'p_width', 'p_height', 'p_shipping' ) ) );
|
||||
$return['package_settings']['weight'] = new \IPS\nexus\Form\Weight( 'p_weight', $package->type === 'product' ? new \IPS\nexus\Shipping\Weight( $package->weight ) : NULL, FALSE, array(), NULL, NULL, NULL, 'p_weight' );
|
||||
$return['package_settings']['length'] = new \IPS\nexus\Form\Length( 'p_length', $package->type === 'product' ? new \IPS\nexus\Shipping\Length( $package->length ) : NULL, FALSE, array(), NULL, NULL, NULL, 'p_length' );
|
||||
$return['package_settings']['width'] = new \IPS\nexus\Form\Length( 'p_width', $package->type === 'product' ? new \IPS\nexus\Shipping\Length( $package->width ) : NULL, FALSE, array(), NULL, NULL, NULL, 'p_width' );
|
||||
$return['package_settings']['height'] = new \IPS\nexus\Form\Length( 'p_height', $package->type === 'product' ? new \IPS\nexus\Shipping\Length( $package->height ) : NULL, FALSE, array(), NULL, NULL, NULL, 'p_height' );
|
||||
$return['package_settings']['physical'] = new \IPS\Helpers\Form\YesNo( 'p_physical', $package->type === 'product' ? $package->physical : FALSE, FALSE, array( 'disableCopy' => TRUE, 'togglesOn' => array( 'p_weight', 'p_length', 'p_width', 'p_height', 'p_shipping' ), 'togglesOff' => array( 'elProductTaxWarningContainer' ) ) );
|
||||
$return['package_settings']['weight'] = new \IPS\nexus\Form\Weight( 'p_weight', $package->type === 'product' ? new \IPS\nexus\Shipping\Weight( $package->weight ) : NULL, FALSE, array( 'disableCopy' => TRUE ), NULL, NULL, NULL, 'p_weight' );
|
||||
$return['package_settings']['length'] = new \IPS\nexus\Form\Length( 'p_length', $package->type === 'product' ? new \IPS\nexus\Shipping\Length( $package->length ) : NULL, FALSE, array( 'disableCopy' => TRUE ), NULL, NULL, NULL, 'p_length' );
|
||||
$return['package_settings']['width'] = new \IPS\nexus\Form\Length( 'p_width', $package->type === 'product' ? new \IPS\nexus\Shipping\Length( $package->width ) : NULL, FALSE, array( 'disableCopy' => TRUE ), NULL, NULL, NULL, 'p_width' );
|
||||
$return['package_settings']['height'] = new \IPS\nexus\Form\Length( 'p_height', $package->type === 'product' ? new \IPS\nexus\Shipping\Length( $package->height ) : NULL, FALSE, array( 'disableCopy' => TRUE ), NULL, NULL, NULL, 'p_height' );
|
||||
|
||||
$availableShippingMethods = array();
|
||||
foreach ( \IPS\nexus\Shipping\FlatRate::roots() as $rate )
|
||||
@@ -75,15 +75,10 @@ class _Product extends \IPS\nexus\Package
|
||||
|
||||
$licenseKeyOptions = array();
|
||||
$licenseKeyToggles = array();
|
||||
foreach ( new \DirectoryIterator( \IPS\ROOT_PATH . '/applications/nexus/sources/Purchase/LicenseKey' ) as $file )
|
||||
foreach ( \IPS\nexus\Purchase\LicenseKey::licenseKeyTypes() as $key => $class )
|
||||
{
|
||||
if ( !$file->isDot() and $file != 'index.html' )
|
||||
{
|
||||
$key = mb_substr( $file, 0, -4 );
|
||||
$class = 'IPS\nexus\Purchase\LicenseKey\\' . $key;
|
||||
$licenseKeyOptions[ mb_strtolower( $key ) ] = 'lkey_' . $key;
|
||||
$licenseKeyToggles[ mb_strtolower( $key ) ] = array( 'p_lkey_identifier', 'p_lkey_uses' );
|
||||
}
|
||||
$licenseKeyOptions[ mb_strtolower( $key ) ] = 'lkey_' . $key;
|
||||
$licenseKeyToggles[ mb_strtolower( $key ) ] = array( 'p_lkey_identifier', 'p_lkey_uses' );
|
||||
}
|
||||
if ( !empty( $licenseKeyOptions ) )
|
||||
{
|
||||
@@ -126,7 +121,7 @@ class _Product extends \IPS\nexus\Package
|
||||
|
||||
if( isset( $values['p_weight'] ) )
|
||||
{
|
||||
$values['p_weight'] = is_object( $values['p_weight'] ) ? $values['p_weight']->kilograms : 0;
|
||||
$values['p_weight'] = \is_object( $values['p_weight'] ) ? $values['p_weight']->kilograms : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -135,7 +130,7 @@ class _Product extends \IPS\nexus\Package
|
||||
|
||||
if( isset( $values['p_length'] ) )
|
||||
{
|
||||
$values['p_length'] = is_object( $values['p_length'] ) ? $values['p_length']->metres : 0;
|
||||
$values['p_length'] = \is_object( $values['p_length'] ) ? $values['p_length']->metres : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -144,7 +139,7 @@ class _Product extends \IPS\nexus\Package
|
||||
|
||||
if( isset( $values['p_width'] ) )
|
||||
{
|
||||
$values['p_width'] = is_object( $values['p_width'] ) ? $values['p_width']->metres : 0;
|
||||
$values['p_width'] = \is_object( $values['p_width'] ) ? $values['p_width']->metres : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -153,7 +148,7 @@ class _Product extends \IPS\nexus\Package
|
||||
|
||||
if( isset( $values['p_height'] ) )
|
||||
{
|
||||
$values['p_height'] = is_object( $values['p_height'] ) ? $values['p_height']->metres : 0;
|
||||
$values['p_height'] = \is_object( $values['p_height'] ) ? $values['p_height']->metres : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -162,7 +157,7 @@ class _Product extends \IPS\nexus\Package
|
||||
|
||||
if( isset( $values['p_shipping'] ) )
|
||||
{
|
||||
$values['p_shipping'] = is_array( $values['p_shipping'] ) ? implode( ',', $values['p_shipping'] ) : '*';
|
||||
$values['p_shipping'] = \is_array( $values['p_shipping'] ) ? implode( ',', $values['p_shipping'] ) : '*';
|
||||
}
|
||||
|
||||
return parent::formatFormValues( $values );
|
||||
@@ -196,18 +191,26 @@ class _Product extends \IPS\nexus\Package
|
||||
if ( array_key_exists( 'lkey', $changes ) )
|
||||
{
|
||||
$oldKey = NULL;
|
||||
try
|
||||
|
||||
$lKey = $purchase->licenseKey();
|
||||
|
||||
if ( $lKey )
|
||||
{
|
||||
$purchase->licenseKey()->delete();
|
||||
$lKey->delete();
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
|
||||
$class = 'IPS\nexus\Purchase\LicenseKey\\' . mb_ucfirst( $this->lkey );
|
||||
$licenseKey = new $class;
|
||||
$licenseKey->identifier = $this->lkey_identifier;
|
||||
$licenseKey->purchase = $purchase;
|
||||
$licenseKey->max_uses = $this->lkey_uses;
|
||||
$licenseKey->save();
|
||||
|
||||
$licenseTypes = \IPS\nexus\Purchase\LicenseKey::licenseKeyTypes();
|
||||
|
||||
if( class_exists( $licenseTypes[ mb_ucfirst( $this->lkey ) ]) )
|
||||
{
|
||||
$class = $licenseTypes[ mb_ucfirst( $this->lkey ) ];
|
||||
$licenseKey = new $class;
|
||||
$licenseKey->identifier = $this->lkey_identifier;
|
||||
$licenseKey->purchase = $purchase;
|
||||
$licenseKey->max_uses = $this->lkey_uses;
|
||||
$licenseKey->save();
|
||||
}
|
||||
|
||||
}
|
||||
elseif ( array_key_exists( 'lkey_identifier', $changes ) or array_key_exists( 'lkey_uses', $changes ) )
|
||||
{
|
||||
@@ -344,6 +347,7 @@ class _Product extends \IPS\nexus\Package
|
||||
{
|
||||
case 'lkeyReset':
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'lkeys_reset' );
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
$oldKey = NULL;
|
||||
try
|
||||
@@ -359,7 +363,8 @@ class _Product extends \IPS\nexus\Package
|
||||
/* Invalidate License Key Cache so old data is not loaded */
|
||||
$purchase->licenseKey = NULL;
|
||||
|
||||
$class = 'IPS\nexus\Purchase\LicenseKey\\' . mb_ucfirst( $this->lkey );
|
||||
$licenseTypes = \IPS\nexus\Purchase\LicenseKey::licenseKeyTypes();
|
||||
$class = $licenseTypes[ mb_ucfirst( $this->lkey ) ];
|
||||
$licenseKey = new $class;
|
||||
$licenseKey->identifier = $this->lkey_identifier;
|
||||
$licenseKey->purchase = $purchase;
|
||||
@@ -385,7 +390,8 @@ class _Product extends \IPS\nexus\Package
|
||||
{
|
||||
if ( $this->lkey )
|
||||
{
|
||||
$class = 'IPS\nexus\Purchase\LicenseKey\\' . mb_ucfirst( $this->lkey );
|
||||
$licenseTypes = \IPS\nexus\Purchase\LicenseKey::licenseKeyTypes();
|
||||
$class = $licenseTypes[ mb_ucfirst( $this->lkey ) ];
|
||||
$licenseKey = new $class;
|
||||
$licenseKey->identifier = $this->lkey_identifier;
|
||||
$licenseKey->purchase = $purchase;
|
||||
|
||||
Reference in new issue
Block a user