Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Shipping Rates
|
||||
* @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 13 Feb 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -36,7 +36,108 @@ class _shippingrates extends \IPS\Node\Controller
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'shipping_manage' );
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'shipmethods_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Warning about unconsecutive rules
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function warning()
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->decision( 'ship_rates_' . \IPS\Request::i()->type, array(
|
||||
'ship_rates_go_back' => \IPS\Http\Url::internal( 'app=nexus&module=payments&controller=shippingrates&do=form&id=' . \IPS\Request::i()->id ),
|
||||
'ship_rates_save_anyway' => \IPS\Http\Url::internal( $this->url ),
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 $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, $lastUsedTab = FALSE )
|
||||
{
|
||||
$haveNoLowerLimit = FALSE;
|
||||
$haveNoUpperLimit = FALSE;
|
||||
$lastUpper = NULL;
|
||||
$consecutive = TRUE;
|
||||
|
||||
foreach ( json_decode( $new->rates, TRUE ) as $rate )
|
||||
{
|
||||
if ( !$haveNoLowerLimit )
|
||||
{
|
||||
if ( $rate['min'] === '*' )
|
||||
{
|
||||
$haveNoLowerLimit = TRUE;
|
||||
}
|
||||
elseif ( is_array( $rate['min'] ) )
|
||||
{
|
||||
$allAreZero = TRUE;
|
||||
foreach ( $rate['min'] as $val )
|
||||
{
|
||||
if ( $val !== 0 )
|
||||
{
|
||||
$allAreZero = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $allAreZero )
|
||||
{
|
||||
$haveNoLowerLimit = TRUE;
|
||||
}
|
||||
}
|
||||
elseif ( $rate['min'] === 0 )
|
||||
{
|
||||
$haveNoLowerLimit = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !$haveNoUpperLimit and $rate['max'] === '*' )
|
||||
{
|
||||
$haveNoUpperLimit = TRUE;
|
||||
}
|
||||
|
||||
if ( $lastUpper !== NULL )
|
||||
{
|
||||
if ( is_array( $lastUpper ) )
|
||||
{
|
||||
foreach ( $lastUpper as $k => $v )
|
||||
{
|
||||
if ( strval( $rate['min'][ $k ] - $v ) > 0.01 ) # @note: We use strval() here to prevent PHP from applying a precision to the float, inadvertently causing this to return TRUE
|
||||
{
|
||||
$consecutive = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ( strval( $rate['min'] - $lastUpper ) > 0.01 ) # @note: We use strval() here to prevent PHP from applying a precision to the float, inadvertently causing this to return TRUE
|
||||
{
|
||||
$consecutive = FALSE;
|
||||
}
|
||||
}
|
||||
$lastUpper = $rate['max'];
|
||||
}
|
||||
|
||||
if( !$haveNoLowerLimit )
|
||||
{
|
||||
\IPS\Output::i()->redirect( $this->url->setQueryString( array( 'do' => 'warning', 'type' => 'missing_lower', 'id' => $new->_id ) ) );
|
||||
}
|
||||
elseif( !$haveNoUpperLimit )
|
||||
{
|
||||
\IPS\Output::i()->redirect( $this->url->setQueryString( array( 'do' => 'warning', 'type' => 'missing_upper', 'id' => $new->_id ) ) );
|
||||
}
|
||||
elseif ( !$consecutive )
|
||||
{
|
||||
\IPS\Output::i()->redirect( $this->url->setQueryString( array( 'do' => 'warning', 'type' => 'unconsecutive', 'id' => $new->_id ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
parent::_afterSave( $old, $new, $lastUsedTab );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user