Version 5.0.0 beta 4
This commit is contained in:
1 parent
e86153356a
commit
2f24f9de48
276 files changed
+8614
-6044
No files matched your search
@@ -16,6 +16,7 @@ namespace IPS\convert\Library;
|
||||
use Exception;
|
||||
use IPS\convert\App;
|
||||
use IPS\convert\Library;
|
||||
use IPS\convert\Software;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\File;
|
||||
@@ -52,7 +53,7 @@ class Nexus extends Library
|
||||
/**
|
||||
* @brief Application
|
||||
*/
|
||||
public $app = 'nexus';
|
||||
public string $app = 'nexus';
|
||||
|
||||
/**
|
||||
* Returns an array of items that we can convert, including the amount of rows stored in the Community Suite as well as the recommend value of rows to convert per cycle
|
||||
@@ -60,7 +61,7 @@ class Nexus extends Library
|
||||
* @param bool $rowCounts enable row counts
|
||||
* @return array
|
||||
*/
|
||||
public function menuRows( $rowCounts=FALSE )
|
||||
public function menuRows( bool $rowCounts=FALSE ) : array
|
||||
{
|
||||
$return = array();
|
||||
$extraRows = $this->software->extraMenuRows();
|
||||
@@ -235,7 +236,7 @@ class Nexus extends Library
|
||||
$return[ $k ] = [
|
||||
'step_title' => 'convert_nexus_subscription_packages',
|
||||
'step_method' => 'convertNexusSubscriptionPackages',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'nexus_member_subscription_packages' ),
|
||||
'ips_rows' => Db::i()->select( 'COUNT(*)', 'nexus_member_subscription_packages' ),
|
||||
'source_rows' => [ 'table' => $v['table'], 'where' => $v['where'] ],
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => [],
|
||||
@@ -433,11 +434,12 @@ class Nexus extends Library
|
||||
* @param string $method Method to truncate
|
||||
* @return array
|
||||
*/
|
||||
protected function truncate( $method )
|
||||
protected function truncate( string $method ) : array
|
||||
{
|
||||
$return = array();
|
||||
$classname = get_class( $this->software );
|
||||
|
||||
/* @var Software $classname */
|
||||
if( $classname::canConvert() === NULL )
|
||||
{
|
||||
return array();
|
||||
@@ -576,7 +578,7 @@ class Nexus extends Library
|
||||
* @param array $fields Custom Field Data
|
||||
* @return int|bool The ID of the inserted customer, or FALSE on failure
|
||||
*/
|
||||
public function convertNexusCustomer( $info, $fields=array() )
|
||||
public function convertNexusCustomer( array $info, array $fields=array() ) : bool|int
|
||||
{
|
||||
if ( !isset( $info['member_id'] ) )
|
||||
{
|
||||
@@ -639,7 +641,7 @@ class Nexus extends Library
|
||||
* @param array $fields The fields
|
||||
* @return array Formatted Fields
|
||||
*/
|
||||
protected function _formatCustomerFields( $fields )
|
||||
protected function _formatCustomerFields( array $fields ) : array
|
||||
{
|
||||
$return = array();
|
||||
foreach( $fields as $key => $value )
|
||||
@@ -667,7 +669,7 @@ class Nexus extends Library
|
||||
/**
|
||||
* @brief Allowed currencies
|
||||
*/
|
||||
protected $_allowedCurrencies = array( 'AED', 'AFN', 'ALL', 'AMD', 'ANG', 'AOA', 'ARS', 'AUD', 'AWG', 'AZN', 'BAM', 'BBD',
|
||||
protected array $_allowedCurrencies = array( 'AED', 'AFN', 'ALL', 'AMD', 'ANG', 'AOA', 'ARS', 'AUD', 'AWG', 'AZN', 'BAM', 'BBD',
|
||||
'BDT', 'BGN', 'BHD', 'BIF', 'BMD', 'BND', 'BOB', 'BRL', 'BSD', 'BTN', 'BWP', 'BYN', 'BYR', 'BZD', 'CAD', 'CDF', 'CHF',
|
||||
'CLF', 'CLP', 'CNY', 'COP', 'CRC', 'CUC', 'CUP', 'CVE', 'CZK', 'DJF', 'DKK', 'DOP', 'DZD', 'EGP', 'ERN', 'ETB', 'EUR',
|
||||
'FJD', 'FKP', 'GBP', 'GEL', 'GGP', 'GHS', 'GIP', 'GMD', 'GNF', 'GTQ', 'GYD', 'HKD', 'HNL', 'HRK', 'HTG', 'HUF', 'IDR',
|
||||
@@ -682,10 +684,10 @@ class Nexus extends Library
|
||||
/**
|
||||
* Convert a currency
|
||||
*
|
||||
* @param array Info
|
||||
* @param array $info Info
|
||||
* @return int|bool The newly inserted currency, or FALSE on failure
|
||||
*/
|
||||
public function convertNexusCurrency( $info )
|
||||
public function convertNexusCurrency( array $info ) : bool|int
|
||||
{
|
||||
if ( !isset( $info['code'] ) )
|
||||
{
|
||||
@@ -725,7 +727,7 @@ class Nexus extends Library
|
||||
* @param array $info Info
|
||||
* @return int|bool The newly inserted note ID, or FALSE on failure
|
||||
*/
|
||||
public function convertNexusNote( $info )
|
||||
public function convertNexusNote( array $info ) : bool|int
|
||||
{
|
||||
$hasId = TRUE;
|
||||
if ( !isset( $info['note_id'] ) )
|
||||
@@ -809,7 +811,7 @@ class Nexus extends Library
|
||||
* @param string|NULL $filedata Raw filedata for the groups cover photo, or NULL
|
||||
* @return int|bool THe ID of the newly inserted package group, or FALSE on failure
|
||||
*/
|
||||
public function convertNexusPackageGroup( $info, $filepath=NULL, $filedata=NULL )
|
||||
public function convertNexusPackageGroup( array $info, ?string $filepath=NULL, ?string $filedata=NULL ) : bool|int
|
||||
{
|
||||
if ( !isset( $info['pg_id'] ) )
|
||||
{
|
||||
@@ -898,7 +900,7 @@ class Nexus extends Library
|
||||
* @param array $info Info
|
||||
* @return int|bool The ID of the newly inserted payment gateway, or FALSE on failure
|
||||
*/
|
||||
public function convertNexusPaymentMethod( $info )
|
||||
public function convertNexusPaymentMethod( array $info ) : bool|int
|
||||
{
|
||||
/* !Required: ID */
|
||||
if ( !isset( $info['m_id'] ) )
|
||||
@@ -962,7 +964,7 @@ class Nexus extends Library
|
||||
* @param string|NULL $filePath Path to images
|
||||
* @return int|bool The ID of the newly inserted package, or FALSE on failure
|
||||
*/
|
||||
public function convertNexusPackage( $info, $filePath=NULL )
|
||||
public function convertNexusPackage( array $info, ?string $filePath=NULL ) : bool|int
|
||||
{
|
||||
/* !Required: ID */
|
||||
if ( !isset( $info['p_id'] ) )
|
||||
@@ -1025,8 +1027,6 @@ class Nexus extends Library
|
||||
}
|
||||
catch( OutOfRangeException $ex ) { }
|
||||
}, $newGroups );
|
||||
|
||||
$info['p_member_group'] = $info['p_member_group'];
|
||||
}
|
||||
|
||||
/* Primary User Group */
|
||||
@@ -1088,13 +1088,13 @@ class Nexus extends Library
|
||||
$renewals = array();
|
||||
if( isset( $info['p_renew_options'] ) AND count( $info['p_renew_options'] ) )
|
||||
{
|
||||
foreach ( $info['p_renew_options'] as $currency => $options )
|
||||
foreach ( $info['p_renew_options'] as $k => $options )
|
||||
{
|
||||
$newOptions = array(
|
||||
'cost' => [],
|
||||
'term' => $options['term'],
|
||||
'unit' => $options['unit'],
|
||||
'add' => isset( $options['add'] ) ? $options['add'] : false
|
||||
'add' => $options['add'] ?? false
|
||||
);
|
||||
|
||||
foreach ( $options['cost'] as $currency => $cost )
|
||||
@@ -1112,7 +1112,7 @@ class Nexus extends Library
|
||||
/* Discounts */
|
||||
//@TODO
|
||||
|
||||
$productImages = isset( $info['p_images'] ) ? $info['p_images'] : NULL;
|
||||
$productImages = $info['p_images'] ?? NULL;
|
||||
unset( $info['p_images'] );
|
||||
|
||||
$package = array(
|
||||
@@ -1178,7 +1178,7 @@ class Nexus extends Library
|
||||
$default = 0;
|
||||
foreach( $productImages as $image )
|
||||
{
|
||||
if ( ( isset( $image['data'] ) AND is_null( $image['data'] ) ) AND !is_null( $filePath ) )
|
||||
if ( ( isset( $image['data'] ) AND empty( $image['data'] ) ) AND !is_null( $filePath ) )
|
||||
{
|
||||
$filedata = @file_get_contents( rtrim( $filePath, '/' ) . '/' . $image['filename'] );
|
||||
unset( $filepath );
|
||||
@@ -1267,12 +1267,12 @@ class Nexus extends Library
|
||||
* @param string|NULL $filePath Path to images
|
||||
* @return int|bool The ID of the newly inserted package, or FALSE on failure
|
||||
*/
|
||||
public function convertNexusSubscriptionPackage( $info, $filePath=NULL )
|
||||
public function convertNexusSubscriptionPackage( array $info, ?string $filePath=NULL ) : bool|int
|
||||
{
|
||||
/* !Required: ID */
|
||||
if ( !isset( $info['sp_id'] ) )
|
||||
{
|
||||
$this->software->app->log( 'nexus_package_missing_id', __METHOD__, \IPS\convert\App::LOG_WARNING );
|
||||
$this->software->app->log( 'nexus_package_missing_id', __METHOD__, App::LOG_WARNING );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1299,7 +1299,7 @@ class Nexus extends Library
|
||||
/* !Required: Price */
|
||||
if( !isset( $info['sp_price'] ) )
|
||||
{
|
||||
$this->software->app->log( 'nexus_subscription_missing_price', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['sp_id'] );
|
||||
$this->software->app->log( 'nexus_subscription_missing_price', __METHOD__, App::LOG_WARNING, $info['sp_id'] );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1321,7 +1321,7 @@ class Nexus extends Library
|
||||
{
|
||||
$newSecondaryGroups[] = $this->software->app->getLink( $group, 'core_groups', TRUE );
|
||||
}
|
||||
catch( \OutOfRangeException $ex ) { }
|
||||
catch( OutOfRangeException $ex ) { }
|
||||
}, $newSecondaryGroups );
|
||||
}
|
||||
|
||||
@@ -1329,25 +1329,25 @@ class Nexus extends Library
|
||||
{
|
||||
try
|
||||
{
|
||||
$position = \IPS\Db::i()->select( 'MAX(p_position)', 'nexus_subscription_packages' )->first();
|
||||
$position = Db::i()->select( 'MAX(p_position)', 'nexus_subscription_packages' )->first();
|
||||
$info['sp_position'] = $position + 1;
|
||||
}
|
||||
catch( \UnderflowException $e ) { }
|
||||
catch( UnderflowException $e ) { }
|
||||
}
|
||||
|
||||
/* Base Price */
|
||||
if( isset( $info['sp_price'] ) AND \count( $info['sp_price'] ) )
|
||||
if( is_array( $info['sp_price'] ) AND count( $info['sp_price'] ) )
|
||||
{
|
||||
$newOptions = array(
|
||||
'cost' => [],
|
||||
'term' => $info['sp_price']['term'],
|
||||
'unit' => $info['sp_price']['unit'],
|
||||
'add' => isset( $info['sp_price']['add'] ) ? $info['sp_price']['add'] : false
|
||||
'add' => $info['sp_price']['add'] ?? false
|
||||
);
|
||||
|
||||
foreach ( $info['sp_price']['cost'] as $currency => $cost )
|
||||
{
|
||||
$price = new \IPS\nexus\Money( $cost, $currency );
|
||||
$price = new Money( $cost, $currency );
|
||||
$newOptions['cost'][ $currency ] = [ 'amount' => $price->amount, 'currency' => $currency ];
|
||||
}
|
||||
}
|
||||
@@ -1356,25 +1356,25 @@ class Nexus extends Library
|
||||
unset( $info['sp_price'] );
|
||||
|
||||
/* Renewal costs & terms */
|
||||
if( isset( $info['sp_renew_options'] ) AND \count( $info['sp_renew_options'] ) )
|
||||
if( isset( $info['sp_renew_options'] ) AND count( $info['sp_renew_options'] ) )
|
||||
{
|
||||
$newOptions = array(
|
||||
'cost' => [],
|
||||
'term' => $info['sp_renew_options']['term'],
|
||||
'unit' => $info['sp_renew_options']['unit'],
|
||||
'add' => isset( $info['sp_renew_options']['add'] ) ? $info['sp_renew_options']['add'] : false
|
||||
'add' => $info['sp_renew_options']['add'] ?? false
|
||||
);
|
||||
|
||||
foreach ( $info['sp_renew_options']['cost'] as $currency => $cost )
|
||||
{
|
||||
$price = new \IPS\nexus\Money( $cost, $currency );
|
||||
$price = new Money( $cost, $currency );
|
||||
$newOptions['cost'][ $currency ] = [ 'amount' => $price->amount, 'currency' => $currency ];
|
||||
}
|
||||
|
||||
$info['sp_renew_options'] = json_encode( $newOptions );
|
||||
}
|
||||
|
||||
$image = isset( $info['sp_image'] ) ? $info['sp_image'] : NULL;
|
||||
$image = $info['sp_image'] ?? NULL;
|
||||
unset( $info['sp_image'] );
|
||||
|
||||
$package = array(
|
||||
@@ -1396,7 +1396,7 @@ class Nexus extends Library
|
||||
/* Images */
|
||||
if( $image )
|
||||
{
|
||||
if ( ( isset( $image['data'] ) AND \is_null( $image['data'] ) ) AND !\is_null( $filePath ) )
|
||||
if ( ( isset( $image['data'] ) AND empty( $image['data'] ) ) AND !is_null( $filePath ) )
|
||||
{
|
||||
$filedata = @file_get_contents( rtrim( $filePath, '/' ) . '/' . $image['filename'] );
|
||||
unset( $filepath );
|
||||
@@ -1406,20 +1406,20 @@ class Nexus extends Library
|
||||
{
|
||||
try
|
||||
{
|
||||
$info['sp_image'] = (string) \IPS\File::create( 'nexus_Products', $image['filename'], $filedata );
|
||||
$info['sp_image'] = (string) File::create( 'nexus_Products', $image['filename'], $filedata );
|
||||
}
|
||||
catch( \Exception $e ) {}
|
||||
catch( Exception $e ) {}
|
||||
}
|
||||
}
|
||||
|
||||
/* Save Package Data */
|
||||
$insertedId = \IPS\Db::i()->insert( 'nexus_member_subscription_packages', $this->_getValues( $package, $info ) );
|
||||
$insertedId = Db::i()->insert( 'nexus_member_subscription_packages', $this->_getValues( $package, $info ) );
|
||||
$originalId = $info['sp_id'];
|
||||
unset( $info['sp_id'] );
|
||||
|
||||
/* Custom lang strings */
|
||||
\IPS\Lang::saveCustom( 'nexus', "nexus_subs_{$insertedId}", $name );
|
||||
\IPS\Lang::saveCustom( 'nexus', "nexus_subs_{$insertedId}_desc", $description );
|
||||
Lang::saveCustom( 'nexus', "nexus_subs_{$insertedId}", $name );
|
||||
Lang::saveCustom( 'nexus', "nexus_subs_{$insertedId}_desc", $description );
|
||||
|
||||
/* Add Link */
|
||||
$this->software->app->addLink( $insertedId, $originalId, 'nexus_members_subs_pkg' );
|
||||
@@ -1434,7 +1434,7 @@ class Nexus extends Library
|
||||
* @param string $currency Invoice Currency
|
||||
* @return int|bool The ID of the newly inserted invoice, or FALSE on failure
|
||||
*/
|
||||
public function convertNexusInvoice( $info, $currency )
|
||||
public function convertNexusInvoice( array $info, string $currency ) : bool|int
|
||||
{
|
||||
/* !Required: ID */
|
||||
if ( !isset( $info['i_id'] ) )
|
||||
@@ -1535,7 +1535,7 @@ class Nexus extends Library
|
||||
* @param string $currency Transaction Currency
|
||||
* @return int|bool The ID of the newly inserted transaction, or FALSE on failure
|
||||
*/
|
||||
public function convertNexusTransaction( $info, $currency )
|
||||
public function convertNexusTransaction( array $info, string $currency ) : bool|int
|
||||
{
|
||||
/* !Required: ID */
|
||||
if ( !isset( $info['t_id'] ) )
|
||||
@@ -1645,7 +1645,7 @@ class Nexus extends Library
|
||||
* @param string $currency Transaction Currency
|
||||
* @return int|bool The ID of the newly inserted purchase, or FALSE on failure
|
||||
*/
|
||||
public function convertNexusPurchase( $info, $currency )
|
||||
public function convertNexusPurchase( array $info, string $currency ) : bool|int
|
||||
{
|
||||
/* !Required: ID */
|
||||
if ( !isset( $info['ps_id'] ) )
|
||||
@@ -1807,7 +1807,7 @@ class Nexus extends Library
|
||||
* @param array $source User-supplied array
|
||||
* @return array
|
||||
*/
|
||||
protected function _getValues( array $defaults, array $source )
|
||||
protected function _getValues( array $defaults, array $source ) : array
|
||||
{
|
||||
array_walk( $defaults, function( &$value, $key, $source )
|
||||
{
|
||||
@@ -1823,10 +1823,10 @@ class Nexus extends Library
|
||||
/**
|
||||
* Check whether a given payment method is supported by Commerce
|
||||
*
|
||||
* @param $method
|
||||
* @param string $method
|
||||
* @return bool
|
||||
*/
|
||||
protected function _isPaymentMethodSupported( $method )
|
||||
protected function _isPaymentMethodSupported( string $method ) : bool
|
||||
{
|
||||
$availableGateways = Gateway::gateways();
|
||||
$methodKey = array_search( $method, array_keys( array_change_key_case( $availableGateways, CASE_LOWER ) ) );
|
||||
|
||||
Reference in new issue
Block a user