Version 4.6.0

This commit is contained in:
Neo committed 2025-12-19 05:55:31 -08:00
1 parent f79dcf067a
commit 517a5e1f70
2036 files changed
+110041 -26162

No files matched your search

@@ -88,25 +88,6 @@ class _purchases extends \IPS\Dispatcher\Controller
return;
}
/* Create associated invoices table */
try
{
$originalInvoice = $this->purchase->original_invoice;
$invoices = \IPS\nexus\Invoice::table( array( array( 'i_id=? OR ' . \IPS\Db::i()->findInSet( 'i_renewal_ids', array( $this->purchase->id ) ), $originalInvoice->id ) ), $this->purchase->acpUrl(), "p.{$this->purchase->id}" );
}
catch ( \OutOfRangeException $e )
{
$invoices = \IPS\nexus\Invoice::table( array( array( \IPS\Db::i()->findInSet( 'i_renewal_ids', array( $this->purchase->id ) ) ) ), $this->purchase->acpUrl(), "p.{$this->purchase->id}" );
}
$invoices->filters = array(
'paid' => array( 'i_status=?', \IPS\nexus\Invoice::STATUS_PAID )
);
$invoices->advancedSearch = array(
'i_status' => array( \IPS\Helpers\Table\SEARCH_SELECT, array( 'options' => \IPS\nexus\Invoice::statuses(), 'multiple' => TRUE ) ),
'i_total' => \IPS\Helpers\Table\SEARCH_NUMERIC,
'i_date' => \IPS\Helpers\Table\SEARCH_DATE_RANGE,
);
/* Custom Fields */
$customFields = array();
foreach ( $this->purchase->custom_fields as $k => $v )
@@ -133,7 +114,38 @@ class _purchases extends \IPS\Dispatcher\Controller
/* Display */
\IPS\Output::i()->sidebar['actions'] = $this->purchase->buttons();
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'purchases' )->view( $this->purchase, $customer, $children, $invoices, $customFields );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'purchases' )->view( $this->purchase, $customer, $children, $customFields );
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'admin_members.js', 'core' ) );
}
/**
* Show the associated invoices table for a purchase
*
* @note This is lazy loaded after the purchase page is generated
* @return void
*/
protected function showInvoices()
{
/* Create associated invoices table */
try
{
$originalInvoice = $this->purchase->original_invoice;
$invoices = \IPS\nexus\Invoice::table( array( array( 'i_id=? OR ' . \IPS\Db::i()->findInSet( 'i_renewal_ids', array( $this->purchase->id ) ), $originalInvoice->id ) ), $this->purchase->acpUrl()->setQueryString( 'do', 'showInvoices' ), "p.{$this->purchase->id}" );
}
catch ( \OutOfRangeException $e )
{
$invoices = \IPS\nexus\Invoice::table( array( array( \IPS\Db::i()->findInSet( 'i_renewal_ids', array( $this->purchase->id ) ) ) ), $this->purchase->acpUrl()->setQueryString( 'do', 'showInvoices' ), "p.{$this->purchase->id}" );
}
$invoices->filters = array(
'paid' => array( 'i_status=?', \IPS\nexus\Invoice::STATUS_PAID )
);
$invoices->advancedSearch = array(
'i_status' => array( \IPS\Helpers\Table\SEARCH_SELECT, array( 'options' => \IPS\nexus\Invoice::statuses(), 'multiple' => TRUE ) ),
'i_total' => \IPS\Helpers\Table\SEARCH_NUMERIC,
'i_date' => \IPS\Helpers\Table\SEARCH_DATE_RANGE,
);
\IPS\Output::i()->output = (string) $invoices;
}
/**
@@ -414,6 +426,12 @@ class _purchases extends \IPS\Dispatcher\Controller
\IPS\Dispatcher::i()->checkAcpPermission( 'purchases_cancel' );
\IPS\Session::i()->csrfCheck();
$error = NULL;
if ( !$this->purchase->canAcpReactivate( $error ) )
{
\IPS\Output::i()->error( $error ?? 'can_not_reactivate', '2X195/K', 403, '' );
}
$parent = $this->purchase->parent();
if ( ( $this->purchase->billing_agreement and !$this->purchase->billing_agreement->canceled ) or ( $this->purchase->grouped_renewals and $parent->billing_agreement and !$parent->billing_agreement->canceled ) )
@@ -96,6 +96,13 @@ class _billingagreements extends \IPS\Dispatcher\Controller
{
if ( $billingAgreement->status() == $billingAgreement::STATUS_ACTIVE )
{
\IPS\Output::i()->sidebar['actions']['refresh'] = array(
'icon' => 'refresh',
'title' => 'billing_agreement_check',
'link' => $billingAgreement->acpUrl()->setQueryString( array( 'do' => 'act', 'act' => 'refresh' ) )->csrf(),
'data' => array( 'confirm' => '' )
);
\IPS\Output::i()->sidebar['actions']['suspend'] = array(
'icon' => 'times',
'title' => 'billing_agreement_suspend',
@@ -184,7 +191,7 @@ class _billingagreements extends \IPS\Dispatcher\Controller
/* Check act */
$act = \IPS\Request::i()->act;
if ( !\in_array( $act, array( 'suspend', 'reactivate', 'cancel' ) ) )
if ( !\in_array( $act, array( 'suspend', 'reactivate', 'cancel', 'refresh' ) ) )
{
\IPS\Output::i()->error( 'node_error', '3X320/8', 403, '' );
}
@@ -1368,6 +1368,39 @@ class _invoices extends \IPS\Dispatcher\Controller
\IPS\Output::i()->output = $form;
}
/**
* Track
*
* @return void
*/
protected function track()
{
\IPS\Session::i()->csrfCheck();
try
{
$invoice = \IPS\nexus\Invoice::load( \IPS\Request::i()->id );
if ( \IPS\Request::i()->track )
{
\IPS\Db::i()->insert( 'nexus_invoice_tracker', array(
'member_id' => \IPS\Member::loggedIn()->member_id,
'invoice_id' => $invoice->id
), TRUE );
}
else
{
\IPS\Db::i()->delete( 'nexus_invoice_tracker', array( 'member_id=? AND invoice_id=?', \IPS\Member::loggedIn()->member_id, $invoice->id ) );
}
$this->_redirect( $invoice );
}
catch ( \OutOfRangeException $e )
{
\IPS\Output::i()->error( 'node_error', '2X190/G', 404, '' );
}
}
/**
* Redirect
*
@@ -72,11 +72,16 @@ class _payouts extends \IPS\Dispatcher\Controller
$classname = \IPS\nexus\Gateway::payoutGateways()[ $gateway ];
if ( class_exists( $classname ) and method_exists( $classname, 'massProcess' ) )
{
\IPS\Output::i()->sidebar['actions'][] = array(
\IPS\Output::i()->sidebar['actions'][] = [
'icon' => 'check',
'title' => \IPS\Member::loggedIn()->language()->addToStack( 'account_credit_mass_payout', TRUE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( 'payout__admin_' . $gateway ) ) ) ),
'link' => \IPS\Http\Url::internal( 'app=nexus&module=payments&controller=payouts&do=massprocess&gateway=' . $gateway )->csrf()
);
'link' => \IPS\Http\Url::internal( 'app=nexus&module=payments&controller=payouts&do=massprocess&gateway=' . $gateway )->csrf(),
'data' => [
'confirm' => '',
'confirmMessage' => \IPS\Member::loggedIn()->language()->addToStack( 'nexus_payout_confirm_title' ),
'confirmSubMessage' => \IPS\Member::loggedIn()->language()->addToStack( 'nexus_payout_confirm_text' )
]
];
}
}
}
@@ -156,7 +161,7 @@ class _payouts extends \IPS\Dispatcher\Controller
protected function massprocess()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'payouts_process' );
\IPS\Session::i()->csrfCheck();
\IPS\Request::i()->confirmedDelete( 'nexus_payout_confirm_title', 'nexus_payout_confirm_text', 'nexus_payout_proceed' );
$classname = \IPS\nexus\Gateway::payoutGateways()[ \IPS\Request::i()->gateway ];
if ( !class_exists( $classname ) or !method_exists( $classname, 'massProcess' ) )
@@ -301,7 +306,7 @@ class _payouts extends \IPS\Dispatcher\Controller
$form = new \IPS\Helpers\Form;
$form->addMessage('payout_description');
$form->addHeader('commission_settings');
$form->add( new \IPS\Helpers\Form\Select( 'nexus_no_commission', explode( ',', \IPS\Settings::i()->nexus_no_commission ), FALSE, array( 'multiple' => TRUE, 'options' => $groups ) ) );
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'nexus_no_commission', explode( ',', \IPS\Settings::i()->nexus_no_commission ), FALSE, array( 'multiple' => TRUE, 'options' => $groups ) ) );
$form->addHeader('withdrawal_methods');
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'nexus_payout', $settings, FALSE, array( 'options' => $options, 'toggles' => $toggles ) ) );
foreach ( $fields as $field )
@@ -319,10 +324,13 @@ class _payouts extends \IPS\Dispatcher\Controller
} ), NULL, NULL, NULL, 'nexus_payout_maximum' ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'nexus_payout_approve', \IPS\Settings::i()->nexus_payout_approve, FALSE, array(), NULL, NULL, NULL, 'nexus_payout_approve' ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'nexus_payout_unlimited_times', \IPS\Settings::i()->nexus_payout_unlimited_times, TRUE ) );
$form->addHeader('topup_settings');
$form->add( new \IPS\Helpers\Form\YesNo( 'allow_topups', \IPS\Settings::i()->nexus_min_topup, FALSE, array( 'togglesOn' => array( 'nexus_min_topup', 'nexus_max_credit' ) ) ) );
$form->add( new \IPS\nexus\Form\Money( 'nexus_min_topup', \IPS\Settings::i()->nexus_min_topup ?: '*', FALSE, array( 'unlimitedLang' => 'no_restriction' ), NULL, NULL, NULL, 'nexus_min_topup' ) );
$form->add( new \IPS\nexus\Form\Money( 'nexus_max_credit', \IPS\Settings::i()->nexus_max_credit ?: '*', FALSE, array( 'unlimitedLang' => 'no_restriction' ), NULL, NULL, NULL, 'nexus_max_credit' ) );
if ( $values = $form->values() )
{
$payoutSettings = array();
@@ -65,7 +65,7 @@ class _shippingrates extends \IPS\Node\Controller
* @param string $lastUsedTab The tab last used in the form
* @return void
*/
protected function _afterSave( \IPS\Node\Model $old = NULL, \IPS\Node\Model $new, $lastUsedTab = FALSE )
protected function _afterSave( ?\IPS\Node\Model $old, \IPS\Node\Model $new, $lastUsedTab = FALSE )
{
$haveNoLowerLimit = FALSE;
$haveNoUpperLimit = FALSE;
@@ -27,6 +27,11 @@ class _income extends \IPS\Dispatcher\Controller
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* @brief Allow MySQL RW separation for efficiency
*/
public static $allowRWSeparation = TRUE;
/**
* Execute
@@ -27,6 +27,11 @@ class _markets extends \IPS\Dispatcher\Controller
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* @brief Allow MySQL RW separation for efficiency
*/
public static $allowRWSeparation = TRUE;
/**
* Execute
@@ -83,7 +88,7 @@ class _markets extends \IPS\Dispatcher\Controller
foreach ( \IPS\GeoLocation::$countries as $countryCode )
{
$chart->addSeries( \IPS\Member::loggedIn()->language()->get( 'country-' . $countryCode ), 'number', $activeTab === 'count' ? 'COUNT(*)' : 'SUM(i_total)', TRUE, $countryCode );
$chart->addSeries( [ 'value' => \IPS\Member::loggedIn()->language()->get( 'country-' . $countryCode ), 'key' => $countryCode ], 'number', $activeTab === 'count' ? 'COUNT(*)' : 'SUM(i_total)', TRUE, $countryCode );
}
if ( $chart->type === 'GeoChart' )
@@ -27,6 +27,11 @@ class _purchases extends \IPS\Dispatcher\Controller
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* @brief Allow MySQL RW separation for efficiency
*/
public static $allowRWSeparation = TRUE;
/**
* Execute
@@ -77,7 +77,7 @@ class _fields extends \IPS\Node\Controller
* @param string $lastUsedTab The tab last used in the form
* @return void
*/
protected function _afterSave( \IPS\Node\Model $old = NULL, \IPS\Node\Model $new, $lastUsedTab = FALSE )
protected function _afterSave( ?\IPS\Node\Model $old, \IPS\Node\Model $new, $lastUsedTab = FALSE )
{
if ( $old AND $old->extra != $new->extra )
{
@@ -89,7 +89,7 @@ class _packages extends \IPS\Node\Controller
* @param string $lastUsedTab The tab last used in the form
* @return void
*/
protected function _afterSave( \IPS\Node\Model $old = NULL, \IPS\Node\Model $new, $lastUsedTab = FALSE )
protected function _afterSave( ?\IPS\Node\Model $old, \IPS\Node\Model $new, $lastUsedTab = FALSE )
{
if ( !( $new instanceof \IPS\nexus\Package ) )
{
@@ -777,7 +777,7 @@ class _packages extends \IPS\Node\Controller
try
{
$themeFunction = 'IPS\\Theme\\'. $functionName;
$output = \IPS\Email::buildFromContent( 'Test', $themeFunction( $dummyPurchase ) )->compileContent( 'html', \IPS\Member::loggedIn() );
$output = \IPS\Email::buildFromContent( 'Test', $themeFunction( $dummyPurchase ), NULL, \IPS\Email::TYPE_TRANSACTIONAL )->compileContent( 'html', \IPS\Member::loggedIn() );
}
catch ( \Exception $e )
{
@@ -91,7 +91,7 @@ class _settings extends \IPS\Dispatcher\Controller
$form->addTab( 'nexus_purchase_settings' );
$form->add( new \IPS\Helpers\Form\YesNo( 'nexus_reg_force', \IPS\Settings::i()->nexus_reg_force, FALSE ) );
$form->add( new \IPS\nexus\Form\Money( 'nexus_minimum_order', json_decode( \IPS\Settings::i()->nexus_minimum_order, TRUE ) ) );
$form->add( new \IPS\Helpers\Form\Select( 'cm_protected', explode( ',', \IPS\Settings::i()->cm_protected ), FALSE, array( 'options' => $groups, 'multiple' => TRUE ) ) );
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'cm_protected', explode( ',', \IPS\Settings::i()->cm_protected ), FALSE, array( 'options' => $groups, 'multiple' => TRUE ) ) );
$form->addTab('nexus_gift_vouchers');
$form->add( new \IPS\Helpers\Form\Stack( 'nexus_gift_vouchers', $giftVouchers, FALSE, array( 'stackFieldType' => 'IPS\nexus\Form\Money' ) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'nexus_gift_vouchers_free', \IPS\Settings::i()->nexus_gift_vouchers_free ) );
@@ -356,8 +356,8 @@ class _subscriptions extends \IPS\Node\Controller
$form->add( new \IPS\Helpers\Form\YesNo( 'nexus_subs_enabled', \IPS\Settings::i()->nexus_subs_enabled, FALSE, array(), NULL, NULL, NULL, 'nexus_subs_enabled' ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'nexus_subs_register', \IPS\Settings::i()->nexus_subs_register, FALSE, array(), NULL, NULL, NULL, 'nexus_subs_register' ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'nexus_subs_show_public', \IPS\Settings::i()->nexus_subs_show_public, FALSE, array(), NULL, NULL, NULL, 'nexus_subs_show_public' ) );
$form->add( new \IPS\Helpers\Form\Interval( 'nexus_subs_invoice_grace', \IPS\Settings::i()->nexus_subs_invoice_grace, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::DAYS ), NULL, NULL, NULL, 'nexus_subs_invoice_grace' ) );
$form->add( new \IPS\Helpers\Form\Select( 'nexus_subs_exclude_groups', explode( ',', \IPS\Settings::i()->nexus_subs_exclude_groups ), FALSE, array( 'options' => $groups, 'multiple' => TRUE ) ) );
$form->add( new \IPS\Helpers\Form\Interval( 'nexus_subs_invoice_grace', \IPS\Settings::i()->nexus_subs_invoice_grace ?: 0, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::DAYS, 'min' => NULL ), NULL, NULL, NULL, 'nexus_subs_invoice_grace' ) );
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'nexus_subs_exclude_groups', explode( ',', \IPS\Settings::i()->nexus_subs_exclude_groups ), FALSE, array( 'options' => $groups, 'multiple' => TRUE ) ) );
$form->addHeader('package_upgrade_downgrade');
@@ -411,7 +411,7 @@ class _subscriptions extends \IPS\Node\Controller
* @param string $lastUsedTab The tab last used in the form
* @return void
*/
protected function _afterSave( \IPS\Node\Model $old = NULL, \IPS\Node\Model $new, $lastUsedTab = FALSE )
protected function _afterSave( ?\IPS\Node\Model $old, \IPS\Node\Model $new, $lastUsedTab = FALSE )
{
$changes = array();
if ( $old )
@@ -526,7 +526,7 @@ class _requests extends \IPS\Dispatcher\Controller
$form->addMessage( 'support_notify_blurb' );
foreach ( $types as $k => $t )
{
$form->add( new \IPS\Helpers\Form\Select( $k, isset( $existing[ $t ] ) ? ( $existing[ $t ] === '*' ? 0 : explode( ',', $existing[ $t ] ) ) : NULL, FALSE, array( 'options' => $myDepartments, 'multiple' => TRUE, 'unlimited' => 0, 'unlimitedLang' => 'all', 'noDefault' => TRUE ) ) );
$form->add( new \IPS\Helpers\Form\CheckboxSet( $k, isset( $existing[ $t ] ) ? ( $existing[ $t ] === '*' ? 0 : explode( ',', $existing[ $t ] ) ) : NULL, FALSE, array( 'options' => $myDepartments, 'multiple' => TRUE, 'unlimited' => 0, 'unlimitedLang' => 'all', 'noDefault' => TRUE, 'impliedUnlimited' => TRUE ) ) );
}
if ( $values = $form->values() )