Version 4.1.19

This commit is contained in:
Neo committed 2025-12-19 05:38:56 -08:00
1 parent 28bd025b35
commit 2bd5025018
2674 files changed
+233518 -77766

No files matched your search

@@ -2,9 +2,9 @@
/**
* @brief Packages
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @subpackage Nexus
* @since 29 Apr 2014
* @version SVN_VERSION_NUMBER
@@ -61,15 +61,16 @@ class _packages extends \IPS\Node\Controller
/**
* Redirect after save
*
* @param \IPS\Node\Model $old A clone of the node as it was before or NULL if this is a creation
* @param \IPS\Node\Model $node The node now
* @param \IPS\Node\Model $old A clone of the node as it was before or NULL if this is a creation
* @param \IPS\Node\Model $new The node now
* @param string $lastUsedTab The tab last used in the form
* @return void
*/
protected function _afterSave( \IPS\Node\Model $old = NULL, \IPS\Node\Model $new )
protected function _afterSave( \IPS\Node\Model $old = NULL, \IPS\Node\Model $new, $lastUsedTab = FALSE )
{
if ( !( $new instanceof \IPS\nexus\Package ) )
{
return parent::_afterSave( $old, $new );
return parent::_afterSave( $old, $new, $lastUsedTab );
}
$changes = array();
@@ -84,18 +85,21 @@ class _packages extends \IPS\Node\Controller
}
}
/* Clear cache */
unset( \IPS\Data\Store::i()->nexusPackagesWithReviews );
/* If something has changed, see if anyone has purchased */
$purchases = 0;
if( count( $changes ) )
{
$purchases = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_app=? AND ps_type=? AND ps_item_id=?', 'nexus', 'package', $new->id ) )->first();
}
}
/* Only show this screen if the package has been purchased. Otherwise even just copying a package and saving asks if you want to update
existing purchases unnecessarily */
if ( !empty( $changes ) AND $purchases )
{
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->decision( 'product_change_blurb', array(
'product_change_blurb_existing' => \IPS\Http\Url::internal( "app=nexus&module=store&controller=packages&do=updateExisting&id={$new->_id}" )->setQueryString( 'changes', json_encode( $changes ) ),
'product_change_blurb_new' => $this->url->setQueryString( array( 'root' => ( $new->parent() ? $new->parent()->_id : '' ) ) ),
@@ -103,7 +107,7 @@ class _packages extends \IPS\Node\Controller
}
else
{
return parent::_afterSave( $old, $new );
return parent::_afterSave( $old, $new, $lastUsedTab );
}
}
@@ -127,7 +131,7 @@ class _packages extends \IPS\Node\Controller
if ( !isset( \IPS\Request::i()->processing ) )
{
if ( isset( $changes['renew_options'] ) )
if ( isset( $changes['renew_options'] ) and $changes['renew_options'] )
{
$matrix = new \IPS\Helpers\Form\Matrix( 'matrix', 'continue' );
$matrix->manageable = FALSE;
@@ -206,36 +210,78 @@ class _packages extends \IPS\Node\Controller
{
$renewOptions = json_decode( $changes['renew_options'], TRUE );
$changes['renew_options'] = array();
foreach ( $renewOptions as $k => $data )
if( !empty( $renewOptions ) )
{
$changes['renew_options'][ $k ] = array( 'old' => $data, 'new' => $values[ $k ]['now_pay'] );
foreach ( $renewOptions as $k => $data )
{
$changes['renew_options'][ $k ] = array( 'old' => $data, 'new' => $values[ $k ]['now_pay'] );
}
}
$changes['renew_options']['x'] = array( 'old' => 'x', 'new' => $values['x']['now_pay'] );
}
else
{
\IPS\Output::i()->output = $matrix;
{
\IPS\Output::i()->output .= $matrix;
return;
}
}
}
if ( isset( $changes['renew_options'] ) and !isset( \IPS\Request::i()->ba ) )
{
$needBaPrompt = FALSE;
foreach ( $changes['renew_options'] as $ro )
{
if ( !in_array( $ro['new'], array( '-', 'x', 'y', 'z' ) ) )
{
$needBaPrompt = TRUE;
break;
}
}
if ( $needBaPrompt and $withBillingAgreement = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_app=? AND ps_type=? AND ps_item_id=? AND ps_billing_agreement>0 AND ba_canceled=0', 'nexus', 'package', $package->id ) )->join( 'nexus_billing_agreements', 'ba_id=ps_billing_agreement' )->first() )
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->decision( 'change_renew_ba_blurb', array(
'change_renew_ba_skip' => \IPS\Http\Url::internal( "app=nexus&module=store&controller=packages&do=updateExisting" )->setQueryString( array(
'id' => \IPS\Request::i()->id,
'changes' => json_encode( $changes ),
'processing'=> 1,
'ba' => 0
) ),
'change_renew_ba_cancel' => \IPS\Http\Url::internal( "app=nexus&module=store&controller=packages&do=updateExisting" )->setQueryString( array(
'id' => \IPS\Request::i()->id,
'changes' => json_encode( $changes ),
'processing'=> 1,
'ba' => 1
) ),
'change_renew_ba_go_back' => \IPS\Http\Url::internal( "app=nexus&module=store&controller=packages&do=updateExisting" )->setQueryString( array(
'id' => \IPS\Request::i()->id,
'changes' => \IPS\Request::i()->changes,
) ),
) );
return;
}
}
\IPS\Output::i()->output = new \IPS\Helpers\MultipleRedirect(
\IPS\Http\Url::internal( "app=nexus&module=store&controller=packages&do=updateExisting&id=1&changes=secondary_group" )->setQueryString( array(
'id' => \IPS\Request::i()->id,
'changes' => json_encode( $changes ),
'processing'=> 1
'processing'=> 1,
'ba' => isset( \IPS\Request::i()->ba ) ? \IPS\Request::i()->ba : 0
) ),
function( $offset ) use ( $package, $changes )
{
$select = \IPS\Db::i()->select( '*', 'nexus_purchases', array( "ps_app=? and ps_type=? and ps_item_id=?", 'nexus', 'package', $package->id ), 'ps_id', array( $offset, 1 ), NULL, NULL, \IPS\DB::SELECT_SQL_CALC_FOUND_ROWS );
$offset = intval( $offset );
$select = \IPS\Db::i()->select( '*', 'nexus_purchases', array( "ps_app=? and ps_type=? and ps_item_id=?", 'nexus', 'package', $package->id ), 'ps_id', array( $offset, 1 ), NULL, NULL, \IPS\Db::SELECT_SQL_CALC_FOUND_ROWS );
try
{
$purchase = \IPS\nexus\Purchase::constructFromData( $select->first() );
$total = $select->count( TRUE );
$package->updatePurchase( $purchase, $changes );
$package->updatePurchase( $purchase, $changes, \IPS\Request::i()->ba );
return array( ++$offset, \IPS\Member::loggedIn()->language()->get('processing'), 100 / $total * $offset );
}
@@ -331,7 +377,7 @@ class _packages extends \IPS\Node\Controller
*
* @return void
*/
protected function view_purchases()
protected function viewPurchases()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'purchases_view', 'nexus', 'customers' );
@@ -344,7 +390,7 @@ class _packages extends \IPS\Node\Controller
\IPS\Output::i()->error( 'node_error', '2X249/2', 404, '' );
}
$table = new \IPS\Helpers\Table\Db( 'nexus_purchases', \IPS\Http\Url::internal( "app=nexus&module=store&controller=packages&do=view_purchases&id={$package->id}" ), array( array( 'ps_app=? AND ps_type=? AND ps_item_id=?', 'nexus', 'package', $package->id ) ) );
$table = new \IPS\Helpers\Table\Db( 'nexus_purchases', \IPS\Http\Url::internal( "app=nexus&module=store&controller=packages&do=viewPurchases&id={$package->id}" ), array( array( 'ps_app=? AND ps_type=? AND ps_item_id=?', 'nexus', 'package', $package->id ) ) );
$table->include = array( 'ps_id', 'ps_member', 'purchase_status', 'ps_start', 'ps_expire', 'ps_renewals' );
$table->quickSearch = 'ps_id';
$table->advancedSearch = array(
@@ -356,7 +402,14 @@ class _packages extends \IPS\Node\Controller
$table->filters = array( 'active' => 'ps_active=1' );
$table->parsers = array(
'ps_member' => function( $val ) {
return \IPS\nexus\Customer::load( $val )->link();
try
{
return \IPS\nexus\Customer::load( $val )->link();
}
catch ( \OutOfRangeException $e )
{
return \IPS\Member::loggedIn()->language()->addToStack('deleted_member');
}
},
'purchase_status' => function( $val, $row ) {
$purchase = \IPS\nexus\Purchase::constructFromData( $row );
@@ -368,7 +421,7 @@ class _packages extends \IPS\Node\Controller
{
return \IPS\Member::loggedIn()->language()->addToStack('purchase_expired');
}
elseif ( $purchase->grace_period and $purchase->expire->getTimestamp() < time() )
elseif ( $purchase->grace_period and ( $purchase->expire and $purchase->expire->getTimestamp() < time() ) )
{
return \IPS\Member::loggedIn()->language()->addToStack('purchase_in_grace_period');
}