Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

+199 -189
View File
@@ -12,35 +12,62 @@
namespace IPS\nexus;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use DomainException;
use Exception;
use IPS\Application as SystemApplication;
use IPS\Application\Module;
use IPS\Data\Store;
use IPS\Db;
use IPS\Dispatcher;
use IPS\Helpers\Form\Select;
use IPS\Helpers\Form\Text;
use IPS\Http\Url;
use IPS\Member;
use IPS\nexus\Invoice\Item\Renewal;
use IPS\Output;
use IPS\Request;
use IPS\Settings;
use IPS\Theme;
use OutOfRangeException;
use UnderflowException;
use function array_merge;
use function count;
use function defined;
use function in_array;
use function intval;
use function is_array;
use function unserialize;
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;
}
/**
* Nexus Application Class
*/
class _Application extends \IPS\Application
class Application extends SystemApplication
{
/**
* Init - catches legacy PayPal IPN messages
*
* @return void
*/
public function init()
public function init(): void
{
if ( !\IPS\Request::i()->isAjax() )
if ( !Request::i()->isAjax() )
{
if ( \IPS\Settings::i()->gateways_counts and $decoded = json_decode( \IPS\Settings::i()->gateways_counts, TRUE ) and isset( $decoded['Stripe'] ) and $decoded['Stripe'] > 0 )
if ( Settings::i()->gateways_counts and $decoded = json_decode( Settings::i()->gateways_counts, TRUE ) and isset( $decoded['Stripe'] ) and $decoded['Stripe'] > 0 )
{
\IPS\Output::i()->jsFiles[] = 'https://js.stripe.com/v3/';
Output::i()->jsFiles[] = 'https://js.stripe.com/v3/';
}
}
if ( \IPS\Request::i()->app == 'nexus' and \IPS\Request::i()->module == 'payments' and \IPS\Request::i()->section == 'receive' and \IPS\Request::i()->validate == 'paypal' )
if ( Request::i()->app == 'nexus' and Request::i()->module == 'payments' and Request::i()->section == 'receive' and Request::i()->validate == 'paypal' )
{
if ( ( \IPS\Request::i()->txn_type == 'subscr_payment' or \IPS\Request::i()->txn_type == 'recurring_payment' ) and \IPS\Request::i()->payment_status == 'Completed' )
if ( ( Request::i()->txn_type == 'subscr_payment' or Request::i()->txn_type == 'recurring_payment' ) and Request::i()->payment_status == 'Completed' )
{
try
{
@@ -49,39 +76,39 @@ class _Application extends \IPS\Application
/* Get the subscription */
try
{
if( \IPS\Request::i()->txn_type == 'subscr_payment' )
if( Request::i()->txn_type == 'subscr_payment' )
{
$subscription = \IPS\Db::i()->select( '*', 'nexus_subscriptions', array( 's_gateway_key=? AND s_id=?', 'paypal', \IPS\Request::i()->subscr_id ) )->first();
$subscription = Db::i()->select( '*', 'nexus_subscriptions', array( 's_gateway_key=? AND s_id=?', 'paypal', Request::i()->subscr_id ) )->first();
}
else
{
$subscription = \IPS\Db::i()->select( '*', 'nexus_subscriptions', array( 's_gateway_key=? AND s_id=?', 'paypalpro', \IPS\Request::i()->recurring_payment_id ) )->first();
$subscription = Db::i()->select( '*', 'nexus_subscriptions', array( 's_gateway_key=? AND s_id=?', 'paypalpro', Request::i()->recurring_payment_id ) )->first();
}
$items = \unserialize( $subscription['s_items'] );
if ( !\is_array( $items ) or empty( $items ) )
$items = unserialize( $subscription['s_items'] );
if ( !is_array( $items ) or empty( $items ) )
{
/* Don't exit here, throw an underflow exception so we can see if this is a legacy subscription */
throw new \UnderflowException( 'NO_ITEMS' );
throw new UnderflowException( 'NO_ITEMS' );
}
}
catch( \UnderflowException $e )
catch( UnderflowException $e )
{
/* Was this from the old IP.Subscriptions? */
if ( isset( \IPS\Request::i()->old ) or mb_strstr( \IPS\Request::i()->custom, '-' ) !== FALSE )
if ( isset( Request::i()->old ) or mb_strstr( Request::i()->custom, '-' ) !== FALSE )
{
if ( mb_strstr( \IPS\Request::i()->custom, '-' ) !== FALSE )
if ( mb_strstr( Request::i()->custom, '-' ) !== FALSE )
{
$exploded = explode( '-', \IPS\Request::i()->custom );
$memberId = \intval( $exploded[0] );
$purchaseId = \intval( $exploded[1] );
$exploded = explode( '-', Request::i()->custom );
$memberId = intval( $exploded[0] );
$purchaseId = intval( $exploded[1] );
$item = \IPS\Db::i()->select( '*', 'nexus_purchases', array( "ps_id=?", $purchaseId ), 'ps_id' )->first();
$item = Db::i()->select( '*', 'nexus_purchases', array( "ps_id=?", $purchaseId ), 'ps_id' )->first();
}
else
{
$memberId = \intval( \IPS\Request::i()->custom );
$memberId = intval( Request::i()->custom );
$item = \IPS\Db::i()->select( '*', 'nexus_purchases', array( "ps_member=? AND ps_name=?", $memberId, \IPS\Request::i()->item_name ), 'ps_start DESC' )->first();
$item = Db::i()->select( '*', 'nexus_purchases', array( "ps_member=? AND ps_name=?", $memberId, Request::i()->item_name ), 'ps_start DESC' )->first();
}
/* If the purchase isn't valid or was cancelled just exit */
@@ -94,13 +121,13 @@ class _Application extends \IPS\Application
$items = array( $item['ps_id'] );
/* Grab the first paypal method we can find */
$method = \IPS\Db::i()->select( 'm_id', 'nexus_paymethods', array( 'm_gateway=?', 'PayPal' ) )->first();
$method = Db::i()->select( 'm_id', 'nexus_paymethods', array( 'm_gateway=?', 'PayPal' ) )->first();
/* We are here because the subscription record doesn't exist. The 3.x code just silently and automatically added one, so do the same now.
Note that we will need the transaction ID to save the subscription, but we can set the array parameters that will be referenced below. */
$subscription = array(
's_gateway_key' => 'paypal',
's_id' => \IPS\Request::i()->subscr_id,
's_id' => Request::i()->subscr_id,
's_start_trans' => 0, // We will set this later after saving the transaction
's_method' => $method,
's_member' => $memberId,
@@ -119,20 +146,20 @@ class _Application extends \IPS\Application
$gateway = NULL;
try
{
$gateway = \IPS\nexus\Gateway::load( $subscription['s_method'] );
$gateway = Gateway::load( $subscription['s_method'] );
}
catch ( \OutOfRangeException $e ) { }
catch ( OutOfRangeException ) { }
/* Check this was actually a PayPal IPN message */
try
{
$response = \IPS\Http\Url::external( 'https://www.' . ( \IPS\NEXUS_TEST_GATEWAYS ? 'sandbox.' : '' ) . 'paypal.com/cgi-bin/webscr/' )->request()->setHeaders( array( 'Accept' => 'application/x-www-form-urlencoded' ) )->post( array_merge( array( 'cmd' => '_notify-validate' ), $_POST ) );
$response = Url::external( 'https://www.' . ( \IPS\NEXUS_TEST_GATEWAYS ? 'sandbox.' : '' ) . 'paypal.com/cgi-bin/webscr/' )->request()->setHeaders( array( 'Accept' => 'application/x-www-form-urlencoded' ) )->post( array_merge( array( 'cmd' => '_notify-validate' ), $_POST ) );
if ( (string) $response !== 'VERIFIED' )
{
exit;
}
}
catch ( \Exception $e )
catch ( Exception )
{
exit;
}
@@ -141,35 +168,35 @@ class _Application extends \IPS\Application
$_items = $items;
try
{
$invoice = \IPS\nexus\Invoice::constructFromData( \IPS\Db::i()->select( '*', 'nexus_invoices', array( 'i_member=? AND i_status=?', $subscription['s_member'], 'pend' ), 'i_date DESC', 1 )->first() );
$invoice = Invoice::constructFromData( Db::i()->select( '*', 'nexus_invoices', array( 'i_member=? AND i_status=?', $subscription['s_member'], 'pend' ), 'i_date DESC', 1 )->first() );
foreach ( $invoice->items as $item )
{
if ( $item instanceof \IPS\nexus\Invoice\Item\Renewal and \in_array( $item->id, $_items ) )
if ( $item instanceof Renewal and in_array( $item->id, $_items ) )
{
unset( $_items[ array_search( $item->id, $_items ) ] );
}
}
}
catch ( \UnderflowException $e ) { }
catch ( UnderflowException ) { }
/* No, create one */
if ( \count( $_items ) )
if ( count( $_items ) )
{
$invoice = new \IPS\nexus\Invoice;
$invoice->member = \IPS\nexus\Customer::load( $subscription['s_member'] );
$invoice = new Invoice;
$invoice->member = Customer::load( $subscription['s_member'] );
foreach ( $items as $purchaseId )
{
try
{
$purchase = \IPS\nexus\Purchase::load( $purchaseId );
$purchase = Purchase::load( $purchaseId );
if ( $purchase->renewals and !$purchase->cancelled )
{
$invoice->addItem( \IPS\nexus\Invoice\Item\Renewal::create( $purchase ) );
$invoice->addItem( Renewal::create( $purchase ) );
}
}
catch ( \OutOfRangeException $e ) { }
catch ( OutOfRangeException ) { }
}
if ( !\count( $invoice->items ) )
if ( !count( $invoice->items ) )
{
exit;
}
@@ -177,14 +204,14 @@ class _Application extends \IPS\Application
}
/* And then log a transaction */
$transaction = new \IPS\nexus\Transaction;
$transaction = new Transaction;
$transaction->member = $invoice->member;
$transaction->invoice = $invoice;
if ( $gateway )
{
$transaction->method = $gateway;
}
$transaction->amount = new \IPS\nexus\Money( $_POST['mc_gross'], $_POST['mc_currency'] );
$transaction->amount = new Money( $_POST['mc_gross'], $_POST['mc_currency'] );
$transaction->gw_id = $_POST['txn_id'];
$transaction->approve();
@@ -193,123 +220,51 @@ class _Application extends \IPS\Application
{
$subscription['s_start_trans'] = $transaction->id;
\IPS\Db::i()->insert( 'nexus_subscriptions', $subscription );
Db::i()->insert( 'nexus_subscriptions', $subscription );
}
}
catch ( \UnderflowException $e ) { }
catch ( UnderflowException ) { }
}
exit;
}
}
/**
* Install Other
*
* @return void
*/
public function installOther()
{
/* Disable support module for new installations */
\IPS\Db::i()->update( 'core_modules', array( 'sys_module_visible' => 0 ), array( 'sys_module_application=? AND sys_module_key=? AND sys_module_area=?', 'nexus', 'support', 'admin' ) );
}
/**
* Returns the ACP Menu JSON for this application.
*
* @return array
*/
public function acpMenu()
{
$menu = parent::acpMenu();
if( $m = \IPS\Application\Module::get( 'nexus', 'support', 'admin' ) AND $m->visible )
{
$menu['support'] = array(
'requests' => array(
'tab' => 'nexus',
'controller' => 'requests',
'do' => '',
'restriction' => 'requests_manage',
'subcontrollers' => 'request'
),
'reports' => array(
'tab' => 'nexus',
'controller' => 'reports',
'do' => '',
'restriction' => 'reports_manage'
),
'settings' => array(
'tab' => 'nexus',
'controller' => 'settings',
'do' => '',
'restriction' => 'settings_manage'
),
'volume' => array(
'tab' => 'stats',
'controller' => 'volume',
'do' => '',
'restriction' => 'volume_manage'
),
);
}
return $menu;
}
/**
* @brief Cached menu counts
*/
protected $menuCounts = array();
protected array $menuCounts = array();
/**
* ACP Menu Numbers
*
* @param array $queryString Query String
* @param string $queryString Query String
* @return int
*/
public function acpMenuNumber( $queryString )
public function acpMenuNumber( string $queryString ): int
{
parse_str( $queryString, $queryString );
switch ( $queryString['controller'] )
parse_str( $queryString, $query );
switch ( $query['controller'] )
{
case 'transactions':
if( !isset( $this->menuCounts['transactions'] ) )
{
$this->menuCounts['transactions'] = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_transactions', array( \IPS\Db::i()->in( 't_status', array( \IPS\nexus\Transaction::STATUS_HELD, \IPS\nexus\Transaction::STATUS_WAITING, \IPS\nexus\Transaction::STATUS_REVIEW, \IPS\nexus\Transaction::STATUS_DISPUTED ) ) ) )->first();
$this->menuCounts['transactions'] = Db::i()->select( 'COUNT(*)', 'nexus_transactions', array( Db::i()->in( 't_status', array( Transaction::STATUS_HELD, Transaction::STATUS_WAITING, Transaction::STATUS_REVIEW, Transaction::STATUS_DISPUTED ) ) ) )->first();
}
return $this->menuCounts['transactions'];
break;
case 'shipping':
if( !isset( $this->menuCounts['shipping'] ) )
{
$this->menuCounts['shipping'] = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_ship_orders', array( 'o_status=?', \IPS\nexus\Shipping\Order::STATUS_PENDING ) )->first();
}
return $this->menuCounts['shipping'];
break;
case 'payouts':
if( !isset( $this->menuCounts['payouts'] ) )
{
$this->menuCounts['payouts'] = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_payouts', array( 'po_status=?', \IPS\nexus\Payout::STATUS_PENDING ) )->first();
$this->menuCounts['payouts'] = Db::i()->select( 'COUNT(*)', 'nexus_payouts', array( 'po_status=?', Payout::STATUS_PENDING ) )->first();
}
return $this->menuCounts['payouts'];
break;
case 'requests':
if( !isset( $this->menuCounts['requests'] ) )
{
$myStream = \IPS\nexus\Support\Stream::myStream();
$this->menuCounts['requests'] = $myStream->count( \IPS\Member::loggedIn() );
}
return $this->menuCounts['requests'];
break;
}
return 0;
}
/**
@@ -317,7 +272,7 @@ class _Application extends \IPS\Application
*
* @return int
*/
public static function cartCount()
public static function cartCount() : int
{
$count = 0;
foreach ( $_SESSION['cart'] as $item )
@@ -331,9 +286,9 @@ class _Application extends \IPS\Application
* [Node] Get Icon for tree
*
* @note Return the class for the icon (e.g. 'globe')
* @return string|null
* @return string
*/
protected function get__icon()
protected function get__icon(): string
{
return 'shopping-cart';
}
@@ -343,50 +298,50 @@ class _Application extends \IPS\Application
*
* @var string[]
*/
static $bypassSubscriptionCheckControllers = ['store', 'checkout', 'subscriptions', 'system', 'clients'];
static array $bypassSubscriptionCheckControllers = ['store', 'checkout', 'subscriptions', 'system', 'clients'];
/**
* Do Member Check
*
* @return \IPS\Http\Url|NULL
* @return Url|NULL
*/
public function doMemberCheck(): ?\IPS\Http\Url
public function doMemberCheck(): ?Url
{
/* These checks do not apply to staff accounts or support account */
if( \is_array( \IPS\Member::loggedIn()->modPermissions() ) OR \IPS\Member::loggedIn()->isAdmin() OR \IPS\Member::loggedIn()->members_bitoptions['is_support_account'] )
if( is_array( Member::loggedIn()->modPermissions() ) OR Member::loggedIn()->isAdmin() OR Member::loggedIn()->members_bitoptions['is_support_account'] )
{
return NULL;
}
if ( \IPS\Settings::i()->nexus_subs_enabled AND \IPS\Settings::i()->nexus_subs_register AND !\in_array( \IPS\Dispatcher::i()->module->key, static::$bypassSubscriptionCheckControllers ) )
if ( Settings::i()->nexus_subs_enabled AND Settings::i()->nexus_subs_register AND !in_array( Dispatcher::i()->module->key, static::$bypassSubscriptionCheckControllers ) )
{
if( !isset( \IPS\Data\Store::i()->nexus_sub_count ) )
if( !isset( Store::i()->nexus_sub_count ) )
{
\IPS\Data\Store::i()->nexus_sub_count = \IPS\Db::i()->select( 'count(*)', 'nexus_member_subscription_packages', [ 'sp_enabled=?', 1 ] )->first();
Store::i()->nexus_sub_count = Db::i()->select( 'count(*)', 'nexus_member_subscription_packages', [ 'sp_enabled=?', 1 ] )->first();
}
/* This user didn't join recently, so we don't need to redirect them */
if( \IPS\Data\Store::i()->nexus_sub_count AND (int) \IPS\Settings::i()->nexus_subs_register === 1 AND !\IPS\Member::loggedIn()->joinedRecently() )
if( Store::i()->nexus_sub_count AND (int) Settings::i()->nexus_subs_register === 1 AND !Member::loggedIn()->joinedRecently() )
{
return NULL;
}
if ( \IPS\Data\Store::i()->nexus_sub_count AND !\IPS\nexus\Subscription::loadByMember( \IPS\Member::loggedIn(), (int) \IPS\Settings::i()->nexus_subs_register === 2 ? TRUE : FALSE ) )
if ( Store::i()->nexus_sub_count AND !Subscription::loadByMember( Member::loggedIn(), (int) Settings::i()->nexus_subs_register === 2 ? TRUE : FALSE ) )
{
return \IPS\Http\Url::internal( "app=nexus&module=subscriptions&controller=subscriptions&register=" . (int) \IPS\Settings::i()->nexus_subs_register, 'front', 'nexus_subscriptions' );
return Url::internal( "app=nexus&module=subscriptions&controller=subscriptions&register=" . (int) Settings::i()->nexus_subs_register, 'front', 'nexus_subscriptions' );
}
}
if ( \IPS\Settings::i()->nexus_reg_force AND !\in_array( \IPS\Dispatcher::i()->module->key, static::$bypassSubscriptionCheckControllers ) AND \IPS\Member::loggedIn()->joinedRecently() )
if ( Settings::i()->nexus_reg_force AND !in_array( Dispatcher::i()->module->key, static::$bypassSubscriptionCheckControllers ) AND Member::loggedIn()->joinedRecently() )
{
if( !isset( \IPS\Data\Store::i()->nexus_reg_product_count ) )
if( !isset( Store::i()->nexus_reg_product_count ) )
{
\IPS\Data\Store::i()->nexus_reg_product_count = \IPS\nexus\Package::haveRegistrationProducts();
Store::i()->nexus_reg_product_count = Package::haveRegistrationProducts();
}
if ( \IPS\Data\Store::i()->nexus_reg_product_count AND !\IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( "ps_member=? AND ps_active=?", \IPS\Member::loggedIn()->member_id, 1 ) )->first() )
if ( Store::i()->nexus_reg_product_count AND !Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( "ps_member=? AND ps_active=?", Member::loggedIn()->member_id, 1 ) )->first() )
{
return \IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=store&controller=store&do=register', 'front', 'store' ) );
return Url::internal( 'app=nexus&module=store&controller=store&do=register', 'front', 'store' );
}
}
@@ -396,27 +351,62 @@ class _Application extends \IPS\Application
/**
* Can view page even when user is a guest when guests cannot access the site
*
* @param \IPS\Application\Module $module The module
* @param string $controller The controller
* @param string|NULL $do To "do" parameter
* @param Module $module The module
* @param string $controller The controller
* @param string|null $do To "do" parameter
* @return bool
*/
public function allowGuestAccess( \IPS\Application\Module $module, $controller, $do )
public function allowGuestAccess(Module $module, string $controller, ?string $do ): bool
{
if( ( \IPS\Settings::i()->nexus_reg_force OR \IPS\nexus\Package::haveRegistrationProducts() ) AND ( $module->key == 'store' OR $module->key == 'checkout' ) )
if( ( Settings::i()->nexus_reg_force OR Package::haveRegistrationProducts() ) AND ( $module->key == 'store' OR $module->key == 'checkout' ) )
{
return TRUE;
}
if ( \IPS\Settings::i()->nexus_subs_register AND ( \in_array( $module->key, [ 'store', 'checkout', 'subscriptions' ] ) ) )
if ( Settings::i()->nexus_subs_register AND ( in_array( $module->key, [ 'store', 'checkout', 'subscriptions' ] ) ) )
{
return TRUE;
}
if ( \IPS\Settings::i()->cm_ref_on AND $module->key == 'promotion' AND $controller == 'referral' )
if ( Settings::i()->cm_ref_on AND $module->key == 'promotion' AND $controller == 'referral' )
{
return TRUE;
}
return FALSE;
}
/**
* Can view page even when the member is validating
*
* @param Module $module
* @param string $controller
* @param string|null $do
* @return bool
*/
public function allowValidatingAccess( Module $module, string $controller, ?string $do ) : bool
{
return (
$module->key == 'store' and $controller == 'store'
) or (
$module->key == 'checkout' and $controller == 'checkout'
);
}
/**
* Do we run doMemberCheck for this controller?
* @see Application::doMemberCheck()(
*
* @param Module $module
* @param string $controller
* @param string|null $do
* @return bool
*/
public function skipDoMemberCheck( Module $module, string $controller, ?string $do ) : bool
{
return (
$module->key == 'subscriptions' and $controller == 'subscriptions'
);
}
/**
@@ -442,12 +432,14 @@ class _Application extends \IPS\Application
* @endcode
* @return array
*/
public function defaultFrontNavigation()
public function defaultFrontNavigation(): array
{
return array(
'rootTabs' => array(
array(
'key' => 'Store',
'app' => 'core',
'key' => 'Menu',
'title' => Member::loggedIn()->language()->get( 'module__nexus_store' ),
'children' => array(
array( 'key' => 'Store' ),
array( 'key' => 'Gifts' ),
@@ -470,15 +462,6 @@ class _Application extends \IPS\Application
)
)
),
),
array(
'app' => 'core',
'key' => 'CustomItem',
'title' => 'default_menu_item_support',
'config' => array( 'menu_custom_item_url' => 'app=nexus&module=support&controller=home', 'internal' => 'support' ),
'children' => array(
array( 'key' => 'Support' )
)
)
),
'browseTabs' => array(),
@@ -492,42 +475,21 @@ class _Application extends \IPS\Application
*
* @return void
*/
public function convertLegacyParameters()
public function convertLegacyParameters() : void
{
/* Support legacy subscriptions */
if( isset( \IPS\Request::i()->app ) AND \IPS\Request::i()->app == 'subscriptions' )
if( isset( Request::i()->app ) AND Request::i()->app == 'subscriptions' )
{
/* Redirecting isn't necessary, we just need to route the payment to the appropriate area.
@see \IPS\nexus\Application */
\IPS\Request::i()->app = 'nexus';
\IPS\Request::i()->module = 'payments';
\IPS\Request::i()->section = 'receive'; /* It actually looks for section=receive, so make sure we set that */
\IPS\Request::i()->controller = 'receive'; /* We set this just to be complete in case anywhere else only looks at controller */
\IPS\Request::i()->validate = 'paypal';
Request::i()->app = 'nexus';
Request::i()->module = 'payments';
Request::i()->section = 'receive'; /* It actually looks for section=receive, so make sure we set that */
Request::i()->controller = 'receive'; /* We set this just to be complete in case anywhere else only looks at controller */
Request::i()->validate = 'paypal';
}
}
/**
* Returns a list of all existing webhooks and their payload in this app.
*
* @return array
*/
public function getWebhooks(): array
{
foreach( [
\IPS\nexus\Support\Request::class,
\IPS\nexus\Support\Reply::class,
] as $class )
{
$key = str_replace( '\\', '', \substr( $class, 3 ) );
$hooks[$key .'_create'] = $class;
$hooks[$key .'_delete'] = $class;
\IPS\Member::loggedIn()->language()->words[ 'webhook_' . $key .'_create' ] = \IPS\Member::loggedIn()->language()->addToStack('webhook_contentitem_created', FALSE, ['sprintf' => [ $class::_indefiniteArticle() ]]);
\IPS\Member::loggedIn()->language()->words[ 'webhook_' . $key .'_delete' ] = \IPS\Member::loggedIn()->language()->addToStack('webhook_contentitem_deleted', FALSE, ['sprintf' => [ $class::_indefiniteArticle() ]]);
}
return $hooks;
}
/**
* Returns a list of essential cookies which are set by this app.
* Wildcards (*) can be used at the end of cookie names for PHP set cookies.
@@ -539,4 +501,52 @@ class _Application extends \IPS\Application
return [ 'cm_reg', 'location', 'currency', 'guestTransactionKey' ];
}
/**
* Retrieve additional form fields for adding an extension
* This should return an array where the key is the tag in
* the extension stub that will be replaced, and the value is
* the form field
*
* @param string $extensionType
* @param string $appKey The application creating the extension
* @return array
*/
public function extensionHelper( string $extensionType, string $appKey ) : array
{
$return = [];
if( $extensionType == 'Item' )
{
$return[ '{itemType}' ] = new Select( 'extension_invoice_item_type', null, true, [
'options' => [
'Purchase' => 'Purchase',
'Charge' => 'Charge'
]
]);
$return[ '{type}' ] = new Text( 'extension_item_key', null, true, [], function( $val ) use ( $appKey ){
foreach( SystemApplication::load( $appKey )->extensions( 'nexus', 'Item', false ) as $ext )
{
if( $ext::$type == $val )
{
throw new DomainException( 'err_duplicate_item_key' );
}
}
} );
}
return $return;
}
/**
* Output CSS files
*
* @return void
*/
public static function outputCss() : void
{
if ( Dispatcher::hasInstance() and Dispatcher::i()->controllerLocation === 'front' )
{
Output::i()->cssFiles = array_merge( Output::i()->cssFiles, Theme::i()->css( 'nexus.css', 'nexus', 'front' ) );
}
}
}