Version 4.2.0

This commit is contained in:
Neo committed 2025-12-19 05:44:59 -08:00
1 parent 0dc2aee5ed
commit 96997ddd8e
2074 files changed
+125454 -55780

No files matched your search

@@ -1,13 +1,12 @@
<?php
/**
* @brief License Key Model
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @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 30 Apr 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\nexus\Purchase;
@@ -1,13 +1,12 @@
<?php
/**
* @brief License Key Model - MD5
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @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 30 Apr 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\nexus\Purchase\LicenseKey;
@@ -1,13 +1,12 @@
<?php
/**
* @brief License Key Model - Standard
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @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 30 Apr 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\nexus\Purchase\LicenseKey;
@@ -1,13 +1,12 @@
<?php
/**
* @brief Purchase Model
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @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 10 Feb 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\nexus;
@@ -1047,7 +1046,7 @@ class _Purchase extends \IPS\Node\Model
* @param \IPS\Member|NULL $member The member to check (NULL for currently logged in member)
* @return bool
*/
public function canView( \IPS\Member $member = NULL )
public function canView( $member = NULL )
{
$member = $member ?: \IPS\Member::loggedIn();
@@ -1,13 +1,12 @@
<?php
/**
* @brief Renewal Term Object
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @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 13 Feb 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\nexus\Purchase;
@@ -249,6 +248,67 @@ class _RenewalTerm
return sprintf( \IPS\Member::loggedIn()->language()->get( 'renew_option'), $cost, $this->getTermUnit() );
}
/**
* Get difference between this term and another
*
* @param \IPS\nexus\Purchase\RenewalTerm $otherTerm The other term
* @param bool $returnAsPercentage If TRUE, will return percentage difference rather than money amount
* @return \IPS\nexus\Money|\IPS\Math\Number
*/
public function diff( $otherTerm, $returnAsPercentage = FALSE )
{
/* Sanity check */
if ( $this->cost->currency !== $otherTerm->cost->currency )
{
throw new \DomainException('currencies_dont_match');
}
/* Try to normalise the terms so we can work off multiplying - we want to either be dealing in days or months */
$thisTermDetails = $this->getTerm();
$otherTermDetails = $otherTerm->getTerm();
foreach ( array( 'thisTermDetails', 'otherTermDetails' ) as $t )
{
if ( $$t['unit'] === 'y' )
{
$$t['unit'] = 'm';
$$t['term'] *= 12;
}
if ( $$t['unit'] === 'w' )
{
$$t['unit'] = 'd';
$$t['term'] *= 7;
}
}
/* If the two terms are now based on the same unit of time, we can just multiply */
if ( $thisTermDetails['unit'] === $otherTermDetails['unit'] )
{
$factor = ( new \IPS\Math\Number( (string) $thisTermDetails['term'] ) )->divide( ( new \IPS\Math\Number( (string) $otherTermDetails['term'] ) ) );
$thisCostPerDivision = $this->cost->amount;
$otherCostPerDivision = $otherTerm->cost->amount->multiply( $factor );
}
/* Otherwise we have to work it out based on the cost per day */
else
{
$days = new \IPS\Math\Number( (string) $this->days() );
$thisCostPerDivision = $this->costPerDay()->amount->multiply( $days );
$otherCostPerDivision = $otherTerm->costPerDay()->amount->multiply( $days );
}
/* Work out the saving */
$saving = $otherCostPerDivision->subtract( $thisCostPerDivision );
/* Return in desired format */
if ( $returnAsPercentage )
{
return ( new \IPS\Math\Number('100') )->divide( $otherCostPerDivision, 4 )->multiply( $saving );
}
else
{
return new \IPS\nexus\Money( $saving, $this->cost->currency );
}
}
/**
* To String
*
@@ -278,7 +338,7 @@ class _RenewalTerm
if ( $quantity != 1 )
{
$cost = new \IPS\nexus\Money( $cost->amount->multiply( $quantity ), $cost->currency );
$cost = new \IPS\nexus\Money( $cost->amount->multiply( new \IPS\Math\Number( "$quantity" ) ), $cost->currency );
}
return sprintf( \IPS\Member::loggedIn()->language()->get( 'renew_option'), $cost, $this->getTermUnit() ) ;