Version 4.6.0
This commit is contained in:
1 parent
f79dcf067a
commit
517a5e1f70
2036 files changed
+110041
-26162
No files matched your search
@@ -77,6 +77,64 @@ class _File extends \IPS\nexus\Invoice\Item\Purchase
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Client Area Action
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @return string
|
||||
*/
|
||||
public static function clientAreaAction( \IPS\nexus\Purchase $purchase )
|
||||
{
|
||||
if( \IPS\Request::i()->act == 'reactivate' AND $purchase->can_reactivate )
|
||||
{
|
||||
/* Cannot renew, do not set renewal periods */
|
||||
$file = \IPS\downloads\File::load( $purchase->item_id );
|
||||
if( !$file->container()->can( 'download', $purchase->member ) )
|
||||
{
|
||||
return parent::clientAreaAction( $purchase );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$file = \IPS\downloads\File::load( $purchase->item_id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
return parent::clientAreaAction( $purchase );
|
||||
}
|
||||
$renewalCosts = json_decode( $file->renewal_price, TRUE );
|
||||
$currency = $purchase->original_invoice->currency;
|
||||
|
||||
$tax = NULL;
|
||||
if ( $purchase->tax )
|
||||
{
|
||||
try
|
||||
{
|
||||
$tax = \IPS\nexus\Tax::load( $purchase->tax );
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
}
|
||||
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
$purchase->renewals = new \IPS\nexus\Purchase\RenewalTerm( new \IPS\nexus\Money( $renewalCosts[ $currency ]['amount'], $currency ), new \DateInterval( 'P' . $file->renewal_term . mb_strtoupper( $file->renewal_units ) ), $tax );
|
||||
$purchase->cancelled = FALSE;
|
||||
$purchase->save();
|
||||
|
||||
$purchase->member->log( 'purchase', array( 'type' => 'info', 'id' => $purchase->id, 'name' => $purchase->name, 'info' => 'change_renewals', 'to' => array( 'cost' => $purchase->renewals->cost->amount, 'currency' => $purchase->renewals->cost->currency, 'term' => $purchase->renewals->getTerm() ) ) );
|
||||
|
||||
if ( !$purchase->active and $cycles = $purchase->canRenewUntil( NULL, TRUE ) AND $cycles !== FALSE )
|
||||
{
|
||||
$url = $cycles === 1 ? $purchase->url()->setQueryString( 'do', 'renew' )->csrf() : $purchase->url()->setQueryString( 'do', 'renew' );
|
||||
\IPS\Output::i()->redirect( $url );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( $purchase->url() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Client Area Page HTML
|
||||
@@ -89,8 +147,15 @@ class _File extends \IPS\nexus\Invoice\Item\Purchase
|
||||
try
|
||||
{
|
||||
$file = \IPS\downloads\File::load( $purchase->item_id );
|
||||
|
||||
/* Reactivate */
|
||||
$reactivateUrl = NULL;
|
||||
if ( $file->container()->can( 'download', $purchase->member ) and !$purchase->renewals and $file->renewal_term and $file->renewal_units and $file->renewal_price and $purchase->can_reactivate and ( !$purchase->billing_agreement or $purchase->billing_agreement->canceled ) )
|
||||
{
|
||||
$reactivateUrl = \IPS\Http\Url::internal( "app=nexus&module=clients&controller=purchases&id={$purchase->id}&do=extra&act=reactivate", 'front', 'clientspurchaseextra', \IPS\Http\Url::seoTitle( $purchase->name ) )->csrf();
|
||||
}
|
||||
|
||||
return array( 'packageInfo' => \IPS\Theme::i()->getTemplate( 'nexus', 'downloads' )->fileInfo( $file ), 'purchaseInfo' => \IPS\Theme::i()->getTemplate( 'nexus', 'downloads' )->filePurchaseInfo( $file ) );
|
||||
return array( 'packageInfo' => \IPS\Theme::i()->getTemplate( 'nexus', 'downloads' )->fileInfo( $file ), 'purchaseInfo' => \IPS\Theme::i()->getTemplate( 'nexus', 'downloads' )->filePurchaseInfo( $file, $reactivateUrl ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
|
||||
@@ -171,7 +236,8 @@ class _File extends \IPS\nexus\Invoice\Item\Purchase
|
||||
{
|
||||
$file = \IPS\downloads\File::load( $purchase->item_id );
|
||||
|
||||
if( $file->canView( \IPS\Member::load( $purchase->member_id ) ) )
|
||||
/* File is viewable and basic download permission check is good */
|
||||
if( $file->canView( $purchase->member ) AND $file->container()->can( 'download', $purchase->member ) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user