Version 4.7.23

This commit is contained in:
Neo committed 2025-12-19 16:21:27 -08:00
1 parent 7124a02564
commit 25ddeb65d6
1791 files changed
+76990 -44452

No files matched your search

@@ -12,6 +12,11 @@
namespace IPS\nexus\modules\admin\payments;
/* To prevent PHP errors (extending class does not exist) revealing path */
use IPS\Lang;
use IPS\Member;
use function in_array;
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
@@ -85,7 +90,7 @@ class _currencies extends \IPS\Dispatcher\Controller
'default' => $defaults
);
if ( !\in_array( $code, 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', 'ILS', 'IMP', 'INR', 'IQD', 'IRR', 'ISK', 'JEP', 'JMD', 'JOD', 'JPY', 'KES', 'KGS', 'KHR', 'KMF', 'KPW', 'KRW', 'KWD', 'KYD', 'KZT', 'LAK', 'LBP', 'LKR', 'LRD', 'LSL', 'LYD', 'MAD', 'MDL', 'MGA', 'MKD', 'MMK', 'MNT', 'MOP', 'MRO', 'MUR', 'MVR', 'MWK', 'MXN', 'MYR', 'MZN', 'NAD', 'NGN', 'NIO', 'NOK', 'NPR', 'NZD', 'OMR', 'PAB', 'PEN', 'PGK', 'PHP', 'PKR', 'PLN', 'PYG', 'QAR', 'RON', 'RSD', 'RUB', 'RWF', 'SAR', 'SBD', 'SCR', 'SDG', 'SEK', 'SGD', 'SHP', 'SLL', 'SOS', 'SPL*', 'SRD', 'STD', 'SVC', 'SYP', 'SZL', 'THB', 'TJS', 'TMT', 'TND', 'TOP', 'TRY', 'TTD', 'TVD', 'TWD', 'TZS', 'UAH', 'UGX', 'USD', 'UYU', 'UZS', 'VEF', 'VND', 'VUV', 'WST', 'XAF', 'XCD', 'XDR', 'XOF', 'XPF', 'YER', 'ZAR', 'ZMW', 'ZWD' ) ) )
if ( !in_array( $code, 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', 'ILS', 'IMP', 'INR', 'IQD', 'IRR', 'ISK', 'JEP', 'JMD', 'JOD', 'JPY', 'KES', 'KGS', 'KHR', 'KMF', 'KPW', 'KRW', 'KWD', 'KYD', 'KZT', 'LAK', 'LBP', 'LKR', 'LRD', 'LSL', 'LYD', 'MAD', 'MDL', 'MGA', 'MKD', 'MMK', 'MNT', 'MOP', 'MRO', 'MUR', 'MVR', 'MWK', 'MXN', 'MYR', 'MZN', 'NAD', 'NGN', 'NIO', 'NOK', 'NPR', 'NZD', 'OMR', 'PAB', 'PEN', 'PGK', 'PHP', 'PKR', 'PLN', 'PYG', 'QAR', 'RON', 'RSD', 'RUB', 'RWF', 'SAR', 'SBD', 'SCR', 'SDG', 'SEK', 'SGD', 'SHP', 'SLL', 'SOS', 'SPL*', 'SRD', 'STD', 'SVC', 'SYP', 'SZL', 'THB', 'TJS', 'TMT', 'TND', 'TOP', 'TRY', 'TTD', 'TVD', 'TWD', 'TZS', 'UAH', 'UGX', 'USD', 'UYU', 'UZS', 'VEF', 'VND', 'VUV', 'WST', 'XAF', 'XCD', 'XDR', 'XOF', 'XPF', 'YER', 'ZAR', 'ZMW', 'ZWD' ) ) )
{
$warnings .= \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->message( \IPS\Member::loggedIn()->language()->addToStack( 'currency_code_invalid', FALSE, array( 'sprintf' => array( $code ) ) ), 'warning' );
}
@@ -98,7 +103,14 @@ class _currencies extends \IPS\Dispatcher\Controller
'default' => \count( $languages ) === 1 ? TRUE : array_keys( $languages )
);
}
$currencies = json_decode( \IPS\Settings::i()->nexus_currency, true );
if( empty( $currencies ) )
{
$currencies = \IPS\Settings::i()->nexus_currency;
}
$errors = $this->_checkCurrencies( $currencies );
if ( $values = $matrix->values() )
{
$save = array();
@@ -121,28 +133,83 @@ class _currencies extends \IPS\Dispatcher\Controller
}
}
}
\IPS\Settings::i()->changeValues( array( 'nexus_currency' => json_encode( $save ) ) );
foreach ( $definition['columns'] AS $key => $value )
/* Sanity check the final result */
$errors = $this->_checkCurrencies( $save );
if( !$errors )
{
if ( $key === 'id' )
\IPS\Settings::i()->changeValues( array( 'nexus_currency' => json_encode( $save ) ) );
foreach ( $definition['columns'] AS $key => $value )
{
continue;
if ( $key === 'id' )
{
continue;
}
if ( !isset( $save[$key] ) )
{
\IPS\Db::i()->dropColumn( 'nexus_package_base_prices', $key );
}
}
if ( !isset( $save[$key] ) )
\IPS\Session::i()->log( 'acplogs__currencies' );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=payments&controller=paymentsettings&tab=currencies' ) );
}
else
{
/* Clear the elements from the matrix so that they are forced to rebuild.
Otherwise, it hides the last row in the table */
$matrix->elements = null;
}
}
\IPS\Output::i()->output = $errors . $matrix . $warnings;
}
/**
* Sanity check on currency settings
*
* @param array|string $values
* @return string
*/
protected function _checkCurrencies( array|string $values ) : string
{
$errors = '';
/* If we have a string here, then we're good to go, we only have one currency */
if( \is_string( $values ) )
{
return $errors;
}
$languages = Lang::languages();
foreach( array_keys( $languages ) as $langId )
{
$langUsed = 0;
foreach( $values as $code => $defaults )
{
if( in_array( $langId, $defaults ) )
{
\IPS\Db::i()->dropColumn( 'nexus_package_base_prices', $key );
$langUsed++;
}
}
\IPS\Session::i()->log( 'acplogs__currencies' );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=payments&controller=paymentsettings&tab=currencies' ) );
/* If the language doesn't have a default, throw an error */
if( !$langUsed )
{
$errors .= \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->message( \IPS\Member::loggedIn()->language()->addToStack( 'currency_code_lang_missing', FALSE, array( 'sprintf' => array( $languages[ $langId ]->_title ) ) ), 'error' );
}
/* A language can't have more than one default */
if( $langUsed > 1 )
{
$errors .= \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->message( \IPS\Member::loggedIn()->language()->addToStack( 'currency_code_multiple_default', false, array( 'sprintf' => array( $languages[ $langId ]->_title ) ) ), 'error' );
}
}
\IPS\Output::i()->output = $matrix . $warnings;
return $errors;
}
}
@@ -1185,9 +1185,12 @@ class _invoices extends \IPS\Dispatcher\Controller
catch( \Exception $e ) {}
}
}
$invoice->sendNotification();
if ( $data['status'] !== \IPS\nexus\Invoice::STATUS_CANCELED )
{
$invoice->sendNotification();
}
\IPS\Output::i()->redirect( $invoice->acpUrl() );
}
elseif ( isset( \IPS\Request::i()->remove ) )
@@ -268,7 +268,7 @@ class _subscriptions extends \IPS\Node\Controller
}
/* If not, just handle the delete as normal */
return parent::delete();
return parent::delete();
}
/**
@@ -294,7 +294,7 @@ class _subscriptions extends \IPS\Node\Controller
$package->enabled = FALSE;
$package->save();
\IPS\Settings::i()->log( 'aplogs__nexus_sub_hidden', array( "nexus_subs_{$sub->id}" => TRUE ) );
\IPS\Session::i()->log( 'aplogs__nexus_sub_hidden', array( "nexus_subs_{$package->id}" => TRUE ) );
/* Redirect */
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=nexus&module=subscriptions&controller=subscriptions" ) );
@@ -337,12 +337,15 @@ class _subscriptions extends \IPS\Node\Controller
switch ( $newOption['unit'] )
{
case 'd':
$initialTerm = \IPS\Member::loggedIn()->language()->addToStack('renew_days_no_term', FALSE, array( 'pluralize' => array( $newOption['term'] ) ) );
$term = \IPS\Member::loggedIn()->language()->addToStack('renew_days', FALSE, array( 'pluralize' => array( $newOption['term'] ) ) );
break;
case 'm':
$initialTerm = \IPS\Member::loggedIn()->language()->addToStack('renew_months_no_term', FALSE, array( 'pluralize' => array( $newOption['term'] ) ) );
$term = \IPS\Member::loggedIn()->language()->addToStack('renew_months', FALSE, array( 'pluralize' => array( $newOption['term'] ) ) );
break;
case 'y':
$initialTerm = \IPS\Member::loggedIn()->language()->addToStack('renew_years_no_term', FALSE, array( 'pluralize' => array( $newOption['term'] ) ) );
$term = \IPS\Member::loggedIn()->language()->addToStack('renew_years', FALSE, array( 'pluralize' => array( $newOption['term'] ) ) );
break;
}
@@ -350,7 +353,7 @@ class _subscriptions extends \IPS\Node\Controller
$form->add( new \IPS\Helpers\Form\Radio( 'nexus_subs_free_period', NULL, TRUE, [
'options' => [
0 => 'nexus_subs_forever',
1 => \IPS\Member::loggedIn()->language()->addToStack( 'nexus_subs_until_renew', FALSE, [ 'sprintf' => [ $newOption['term'], $term, \IPS\Member::loggedIn()->language()->formatList( $costs, \IPS\Member::loggedIn()->language()->get('or_list_format') ), $term ] ] )
1 => \IPS\Member::loggedIn()->language()->addToStack( 'nexus_subs_until_renew', FALSE, [ 'sprintf' => [ $newOption['term'], $initialTerm, \IPS\Member::loggedIn()->language()->formatList( $costs, \IPS\Member::loggedIn()->language()->get('or_list_format') ), $term ] ] )
]
] ) );
}
@@ -358,7 +361,7 @@ class _subscriptions extends \IPS\Node\Controller
if ( $values = $form->values() )
{
$customer = \IPS\nexus\Customer::load( $values['nexus_subs_member_to_add']->member_id );
$sub = \IPS\nexus\Subscription\Package::load( \IPS\Request::i()->id )->addMember( $customer, TRUE, (bool) $values['nexus_subs_free_period'] );
$sub = \IPS\nexus\Subscription\Package::load( \IPS\Request::i()->id )->addMember( $customer, TRUE, isset( $values[ 'nexus_subs_free_period' ] ) && (bool) $values[ 'nexus_subs_free_period' ] );
$sub->added_manually = 1;
$sub->save();