Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

+126 -13
View File
@@ -12,7 +12,7 @@
namespace IPS\nexus;
/* 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;
@@ -50,7 +50,7 @@ class _Application extends \IPS\Application
$subscription = \IPS\Db::i()->select( '*', 'nexus_subscriptions', array( 's_gateway_key=? AND s_id=?', 'paypalpro', \IPS\Request::i()->recurring_payment_id ) )->first();
}
$items = \unserialize( $subscription['s_items'] );
if ( !is_array( $items ) or empty( $items ) )
if ( !\is_array( $items ) or empty( $items ) )
{
/* Don't exit here, throw an underflow exception so we can see if this is a legacy subscription */
throw new \UnderflowException( 'NO_ITEMS' );
@@ -64,14 +64,14 @@ class _Application extends \IPS\Application
if ( mb_strstr( \IPS\Request::i()->custom, '-' ) !== FALSE )
{
$exploded = explode( '-', \IPS\Request::i()->custom );
$memberId = intval( $exploded[0] );
$purchaseId = intval( $exploded[1] );
$memberId = \intval( $exploded[0] );
$purchaseId = \intval( $exploded[1] );
$item = \IPS\Db::i()->select( '*', 'nexus_purchases', array( "ps_id=?", $purchaseId ), 'ps_id' )->first();
}
else
{
$memberId = intval( \IPS\Request::i()->custom );
$memberId = \intval( \IPS\Request::i()->custom );
$item = \IPS\Db::i()->select( '*', 'nexus_purchases', array( "ps_member=? AND ps_name=?", $memberId, \IPS\Request::i()->item_name ), 'ps_start DESC' )->first();
}
@@ -136,7 +136,7 @@ class _Application extends \IPS\Application
$invoice = \IPS\nexus\Invoice::constructFromData( \IPS\Db::i()->select( '*', 'nexus_invoices', array( 'i_member=? AND i_status=?', $subscription['s_member'], 'pend' ), 'i_date DESC', 1 )->first() );
foreach ( $invoice->items as $item )
{
if ( $item instanceof \IPS\nexus\Invoice\Item\Renewal and in_array( $item->id, $_items ) )
if ( $item instanceof \IPS\nexus\Invoice\Item\Renewal and \in_array( $item->id, $_items ) )
{
unset( $_items[ array_search( $item->id, $_items ) ] );
}
@@ -145,7 +145,7 @@ class _Application extends \IPS\Application
catch ( \UnderflowException $e ) { }
/* No, create one */
if ( count( $_items ) )
if ( \count( $_items ) )
{
$invoice = new \IPS\nexus\Invoice;
$invoice->member = \IPS\nexus\Customer::load( $subscription['s_member'] );
@@ -161,7 +161,7 @@ class _Application extends \IPS\Application
}
catch ( \OutOfRangeException $e ) { }
}
if ( !count( $invoice->items ) )
if ( !\count( $invoice->items ) )
{
exit;
}
@@ -194,6 +194,66 @@ class _Application extends \IPS\Application
exit;
}
}
/**
* Install Other
*
* @return void
*/
public function installOther()
{
/* Disable hosting support for new installations */
\IPS\Db::i()->update( 'core_modules', array( 'sys_module_visible' => 0 ), array( 'sys_module_application=? AND sys_module_key=? AND sys_module_area=?', 'nexus', 'hosting', 'admin' ) );
}
/**
* Returns the ACP Menu JSON for this application.
*
* @return array
*/
public function acpMenu()
{
$menu = parent::acpMenu();
if( $m = \IPS\Application\Module::get( 'nexus', 'hosting', 'admin' ) AND $m->visible )
{
$menu['hosting'] = array(
'queues' => array(
'tab' => 'nexus',
'controller' => 'queues',
'do' => '',
'restriction' => 'queues_manage'
),
'servers' => array(
'tab' => 'nexus',
'controller' => 'servers',
'do' => '',
'restriction' => 'servers_manage'
),
'monitoring' => array(
'tab' => 'nexus',
'controller' => 'monitoring',
'do' => '',
'restriction' => null
),
'errors' => array(
'tab' => 'nexus',
'controller' => 'errors',
'do' => '',
'restriction' => 'errors_manage'
),
'settings' => array(
'tab' => 'nexus',
'controller' => 'settings',
'do' => '',
'restriction' => 'settings_manage'
)
);
}
return $menu;
}
/**
* @brief Cached menu counts
@@ -214,7 +274,7 @@ class _Application extends \IPS\Application
case 'transactions':
if( !isset( $this->menuCounts['transactions'] ) )
{
$this->menuCounts['transactions'] = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_transactions', array( '( t_status=? OR t_status=? OR t_status=? )', \IPS\nexus\Transaction::STATUS_HELD, \IPS\nexus\Transaction::STATUS_REVIEW, \IPS\nexus\Transaction::STATUS_DISPUTED ) )->first();
$this->menuCounts['transactions'] = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_transactions', array( \IPS\Db::i()->in( 't_status', array( \IPS\nexus\Transaction::STATUS_HELD, \IPS\nexus\Transaction::STATUS_WAITING, \IPS\nexus\Transaction::STATUS_REVIEW, \IPS\nexus\Transaction::STATUS_DISPUTED ) ) ) )->first();
}
return $this->menuCounts['transactions'];
break;
@@ -294,12 +354,17 @@ class _Application extends \IPS\Application
*/
public function allowGuestAccess( \IPS\Application\Module $module, $controller, $do )
{
if( ( \IPS\Settings::i()->nexus_reg_force OR \IPS\Db::i()->select( 'COUNT(*)', 'nexus_packages', 'p_reg=1' )->first() ) AND ( $module->key == 'store' OR $module->key == 'checkout' ) )
if( ( \IPS\Settings::i()->nexus_reg_force OR \IPS\nexus\Package::haveRegistrationProducts() ) AND ( $module->key == 'store' OR $module->key == 'checkout' ) )
{
return TRUE;
}
if ( \IPS\Settings::i()->nexus_subs_register AND ( $module->key == 'store' OR $module->key == 'checkout' ) )
if ( \IPS\Settings::i()->nexus_subs_register AND ( \in_array( $module->key, [ 'store', 'checkout', 'subscriptions' ] ) ) )
{
return TRUE;
}
if ( \IPS\Settings::i()->cm_ref_on AND $module->key == 'promotion' AND $controller == 'referral' )
{
return TRUE;
}
@@ -335,13 +400,15 @@ class _Application extends \IPS\Application
array(
'key' => 'Store',
'children' => array(
array( 'key' => 'Store' ),
array( 'key' => 'Gifts' ),
array( 'key' => 'Subscriptions' ),
array( 'key' => 'Donations' ),
array( 'key' => 'Orders' ),
array( 'key' => 'Purchases' ),
array(
'app' => 'core',
'key' => 'Menu',
'app' => 'core',
'key' => 'Menu',
'title' => 'default_menu_item_my_details',
'children' => array(
array( 'key' => 'Info' ),
@@ -373,6 +440,35 @@ class _Application extends \IPS\Application
}
/**
* Get Extensions - Deprecate Hosting Utilities
*
* @param \IPS\Application|string $app The app key of the application which owns the extension
* @param string $extension Extension Type
* @param bool $construct Should an object be returned? (If false, just the classname will be returned)
* @param \IPS\Member|\IPS\Member\Group|bool $checkAccess Check access permission for extension against supplied member/group (or logged in member, if TRUE)
* @return array
*/
public function extensions( $app, $extension, $construct=TRUE, $checkAccess=FALSE )
{
$extensions = parent::extensions( $app, $extension, $construct, $checkAccess );
/* If Item extension and hosting support is hidden, we'll need to remove the hosting specific items that are deprecated */
if( $extension == 'Item' AND $m = \IPS\Application\Module::get( 'nexus', 'hosting', 'admin' ) AND !$m->visible )
{
$deprecated = array( 'Bandwidth', 'DedicatedServer', 'Domain' );
foreach( $extensions as $key => $class )
{
if( \in_array( $key, $deprecated ) )
{
unset( $extensions[ $key ] );
}
}
}
return $extensions;
}
/**
* Perform some legacy URL parameter conversions
*
* @return void
@@ -391,4 +487,21 @@ class _Application extends \IPS\Application
\IPS\Request::i()->validate = 'paypal';
}
}
/**
* Return an array of specific links to add to the sitemap
*
* @return array
*/
public function sitemapLinks()
{
$return = array( \IPS\Http\Url::internal( 'app=nexus&module=store&controller=store', 'front', 'store' ) );
if( \IPS\Settings::i()->nexus_subs_enabled )
{
$return[] = \IPS\Http\Url::internal( 'app=nexus&module=subscriptions&controller=subscriptions', 'front', 'nexus_subscriptions' );
}
return $return;
}
}