Version 4.7.13

This commit is contained in:
Neo committed 2025-12-19 16:14:56 -08:00
1 parent fd22d99e69
commit 7124a02564
954 files changed
+29277 -59308

No files matched your search

@@ -244,6 +244,18 @@ class _CustomField extends \IPS\CustomField
return \IPS\Theme::i()->getTemplate( 'forms', 'nexus', 'global' )->usernamePasswordDisplay( $value );
}
/* Select boxes store the value and not the index, but the parent method uses the index to determine the value.
When using numeric options, this causes the wrong value to be returned. */
if( $this->type == 'Select' )
{
if( $this->multiple )
{
return implode( ( $separator ) ? $separator : '<br>', explode( ',', htmlspecialchars( $value, ENT_DISALLOWED | ENT_QUOTES, 'UTF-8', FALSE ) ) );
}
return htmlspecialchars( $value, ENT_DISALLOWED | ENT_QUOTES, 'UTF-8', FALSE );
}
return parent::displayValue( $value, $showSensitiveInformation );
}
@@ -1,84 +0,0 @@
<?php
/**
* @brief Dedicated Server Package
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Nexus
* @since 29 Apr 2014
*/
namespace IPS\nexus\Package;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Dedicated Server Package
*/
class _Dedi extends \IPS\nexus\Package
{
/**
* @brief Icon
*/
public static $icon = 'database';
/**
* @brief Title
*/
public static $title = 'dedicated_server';
/**
* Show Purchase Record?
*
* @return bool
*/
public function showPurchaseRecord()
{
return TRUE;
}
/**
* On Purchase Generated
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @param \IPS\nexus\Invoice $invoice The invoice
* @return void
*/
public function onPurchaseGenerated( \IPS\nexus\Purchase $purchase, \IPS\nexus\Invoice $invoice )
{
try
{
$server = \IPS\nexus\Hosting\Server::load( $purchase->name, 'server_hostname' );
$server->dedicated = $purchase->id;
$server->save();
}
catch ( \OutOfRangeException $e ) { }
return parent::onPurchaseGenerated( $purchase, $invoice );
}
/**
* On Purchase Canceled
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @return void
*/
public function onCancel( \IPS\nexus\Purchase $purchase )
{
try
{
$server = \IPS\nexus\Hosting\Server::load( $purchase->id, 'server_dedicated' );
$server->dedicated = 0;
$server->save();
}
catch ( \OutOfRangeException $e ) { }
return parent::onCancel( $purchase );
}
}
File diff suppressed because it is too large. Load diff
+7 -1
View File
@@ -359,7 +359,13 @@ class _Item extends \IPS\Content\Item implements \IPS\Content\Featurable, \IPS\C
$titles = array();
foreach ( \IPS\Lang::languages() as $lang )
{
$titles[] = $lang->get("nexus_package_{$this->id}");
try
{
$titles[] = $lang->get( "nexus_package_{$this->id}" );
}
catch( \UnderflowException $e )
{
}
}
return implode( ' ', $titles );
}
+57 -9
View File
@@ -83,8 +83,7 @@ class _Package extends \IPS\Node\Model
{
return array(
'Product' => 'IPS\nexus\Package\Product',
'Ad' => 'IPS\nexus\Package\Ad',
'Hosting' => 'IPS\nexus\Package\Hosting',
'Ad' => 'IPS\nexus\Package\Ad'
);
}
@@ -100,14 +99,15 @@ class _Package extends \IPS\Node\Model
public static function constructFromData( $data, $updateMultitonStoreIfExists = TRUE )
{
$types = static::packageTypes();
$classname = $types[ mb_ucfirst( $data['p_type'] ) ];
if ( isset( $classname::$packageDatabaseTable ) )
$classname = isset( $types[ mb_ucfirst( $data['p_type'] ) ] ) ? $types[ mb_ucfirst( $data['p_type'] ) ] : '';
if ( $classname and isset( $classname::$packageDatabaseTable ) )
{
$data = array_merge( $data, \IPS\Db::i()->select( '*', $classname::$packageDatabaseTable, array( 'p_id=?', $data['p_id'] ) )->first() );
}
/* Initiate an object */
$obj = new $classname;
$obj = ( $classname ) ? new $classname : new \IPS\nexus\Package;
$obj->_new = FALSE;
/* Import data */
@@ -230,8 +230,12 @@ class _Package extends \IPS\Node\Model
{
$this->item()->delete();
parent::delete();
\IPS\Db::i()->delete( static::$packageDatabaseTable, array( 'p_id=?', $this->id ) );
if( isset( static::$packageDatabaseTable ) )
{
\IPS\Db::i()->delete( static::$packageDatabaseTable, array( 'p_id=?', $this->id ) );
}
/* Translatables */
foreach ( array( '_assoc', '_page', '_email_purchase_subject', '_email_expire_soon_subject', '_email_expire_subject' ) as $suffix )
{
@@ -746,6 +750,11 @@ class _Package extends \IPS\Node\Model
if ( \count( $renewOptions ) === 1 and isset( $renewOptions[0]['cost'][ $currency ] ) and $renewOptions[0]['cost'][ $currency ]['amount'] == $price and !$renewOptions[0]['add'] )
{
$primaryPrice = new \IPS\nexus\Purchase\RenewalTerm( $primaryPrice, new \DateInterval( "P{$renewOptions[0]['term']}" . mb_strtoupper( $renewOptions[0]['unit'] ) ), $tax );
if ( $initialTerm !== NULL )
{
$initialTerm = ( new \IPS\nexus\Purchase\RenewalTerm( [], $initialTerm ) )->getTermUnit();
}
}
else
{
@@ -1871,13 +1880,27 @@ class _Package extends \IPS\Node\Model
}
$key = 'x';
$childPurchaseRenewalCost = NULL;
if ( $purchase->renewals )
{
/* If the purchase has any child purchases, subtract them from the renewal cost to find the actual cost of this product */
$thisPurchaseRenewalCost = $purchase->renewals->cost->amount;
$childPurchaseRenewalCost = new \IPS\Math\Number( "0" );
foreach( $purchase->children() as $child )
{
if( $child->renewals )
{
$childPurchaseRenewalCost = $childPurchaseRenewalCost->add( $child->renewals->cost->amount );
$thisPurchaseRenewalCost = $thisPurchaseRenewalCost->subtract( $child->renewals->cost->amount );
}
}
foreach ( $changes['renew_options'] as $k => $data )
{
if ( $data['old'] != 'x' )
{
if ( $purchase->renewals->cost->amount->compare( new \IPS\Math\Number( number_format( $data['old']['cost'][ $purchase->renewals->cost->currency ]['amount'], \IPS\nexus\Money::numberOfDecimalsForCurrency( $purchase->renewals->cost->currency ), '.', '' ) ) ) === 0 )
/* Compare against the actual renewal cost */
if ( $thisPurchaseRenewalCost->compare( new \IPS\Math\Number( number_format( $data['old']['cost'][ $purchase->renewals->cost->currency ]['amount'], \IPS\nexus\Money::numberOfDecimalsForCurrency( $purchase->renewals->cost->currency ), '.', '' ) ) ) === 0 )
{
$term = $purchase->renewals->getTerm();
if ( $data['old']['term'] == $term['term'] and $data['old']['unit'] == $term['unit'] )
@@ -1965,13 +1988,38 @@ class _Package extends \IPS\Node\Model
}
$currency = $purchase->renewal_currency ?: $purchase->member->defaultCurrency( );
$originalRenewalCost = $purchase->renewals->cost->amount;
/* If we had child purchases, add back the renewal amounts */
$newRenewalCost = new \IPS\Math\Number( $newRenewTerms[ $key ]['cost'][ $currency ]['amount'] );
if( $childPurchaseRenewalCost !== NULL )
{
$newRenewalCost = $newRenewalCost->add( $childPurchaseRenewalCost );
}
$purchase->renewals = new \IPS\nexus\Purchase\RenewalTerm(
new \IPS\nexus\Money( $newRenewTerms[ $key ]['cost'][ $currency ]['amount'], $currency ),
new \IPS\nexus\Money( $newRenewalCost, $currency ),
new \DateInterval( 'P' . $newRenewTerms[ $key ]['term'] . mb_strtoupper( $newRenewTerms[ $key ]['unit'] ) ),
$tax
);
$purchase->save();
/* If we have a parent purchase, update the renewals for the parent */
if( $parent = $purchase->parent() )
{
if( $parentRenewals = $parent->renewals )
{
$parentRenewalCost = $parentRenewals->cost->amount->subtract( $originalRenewalCost );
$parentRenewalCost = $parentRenewalCost->add( $newRenewalCost );
$parent->renewals = new \IPS\nexus\Purchase\RenewalTerm(
new \IPS\nexus\Money( $parentRenewalCost, $currency ),
$parentRenewals->interval,
$parentRenewals->tax
);
$parent->save();
}
}
}
}
}
@@ -3528,7 +3576,7 @@ class _Package extends \IPS\Node\Model
/* If we're still in the initial period of the new package */
$diff = \IPS\DateTime::create()->diff( $purchase->start->add( $initial ) );
if( $diff->days > 0 )
if( !$diff->invert and $diff->days > 0 )
{
$purchase->expire = $purchase->start->add( $diff );
}