Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -12,52 +12,74 @@
|
||||
namespace IPS\core\extensions\nexus\Item;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use DomainException;
|
||||
use Exception;
|
||||
use IPS\Application\Module;
|
||||
use IPS\DateTime;
|
||||
use IPS\File;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Url as FormUrl;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Member\Club;
|
||||
use IPS\nexus\Invoice;
|
||||
use IPS\nexus\Money;
|
||||
use IPS\nexus\Purchase;
|
||||
use IPS\nexus\Tax;
|
||||
use IPS\Output;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* ClubMembership
|
||||
*/
|
||||
class _ClubMembership extends \IPS\nexus\Invoice\Item\Purchase
|
||||
class ClubMembership extends Invoice\Item\Purchase
|
||||
{
|
||||
/**
|
||||
* @brief Application
|
||||
*/
|
||||
public static $application = 'core';
|
||||
public static string $application = 'core';
|
||||
|
||||
/**
|
||||
* @brief Application
|
||||
*/
|
||||
public static $type = 'club';
|
||||
public static string $type = 'club';
|
||||
|
||||
/**
|
||||
* @brief Icon
|
||||
*/
|
||||
public static $icon = 'users';
|
||||
public static string $icon = 'users';
|
||||
|
||||
/**
|
||||
* @brief Title
|
||||
*/
|
||||
public static $title = 'club_membership_item';
|
||||
public static string $title = 'club_membership_item';
|
||||
|
||||
/**
|
||||
* Image
|
||||
*
|
||||
* @return |IPS\File|NULL
|
||||
* @return File|null
|
||||
*/
|
||||
public function image()
|
||||
public function image(): File|null
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( $photo = \IPS\Member\Club::load( $this->id )->profile_photo )
|
||||
if ( $photo = Club::load( $this->id )->profile_photo )
|
||||
{
|
||||
return \IPS\File::get( 'core_Clubs', $photo );
|
||||
return File::get( 'core_Clubs', $photo );
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
catch ( Exception ) {}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -65,19 +87,19 @@ class _ClubMembership extends \IPS\nexus\Invoice\Item\Purchase
|
||||
/**
|
||||
* Image
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @return |IPS\File|NULL
|
||||
* @param Purchase $purchase The purchase
|
||||
* @return File|null
|
||||
*/
|
||||
public static function purchaseImage( \IPS\nexus\Purchase $purchase )
|
||||
public static function purchaseImage( Purchase $purchase ): File|null
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( $photo = \IPS\Member\Club::load( $purchase->item_id )->profile_photo )
|
||||
if ( $photo = Club::load( $purchase->item_id )->profile_photo )
|
||||
{
|
||||
return \IPS\File::get( 'core_Clubs', $photo );
|
||||
return File::get( 'core_Clubs', $photo );
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
catch ( Exception ) {}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -85,39 +107,35 @@ class _ClubMembership extends \IPS\nexus\Invoice\Item\Purchase
|
||||
/**
|
||||
* Get Client Area Page HTML
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @return array( 'packageInfo' => '...', 'purchaseInfo' => '...' )
|
||||
* @param Purchase $purchase The purchase
|
||||
* @return array ( 'packageInfo' => '...', 'purchaseInfo' => '...' )
|
||||
*/
|
||||
public static function clientAreaPage( \IPS\nexus\Purchase $purchase )
|
||||
public static function clientAreaPage( Purchase $purchase ): array
|
||||
{
|
||||
try
|
||||
{
|
||||
$club = \IPS\Member\Club::load( $purchase->item_id );
|
||||
$club = Club::load( $purchase->item_id );
|
||||
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'styles/clubs.css', 'core', 'front' ) );
|
||||
if ( \IPS\Theme::i()->settings['responsive'] )
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'styles/clubs_responsive.css', 'core', 'front' ) );
|
||||
}
|
||||
return array( 'packageInfo' => \IPS\Theme::i()->getTemplate( 'clubs', 'core' )->clubClientArea( $club ) );
|
||||
Output::i()->cssFiles = array_merge( Output::i()->cssFiles, Theme::i()->css( 'styles/clubs.css', 'core', 'front' ) );
|
||||
return array( 'packageInfo' => Theme::i()->getTemplate( 'clubs', 'core' )->clubClientArea( $club ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
catch ( OutOfRangeException ) { }
|
||||
|
||||
return NULL;
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ACP Page Buttons
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @param \IPS\Http\Url $url The page URL
|
||||
* @return array
|
||||
* @param Purchase $purchase The purchase
|
||||
* @param Url $url The page URL
|
||||
* @return array
|
||||
*/
|
||||
public static function acpButtons( \IPS\nexus\Purchase $purchase, \IPS\Http\Url $url )
|
||||
public static function acpButtons(Purchase $purchase, Url $url ): array
|
||||
{
|
||||
try
|
||||
{
|
||||
$club = \IPS\Member\Club::load( $purchase->item_id );
|
||||
$club = Club::load( $purchase->item_id );
|
||||
|
||||
return array( 'view_club' => array(
|
||||
'icon' => 'users',
|
||||
@@ -126,7 +144,7 @@ class _ClubMembership extends \IPS\nexus\Invoice\Item\Purchase
|
||||
'target'=> '_blank'
|
||||
) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
catch ( OutOfRangeException ) { }
|
||||
|
||||
return array();
|
||||
}
|
||||
@@ -134,15 +152,15 @@ class _ClubMembership extends \IPS\nexus\Invoice\Item\Purchase
|
||||
/**
|
||||
* URL
|
||||
*
|
||||
* @return \IPS\Http\Url|NULL
|
||||
* @return Url|string|NULL
|
||||
*/
|
||||
public function url()
|
||||
function url(): Url|string|null
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\Member\Club::load( $this->id )->url();
|
||||
return Club::load( $this->id )->url();
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -151,15 +169,15 @@ class _ClubMembership extends \IPS\nexus\Invoice\Item\Purchase
|
||||
/**
|
||||
* ACP URL
|
||||
*
|
||||
* @return \IPS\Http\Url|NULL
|
||||
* @return Url|NULL
|
||||
*/
|
||||
public function acpUrl()
|
||||
public function acpUrl(): Url|null
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\Member\Club::load( $this->id )->url();
|
||||
return Club::load( $this->id )->url();
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -168,14 +186,14 @@ class _ClubMembership extends \IPS\nexus\Invoice\Item\Purchase
|
||||
/**
|
||||
* Get renewal payment methods IDs
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @return array|NULL
|
||||
* @param Purchase $purchase The purchase
|
||||
* @return array|NULL
|
||||
*/
|
||||
public static function renewalPaymentMethodIds( \IPS\nexus\Purchase $purchase )
|
||||
public static function renewalPaymentMethodIds( Purchase $purchase ): array|null
|
||||
{
|
||||
if ( \IPS\Settings::i()->clubs_paid_gateways )
|
||||
if ( Settings::i()->clubs_paid_gateways )
|
||||
{
|
||||
return explode( ',', \IPS\Settings::i()->clubs_paid_gateways );
|
||||
return explode( ',', Settings::i()->clubs_paid_gateways );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -186,21 +204,21 @@ class _ClubMembership extends \IPS\nexus\Invoice\Item\Purchase
|
||||
/**
|
||||
* Purchase can be renewed?
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @return boolean
|
||||
* @param Purchase $purchase The purchase
|
||||
* @return boolean
|
||||
*/
|
||||
public static function canBeRenewed( \IPS\nexus\Purchase $purchase )
|
||||
public static function canBeRenewed( Purchase $purchase ): bool
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( !$purchase->member->canAccessModule( \IPS\Application\Module::get( 'core', 'clubs', 'front' ) ) )
|
||||
if ( !$purchase->member->canAccessModule( Module::get( 'core', 'clubs', 'front' ) ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return \in_array( \IPS\Member\Club::load( $purchase->item_id )->memberStatus( $purchase->member ), array( \IPS\Member\Club::STATUS_MEMBER, \IPS\Member\Club::STATUS_MODERATOR, \IPS\Member\Club::STATUS_LEADER, \IPS\Member\Club::STATUS_EXPIRED, \IPS\Member\Club::STATUS_EXPIRED_MODERATOR ) );
|
||||
return in_array( Club::load( $purchase->item_id )->memberStatus( $purchase->member ), array( Club::STATUS_MEMBER, Club::STATUS_MODERATOR, Club::STATUS_LEADER, Club::STATUS_EXPIRED, Club::STATUS_EXPIRED_MODERATOR ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) {}
|
||||
catch ( OutOfRangeException ) {}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@@ -208,11 +226,11 @@ class _ClubMembership extends \IPS\nexus\Invoice\Item\Purchase
|
||||
/**
|
||||
* Can Renew Until
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @param Purchase $purchase The purchase
|
||||
* @param bool $admin If TRUE, is for ACP. If FALSE, is for front-end.
|
||||
* @return \IPS\DateTime|bool TRUE means can renew as much as they like. FALSE means cannot renew at all. \IPS\DateTime means can renew until that date
|
||||
* @return DateTime|bool TRUE means can renew as much as they like. FALSE means cannot renew at all. \IPS\DateTime means can renew until that date
|
||||
*/
|
||||
public static function canRenewUntil( \IPS\nexus\Purchase $purchase, $admin )
|
||||
public static function canRenewUntil( Purchase $purchase, bool $admin=FALSE ): DateTime|bool
|
||||
{
|
||||
if( $admin )
|
||||
{
|
||||
@@ -225,60 +243,60 @@ class _ClubMembership extends \IPS\nexus\Invoice\Item\Purchase
|
||||
/**
|
||||
* On Purchase Generated
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @param \IPS\nexus\Invoice $invoice The invoice
|
||||
* @return void
|
||||
* @param Purchase $purchase The purchase
|
||||
* @param Invoice $invoice The invoice
|
||||
* @return void
|
||||
*/
|
||||
public static function onPurchaseGenerated( \IPS\nexus\Purchase $purchase, \IPS\nexus\Invoice $invoice )
|
||||
public static function onPurchaseGenerated( Purchase $purchase, Invoice $invoice ): void
|
||||
{
|
||||
try
|
||||
{
|
||||
$club = \IPS\Member\Club::load( $purchase->item_id );
|
||||
$club->addMember( $purchase->member, \IPS\Member\Club::STATUS_MEMBER, TRUE, NULL, NULL, TRUE );
|
||||
$club = Club::load( $purchase->item_id );
|
||||
$club->addMember( $purchase->member, Club::STATUS_MEMBER, TRUE, NULL, NULL, TRUE );
|
||||
$club->recountMembers();
|
||||
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
catch ( Exception ) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* On Purchase Expired
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @return void
|
||||
* @param Purchase $purchase The purchase
|
||||
* @return void
|
||||
*/
|
||||
public static function onExpire( \IPS\nexus\Purchase $purchase )
|
||||
public static function onExpire( Purchase $purchase ): void
|
||||
{
|
||||
try
|
||||
{
|
||||
$club = \IPS\Member\Club::load( $purchase->item_id );
|
||||
$club = Club::load( $purchase->item_id );
|
||||
|
||||
switch ( $club->memberStatus( $purchase->member ) )
|
||||
{
|
||||
case $club::STATUS_MEMBER:
|
||||
$club->addMember( $purchase->member, \IPS\Member\Club::STATUS_EXPIRED, TRUE );
|
||||
$club->addMember( $purchase->member, Club::STATUS_EXPIRED, TRUE );
|
||||
break;
|
||||
|
||||
case $club::STATUS_MODERATOR:
|
||||
$club->addMember( $purchase->member, \IPS\Member\Club::STATUS_EXPIRED_MODERATOR, TRUE );
|
||||
$club->addMember( $purchase->member, Club::STATUS_EXPIRED_MODERATOR, TRUE );
|
||||
break;
|
||||
}
|
||||
$club->recountMembers();
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
catch ( Exception ) { }
|
||||
}
|
||||
|
||||
/**
|
||||
* On Purchase Canceled
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @return void
|
||||
* @param Purchase $purchase The purchase
|
||||
* @return void
|
||||
*/
|
||||
public static function onCancel( \IPS\nexus\Purchase $purchase )
|
||||
public static function onCancel( Purchase $purchase ): void
|
||||
{
|
||||
try
|
||||
{
|
||||
$club = \IPS\Member\Club::load( $purchase->item_id );
|
||||
$club = Club::load( $purchase->item_id );
|
||||
|
||||
switch ( $club->memberStatus( $purchase->member ) )
|
||||
{
|
||||
@@ -290,16 +308,16 @@ class _ClubMembership extends \IPS\nexus\Invoice\Item\Purchase
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
catch ( Exception ) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Warning to display to admin when cancelling a purchase
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The Purchase
|
||||
* @return string
|
||||
* @param Purchase $purchase The Purchase
|
||||
* @return string|null
|
||||
*/
|
||||
public static function onCancelWarning( \IPS\nexus\Purchase $purchase )
|
||||
public static function onCancelWarning( Purchase $purchase ): string|null
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -307,10 +325,10 @@ class _ClubMembership extends \IPS\nexus\Invoice\Item\Purchase
|
||||
/**
|
||||
* On Purchase Deleted
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @return void
|
||||
* @param Purchase $purchase The purchase
|
||||
* @return void
|
||||
*/
|
||||
public static function onDelete( \IPS\nexus\Purchase $purchase )
|
||||
public static function onDelete( Purchase $purchase ): void
|
||||
{
|
||||
static::onCancel( $purchase );
|
||||
}
|
||||
@@ -318,44 +336,44 @@ class _ClubMembership extends \IPS\nexus\Invoice\Item\Purchase
|
||||
/**
|
||||
* On Purchase Reactivated (renewed after being expired or reactivated after being canceled)
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @return void
|
||||
* @param Purchase $purchase The purchase
|
||||
* @return void
|
||||
*/
|
||||
public static function onReactivate( \IPS\nexus\Purchase $purchase )
|
||||
public static function onReactivate( Purchase $purchase ): void
|
||||
{
|
||||
try
|
||||
{
|
||||
$club = \IPS\Member\Club::load( $purchase->item_id );
|
||||
$club = Club::load( $purchase->item_id );
|
||||
|
||||
switch ( $club->memberStatus( $purchase->member ) )
|
||||
{
|
||||
case $club::STATUS_EXPIRED_MODERATOR:
|
||||
$club->addMember( $purchase->member, \IPS\Member\Club::STATUS_MODERATOR, TRUE );
|
||||
$club->addMember( $purchase->member, Club::STATUS_MODERATOR, TRUE );
|
||||
break;
|
||||
|
||||
default:
|
||||
$club->addMember( $purchase->member, \IPS\Member\Club::STATUS_MEMBER, TRUE );
|
||||
$club->addMember( $purchase->member, Club::STATUS_MEMBER, TRUE );
|
||||
break;
|
||||
}
|
||||
$club->recountMembers();
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
catch ( Exception ) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* On Transfer (is ran before transferring)
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @param \IPS\Member $newCustomer New Customer
|
||||
* @return void
|
||||
* @param Purchase $purchase The purchase
|
||||
* @param Member $newCustomer New Customer
|
||||
* @return void
|
||||
*/
|
||||
public static function onTransfer( \IPS\nexus\Purchase $purchase, \IPS\Member $newCustomer )
|
||||
public static function onTransfer( Purchase $purchase, Member $newCustomer ): void
|
||||
{
|
||||
try
|
||||
{
|
||||
$club = \IPS\Member\Club::load( $purchase->item_id );
|
||||
$club = Club::load( $purchase->item_id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -363,21 +381,21 @@ class _ClubMembership extends \IPS\nexus\Invoice\Item\Purchase
|
||||
switch ( $club->memberStatus( $newCustomer ) )
|
||||
{
|
||||
/* If they are already a member, we can't really transfer a different membership to them... */
|
||||
case \IPS\Member\Club::STATUS_MEMBER:
|
||||
case \IPS\Member\Club::STATUS_INVITED_BYPASSING_PAYMENT:
|
||||
case \IPS\Member\Club::STATUS_EXPIRED:
|
||||
case \IPS\Member\Club::STATUS_EXPIRED_MODERATOR:
|
||||
case \IPS\Member\Club::STATUS_MODERATOR:
|
||||
case \IPS\Member\Club::STATUS_LEADER:
|
||||
throw new \DomainException( 'club_cannot_transfer_membership' );
|
||||
case Club::STATUS_MEMBER:
|
||||
case Club::STATUS_INVITED_BYPASSING_PAYMENT:
|
||||
case Club::STATUS_EXPIRED:
|
||||
case Club::STATUS_EXPIRED_MODERATOR:
|
||||
case Club::STATUS_MODERATOR:
|
||||
case Club::STATUS_LEADER:
|
||||
throw new DomainException( 'club_cannot_transfer_membership' );
|
||||
|
||||
/* Buf if they're *not* a member we can */
|
||||
case NULL:
|
||||
case \IPS\Member\Club::STATUS_INVITED:
|
||||
case \IPS\Member\Club::STATUS_REQUESTED:
|
||||
case \IPS\Member\Club::STATUS_WAITING_PAYMENT:
|
||||
case \IPS\Member\Club::STATUS_DECLINED:
|
||||
case \IPS\Member\Club::STATUS_BANNED:
|
||||
case Club::STATUS_INVITED:
|
||||
case Club::STATUS_REQUESTED:
|
||||
case Club::STATUS_WAITING_PAYMENT:
|
||||
case Club::STATUS_DECLINED:
|
||||
case Club::STATUS_BANNED:
|
||||
|
||||
/* Remove the old member's record */
|
||||
$club->removeMember( $purchase->member );
|
||||
@@ -387,7 +405,7 @@ class _ClubMembership extends \IPS\nexus\Invoice\Item\Purchase
|
||||
{
|
||||
/* Remove any request/invitation for the new member and add the new record */
|
||||
$club->removeMember( $newCustomer );
|
||||
$club->addMember( $newCustomer, $purchase->active ? \IPS\Member\Club::STATUS_MEMBER : \IPS\Member\Club::STATUS_EXPIRED, FALSE, \IPS\Member::loggedIn() );
|
||||
$club->addMember( $newCustomer, $purchase->active ? Club::STATUS_MEMBER : Club::STATUS_EXPIRED, FALSE, Member::loggedIn() );
|
||||
}
|
||||
|
||||
/* Recount */
|
||||
@@ -398,25 +416,25 @@ class _ClubMembership extends \IPS\nexus\Invoice\Item\Purchase
|
||||
/**
|
||||
* Generate Invoice Form
|
||||
*
|
||||
* @param \IPS\Helpers\Form $form The form
|
||||
* @param \IPS\nexus\Invoice $invoice The invoice
|
||||
* @return void
|
||||
* @param Form $form The form
|
||||
* @param Invoice $invoice The invoice
|
||||
* @return void
|
||||
*/
|
||||
public static function form( \IPS\Helpers\Form $form, \IPS\nexus\Invoice $invoice )
|
||||
public static function form( Form $form, Invoice $invoice ): void
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Url( 'url_to_club', NULL, TRUE, array(), function( $value )
|
||||
$form->add( new FormUrl( 'url_to_club', NULL, TRUE, array(), function($value )
|
||||
{
|
||||
try
|
||||
{
|
||||
$club = \IPS\Member\Club::loadFromUrl( $value );
|
||||
$club = Club::loadFromUrl( $value );
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
catch ( Exception )
|
||||
{
|
||||
throw new \DomainException('url_to_club_invalid');
|
||||
throw new DomainException('url_to_club_invalid');
|
||||
}
|
||||
if ( !$club->isPaid() )
|
||||
{
|
||||
throw new \DomainException('url_to_club_free');
|
||||
throw new DomainException('url_to_club_free');
|
||||
}
|
||||
} ) );
|
||||
}
|
||||
@@ -425,32 +443,32 @@ class _ClubMembership extends \IPS\nexus\Invoice\Item\Purchase
|
||||
* Create From Form
|
||||
*
|
||||
* @param array $values Values from form
|
||||
* @param \IPS\nexus\Invoice $invoice The invoice
|
||||
* @return \IPS\core\extensions\nexus\Item\ClubMembership
|
||||
* @param Invoice $invoice The invoice
|
||||
* @return ClubMembership
|
||||
*/
|
||||
public static function createFromForm( array $values, \IPS\nexus\Invoice $invoice )
|
||||
public static function createFromForm( array $values, Invoice $invoice ): ClubMembership
|
||||
{
|
||||
$club = \IPS\Member\Club::loadFromUrl( $values['url_to_club'] );
|
||||
$club = Club::loadFromUrl( $values['url_to_club'] );
|
||||
|
||||
$fee = $club->joiningFee( $invoice->currency );
|
||||
|
||||
$item = new \IPS\core\extensions\nexus\Item\ClubMembership( $club->name, $fee );
|
||||
$item = new ClubMembership( $club->name, $fee );
|
||||
$item->id = $club->id;
|
||||
try
|
||||
{
|
||||
$item->tax = \IPS\Settings::i()->clubs_paid_tax ? \IPS\nexus\Tax::load( \IPS\Settings::i()->clubs_paid_tax ) : NULL;
|
||||
$item->tax = Settings::i()->clubs_paid_tax ? Tax::load( Settings::i()->clubs_paid_tax ) : NULL;
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
if ( \IPS\Settings::i()->clubs_paid_gateways )
|
||||
catch ( OutOfRangeException ) { }
|
||||
if ( Settings::i()->clubs_paid_gateways )
|
||||
{
|
||||
$item->paymentMethodIds = explode( ',', \IPS\Settings::i()->clubs_paid_gateways );
|
||||
$item->paymentMethodIds = explode( ',', Settings::i()->clubs_paid_gateways );
|
||||
}
|
||||
$item->renewalTerm = $club->renewalTerm( $fee->currency );
|
||||
$item->payTo = $club->owner;
|
||||
$item->commission = \IPS\Settings::i()->clubs_paid_commission;
|
||||
if ( $fees = \IPS\Settings::i()->clubs_paid_transfee and isset( $fees[ $fee->currency ] ) )
|
||||
$item->commission = Settings::i()->clubs_paid_commission;
|
||||
if ( $fees = Settings::i()->clubs_paid_transfee and isset( $fees[ $fee->currency ] ) )
|
||||
{
|
||||
$item->fee = new \IPS\nexus\Money( $fees[ $fee->currency ]['amount'], $fee->currency );
|
||||
$item->fee = new Money( $fees[ $fee->currency ]['amount'], $fee->currency );
|
||||
}
|
||||
|
||||
return $item;
|
||||
|
||||
Reference in new issue
Block a user