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
+199
-189
@@ -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®ister=" . (int) \IPS\Settings::i()->nexus_subs_register, 'front', 'nexus_subscriptions' );
|
||||
return Url::internal( "app=nexus&module=subscriptions&controller=subscriptions®ister=" . (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' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,16 +12,28 @@
|
||||
namespace IPS\nexus\api;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Api\Controller;
|
||||
use IPS\Api\Exception;
|
||||
use IPS\Api\PaginatedResponse;
|
||||
use IPS\Api\Response;
|
||||
use IPS\Db;
|
||||
use IPS\nexus\Invoice;
|
||||
use IPS\Request;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Invoices API
|
||||
*/
|
||||
class _invoices extends \IPS\Api\Controller
|
||||
class invoices extends Controller
|
||||
{
|
||||
/**
|
||||
* GET /nexus/invoices
|
||||
@@ -34,9 +46,10 @@ class _invoices extends \IPS\Api\Controller
|
||||
* @apiparam string sortDir Sort direction. Can be 'asc' or 'desc' - defaults to 'asc'
|
||||
* @apiparam int page Page number
|
||||
* @apiparam int perPage Number of results per page - defaults to 25
|
||||
* @return \IPS\Api\PaginatedResponse<IPS\nexus\Invoice>
|
||||
* @apireturn PaginatedResponse<IPS\nexus\Invoice>
|
||||
* @return PaginatedResponse<Invoice>
|
||||
*/
|
||||
public function GETindex()
|
||||
public function GETindex(): PaginatedResponse
|
||||
{
|
||||
/* Where clause */
|
||||
$where = array();
|
||||
@@ -46,37 +59,37 @@ class _invoices extends \IPS\Api\Controller
|
||||
{
|
||||
$where[] = array( 'i_member=?', $this->member->member_id );
|
||||
}
|
||||
elseif ( isset( \IPS\Request::i()->customers ) )
|
||||
elseif ( isset( Request::i()->customers ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 'i_member', array_map( 'intval', array_filter( explode( ',', \IPS\Request::i()->customers ) ) ) ) );
|
||||
$where[] = array( Db::i()->in( 'i_member', array_map( 'intval', array_filter( explode( ',', Request::i()->customers ) ) ) ) );
|
||||
}
|
||||
|
||||
/* Statuses */
|
||||
if ( isset( \IPS\Request::i()->statuses ) )
|
||||
if ( isset( Request::i()->statuses ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 'i_status', array_filter( explode( ',', \IPS\Request::i()->statuses ) ) ) );
|
||||
$where[] = array( Db::i()->in( 'i_status', array_filter( explode( ',', Request::i()->statuses ) ) ) );
|
||||
}
|
||||
|
||||
/* Sort */
|
||||
if ( isset( \IPS\Request::i()->sortBy ) and \in_array( \IPS\Request::i()->sortBy, array( 'date', 'title', 'total' ) ) )
|
||||
if ( isset( Request::i()->sortBy ) and in_array( Request::i()->sortBy, array( 'date', 'title', 'total' ) ) )
|
||||
{
|
||||
$sortBy = 'i_' . \IPS\Request::i()->sortBy;
|
||||
$sortBy = 'i_' . Request::i()->sortBy;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sortBy = 'i_id';
|
||||
}
|
||||
$sortDir = ( isset( \IPS\Request::i()->sortDir ) and \in_array( mb_strtolower( \IPS\Request::i()->sortDir ), array( 'asc', 'desc' ) ) ) ? \IPS\Request::i()->sortDir : 'asc';
|
||||
$sortDir = ( isset( Request::i()->sortDir ) and in_array( mb_strtolower( Request::i()->sortDir ), array( 'asc', 'desc' ) ) ) ? Request::i()->sortDir : 'asc';
|
||||
|
||||
/* Return */
|
||||
return new \IPS\Api\PaginatedResponse(
|
||||
return new PaginatedResponse(
|
||||
200,
|
||||
\IPS\Db::i()->select( '*', 'nexus_invoices', $where, "{$sortBy} {$sortDir}" ),
|
||||
isset( \IPS\Request::i()->page ) ? \IPS\Request::i()->page : 1,
|
||||
Db::i()->select( '*', 'nexus_invoices', $where, "{$sortBy} {$sortDir}" ),
|
||||
isset( Request::i()->page ) ? Request::i()->page : 1,
|
||||
'IPS\nexus\Invoice',
|
||||
\IPS\Db::i()->select( 'COUNT(*)', 'nexus_invoices', $where )->first(),
|
||||
Db::i()->select( 'COUNT(*)', 'nexus_invoices', $where )->first(),
|
||||
$this->member,
|
||||
isset( \IPS\Request::i()->perPage ) ? \IPS\Request::i()->perPage : NULL
|
||||
isset( Request::i()->perPage ) ? Request::i()->perPage : NULL
|
||||
);
|
||||
}
|
||||
|
||||
@@ -86,23 +99,24 @@ class _invoices extends \IPS\Api\Controller
|
||||
*
|
||||
* @param int $id ID Number
|
||||
* @throws 2X299/1 INVALID_ID The invoice ID does not exist or the authorized user does not have permission to view it
|
||||
* @return \IPS\nexus\Invoice
|
||||
* @apireturn \IPS\nexus\Invoice
|
||||
* @return Response
|
||||
*/
|
||||
public function GETitem( $id )
|
||||
public function GETitem( int $id ): Response
|
||||
{
|
||||
try
|
||||
{
|
||||
$object = \IPS\nexus\Invoice::load( $id );
|
||||
$object = Invoice::load( $id );
|
||||
if ( $this->member and !$object->canView( $this->member ) )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
throw new OutOfRangeException;
|
||||
}
|
||||
|
||||
return new \IPS\Api\Response( 200, $object->apiOutput( $this->member ) );
|
||||
return new Response( 200, $object->apiOutput( $this->member ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'INVALID_ID', '2X299/1', 404 );
|
||||
throw new Exception( 'INVALID_ID', '2X299/1', 404 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,16 +12,25 @@
|
||||
namespace IPS\nexus\api;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Api\Controller;
|
||||
use IPS\Api\Exception;
|
||||
use IPS\Api\Response;
|
||||
use IPS\nexus\Purchase\LicenseKey;
|
||||
use IPS\Request;
|
||||
use OutOfRangeException;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief License Key API
|
||||
*/
|
||||
class _lkey extends \IPS\Api\Controller
|
||||
class lkey extends Controller
|
||||
{
|
||||
/**
|
||||
* GET /nexus/lkey/{key}
|
||||
@@ -29,24 +38,25 @@ class _lkey extends \IPS\Api\Controller
|
||||
*
|
||||
* @param string $lkey License key
|
||||
* @throws 2X310/1 INVALID_KEY The license key does not exist or the authorized user does not have permission to view it
|
||||
* @return \IPS\nexus\Purchase
|
||||
* @apireturn \IPS\nexus\Purchase
|
||||
* @return Response
|
||||
*/
|
||||
public function GETitem( $lkey )
|
||||
public function GETitem( string $lkey ): Response
|
||||
{
|
||||
try
|
||||
{
|
||||
$licenseKey = \IPS\nexus\Purchase\LicenseKey::load( $lkey );
|
||||
$licenseKey = LicenseKey::load( $lkey );
|
||||
$purchase = $licenseKey->purchase;
|
||||
if ( $this->member and !$purchase->canView( $this->member ) )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
throw new OutOfRangeException;
|
||||
}
|
||||
|
||||
return new \IPS\Api\Response( 200, $purchase->apiOutput( $this->member ) );
|
||||
return new Response( 200, $purchase->apiOutput( $this->member ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'INVALID_KEY', '2X332/1', 404 );
|
||||
throw new Exception( 'INVALID_KEY', '2X332/1', 404 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,24 +68,25 @@ class _lkey extends \IPS\Api\Controller
|
||||
* @apiparam object customFields Values for custom fields
|
||||
* @param string $lkey License key
|
||||
* @throws 2X310/2 INVALID_KEY The license key does not exist
|
||||
* @return \IPS\nexus\Purchase
|
||||
* @apireturn \IPS\nexus\Purchase
|
||||
* @return Response
|
||||
*/
|
||||
public function POSTitem( $lkey )
|
||||
public function POSTitem( string $lkey ): Response
|
||||
{
|
||||
try
|
||||
{
|
||||
$licenseKey = \IPS\nexus\Purchase\LicenseKey::load( $lkey );
|
||||
$purchase = $licenseKey->purchase;
|
||||
$licenseKey = LicenseKey::load( $lkey );
|
||||
$purchase = $licenseKey->purchase;
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'INVALID_KEY', '2X332/2', 404 );
|
||||
throw new Exception( 'INVALID_KEY', '2X332/2', 404 );
|
||||
}
|
||||
|
||||
if ( isset( \IPS\Request::i()->customFields ) )
|
||||
if ( isset( Request::i()->customFields ) )
|
||||
{
|
||||
$customFields = $purchase->custom_fields;
|
||||
foreach ( \IPS\Request::i()->customFields as $k => $v )
|
||||
foreach ( Request::i()->customFields as $k => $v )
|
||||
{
|
||||
$customFields[ $k ] = $v;
|
||||
}
|
||||
@@ -84,6 +95,6 @@ class _lkey extends \IPS\Api\Controller
|
||||
|
||||
$purchase->save();
|
||||
|
||||
return new \IPS\Api\Response( 200, $purchase->apiOutput( $this->member ) );
|
||||
return new Response( 200, $purchase->apiOutput( $this->member ) );
|
||||
}
|
||||
}
|
||||
@@ -12,16 +12,30 @@
|
||||
namespace IPS\nexus\api;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Api\Controller;
|
||||
use IPS\Api\Exception;
|
||||
use IPS\Api\PaginatedResponse;
|
||||
use IPS\Api\Response;
|
||||
use IPS\Application;
|
||||
use IPS\Db;
|
||||
use IPS\nexus\Purchase;
|
||||
use IPS\Request;
|
||||
use OutOfRangeException;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
use function intval;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Purchases API
|
||||
*/
|
||||
class _purchases extends \IPS\Api\Controller
|
||||
class purchases extends Controller
|
||||
{
|
||||
/**
|
||||
* GET /nexus/purchases
|
||||
@@ -40,82 +54,83 @@ class _purchases extends \IPS\Api\Controller
|
||||
* @apiparam string sortDir Sort direction. Can be 'asc' or 'desc' - defaults to 'asc'
|
||||
* @apiparam int page Page number
|
||||
* @apiparam int perPage Number of results per page - defaults to 25
|
||||
* @return \IPS\Api\PaginatedResponse<IPS\nexus\Purchase>
|
||||
* @apireturn PaginatedResponse<IPS\nexus\Purchase>
|
||||
* @return PaginatedResponse<Purchase>
|
||||
*/
|
||||
public function GETindex()
|
||||
public function GETindex(): PaginatedResponse
|
||||
{
|
||||
/* Where clause */
|
||||
$where = array();
|
||||
|
||||
/* Get only the purchases from active applications */
|
||||
$where[] = array( "ps_app IN('" . implode( "','", array_keys( \IPS\Application::enabledApplications() ) ) . "')" );
|
||||
$where[] = array( "ps_app IN('" . implode( "','", array_keys( Application::enabledApplications() ) ) . "')" );
|
||||
|
||||
/* Customers */
|
||||
if ( $this->member )
|
||||
{
|
||||
$where[] = array( 'ps_member=?', $this->member->member_id );
|
||||
}
|
||||
elseif ( isset( \IPS\Request::i()->customers ) )
|
||||
elseif ( isset( Request::i()->customers ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 'ps_member', array_map( 'intval', array_filter( explode( ',', \IPS\Request::i()->customers ) ) ) ) );
|
||||
$where[] = array( Db::i()->in( 'ps_member', array_map( 'intval', array_filter( explode( ',', Request::i()->customers ) ) ) ) );
|
||||
}
|
||||
|
||||
/* Status */
|
||||
if ( isset( \IPS\Request::i()->active ) )
|
||||
if ( isset( Request::i()->active ) )
|
||||
{
|
||||
$where[] = array( 'ps_active=?', \intval( \IPS\Request::i()->active ) );
|
||||
$where[] = array( 'ps_active=?', intval( Request::i()->active ) );
|
||||
}
|
||||
if ( isset( \IPS\Request::i()->canceled ) )
|
||||
if ( isset( Request::i()->canceled ) )
|
||||
{
|
||||
$where[] = array( 'ps_cancelled=?', \intval( \IPS\Request::i()->canceled ) );
|
||||
$where[] = array( 'ps_cancelled=?', intval( Request::i()->canceled ) );
|
||||
}
|
||||
|
||||
/* Item */
|
||||
if ( isset( \IPS\Request::i()->itemApp ) )
|
||||
if ( isset( Request::i()->itemApp ) )
|
||||
{
|
||||
$where[] = array( 'ps_app=?', \IPS\Request::i()->itemApp );
|
||||
$where[] = array( 'ps_app=?', Request::i()->itemApp );
|
||||
}
|
||||
if ( isset( \IPS\Request::i()->itemType ) )
|
||||
if ( isset( Request::i()->itemType ) )
|
||||
{
|
||||
$where[] = array( 'ps_type=?', \IPS\Request::i()->itemType );
|
||||
$where[] = array( 'ps_type=?', Request::i()->itemType );
|
||||
}
|
||||
if ( isset( \IPS\Request::i()->itemId ) )
|
||||
if ( isset( Request::i()->itemId ) )
|
||||
{
|
||||
$where[] = array( 'ps_item_id=?', \IPS\Request::i()->itemId );
|
||||
$where[] = array( 'ps_item_id=?', Request::i()->itemId );
|
||||
}
|
||||
|
||||
/* Parent */
|
||||
if ( isset( \IPS\Request::i()->parent ) )
|
||||
if ( isset( Request::i()->parent ) )
|
||||
{
|
||||
$where[] = array( 'ps_parent=?', \intval( \IPS\Request::i()->parent ) );
|
||||
$where[] = array( 'ps_parent=?', intval( Request::i()->parent ) );
|
||||
}
|
||||
|
||||
/* Show */
|
||||
if ( isset( \IPS\Request::i()->show ) )
|
||||
if ( isset( Request::i()->show ) )
|
||||
{
|
||||
$where[] = array( 'ps_show=?', \intval( \IPS\Request::i()->show ) );
|
||||
$where[] = array( 'ps_show=?', intval( Request::i()->show ) );
|
||||
}
|
||||
|
||||
/* Sort */
|
||||
if ( isset( \IPS\Request::i()->sortBy ) and \in_array( \IPS\Request::i()->sortBy, array( 'start', 'expire' ) ) )
|
||||
if ( isset( Request::i()->sortBy ) and in_array( Request::i()->sortBy, array( 'start', 'expire' ) ) )
|
||||
{
|
||||
$sortBy = 'ps_' . \IPS\Request::i()->sortBy;
|
||||
$sortBy = 'ps_' . Request::i()->sortBy;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sortBy = 'ps_id';
|
||||
}
|
||||
$sortDir = ( isset( \IPS\Request::i()->sortDir ) and \in_array( mb_strtolower( \IPS\Request::i()->sortDir ), array( 'asc', 'desc' ) ) ) ? \IPS\Request::i()->sortDir : 'asc';
|
||||
$sortDir = ( isset( Request::i()->sortDir ) and in_array( mb_strtolower( Request::i()->sortDir ), array( 'asc', 'desc' ) ) ) ? Request::i()->sortDir : 'asc';
|
||||
|
||||
/* Return */
|
||||
return new \IPS\Api\PaginatedResponse(
|
||||
return new PaginatedResponse(
|
||||
200,
|
||||
\IPS\Db::i()->select( '*', 'nexus_purchases', $where, "{$sortBy} {$sortDir}" ),
|
||||
isset( \IPS\Request::i()->page ) ? \IPS\Request::i()->page : 1,
|
||||
Db::i()->select( '*', 'nexus_purchases', $where, "{$sortBy} {$sortDir}" ),
|
||||
isset( Request::i()->page ) ? Request::i()->page : 1,
|
||||
'IPS\nexus\Purchase',
|
||||
\IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', $where )->first(),
|
||||
Db::i()->select( 'COUNT(*)', 'nexus_purchases', $where )->first(),
|
||||
$this->member,
|
||||
isset( \IPS\Request::i()->perPage ) ? \IPS\Request::i()->perPage : NULL
|
||||
isset( Request::i()->perPage ) ? Request::i()->perPage : NULL
|
||||
);
|
||||
}
|
||||
|
||||
@@ -125,23 +140,24 @@ class _purchases extends \IPS\Api\Controller
|
||||
*
|
||||
* @param int $id ID Number
|
||||
* @throws 2X310/1 INVALID_ID The purchase ID does not exist or the authorized user does not have permission to view it
|
||||
* @return \IPS\nexus\Purchase
|
||||
* @apireturn \IPS\nexus\Purchase
|
||||
* @return Response
|
||||
*/
|
||||
public function GETitem( $id )
|
||||
public function GETitem( int $id ): Response
|
||||
{
|
||||
try
|
||||
{
|
||||
$object = \IPS\nexus\Purchase::load( $id );
|
||||
$object = Purchase::load( $id );
|
||||
if ( $this->member and !$object->canView( $this->member ) )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
throw new OutOfRangeException;
|
||||
}
|
||||
|
||||
return new \IPS\Api\Response( 200, $object->apiOutput( $this->member ) );
|
||||
return new Response( 200, $object->apiOutput( $this->member ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'INVALID_ID', '2X309/1', 404 );
|
||||
throw new Exception( 'INVALID_ID', '2X309/1', 404 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,23 +169,24 @@ class _purchases extends \IPS\Api\Controller
|
||||
* @apiparam object customFields Values for custom fields
|
||||
* @param int $id ID Number
|
||||
* @throws 2X309/1 INVALID_ID The purchase ID does not exist
|
||||
* @return \IPS\nexus\Purchase
|
||||
* @apireturn \IPS\nexus\Purchase
|
||||
* @return Response
|
||||
*/
|
||||
public function POSTitem( $id )
|
||||
public function POSTitem( int $id ): Response
|
||||
{
|
||||
try
|
||||
{
|
||||
$purchase = \IPS\nexus\Purchase::load( $id );
|
||||
$purchase = Purchase::load( $id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'INVALID_ID', '2X309/1', 404 );
|
||||
throw new Exception( 'INVALID_ID', '2X309/1', 404 );
|
||||
}
|
||||
|
||||
if ( isset( \IPS\Request::i()->customFields ) )
|
||||
if ( isset( Request::i()->customFields ) )
|
||||
{
|
||||
$customFields = $purchase->custom_fields;
|
||||
foreach ( \IPS\Request::i()->customFields as $k => $v )
|
||||
foreach ( Request::i()->customFields as $k => $v )
|
||||
{
|
||||
$customFields[ $k ] = $v;
|
||||
}
|
||||
@@ -178,6 +195,6 @@ class _purchases extends \IPS\Api\Controller
|
||||
|
||||
$purchase->save();
|
||||
|
||||
return new \IPS\Api\Response( 200, $purchase->apiOutput( $this->member ) );
|
||||
return new Response( 200, $purchase->apiOutput( $this->member ) );
|
||||
}
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Shipments API
|
||||
* @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 Dec 2015
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\api;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Shipments API
|
||||
*/
|
||||
class _shipments extends \IPS\Api\Controller
|
||||
{
|
||||
/**
|
||||
* GET /nexus/shipments
|
||||
* Get list of shipments
|
||||
*
|
||||
* @note For requests using an OAuth Access Token for a particular member, only the members own shipments will be included
|
||||
* @apiparam string statuses Comma-delimited list of statuses - if provided, only transactions with those statuses are returned - see order object for status keys
|
||||
* @apiparam string methods Comma-delimited list of shipping method IDs - if provided, only shipments from those methods are returned
|
||||
* @apiparam string sortBy What to sort by. Can be 'date', 'shipped_date' or do not specify for ID
|
||||
* @apiparam string sortDir Sort direction. Can be 'asc' or 'desc' - defaults to 'asc'
|
||||
* @apiparam int page Page number
|
||||
* @apiparam int perPage Number of results per page - defaults to 25
|
||||
* @return \IPS\Api\PaginatedResponse<IPS\nexus\Shipping\Order>
|
||||
*/
|
||||
public function GETindex()
|
||||
{
|
||||
/* Where clause */
|
||||
$where = array();
|
||||
|
||||
/* Statuses */
|
||||
if ( isset( \IPS\Request::i()->statuses ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 'o_status', array_filter( explode( ',', \IPS\Request::i()->statuses ) ) ) );
|
||||
}
|
||||
|
||||
/* Methods */
|
||||
if ( isset( \IPS\Request::i()->methods ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 'o_method', array_filter( explode( ',', \IPS\Request::i()->methods ) ) ) );
|
||||
}
|
||||
|
||||
/* Permission */
|
||||
if ( $this->member )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 'o_invoice', iterator_to_array( \IPS\Db::i()->select( 'i_id', 'nexus_invoices', array( 'i_member=?', $this->member->member_id ) ) ) ) );
|
||||
}
|
||||
|
||||
/* Sort */
|
||||
if ( isset( \IPS\Request::i()->sortBy ) and \in_array( \IPS\Request::i()->sortBy, array( 'date', 'shipped_date' ) ) )
|
||||
{
|
||||
$sortBy = 'o_' . \IPS\Request::i()->sortBy;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sortBy = 'o_id';
|
||||
}
|
||||
$sortDir = ( isset( \IPS\Request::i()->sortDir ) and \in_array( mb_strtolower( \IPS\Request::i()->sortDir ), array( 'asc', 'desc' ) ) ) ? \IPS\Request::i()->sortDir : 'asc';
|
||||
|
||||
/* Return */
|
||||
return new \IPS\Api\PaginatedResponse(
|
||||
200,
|
||||
\IPS\Db::i()->select( '*', 'nexus_ship_orders', $where, "{$sortBy} {$sortDir}" ),
|
||||
isset( \IPS\Request::i()->page ) ? \IPS\Request::i()->page : 1,
|
||||
'IPS\nexus\Shipping\Order',
|
||||
\IPS\Db::i()->select( 'COUNT(*)', 'nexus_ship_orders', $where )->first(),
|
||||
$this->member,
|
||||
isset( \IPS\Request::i()->perPage ) ? \IPS\Request::i()->perPage : NULL
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /nexus/shipments/{id}
|
||||
* Get information about a specific shipment
|
||||
*
|
||||
* @param int $id ID Number
|
||||
* @throws 2X307/1 INVALID_ID The shipment ID does not exist or the authorized user does not have permission to view it
|
||||
* @return \IPS\nexus\Shipping\Order
|
||||
*/
|
||||
public function GETitem( $id )
|
||||
{
|
||||
try
|
||||
{
|
||||
$shipment = \IPS\nexus\Shipping\Order::load( $id );
|
||||
if ( $this->member and !$shipment->invoice->canView( $this->member ) )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
return new \IPS\Api\Response( 200, $shipment->apiOutput( $this->member ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'INVALID_ID', '2X308/1', 404 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,294 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Support Replies API
|
||||
* @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 11 Dec 2015
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\api;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Support Replies API
|
||||
*/
|
||||
class _supportreplies extends \IPS\Content\Api\CommentController
|
||||
{
|
||||
/**
|
||||
* Class
|
||||
*/
|
||||
protected $class = 'IPS\nexus\Support\Reply';
|
||||
|
||||
/**
|
||||
* GET /nexus/supportreplies
|
||||
* Get list of support replies
|
||||
*
|
||||
* @note For requests using an OAuth Access Token for a particular member, only topics the authorized user can view will be included - if the user is a staff member, will use their staff permissions
|
||||
* @apiparam int staffReplies If 1, only replies by staff will be included. If 0, only replies by non-staff.
|
||||
* @apiparam string authors Comma-delimited list of member IDs - if provided, only replies by those members are returned
|
||||
* @apiparam string departments Comma-delimited list of department IDs
|
||||
* @apiparam string statuses Comma-delimited list of status IDs
|
||||
* @apiparam string severities Comma-delimited list of severity IDs
|
||||
* @apiparam string sortBy What to sort by. Can be 'date', 'title' or leave unspecified for ID
|
||||
* @apiparam string sortDir Sort direction. Can be 'asc' or 'desc' - defaults to 'asc'
|
||||
* @apiparam int page Page number
|
||||
* @apiparam int perPage Number of results per page - defaults to 25
|
||||
* @return \IPS\Api\PaginatedResponse<IPS\nexus\Support\Reply>
|
||||
*/
|
||||
public function GETindex()
|
||||
{
|
||||
/* Init */
|
||||
$where = array();
|
||||
|
||||
/* Type */
|
||||
if ( isset( \IPS\Request::i()->staffReplies ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 'reply_type', \IPS\Request::i()->staffReplies ? array( \IPS\nexus\Support\Reply::REPLY_STAFF, \IPS\nexus\Support\Reply::REPLY_HIDDEN ) : array( \IPS\nexus\Support\Reply::REPLY_MEMBER, \IPS\nexus\Support\Reply::REPLY_ALTCONTACT, \IPS\nexus\Support\Reply::REPLY_EMAIL ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where[] = array( 'reply_type<>?', \IPS\nexus\Support\Reply::REPLY_PENDING );
|
||||
}
|
||||
|
||||
/* Departments */
|
||||
if ( isset( \IPS\Request::i()->departments ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 'r_department', array_map( 'intval', array_filter( explode( ',', \IPS\Request::i()->departments ) ) ) ) );
|
||||
}
|
||||
|
||||
/* Statuses */
|
||||
if ( isset( \IPS\Request::i()->statuses ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 'r_status', array_map( 'intval', array_filter( explode( ',', \IPS\Request::i()->statuses ) ) ) ) );
|
||||
}
|
||||
|
||||
/* Severities */
|
||||
if ( isset( \IPS\Request::i()->severities ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 'r_severity', array_map( 'intval', array_filter( explode( ',', \IPS\Request::i()->statuses ) ) ) ) );
|
||||
}
|
||||
|
||||
/* Are we a staff member? */
|
||||
$bypassPerms = FALSE;
|
||||
if ( $this->member and $this->member->isAdmin() and \count( \IPS\nexus\Support\Department::departmentsWithPermission( $this->member ) ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 'r_department', array_keys( iterator_to_array( \IPS\nexus\Support\Department::departmentsWithPermission( $this->member ) ) ) ) );
|
||||
$bypassPerms = TRUE;
|
||||
}
|
||||
|
||||
/* Return */
|
||||
return $this->_list( $where, NULL, $bypassPerms );
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /nexus/supportreplies/{id}
|
||||
* View information about a specific reply
|
||||
*
|
||||
* @param int $id ID Number
|
||||
* @throws 2X314/1 INVALID_ID The reply ID does not exist or the authorized user does not have permission to view it
|
||||
* @return \IPS\nexus\Support\Reply
|
||||
*/
|
||||
public function GETitem( $id )
|
||||
{
|
||||
try
|
||||
{
|
||||
$class = $this->class;
|
||||
if ( $this->member )
|
||||
{
|
||||
$object = $class::loadAndCheckPerms( $id, $this->member );
|
||||
}
|
||||
else
|
||||
{
|
||||
$object = $class::load( $id );
|
||||
}
|
||||
|
||||
return new \IPS\Api\Response( 200, $object->apiOutput( $this->member ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'INVALID_ID', '2X314/1', 404 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /nexus/supportreplies
|
||||
* Create a reply
|
||||
*
|
||||
* @reqapiparam int request The ID number of the request the reply is for
|
||||
* @reqapiparam int author The ID number of the member making the post (0 for guest). Required for requests made using an API Key or the Client Credentials Grant Type. For requests using an OAuth Access Token for a particular member, that member will always be the author.
|
||||
* @reqapiparam string message The reply content as HTML (e.g. "<p>This is a post.</p>"). Will be sanatized for requests using an OAuth Access Token for a particular member; will be saved unaltered for requests made using an API Key or the Client Credentials Grant Type.
|
||||
* @apiparam datetime date The date/time that should be used for the topic/post post date. If not provided, will use the current date/time. Ignored for requests using an OAuth Access Token for a particular member
|
||||
* @apiparam string ip_address The IP address that should be stored for the topic/post. If not provided, will use the IP address from the API request. Ignored for requests using an OAuth Access Token for a particular member
|
||||
* @apiparam bool hidden If true will be added as a hidden note. Ignored if authorized member is not staff
|
||||
* @throws 2X314/2 NO_REQUEST The support request ID does not exist or the authorized user does not have permission to access it
|
||||
* @throws 1X314/3 NO_AUTHOR The author ID does not exist
|
||||
* @throws 1X314/4 NO_MESSAGE No message was supplied
|
||||
* @return \IPS\nexus\Support\Reply
|
||||
*/
|
||||
public function POSTindex()
|
||||
{
|
||||
/* Get request */
|
||||
try
|
||||
{
|
||||
$request = \IPS\nexus\Support\Request::load( \IPS\Request::i()->request );
|
||||
if ( $this->member )
|
||||
{
|
||||
if ( $request->canView( $this->member ) )
|
||||
{
|
||||
// Okay
|
||||
}
|
||||
elseif ( $this->member->isAdmin() and ( $request->department->staff === '*' or \count( array_intersect( explode( ',', $request->department->staff ), Department::staffDepartmentPerms( $this->member ) ) ) ) )
|
||||
{
|
||||
// Okay
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'NO_REQUEST', '2X314/2', 403 );
|
||||
}
|
||||
|
||||
/* Get author */
|
||||
if ( $this->member )
|
||||
{
|
||||
$author = $this->member;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( \IPS\Request::i()->author )
|
||||
{
|
||||
$author = \IPS\Member::load( \IPS\Request::i()->author );
|
||||
if ( !$author->member_id )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'NO_AUTHOR', '1X314/3', 403 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( \IPS\Request::i()->author === 0 )
|
||||
{
|
||||
$author = new \IPS\Member;
|
||||
$author->name = \IPS\Request::i()->author_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'NO_AUTHOR', '1X314/3', 400 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check we have a post */
|
||||
if ( !\IPS\Request::i()->message )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'NO_MESSAGE', '1X314/4', 403 );
|
||||
}
|
||||
|
||||
/* Do it */
|
||||
return $this->_create( $request, $author, 'message' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Create
|
||||
*
|
||||
* @param \IPS\Content\Item $item Content Item
|
||||
* @param \IPS\Member $author Author
|
||||
* @param string $contentParam The parameter that contains the content body
|
||||
* @return \IPS\Api\Response
|
||||
*/
|
||||
protected function _createComment( \IPS\Content\Item $item, \IPS\Member $author, $contentParam='content' )
|
||||
{
|
||||
$comment = parent::_createComment( $item, $author, $contentParam );
|
||||
if ( $this->member )
|
||||
{
|
||||
if ( !$item->canView( $this->member ) )
|
||||
{
|
||||
$comment->type = $comment::REPLY_STAFF;
|
||||
if ( \IPS\Request::i()->hidden )
|
||||
{
|
||||
$comment->type = $comment::REPLY_HIDDEN;
|
||||
}
|
||||
}
|
||||
}
|
||||
$comment->save();
|
||||
return $comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /nexus/supportreplies/{id}
|
||||
* Edit a reply
|
||||
*
|
||||
* @apiclientonly
|
||||
* @param int $id ID Number
|
||||
* @apiparam int author The ID number of the member making the post (0 for guest)
|
||||
* @apiparam string message The post content as HTML (e.g. "<p>This is a post.</p>")
|
||||
* @throws 2X314/5 INVALID_ID The post ID does not exist
|
||||
* @throws 1X314/6 NO_AUTHOR The author ID does not exist
|
||||
* @return \IPS\forums\Topic\Post
|
||||
*/
|
||||
public function POSTitem( $id )
|
||||
{
|
||||
try
|
||||
{
|
||||
/* Load */
|
||||
$post = \IPS\nexus\Support\Reply::load( $id );
|
||||
|
||||
/* Do it */
|
||||
try
|
||||
{
|
||||
return $this->_edit( $post, 'message' );
|
||||
}
|
||||
catch ( \InvalidArgumentException $e )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'NO_AUTHOR', '1X314/6', 400 );
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'INVALID_ID', '2X314/5', 404 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DELETE /nexus/supportreplies/{id}
|
||||
* Deletes a reply
|
||||
*
|
||||
* @apiclientonly
|
||||
* @param int $id ID Number
|
||||
* @throws 2X314/7 INVALID_ID The post ID does not exist
|
||||
* @throws 1X314/8 CANNOT_DELETE_FIRST_POST You cannot delete the first reply to a request. Delete the request itself instead.
|
||||
* @return void
|
||||
*/
|
||||
public function DELETEitem( $id )
|
||||
{
|
||||
try
|
||||
{
|
||||
$reply = \IPS\nexus\Support\Reply::load( $id );
|
||||
|
||||
if ( $reply->isFirst() )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'CANNOT_DELETE_FIRST_POST', '1X314/8', 403 );
|
||||
}
|
||||
|
||||
$reply->delete();
|
||||
|
||||
return new \IPS\Api\Response( 200, NULL );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'INVALID_ID', '2X314/7', 404 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,402 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Support Requests API
|
||||
* @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 4 Dec 2015
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\api;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Support Requests API
|
||||
*/
|
||||
class _supportrequests extends \IPS\Content\Api\ItemController
|
||||
{
|
||||
/**
|
||||
* Class
|
||||
*/
|
||||
protected $class = 'IPS\nexus\Support\Request';
|
||||
|
||||
/**
|
||||
* GET /nexus/supportrequests
|
||||
* Get list of support requests
|
||||
*
|
||||
* @note For requests using an OAuth Access Token for a particular member, only topics the authorized user can view will be included - if the user is a staff member, will use their staff permissions
|
||||
* @apiparam string authors Comma-delimited list of member IDs - if provided, only support requests belonging to those members (or emails specified by email param) are returned
|
||||
* @apiparam string email Comma-delimited list of email addresses - if provided, only support requests created by those emails (or members specified by authors param) are returned
|
||||
* @apiparam string departments Comma-delimited list of department IDs
|
||||
* @apiparam string statuses Comma-delimited list of status IDs
|
||||
* @apiparam string severities Comma-delimited list of severity IDs
|
||||
* @apiparam string purchases Comma-delimited list of purchase IDs - if provided, only support requests associated with one of the provided purchase IDs are returned
|
||||
* @apiparam string staff Comma-delimited list of member IDs - if provided, only support requests assigned to the staff members with one of the provided IDs are returned
|
||||
* @apiparam int hidden If 1, only replies which are hidden are returned, if 0 only not hidden
|
||||
* @apiparam string sortBy What to sort by. Can be 'date', 'title' or leave unspecified for ID
|
||||
* @apiparam string sortDir Sort direction. Can be 'asc' or 'desc' - defaults to 'asc'
|
||||
* @apiparam int page Page number
|
||||
* @apiparam int perPage Number of results per page - defaults to 25
|
||||
* @return \IPS\Api\PaginatedResponse<IPS\nexus\Support\Request>
|
||||
*/
|
||||
public function GETindex()
|
||||
{
|
||||
/* Init */
|
||||
$where = array();
|
||||
|
||||
/* Authors */
|
||||
if ( isset( \IPS\Request::i()->authors ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 'r_member', array_map( 'intval', array_filter( explode( ',', \IPS\Request::i()->authors ) ) ) ) );
|
||||
}
|
||||
if ( isset( \IPS\Request::i()->authors ) and isset( \IPS\Request::i()->emails ) )
|
||||
{
|
||||
$where[] = array( '( ' . \IPS\Db::i()->in( 'r_member', array_filter( explode( ',', \IPS\Request::i()->authors ) ) ) . ' OR ' . \IPS\Db::i()->in( 'r_email', array_filter( explode( ',', \IPS\Request::i()->emails ) ) ) . ' )' );
|
||||
}
|
||||
elseif ( isset( \IPS\Request::i()->authors ) )
|
||||
{
|
||||
$where[] = array( '( ' . \IPS\Db::i()->in( 'r_member', array_filter( explode( ',', \IPS\Request::i()->authors ) ) ) . ' OR r_email<>? )', '' );
|
||||
}
|
||||
elseif ( isset( \IPS\Request::i()->emails ) )
|
||||
{
|
||||
$where[] = array( '( r_member>0 OR ' . \IPS\Db::i()->findInSet( 'r_email', array_filter( explode( ',', \IPS\Request::i()->emails ) ) ) . ' )' );
|
||||
}
|
||||
|
||||
/* Departments */
|
||||
if ( isset( \IPS\Request::i()->departments ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 'r_department', array_map( 'intval', array_filter( explode( ',', \IPS\Request::i()->departments ) ) ) ) );
|
||||
}
|
||||
|
||||
/* Statuses */
|
||||
if ( isset( \IPS\Request::i()->statuses ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 'r_status', array_map( 'intval', array_filter( explode( ',', \IPS\Request::i()->statuses ) ) ) ) );
|
||||
}
|
||||
|
||||
/* Severities */
|
||||
if ( isset( \IPS\Request::i()->severities ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 'r_severity', array_map( 'intval', array_filter( explode( ',', \IPS\Request::i()->statuses ) ) ) ) );
|
||||
}
|
||||
|
||||
/* Purchases */
|
||||
if ( isset( \IPS\Request::i()->purchases ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 'r_purchase', array_map( 'intval', array_filter( explode( ',', \IPS\Request::i()->purchases ) ) ) ) );
|
||||
}
|
||||
|
||||
/* Staff */
|
||||
if ( isset( \IPS\Request::i()->staff ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 'r_staff', array_map( 'intval', array_filter( explode( ',', \IPS\Request::i()->staff ) ) ) ) );
|
||||
}
|
||||
|
||||
/* Are we a staff member? */
|
||||
$bypassPerms = FALSE;
|
||||
if ( $this->member and $this->member->isAdmin() and \count( \IPS\nexus\Support\Department::departmentsWithPermission( $this->member ) ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 'r_department', array_keys( iterator_to_array( \IPS\nexus\Support\Department::departmentsWithPermission( $this->member ) ) ) ) );
|
||||
$bypassPerms = TRUE;
|
||||
}
|
||||
|
||||
/* Return */
|
||||
return $this->_list( $where, NULL, $bypassPerms );
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /nexus/supportrequests/{id}
|
||||
* Get information about and replies to a specific support request
|
||||
*
|
||||
* @param int $id ID Number
|
||||
* @apiparam int hidden If 1, only posts which are hidden are returned, if 0 only not hidden
|
||||
* @apiparam string sortDir Sort direction. Can be 'asc' or 'desc' - defaults to 'asc'
|
||||
* @throws 2X313/1 INVALID_ID The request does not exist or the authorized user does not have permission to view it
|
||||
* @return \IPS\nexus\Support\Request
|
||||
*/
|
||||
public function GETitem( $id )
|
||||
{
|
||||
try
|
||||
{
|
||||
$request = \IPS\nexus\Support\Request::load( $id );
|
||||
if ( $this->member and !$request->canView( $this->member ) )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
return new \IPS\Api\Response( 200, $request->apiOutput( $this->member ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'INVALID_ID', '2X313/1', 404 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /nexus/supportrequests/{id}/replies
|
||||
* Get replies to a specific support request
|
||||
*
|
||||
* @param int $id ID Number
|
||||
* @apiparam int hidden If 1, only replies which are hidden are returned, if 0 only not hidden
|
||||
* @apiparam string sortDir Sort direction. Can be 'asc' or 'desc' - defaults to 'asc'
|
||||
* @apiparam int page Page number
|
||||
* @apiparam int perPage Number of results per page - defaults to 25
|
||||
* @throws 2X313/2 INVALID_ID The request does not exist or the authorized user does not have permission to view it
|
||||
* @return \IPS\Api\PaginatedResponse<IPS\nexus\Support\Reply>
|
||||
*/
|
||||
public function GETitem_replies( $id )
|
||||
{
|
||||
try
|
||||
{
|
||||
$request = \IPS\nexus\Support\Request::load( $id );
|
||||
if ( $this->member and !$request->canView( $this->member ) )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
return $this->_comments( $id, 'IPS\nexus\Support\Reply', array( array( 'reply_type<>?', \IPS\nexus\Support\Reply::REPLY_PENDING ) ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'INVALID_ID', '2X313/2', 404 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create or update item
|
||||
*
|
||||
* @param \IPS\Content\Item $item The item
|
||||
* @param string $type add or edit
|
||||
* @return \IPS\Content\Item
|
||||
*/
|
||||
protected function _createOrUpdate( \IPS\Content\Item $item, $type='add' )
|
||||
{
|
||||
/* Department, status, etc */
|
||||
foreach ( array( 'department' => 'IPS\nexus\Support\Department', 'status' => 'IPS\nexus\Support\Status', 'severity' => 'IPS\nexus\Support\Severity', 'purchase' => 'IPS\nexus\Purchase', 'staff' => 'IPS\Member' ) as $key => $class )
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->$key ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$object = $class::load( \IPS\Request::i()->$key );
|
||||
|
||||
if ( $this->member )
|
||||
{
|
||||
if ( $key === 'department' and $type == 'edit' )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ( $key === 'severity' and ( !$this->member->cm_no_sev or !\in_array( $object, \IPS\nexus\Support\Department::load( \IPS\Request::i()->department )->availableSeverities() ) ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ( $key === 'purchase' and ( $type == 'edit' or !$object->canView( $this->member ) ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ( $key === 'staff' )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ( $key === 'status' and ( $type == 'add' or !\IPS\Member::loggedIn()->language()->checkKeyExists("nexus_status_{$object->id}_set") ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$item->$key = $object;
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) {}
|
||||
}
|
||||
}
|
||||
if ( ( $type == 'add' or !$this->member ) and !isset( \IPS\Request::i()->purchase ) and isset( \IPS\Request::i()->lkey ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$licenseKey = \IPS\nexus\Purchase\LicenseKey::load( \IPS\Request::i()->lkey );
|
||||
if ( !$this->member or $licenseKey->purchase->canView( $this->member ) )
|
||||
{
|
||||
$item->purchase = $licenseKey->purchase;
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) {}
|
||||
}
|
||||
|
||||
/* Defaults */
|
||||
if ( !$item->id )
|
||||
{
|
||||
if ( !$item->_data['status'] )
|
||||
{
|
||||
$item->status = \IPS\nexus\Support\Status::load( TRUE, 'status_default_member' );
|
||||
}
|
||||
if ( !$item->_data['severity'] )
|
||||
{
|
||||
$item->severity = \IPS\nexus\Support\Severity::load( TRUE, 'sev_default' );
|
||||
}
|
||||
}
|
||||
|
||||
/* Cannot edit title */
|
||||
if ( $this->member and $type == 'edit' )
|
||||
{
|
||||
unset( \IPS\Request::i()->title );
|
||||
}
|
||||
|
||||
/* Pass up */
|
||||
return parent::_createOrUpdate( $item );
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /nexus/supportrequests
|
||||
* Create a support request
|
||||
*
|
||||
* @note For requests using an OAuth Access Token for a particular member, pay-per-incident departments cannot be used. Any parameters the user doesn't have permission to use are ignored (for example, severities they cannot set).
|
||||
* @reqapiparam string title The support request title
|
||||
* @reqapiparam int department Department ID number
|
||||
* @reqapiparam int account The ID number of the member creating the support request - not required if email is provided. For requests using an OAuth Access Token for a particular member, this is ignored and that member will always be the author.
|
||||
* @reqapiparam string email The email address creating the support request - not required if account is provided. For requests using an OAuth Access Token for a particular member, this is ignored and that member will always be the author.
|
||||
* @reqapiparam string message The content as HTML (e.g. "<p>This is a support request.</p>"). Will be sanatized for requests using an OAuth Access Token for a particular member; will be saved unaltered for requests made using an API Key or the Client Credentials Grant Type.
|
||||
* @apiparam int status Status ID number. If not provided, will use the default. Ignored for requests using an OAuth Access Token for a particular member
|
||||
* @apiparam int severity Severity ID number. If not provided, will use the default.
|
||||
* @apiparam int purchase Associated purchase ID number.
|
||||
* @apiparam string lkey License key of associated purchase ID number. (Will be ignored if "purchase" is provided)
|
||||
* @apiparam int staff Assigned staff ID number. Ignored for requests using an OAuth Access Token for a particular member
|
||||
* @apiparam datetime date The date/time that should be used for the support request date. If not provided, will use the current date/time. Ignored for requests using an OAuth Access Token for a particular member
|
||||
* @throws 1X313/3 NO_DEPARTMENT The department does not exist
|
||||
* @throws 1X313/6 NO_PERMISSION The request is for an authorizes member and the department does not accept submissions or is pay-per-incident
|
||||
* @throws 1X313/4 NO_AUTHOR The author ID does not exist
|
||||
* @throws 1X313/5 NO_TITLE No title was supplied
|
||||
* @throws 1X313/4 NO_POST No post was supplied
|
||||
* @return \IPS\nexus\Support\Request
|
||||
*/
|
||||
public function POSTindex()
|
||||
{
|
||||
/* Get department */
|
||||
try
|
||||
{
|
||||
$department = \IPS\nexus\Support\Department::load( \IPS\Request::i()->department );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'NO_DEPARTMENT', '1X313/3', 400 );
|
||||
}
|
||||
if ( $this->member and ( !$department->open or $department->ppiCost() ) )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'NO_PERMISSION', '1X313/6', 403 );
|
||||
}
|
||||
|
||||
/* Get author */
|
||||
if ( $this->member )
|
||||
{
|
||||
$author = $this->member;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( \IPS\Request::i()->account )
|
||||
{
|
||||
$author = \IPS\Member::load( \IPS\Request::i()->account );
|
||||
if ( !$author->member_id )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'NO_AUTHOR', '1X313/4', 400 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$author = new \IPS\Member;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check we have a title and a post */
|
||||
if ( !\IPS\Request::i()->title )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'NO_TITLE', '1X313/5', 400 );
|
||||
}
|
||||
if ( !\IPS\Request::i()->message )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'NO_POST', '1X313/4', 400 );
|
||||
}
|
||||
|
||||
/* Create */
|
||||
$item = $this->_create( NULL, $author, 'message' );
|
||||
|
||||
/* Email */
|
||||
if ( !$this->member and isset( \IPS\Request::i()->email ) )
|
||||
{
|
||||
$item->email = \IPS\Request::i()->email;
|
||||
$item->save();
|
||||
}
|
||||
|
||||
/* Do it */
|
||||
return new \IPS\Api\Response( 201, $item->apiOutput( $this->member ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /nexus/supportrequests/{id}
|
||||
* Edit a support request
|
||||
*
|
||||
* @note For requests using an OAuth Access Token for a particular member, any parameters the user doesn't have permission to use are ignored (for example, severities they cannot set).
|
||||
* @apiparam string title The support request title. Ignored for requests using an OAuth Access Token for a particular member (users cannot edit request titles after they're created)
|
||||
* @apiparam int department Department ID number. Ignored for requests using an OAuth Access Token for a particular member (users cannot move requests after they're created)
|
||||
* @apiparam int status Status ID number. If not provided, will use the default.
|
||||
* @apiparam int severity Severity ID number. If not provided, will use the default.
|
||||
* @apiparam int purchase Associated purchase ID number. Ignored for requests using an OAuth Access Token for a particular member (users cannot change associated purchase of request after its created)
|
||||
* @apiparam string lkey License key of associated purchase ID number. (Will be ignored if "purchase" is provided). Ignored for requests using an OAuth Access Token for a particular member (users cannot change associated purchase of request after its created)
|
||||
* @apiparam int staff Assigned staff ID number. Ignored for requests using an OAuth Access Token for a particular member
|
||||
* @param int $id ID Number
|
||||
* @throws 2X313/7 INVALID_ID The topic ID does not exist or the authorized user does not have permission to view it
|
||||
* @return \IPS\nexus\Support\Request
|
||||
*/
|
||||
public function POSTitem( $id )
|
||||
{
|
||||
try
|
||||
{
|
||||
$request = \IPS\nexus\Support\Request::load( $id );
|
||||
if ( $this->member and !$request->canView( $this->member ) )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
/* Process */
|
||||
$this->_createOrUpdate( $request, 'edit' );
|
||||
|
||||
/* Save and return */
|
||||
$request->save();
|
||||
return new \IPS\Api\Response( 200, $request->apiOutput( $this->member ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'INVALID_ID', '2X313/7', 404 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DELETE /nexus/supportrequests/{id}
|
||||
* Delete a support request
|
||||
*
|
||||
* @apiclientonly
|
||||
* @param int $id ID Number
|
||||
* @throws 1F294/5 INVALID_ID The topic ID does not exist
|
||||
* @return void
|
||||
*/
|
||||
public function DELETEitem( $id )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\nexus\Support\Request::load( $id )->delete();
|
||||
|
||||
return new \IPS\Api\Response( 200, NULL );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'INVALID_ID', '2X313/8', 404 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,16 +12,28 @@
|
||||
namespace IPS\nexus\api;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Api\Controller;
|
||||
use IPS\Api\Exception;
|
||||
use IPS\Api\PaginatedResponse;
|
||||
use IPS\Api\Response;
|
||||
use IPS\Db;
|
||||
use IPS\nexus\Transaction;
|
||||
use IPS\Request;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Transactions API
|
||||
*/
|
||||
class _transactions extends \IPS\Api\Controller
|
||||
class transactions extends Controller
|
||||
{
|
||||
/**
|
||||
* GET /nexus/transactions
|
||||
@@ -35,9 +47,10 @@ class _transactions extends \IPS\Api\Controller
|
||||
* @apiparam string sortDir Sort direction. Can be 'asc' or 'desc' - defaults to 'asc'
|
||||
* @apiparam int page Page number
|
||||
* @apiparam int perPage Number of results per page - defaults to 25
|
||||
* @return \IPS\Api\PaginatedResponse<IPS\nexus\Transaction>
|
||||
* @apireturn PaginatedResponse<IPS\nexus\Transaction>
|
||||
* @return PaginatedResponse<Transaction>
|
||||
*/
|
||||
public function GETindex()
|
||||
public function GETindex(): PaginatedResponse
|
||||
{
|
||||
/* Where clause */
|
||||
$where = array();
|
||||
@@ -47,43 +60,43 @@ class _transactions extends \IPS\Api\Controller
|
||||
{
|
||||
$where[] = array( 't_member=?', $this->member->member_id );
|
||||
}
|
||||
elseif ( isset( \IPS\Request::i()->customers ) )
|
||||
elseif ( isset( Request::i()->customers ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 't_member', array_map( 'intval', array_filter( explode( ',', \IPS\Request::i()->customers ) ) ) ) );
|
||||
$where[] = array( Db::i()->in( 't_member', array_map( 'intval', array_filter( explode( ',', Request::i()->customers ) ) ) ) );
|
||||
}
|
||||
|
||||
/* Statuses */
|
||||
if ( isset( \IPS\Request::i()->statuses ) )
|
||||
if ( isset( Request::i()->statuses ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 't_status', array_filter( explode( ',', \IPS\Request::i()->statuses ) ) ) );
|
||||
$where[] = array( Db::i()->in( 't_status', array_filter( explode( ',', Request::i()->statuses ) ) ) );
|
||||
}
|
||||
|
||||
/* Methods */
|
||||
if ( isset( \IPS\Request::i()->gateways ) )
|
||||
if ( isset( Request::i()->gateways ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 't_method', array_filter( explode( ',', \IPS\Request::i()->gateways ) ) ) );
|
||||
$where[] = array( Db::i()->in( 't_method', array_filter( explode( ',', Request::i()->gateways ) ) ) );
|
||||
}
|
||||
|
||||
/* Sort */
|
||||
if ( isset( \IPS\Request::i()->sortBy ) and \in_array( \IPS\Request::i()->sortBy, array( 'date', 'amount' ) ) )
|
||||
if ( isset( Request::i()->sortBy ) and in_array( Request::i()->sortBy, array( 'date', 'amount' ) ) )
|
||||
{
|
||||
$sortBy = 't_' . \IPS\Request::i()->sortBy;
|
||||
$sortBy = 't_' . Request::i()->sortBy;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sortBy = 't_id';
|
||||
}
|
||||
$sortDir = ( isset( \IPS\Request::i()->sortDir ) and \in_array( mb_strtolower( \IPS\Request::i()->sortDir ), array( 'asc', 'desc' ) ) ) ? \IPS\Request::i()->sortDir : 'asc';
|
||||
$sortDir = ( isset( Request::i()->sortDir ) and in_array( mb_strtolower( Request::i()->sortDir ), array( 'asc', 'desc' ) ) ) ? Request::i()->sortDir : 'asc';
|
||||
|
||||
/* Return */
|
||||
return new \IPS\Api\PaginatedResponse(
|
||||
return new PaginatedResponse(
|
||||
200,
|
||||
\IPS\Db::i()->select( '*', 'nexus_transactions', $where, "{$sortBy} {$sortDir}" ),
|
||||
isset( \IPS\Request::i()->page ) ? \IPS\Request::i()->page : 1,
|
||||
Db::i()->select( '*', 'nexus_transactions', $where, "{$sortBy} {$sortDir}" ),
|
||||
isset( Request::i()->page ) ? Request::i()->page : 1,
|
||||
'IPS\nexus\Transaction',
|
||||
\IPS\Db::i()->select( 'COUNT(*)', 'nexus_transactions', $where )->first(),
|
||||
Db::i()->select( 'COUNT(*)', 'nexus_transactions', $where )->first(),
|
||||
$this->member,
|
||||
isset( \IPS\Request::i()->perPage ) ? \IPS\Request::i()->perPage : NULL
|
||||
isset( Request::i()->perPage ) ? Request::i()->perPage : NULL
|
||||
);
|
||||
}
|
||||
|
||||
@@ -93,18 +106,19 @@ class _transactions extends \IPS\Api\Controller
|
||||
*
|
||||
* @param int $id ID Number
|
||||
* @throws 2X307/1 INVALID_ID The transaction ID does not exist or the authorized user does not have permission to view it
|
||||
* @return \IPS\nexus\Transaction
|
||||
* @apireturn \IPS\nexus\Transaction
|
||||
* @return Response
|
||||
*/
|
||||
public function GETitem( $id )
|
||||
public function GETitem( int $id ): Response
|
||||
{
|
||||
try
|
||||
{
|
||||
$object = $this->member ? \IPS\nexus\Transaction::loadAndCheckPerms( $id ) : \IPS\nexus\Transaction::load( $id );
|
||||
return new \IPS\Api\Response( 200, $object->apiOutput( $this->member ) );
|
||||
$object = $this->member ? Transaction::loadAndCheckPerms( $id ) : Transaction::load( $id );
|
||||
return new Response( 200, $object->apiOutput( $this->member ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'INVALID_ID', '2X307/1', 404 );
|
||||
throw new Exception( 'INVALID_ID', '2X307/1', 404 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,16 +12,28 @@
|
||||
namespace IPS\nexus\api;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Api\Controller;
|
||||
use IPS\Api\Exception;
|
||||
use IPS\Api\PaginatedResponse;
|
||||
use IPS\Api\Response;
|
||||
use IPS\Db;
|
||||
use IPS\nexus\Payout;
|
||||
use IPS\Request;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Withdrawals API
|
||||
*/
|
||||
class _withdrawals extends \IPS\Api\Controller
|
||||
class withdrawals extends Controller
|
||||
{
|
||||
/**
|
||||
* GET /nexus/withdrawals
|
||||
@@ -34,9 +46,10 @@ class _withdrawals extends \IPS\Api\Controller
|
||||
* @apiparam string sortDir Sort direction. Can be 'asc' or 'desc' - defaults to 'asc'
|
||||
* @apiparam int page Page number
|
||||
* @apiparam int perPage Number of results per page - defaults to 25
|
||||
* @return \IPS\Api\PaginatedResponse<IPS\nexus\Shipping\Order>
|
||||
* @apireturn PaginatedResponse<IPS\nexus\Payout>
|
||||
* @return PaginatedResponse<Payout>
|
||||
*/
|
||||
public function GETindex()
|
||||
public function GETindex() : PaginatedResponse
|
||||
{
|
||||
/* Where clause */
|
||||
$where = array();
|
||||
@@ -46,37 +59,37 @@ class _withdrawals extends \IPS\Api\Controller
|
||||
{
|
||||
$where[] = array( 'po_member=?', $this->member->member_id );
|
||||
}
|
||||
elseif ( isset( \IPS\Request::i()->customers ) )
|
||||
elseif ( isset( Request::i()->customers ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 'po_member', array_map( 'intval', array_filter( explode( ',', \IPS\Request::i()->customers ) ) ) ) );
|
||||
$where[] = array( Db::i()->in( 'po_member', array_map( 'intval', array_filter( explode( ',', Request::i()->customers ) ) ) ) );
|
||||
}
|
||||
|
||||
/* Statuses */
|
||||
if ( isset( \IPS\Request::i()->statuses ) )
|
||||
if ( isset( Request::i()->statuses ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 'po_status', array_filter( explode( ',', \IPS\Request::i()->statuses ) ) ) );
|
||||
$where[] = array( Db::i()->in( 'po_status', array_filter( explode( ',', Request::i()->statuses ) ) ) );
|
||||
}
|
||||
|
||||
/* Sort */
|
||||
if ( isset( \IPS\Request::i()->sortBy ) and \in_array( \IPS\Request::i()->sortBy, array( 'date', 'amount' ) ) )
|
||||
if ( isset( Request::i()->sortBy ) and in_array( Request::i()->sortBy, array( 'date', 'amount' ) ) )
|
||||
{
|
||||
$sortBy = 'po_' . \IPS\Request::i()->sortBy;
|
||||
$sortBy = 'po_' . Request::i()->sortBy;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sortBy = 'po_id';
|
||||
}
|
||||
$sortDir = ( isset( \IPS\Request::i()->sortDir ) and \in_array( mb_strtolower( \IPS\Request::i()->sortDir ), array( 'asc', 'desc' ) ) ) ? \IPS\Request::i()->sortDir : 'asc';
|
||||
$sortDir = ( isset( Request::i()->sortDir ) and in_array( mb_strtolower( Request::i()->sortDir ), array( 'asc', 'desc' ) ) ) ? Request::i()->sortDir : 'asc';
|
||||
|
||||
/* Return */
|
||||
return new \IPS\Api\PaginatedResponse(
|
||||
return new PaginatedResponse(
|
||||
200,
|
||||
\IPS\Db::i()->select( '*', 'nexus_payouts', $where, "{$sortBy} {$sortDir}" ),
|
||||
isset( \IPS\Request::i()->page ) ? \IPS\Request::i()->page : 1,
|
||||
Db::i()->select( '*', 'nexus_payouts', $where, "{$sortBy} {$sortDir}" ),
|
||||
isset( Request::i()->page ) ? Request::i()->page : 1,
|
||||
'IPS\nexus\Payout`',
|
||||
\IPS\Db::i()->select( 'COUNT(*)', 'nexus_payouts', $where )->first(),
|
||||
Db::i()->select( 'COUNT(*)', 'nexus_payouts', $where )->first(),
|
||||
$this->member,
|
||||
isset( \IPS\Request::i()->perPage ) ? \IPS\Request::i()->perPage : NULL
|
||||
isset( Request::i()->perPage ) ? Request::i()->perPage : NULL
|
||||
);
|
||||
}
|
||||
|
||||
@@ -86,23 +99,24 @@ class _withdrawals extends \IPS\Api\Controller
|
||||
*
|
||||
* @param int $id ID Number
|
||||
* @throws 2X307/1 INVALID_ID The withdrawal ID does not exist or the authorized user does not have permission to view it
|
||||
* @return \IPS\nexus\Payout
|
||||
* @apireturn \IPS\nexus\Payout
|
||||
* @return Response
|
||||
*/
|
||||
public function GETitem( $id )
|
||||
public function GETitem( int $id ): Response
|
||||
{
|
||||
try
|
||||
{
|
||||
$payout = \IPS\nexus\Payout::load( $id );
|
||||
$payout = Payout::load( $id );
|
||||
if ( $this->member and $this->member->member_id != $payout->member->member_id )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
throw new OutOfRangeException;
|
||||
}
|
||||
|
||||
return new \IPS\Api\Response( 200, $payout->apiOutput( $this->member ) );
|
||||
return new Response( 200, $payout->apiOutput( $this->member ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'INVALID_ID', '2X309/1', 404 );
|
||||
throw new Exception( 'INVALID_ID', '2X309/1', 404 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,12 +12,6 @@
|
||||
"do": "",
|
||||
"restriction": "invoices_manage"
|
||||
},
|
||||
"shipping": {
|
||||
"tab": "nexus",
|
||||
"controller": "shipping",
|
||||
"do": "",
|
||||
"restriction": "shiporders_manage"
|
||||
},
|
||||
"donations": {
|
||||
"tab": "nexus",
|
||||
"controller": "donations",
|
||||
@@ -28,8 +22,7 @@
|
||||
"tab": "nexus",
|
||||
"controller": "payouts",
|
||||
"do": "",
|
||||
"restriction": null,
|
||||
"callback": "return ( ( \\IPS\\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'payouts_manage' ) and \\IPS\\Settings::i()->nexus_payout ) or \\IPS\\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'payouts_settings' ) );"
|
||||
"restriction": "payouts_manage"
|
||||
},
|
||||
"paymentsettings": {
|
||||
"tab": "nexus",
|
||||
@@ -116,6 +109,13 @@
|
||||
"controller": "markets",
|
||||
"do": "",
|
||||
"restriction": "markets_manage"
|
||||
},
|
||||
"donations": {
|
||||
"tab": "stats",
|
||||
"controller": "donations",
|
||||
"do": "",
|
||||
"restriction": "donations_stats_manage",
|
||||
"subcontrollers": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,12 +15,6 @@
|
||||
"invoices_delete": "invoices_delete",
|
||||
"invoices_settings": "invoices_settings"
|
||||
},
|
||||
"shipping": {
|
||||
"shiporders_manage": "shiporders_manage",
|
||||
"shiporders_edit": "shiporders_edit",
|
||||
"shiporders_delete": "shiporders_delete",
|
||||
"shipmethods_manage": "shipmethods_manage"
|
||||
},
|
||||
"paymentsettings": {
|
||||
"paymentsettings_overview": "paymentsettings_overview",
|
||||
"gateways_manage": "gateways_manage",
|
||||
@@ -79,37 +73,6 @@
|
||||
"customer_notes_delete": "customer_notes_delete"
|
||||
}
|
||||
},
|
||||
"support": {
|
||||
"requests": {
|
||||
"requests_ratings": "requests_ratings",
|
||||
"requests_ratings_feedback": "requests_ratings_feedback",
|
||||
"requests_split": "requests_split",
|
||||
"requests_block_sev": "requests_block_sev",
|
||||
"requests_reply_delete": "requests_reply_delete",
|
||||
"requests_create": "requests_create",
|
||||
"requests_merge": "requests_merge",
|
||||
"requests_delete": "requests_delete",
|
||||
"requests_manage": "requests_manage"
|
||||
},
|
||||
"support_reports": {
|
||||
"reports_manage": "reports_manage"
|
||||
},
|
||||
"settings": {
|
||||
"settings_manage": "settings_manage",
|
||||
"departments_manage": "departments_manage",
|
||||
"stockactions_manage": "stockactions_manage",
|
||||
"scfields_manage": "scfields_manage",
|
||||
"severities_manage": "severities_manage",
|
||||
"statuses_manage": "statuses_manage",
|
||||
"autoresolve_manage": "autoresolve_manage",
|
||||
"customerfeedback_manage": "customerfeedback_manage",
|
||||
"outgoingemail_manage": "outgoingemail_manage",
|
||||
"incomingemail_manage": "incomingemail_manage"
|
||||
},
|
||||
"stats": {
|
||||
"volume_manage": "volume_manage"
|
||||
}
|
||||
},
|
||||
"store": {
|
||||
"packages": {
|
||||
"packages_manage": "packages_manage",
|
||||
@@ -142,6 +105,9 @@
|
||||
},
|
||||
"markets": {
|
||||
"markets_manage": "markets_manage"
|
||||
},
|
||||
"donations": {
|
||||
"donations_stats_manage": "donations_stats_manage"
|
||||
}
|
||||
},
|
||||
"subscriptions": {
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
{
|
||||
"app=core&module=applications&controller=enhancements&do=edit&id=nexus_EasyPost&searchResult=form_easypost_enable": {
|
||||
"lang_key": "easypost_enable",
|
||||
"restriction": "enhancements_manage",
|
||||
"keywords": [
|
||||
"easy post",
|
||||
"easypost"
|
||||
]
|
||||
},
|
||||
"app=core&module=applications&controller=enhancements&do=edit&id=nexus_MaxMind&searchResult=form_maxmind_enable": {
|
||||
"lang_key": "maxmind_enable",
|
||||
"restriction": "enhancements_manage",
|
||||
@@ -16,7 +8,7 @@
|
||||
]
|
||||
},
|
||||
"app=nexus&module=customers&controller=fields": {
|
||||
"lang_key": "menu__nexus_customers_fields",
|
||||
"lang_key": "acpsearch__nexus_customers_fields",
|
||||
"restriction": null,
|
||||
"keywords": [
|
||||
"custom customer fields",
|
||||
@@ -213,9 +205,6 @@
|
||||
"lang_key": "payment_methods",
|
||||
"restriction": "gateways_manage",
|
||||
"keywords": [
|
||||
"2checkout",
|
||||
"auth.net",
|
||||
"authorize.net",
|
||||
"bank",
|
||||
"cards",
|
||||
"checks",
|
||||
@@ -239,13 +228,6 @@
|
||||
"transaction review"
|
||||
]
|
||||
},
|
||||
"app=nexus&module=payments&controller=paymentsettings&tab=review&searchResult=form_nexus_revw_sa_on": {
|
||||
"lang_key": "nexus_revw_sa_on",
|
||||
"restriction": "paymentsettings_overview",
|
||||
"keywords": [
|
||||
"transaction review support ticket"
|
||||
]
|
||||
},
|
||||
"app=nexus&module=payments&controller=paymentsettings&tab=tax": {
|
||||
"lang_key": "tax_rates",
|
||||
"restriction": "tax_manage",
|
||||
@@ -268,7 +250,7 @@
|
||||
]
|
||||
},
|
||||
"app=nexus&module=payments&controller=payouts&do=settings": {
|
||||
"lang_key": "menu__nexus_payments_payouts",
|
||||
"lang_key": "account_credit_settings",
|
||||
"restriction": "payouts_manage",
|
||||
"keywords": [
|
||||
"account credit",
|
||||
@@ -352,36 +334,6 @@
|
||||
"minimum withdrawal"
|
||||
]
|
||||
},
|
||||
"app=nexus&module=payments&controller=shipping": {
|
||||
"lang_key": "menu__nexus_payments_shipping",
|
||||
"restriction": "shiporders_manage",
|
||||
"keywords": [
|
||||
"handling",
|
||||
"orders",
|
||||
"postage",
|
||||
"ship",
|
||||
"shipments",
|
||||
"shipping"
|
||||
]
|
||||
},
|
||||
"app=nexus&module=payments&controller=shippingrates": {
|
||||
"lang_key": "shipping_rates",
|
||||
"restriction": "shipmethods_manage",
|
||||
"keywords": [
|
||||
"air mail",
|
||||
"airmail",
|
||||
"fedex",
|
||||
"mail",
|
||||
"orders",
|
||||
"post",
|
||||
"royal mail",
|
||||
"shipments",
|
||||
"shipping",
|
||||
"tracking",
|
||||
"ups",
|
||||
"usps"
|
||||
]
|
||||
},
|
||||
"app=nexus&module=payments&controller=transactions": {
|
||||
"lang_key": "menu__nexus_payments_transactions",
|
||||
"restriction": "transactions_manage",
|
||||
@@ -459,7 +411,7 @@
|
||||
]
|
||||
},
|
||||
"app=nexus&module=store&controller=fields": {
|
||||
"lang_key": "menu__nexus_store_fields",
|
||||
"lang_key": "acpsearch__nexus_store_fields",
|
||||
"restriction": "package_fields_manage",
|
||||
"keywords": [
|
||||
"custom package fields",
|
||||
@@ -596,194 +548,40 @@
|
||||
"require subscription"
|
||||
]
|
||||
},
|
||||
"app=nexus&module=support&controller=reports": {
|
||||
"lang_key": "menu__nexus_support_reports",
|
||||
"restriction": "reports_manage",
|
||||
"app=nexus&module=payments&controller=paymentsettings": {
|
||||
"lang_key": "acpsearch__nexus_payments_paymentsettings",
|
||||
"restriction": "paymentsettings_overview",
|
||||
"keywords": [
|
||||
"customer feedback",
|
||||
"customer satisfaction",
|
||||
"staff performance",
|
||||
"support performance",
|
||||
"support ratings",
|
||||
"support replies",
|
||||
"support reports",
|
||||
"support reviews",
|
||||
"support staff"
|
||||
"payment",
|
||||
"gateway",
|
||||
"paypal",
|
||||
"stripe"
|
||||
]
|
||||
},
|
||||
"app=nexus&module=support&controller=reports&tab=feedback_ratings": {
|
||||
"lang_key": "feedback_ratings",
|
||||
"restriction": "reports_manage",
|
||||
"app=nexus&module=store&controller=filters": {
|
||||
"lang_key": "menu__nexus_store_filters",
|
||||
"restriction": "packages_manage",
|
||||
"keywords": [
|
||||
"support feedback"
|
||||
"product",
|
||||
"filters",
|
||||
"store",
|
||||
"package"
|
||||
]
|
||||
},
|
||||
"app=nexus&module=support&controller=reports&tab=latest_feedback": {
|
||||
"lang_key": "latest_feedback",
|
||||
"restriction": "reports_manage",
|
||||
"keywords": [
|
||||
"latest support feedback"
|
||||
]
|
||||
},
|
||||
"app=nexus&module=support&controller=reports&tab=overview": {
|
||||
"lang_key": "overview",
|
||||
"restriction": "reports_manage",
|
||||
"keywords": [
|
||||
"support overview"
|
||||
]
|
||||
},
|
||||
"app=nexus&module=support&controller=reports&tab=replies": {
|
||||
"lang_key": "replies",
|
||||
"restriction": "reports_manage",
|
||||
"keywords": [
|
||||
"support replies"
|
||||
]
|
||||
},
|
||||
"app=nexus&module=support&controller=requests": {
|
||||
"lang_key": "menu__nexus_support_requests",
|
||||
"restriction": "requests_manage",
|
||||
"keywords": [
|
||||
"support",
|
||||
"support requests",
|
||||
"support tickets",
|
||||
"tickets"
|
||||
]
|
||||
},
|
||||
"app=nexus&module=support&controller=settings&tab=autoresolve": {
|
||||
"lang_key": "autoresolve",
|
||||
"restriction": "autoresolve_manage",
|
||||
"keywords": [
|
||||
"auto resolve",
|
||||
"auto-resolve",
|
||||
"automatic resolve",
|
||||
"automatically resolve",
|
||||
"autoresolve",
|
||||
"resolve"
|
||||
]
|
||||
},
|
||||
"app=nexus&module=support&controller=settings&tab=customerfeedback": {
|
||||
"lang_key": "customer_feedback",
|
||||
"restriction": "customerfeedback_manage",
|
||||
"keywords": [
|
||||
"feedback",
|
||||
"performance",
|
||||
"ratings",
|
||||
"satisfaction"
|
||||
]
|
||||
},
|
||||
"app=nexus&module=support&controller=settings&tab=departments": {
|
||||
"lang_key": "departments",
|
||||
"restriction": "departments_manage",
|
||||
"keywords": [
|
||||
"categories",
|
||||
"departments",
|
||||
"email"
|
||||
]
|
||||
},
|
||||
"app=nexus&module=support&controller=settings&tab=fields": {
|
||||
"lang_key": "custom_support_fields",
|
||||
"restriction": "scfields_manage",
|
||||
"keywords": [
|
||||
"custom support fields",
|
||||
"custom ticket fields",
|
||||
"support custom fields",
|
||||
"support fields",
|
||||
"support form",
|
||||
"support information",
|
||||
"ticket custom fields",
|
||||
"ticket fields",
|
||||
"ticket information"
|
||||
]
|
||||
},
|
||||
"app=nexus&module=support&controller=settings&tab=incomingemail": {
|
||||
"lang_key": "incoming_emails",
|
||||
"restriction": "incomingemail_manage",
|
||||
"keywords": [
|
||||
"email filters",
|
||||
"email piping",
|
||||
"incoming emails",
|
||||
"pop3",
|
||||
"spam filters",
|
||||
"support emails",
|
||||
"ticket emails"
|
||||
]
|
||||
},
|
||||
"app=nexus&module=support&controller=settings&tab=outgoingemail": {
|
||||
"lang_key": "outgoing_emails",
|
||||
"restriction": "outgoingemail_manage",
|
||||
"keywords": [
|
||||
"support emails",
|
||||
"ticket emails"
|
||||
]
|
||||
},
|
||||
"app=nexus&module=support&controller=settings&tab=outgoingemail&searchResult=form_nexus_sout_autoreply": {
|
||||
"lang_key": "nexus_sout_autoreply",
|
||||
"app=nexus&module=store&controller=settings": {
|
||||
"lang_key": "acpsearch__nexus_store_settings",
|
||||
"restriction": "settings_manage",
|
||||
"keywords": [
|
||||
"support confirmation",
|
||||
"ticket confirmation"
|
||||
"store",
|
||||
"store setting"
|
||||
]
|
||||
},
|
||||
"app=nexus&module=support&controller=settings&tab=outgoingemail&searchResult=form_nexus_sout_chrome": {
|
||||
"lang_key": "nexus_sout_chrome",
|
||||
"restriction": "settings_manage",
|
||||
"app=nexus&module=reports&controller=donations": {
|
||||
"lang_key": "acpsearch__nexus_reports_donations",
|
||||
"restriction": "donations_stats_manage",
|
||||
"keywords": [
|
||||
"email format",
|
||||
"email template"
|
||||
]
|
||||
},
|
||||
"app=nexus&module=support&controller=settings&tab=outgoingemail&searchResult=form_nexus_sout_from": {
|
||||
"lang_key": "nexus_sout_from",
|
||||
"restriction": "settings_manage",
|
||||
"keywords": [
|
||||
"email from"
|
||||
]
|
||||
},
|
||||
"app=nexus&module=support&controller=settings&tab=severities": {
|
||||
"lang_key": "severities",
|
||||
"restriction": "severities_manage",
|
||||
"keywords": [
|
||||
"critical",
|
||||
"emergency",
|
||||
"severities",
|
||||
"severity",
|
||||
"urgency",
|
||||
"urgent"
|
||||
]
|
||||
},
|
||||
"app=nexus&module=support&controller=settings&tab=statuses": {
|
||||
"lang_key": "statuses",
|
||||
"restriction": "settings_manage",
|
||||
"keywords": [
|
||||
"closed",
|
||||
"open",
|
||||
"resolved",
|
||||
"statuses",
|
||||
"tags"
|
||||
]
|
||||
},
|
||||
"app=nexus&module=support&controller=settings&tab=stockactions": {
|
||||
"lang_key": "stock_actions",
|
||||
"restriction": "stockactions_manage",
|
||||
"keywords": [
|
||||
"defined",
|
||||
"pre defined",
|
||||
"pre set",
|
||||
"predefined",
|
||||
"preset",
|
||||
"stock",
|
||||
"stock actions",
|
||||
"stock messages",
|
||||
"stock replies"
|
||||
]
|
||||
},
|
||||
"app=nexus&module=support&controller=volume": {
|
||||
"lang_key": "menu__nexus_support_volume",
|
||||
"restriction": "volume_manage",
|
||||
"keywords": [
|
||||
"new ticket stats",
|
||||
"support statistics",
|
||||
"support stats"
|
||||
"donation",
|
||||
"goal"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
"app_author": "",
|
||||
"app_directory": "nexus",
|
||||
"app_protected": 0,
|
||||
"app_website": null,
|
||||
"app_update_check": null,
|
||||
"app_website": "",
|
||||
"app_update_check": "",
|
||||
"app_hide_tab": 0
|
||||
}
|
||||
@@ -2,13 +2,10 @@
|
||||
<build>
|
||||
<module key="front/store"><![CDATA[{"default_controller":"store","protected":0,"default":1}]]></module>
|
||||
<module key="front/checkout"><![CDATA[{"default_controller":null,"protected":1,"default":0}]]></module>
|
||||
<module key="front/support"><![CDATA[{"default_controller":"home","protected":0,"default":0}]]></module>
|
||||
<module key="front/clients"><![CDATA[{"default_controller":"purchases","protected":0,"default":0}]]></module>
|
||||
<module key="front/promotion"><![CDATA[{"default_controller":"","protected":0,"default":0}]]></module>
|
||||
<module key="front/subscriptions"><![CDATA[{"default_controller":"","protected":0,"default":0}]]></module>
|
||||
<module key="admin/payments"><![CDATA[{"default_controller":"transactions","protected":0,"default":1}]]></module>
|
||||
<module key="admin/customers"><![CDATA[{"default_controller":null,"protected":0,"default":0}]]></module>
|
||||
<module key="admin/support"><![CDATA[{"default_controller":"","protected":0,"default":0}]]></module>
|
||||
<module key="admin/store"><![CDATA[{"default_controller":"","protected":0,"default":0}]]></module>
|
||||
<module key="admin/reports"><![CDATA[{"default_controller":"","protected":0,"default":0}]]></module>
|
||||
<module key="admin/subscriptions"><![CDATA[{"default_controller":"subscriptions","protected":0,"default":0}]]></module>
|
||||
@@ -17,8 +14,6 @@
|
||||
<task frequency="P0Y0M0DT0H30M0S">generateRenewalInvoices</task>
|
||||
<task frequency="P0Y0M0DT1H0M0S">expirePurchases</task>
|
||||
<task frequency="P0Y0M0DT1H0M0S">expireInvoices</task>
|
||||
<task frequency="P0Y0M0DT1H0M0S">supportAutoresolve</task>
|
||||
<task frequency="P0Y0M1DT0H0M0S">supportAssignedReminder</task>
|
||||
<task frequency="P0Y0M1DT0H0M0S">cartCleanup</task>
|
||||
<task frequency="P0Y0M0DT0H10M0S">billingAgreements</task>
|
||||
<task frequency="P0Y0M0DT0H10M0S">gatewayPending</task>
|
||||
@@ -29,15 +24,7 @@
|
||||
<setting key="cm_invoice_generate"><![CDATA[{"key":"cm_invoice_generate","default":"12","report":"full"}]]></setting>
|
||||
<setting key="cm_invoice_warning"><![CDATA[{"key":"cm_invoice_warning","default":"72","report":"full"}]]></setting>
|
||||
<setting key="cm_protected"><![CDATA[{"key":"cm_protected","default":"","report":"bool"}]]></setting>
|
||||
<setting key="customer_fields"><![CDATA[{"key":"customer_fields","default":"0","report":"bool"}]]></setting>
|
||||
<setting key="donation_goals"><![CDATA[{"key":"donation_goals","default":"0","report":"bool"}]]></setting>
|
||||
<setting key="easypost_address"><![CDATA[{"key":"easypost_address","default":"","report":"bool"}]]></setting>
|
||||
<setting key="easypost_api_key"><![CDATA[{"key":"easypost_api_key","default":"","report":"bool"}]]></setting>
|
||||
<setting key="easypost_delivery_adjustment"><![CDATA[{"key":"easypost_delivery_adjustment","default":"0","report":"full"}]]></setting>
|
||||
<setting key="easypost_phone"><![CDATA[{"key":"easypost_phone","default":"","report":"bool"}]]></setting>
|
||||
<setting key="easypost_price_adjustment"><![CDATA[{"key":"easypost_price_adjustment","default":"","report":"bool"}]]></setting>
|
||||
<setting key="easypost_show_rates"><![CDATA[{"key":"easypost_show_rates","default":"0","report":"full"}]]></setting>
|
||||
<setting key="easypost_tax"><![CDATA[{"key":"easypost_tax","default":"0","report":"bool"}]]></setting>
|
||||
<setting key="gateways_counts"><![CDATA[{"key":"gateways_counts","default":"{}","report":"none"}]]></setting>
|
||||
<setting key="idm_nexus_display"><![CDATA[{"key":"idm_nexus_display","default":"purchases","report":"full"}]]></setting>
|
||||
<setting key="idm_nexus_gateways"><![CDATA[{"key":"idm_nexus_gateways","default":"","report":"bool"}]]></setting>
|
||||
@@ -51,17 +38,11 @@
|
||||
<setting key="maxmind_id"><![CDATA[{"key":"maxmind_id","default":"","report":"none"}]]></setting>
|
||||
<setting key="maxmind_key"><![CDATA[{"key":"maxmind_key","default":"","report":"bool"}]]></setting>
|
||||
<setting key="maxmind_tracking_code"><![CDATA[{"key":"maxmind_tracking_code","default":"0","report":"bool"}]]></setting>
|
||||
<setting key="nexus_autoresolve_applicable"><![CDATA[{"key":"nexus_autoresolve_applicable","default":"3","report":"full"}]]></setting>
|
||||
<setting key="nexus_autoresolve_days"><![CDATA[{"key":"nexus_autoresolve_days","default":"0","report":"full"}]]></setting>
|
||||
<setting key="nexus_autoresolve_departments"><![CDATA[{"key":"nexus_autoresolve_departments","default":"*","report":"bool"}]]></setting>
|
||||
<setting key="nexus_autoresolve_notify"><![CDATA[{"key":"nexus_autoresolve_notify","default":"24","report":"full"}]]></setting>
|
||||
<setting key="nexus_autoresolve_status"><![CDATA[{"key":"nexus_autoresolve_status","default":"4","report":"full"}]]></setting>
|
||||
<setting key="nexus_checkreg_captcha"><![CDATA[{"key":"nexus_checkreg_captcha","default":"0","report":"full"}]]></setting>
|
||||
<setting key="nexus_checkreg_usernames"><![CDATA[{"key":"nexus_checkreg_usernames","default":"0","report":"full"}]]></setting>
|
||||
<setting key="nexus_checkreg_validate"><![CDATA[{"key":"nexus_checkreg_validate","default":"0","report":"full"}]]></setting>
|
||||
<setting key="nexus_com_rules"><![CDATA[{"key":"nexus_com_rules","default":"1","report":"full"}]]></setting>
|
||||
<setting key="nexus_currency"><![CDATA[{"key":"nexus_currency","default":"USD","report":"none"}]]></setting>
|
||||
<setting key="nexus_donate_loggedin"><![CDATA[{"key":"nexus_donate_loggedin","default":"0","report":"full"}]]></setting>
|
||||
<setting key="nexus_gift_vouchers"><![CDATA[{"key":"nexus_gift_vouchers","default":"{}","report":"bool"}]]></setting>
|
||||
<setting key="nexus_gift_vouchers_free"><![CDATA[{"key":"nexus_gift_vouchers_free","default":"0","report":"full"}]]></setting>
|
||||
<setting key="nexus_invoice_footer"><![CDATA[{"key":"nexus_invoice_footer","default":"","report":"bool"}]]></setting>
|
||||
@@ -80,16 +61,10 @@
|
||||
<setting key="nexus_payout_unlimited_times"><![CDATA[{"key":"nexus_payout_unlimited_times","default":"1","report":"full"}]]></setting>
|
||||
<setting key="nexus_prune_history"><![CDATA[{"key":"nexus_prune_history","default":"0","report":"none"}]]></setting>
|
||||
<setting key="nexus_reg_force"><![CDATA[{"key":"nexus_reg_force","default":"0","report":"full"}]]></setting>
|
||||
<setting key="nexus_reg_group"><![CDATA[{"key":"nexus_reg_group","default":"0","report":"bool"}]]></setting>
|
||||
<setting key="nexus_require_billing"><![CDATA[{"key":"nexus_require_billing","default":"product,giftvoucher,donation,other,subscriptions","report":"bool"}]]></setting>
|
||||
<setting key="nexus_revw_sa"><![CDATA[{"key":"nexus_revw_sa","default":"0","report":"full"}]]></setting>
|
||||
<setting key="nexus_severities"><![CDATA[{"key":"nexus_severities","default":"1","report":"full"}]]></setting>
|
||||
<setting key="nexus_show_renew_option_savings"><![CDATA[{"key":"nexus_show_renew_option_savings","default":"amount","report":"full"}]]></setting>
|
||||
<setting key="nexus_show_stock"><![CDATA[{"key":"nexus_show_stock","default":"0","report":"full"}]]></setting>
|
||||
<setting key="nexus_show_tax"><![CDATA[{"key":"nexus_show_tax","default":"0","report":"full"}]]></setting>
|
||||
<setting key="nexus_sout_autoreply"><![CDATA[{"key":"nexus_sout_autoreply","default":"0","report":"full"}]]></setting>
|
||||
<setting key="nexus_sout_chrome"><![CDATA[{"key":"nexus_sout_chrome","default":"0","report":"full"}]]></setting>
|
||||
<setting key="nexus_sout_from"><![CDATA[{"key":"nexus_sout_from","default":"staff","report":"full"}]]></setting>
|
||||
<setting key="nexus_split_payments"><![CDATA[{"key":"nexus_split_payments","default":"0","report":"full"}]]></setting>
|
||||
<setting key="nexus_store_new"><![CDATA[{"key":"nexus_store_new","default":"10,30","report":"bool"}]]></setting>
|
||||
<setting key="nexus_store_popular"><![CDATA[{"key":"nexus_store_popular","default":"10,365","report":"bool"}]]></setting>
|
||||
@@ -100,10 +75,8 @@
|
||||
<setting key="nexus_subs_register"><![CDATA[{"key":"nexus_subs_register","default":"0","report":"full"}]]></setting>
|
||||
<setting key="nexus_subs_show_public"><![CDATA[{"key":"nexus_subs_show_public","default":"1","report":"full"}]]></setting>
|
||||
<setting key="nexus_subs_upgrade"><![CDATA[{"key":"nexus_subs_upgrade","default":"0","report":"full"}]]></setting>
|
||||
<setting key="nexus_support_satisfaction"><![CDATA[{"key":"nexus_support_satisfaction","default":"1","report":"full"}]]></setting>
|
||||
<setting key="nexus_tac"><![CDATA[{"key":"nexus_tac","default":"none","report":"full"}]]></setting>
|
||||
<setting key="nexus_tac_link"><![CDATA[{"key":"nexus_tac_link","default":"","report":"bool"}]]></setting>
|
||||
<setting key="reply_request_resolved"><![CDATA[{"key":"reply_request_resolved","default":"reopen","report":"full"}]]></setting>
|
||||
<widget key="pendingActions"><![CDATA[{"class":"\\IPS\\Widget","restrict":["sidebar","cms"],"default_area":"","allow_reuse":false,"menu_style":"menu","embeddable":true}]]></widget>
|
||||
<widget key="donations"><![CDATA[{"class":"\\IPS\\Widget\\StaticCache","restrict":["sidebar","cms"],"default_area":"","allow_reuse":false,"menu_style":"menu","embeddable":true}]]></widget>
|
||||
<widget key="subscriptions"><![CDATA[{"class":"\\IPS\\Widget","restrict":["sidebar","cms"],"default_area":"","allow_reuse":false,"menu_style":"menu","embeddable":true}]]></widget>
|
||||
@@ -111,9 +84,8 @@
|
||||
<widget key="latestProducts"><![CDATA[{"class":"\\IPS\\Widget\\PermissionCache","restrict":["sidebar","cms"],"default_area":"","allow_reuse":true,"menu_style":"menu","embeddable":true}]]></widget>
|
||||
<widget key="recentCommerceReviews"><![CDATA[{"class":"\\IPS\\Widget\\PermissionCache","restrict":["sidebar","cms"],"default_area":"","allow_reuse":true,"menu_style":"menu","embeddable":true}]]></widget>
|
||||
<widget key="featuredProduct"><![CDATA[{"class":"\\IPS\\Widget\\PermissionCache","restrict":["sidebar","cms"],"default_area":"","allow_reuse":true,"menu_style":"menu","embeddable":true}]]></widget>
|
||||
<acpsearch key="app=core&module=applications&controller=enhancements&do=edit&id=nexus_EasyPost&searchResult=form_easypost_enable"><![CDATA[{"lang_key":"easypost_enable","restriction":"enhancements_manage","keywords":["easy post","easypost"]}]]></acpsearch>
|
||||
<acpsearch key="app=core&module=applications&controller=enhancements&do=edit&id=nexus_MaxMind&searchResult=form_maxmind_enable"><![CDATA[{"lang_key":"maxmind_enable","restriction":"enhancements_manage","keywords":["fraud","maxmind"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=customers&controller=fields"><![CDATA[{"lang_key":"menu__nexus_customers_fields","restriction":null,"keywords":["custom customer fields","custom fields","custom nexus fields","customer fields","nexus fields"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=customers&controller=fields"><![CDATA[{"lang_key":"acpsearch__nexus_customers_fields","restriction":null,"keywords":["custom customer fields","custom fields","custom nexus fields","customer fields","nexus fields"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=customers&controller=search"><![CDATA[{"lang_key":"menu__nexus_customers_search","restriction":"customers_view","keywords":["clients","customers"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=payments&controller=donations"><![CDATA[{"lang_key":"menu__nexus_payments_donations","restriction":"donations_manage","keywords":["donate","donations","goals"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=payments&controller=invoices"><![CDATA[{"lang_key":"menu__nexus_payments_invoices","restriction":"invoices_manage","keywords":["invoices","orders"]}]]></acpsearch>
|
||||
@@ -135,20 +107,17 @@
|
||||
<acpsearch key="app=nexus&module=payments&controller=paymentsettings&tab=emails&searchResult=form_nexus_notify_copy_email"><![CDATA[{"lang_key":"nexus_notify_copy_email","restriction":"paymentsettings_overview","keywords":["email notification","email notifications list commerce"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=payments&controller=paymentsettings&tab=emails&searchResult=form_nexus_notify_copy_types"><![CDATA[{"lang_key":"nexus_notify_copy_types","restriction":"paymentsettings_overview","keywords":["commission notification","email notifications commerce","payment notification","transaction notification"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=payments&controller=paymentsettings&tab=fraud"><![CDATA[{"lang_key":"anti_fraud_rules","restriction":"fraud_manage","keywords":["anti fraud rules","anti-fraud rules","antifraud rules","fraud","fraud rules"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=payments&controller=paymentsettings&tab=gateways"><![CDATA[{"lang_key":"payment_methods","restriction":"gateways_manage","keywords":["2checkout","auth.net","authorize.net","bank","cards","checks","cheques","credit","credit cards","debit","gateways","methods","paypal","stripe"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=payments&controller=paymentsettings&tab=gateways"><![CDATA[{"lang_key":"payment_methods","restriction":"gateways_manage","keywords":["bank","cards","checks","cheques","credit","credit cards","debit","gateways","methods","paypal","stripe"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=payments&controller=paymentsettings&tab=review"><![CDATA[{"lang_key":"transaction_review","restriction":null,"keywords":["flag for review","hold for review","transaction flag","transaction review"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=payments&controller=paymentsettings&tab=review&searchResult=form_nexus_revw_sa_on"><![CDATA[{"lang_key":"nexus_revw_sa_on","restriction":"paymentsettings_overview","keywords":["transaction review support ticket"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=payments&controller=paymentsettings&tab=tax"><![CDATA[{"lang_key":"tax_rates","restriction":"tax_manage","keywords":["sales tax","tax","tax rate","vat"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=payments&controller=payouts"><![CDATA[{"lang_key":"menu__nexus_payments_payouts","restriction":"payouts_manage","keywords":["account credit","credit","pay outs","payouts","withdrawals"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=payments&controller=payouts&do=settings"><![CDATA[{"lang_key":"menu__nexus_payments_payouts","restriction":"payouts_manage","keywords":["account credit","account credit settings","credit","credit settings","pay out","pay out settings","pay outs settings","payout settings","payouts","payouts settings","withdrawal settings","withdrawals","withdrawals settings"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=payments&controller=payouts&do=settings"><![CDATA[{"lang_key":"account_credit_settings","restriction":"payouts_manage","keywords":["account credit","account credit settings","credit","credit settings","pay out","pay out settings","pay outs settings","payout settings","payouts","payouts settings","withdrawal settings","withdrawals","withdrawals settings"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=payments&controller=payouts&do=settings&searchResult=form_allow_topups"><![CDATA[{"lang_key":"allow_topups","restriction":"payouts_manage","keywords":["account credit","add credit","buy credit","credit","top ups","topups"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=payments&controller=payouts&do=settings&searchResult=form_nexus_no_commission"><![CDATA[{"lang_key":"nexus_no_commission","restriction":"payouts_settings","keywords":["comision","comission","commission","no commission"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=payments&controller=payouts&do=settings&searchResult=form_nexus_payout"><![CDATA[{"lang_key":"nexus_payout","restriction":"payouts_settings","keywords":["bank","check","cheque","credit card","pay outs","payouts","paypal","stripe","withdrawals"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=payments&controller=payouts&do=settings&searchResult=nexus_max_credit"><![CDATA[{"lang_key":"nexus_max_credit","restriction":"payouts_manage","keywords":["maximum account credit","maximum credit"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=payments&controller=payouts&do=settings&searchResult=nexus_payout_approve"><![CDATA[{"lang_key":"nexus_payout_approve","restriction":"payouts_manage","keywords":["approve pay outs","approve payouts","approve withdrawals","pay out approve","payout approve","withdrawal approve"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=payments&controller=payouts&do=settings&searchResult=nexus_payout_min"><![CDATA[{"lang_key":"nexus_payout_min","restriction":"payouts_manage","keywords":["minimum pay out","minimum payout","minimum withdrawal"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=payments&controller=shipping"><![CDATA[{"lang_key":"menu__nexus_payments_shipping","restriction":"shiporders_manage","keywords":["handling","orders","postage","ship","shipments","shipping"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=payments&controller=shippingrates"><![CDATA[{"lang_key":"shipping_rates","restriction":"shipmethods_manage","keywords":["air mail","airmail","fedex","mail","orders","post","royal mail","shipments","shipping","tracking","ups","usps"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=payments&controller=transactions"><![CDATA[{"lang_key":"menu__nexus_payments_transactions","restriction":"transactions_manage","keywords":["approve","payments","sales","transactions"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=reports&controller=income"><![CDATA[{"lang_key":"menu__nexus_reports_income","restriction":"income_manage","keywords":["income","income stats","revenue"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=reports&controller=income&tab=totals"><![CDATA[{"lang_key":"nexus_report_income_totals","restriction":"income_manage","keywords":["income","total income"]}]]></acpsearch>
|
||||
@@ -158,7 +127,7 @@
|
||||
<acpsearch key="app=nexus&module=reports&controller=markets&tab=USD"><![CDATA[{"lang_key":"USD Income","restriction":"markets_manage","keywords":["income reports"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=reports&controller=purchases"><![CDATA[{"lang_key":"menu__nexus_reports_purchases","restriction":"purchases_manage","keywords":["order stats","sale stats","sales stats"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=store&controller=coupons"><![CDATA[{"lang_key":"menu__nexus_store_coupons","restriction":"coupons_manage","keywords":["coupons","discounts","gift","promotions","vouchers"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=store&controller=fields"><![CDATA[{"lang_key":"menu__nexus_store_fields","restriction":"package_fields_manage","keywords":["custom package fields","custom product fields","package fields","product fields"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=store&controller=fields"><![CDATA[{"lang_key":"acpsearch__nexus_store_fields","restriction":"package_fields_manage","keywords":["custom package fields","custom product fields","package fields","product fields"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=store&controller=packages"><![CDATA[{"lang_key":"menu__nexus_store_packages","restriction":"packages_manage","keywords":["items","packages","plans","products","stock","store"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=store&controller=settings&searchResult=form_cm_protected"><![CDATA[{"lang_key":"cm_protected","restriction":"settings_manage","keywords":["protected groups"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=store&controller=settings&searchResult=form_nexus_gift_vouchers"><![CDATA[{"lang_key":"nexus_gift_vouchers","restriction":"settings_manage","keywords":["gift cards","gift vouchers","vouchers"]}]]></acpsearch>
|
||||
@@ -174,29 +143,9 @@
|
||||
<acpsearch key="app=nexus&module=subscriptions&controller=subscriptions"><![CDATA[{"lang_key":"menu__nexus_subscriptions_subscriptions","restriction":"subscriptions_manage","keywords":["monetize","package","subscription"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=subscriptions&controller=subscriptions&do=settings&searchResult=nexus_subs_enabled"><![CDATA[{"lang_key":"nexus_subs_enabled","restriction":"subscriptions_manage","keywords":["member subscription","package","subscription"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=subscriptions&controller=subscriptions&do=settings&searchResult=nexus_subs_register"><![CDATA[{"lang_key":"nexus_subs_register","restriction":"subscriptions_manage","keywords":["require subscription"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=support&controller=reports"><![CDATA[{"lang_key":"menu__nexus_support_reports","restriction":"reports_manage","keywords":["customer feedback","customer satisfaction","staff performance","support performance","support ratings","support replies","support reports","support reviews","support staff"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=support&controller=reports&tab=feedback_ratings"><![CDATA[{"lang_key":"feedback_ratings","restriction":"reports_manage","keywords":["support feedback"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=support&controller=reports&tab=latest_feedback"><![CDATA[{"lang_key":"latest_feedback","restriction":"reports_manage","keywords":["latest support feedback"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=support&controller=reports&tab=overview"><![CDATA[{"lang_key":"overview","restriction":"reports_manage","keywords":["support overview"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=support&controller=reports&tab=replies"><![CDATA[{"lang_key":"replies","restriction":"reports_manage","keywords":["support replies"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=support&controller=requests"><![CDATA[{"lang_key":"menu__nexus_support_requests","restriction":"requests_manage","keywords":["support","support requests","support tickets","tickets"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=support&controller=settings&tab=autoresolve"><![CDATA[{"lang_key":"autoresolve","restriction":"autoresolve_manage","keywords":["auto resolve","auto-resolve","automatic resolve","automatically resolve","autoresolve","resolve"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=support&controller=settings&tab=customerfeedback"><![CDATA[{"lang_key":"customer_feedback","restriction":"customerfeedback_manage","keywords":["feedback","performance","ratings","satisfaction"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=support&controller=settings&tab=departments"><![CDATA[{"lang_key":"departments","restriction":"departments_manage","keywords":["categories","departments","email"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=support&controller=settings&tab=fields"><![CDATA[{"lang_key":"custom_support_fields","restriction":"scfields_manage","keywords":["custom support fields","custom ticket fields","support custom fields","support fields","support form","support information","ticket custom fields","ticket fields","ticket information"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=support&controller=settings&tab=incomingemail"><![CDATA[{"lang_key":"incoming_emails","restriction":"incomingemail_manage","keywords":["email filters","email piping","incoming emails","pop3","spam filters","support emails","ticket emails"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=support&controller=settings&tab=outgoingemail"><![CDATA[{"lang_key":"outgoing_emails","restriction":"outgoingemail_manage","keywords":["support emails","ticket emails"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=support&controller=settings&tab=outgoingemail&searchResult=form_nexus_sout_autoreply"><![CDATA[{"lang_key":"nexus_sout_autoreply","restriction":"settings_manage","keywords":["support confirmation","ticket confirmation"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=support&controller=settings&tab=outgoingemail&searchResult=form_nexus_sout_chrome"><![CDATA[{"lang_key":"nexus_sout_chrome","restriction":"settings_manage","keywords":["email format","email template"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=support&controller=settings&tab=outgoingemail&searchResult=form_nexus_sout_from"><![CDATA[{"lang_key":"nexus_sout_from","restriction":"settings_manage","keywords":["email from"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=support&controller=settings&tab=severities"><![CDATA[{"lang_key":"severities","restriction":"severities_manage","keywords":["critical","emergency","severities","severity","urgency","urgent"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=support&controller=settings&tab=statuses"><![CDATA[{"lang_key":"statuses","restriction":"settings_manage","keywords":["closed","open","resolved","statuses","tags"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=support&controller=settings&tab=stockactions"><![CDATA[{"lang_key":"stock_actions","restriction":"stockactions_manage","keywords":["defined","pre defined","pre set","predefined","preset","stock","stock actions","stock messages","stock replies"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=support&controller=volume"><![CDATA[{"lang_key":"menu__nexus_support_volume","restriction":"volume_manage","keywords":["new ticket stats","support statistics","support stats"]}]]></acpsearch>
|
||||
<hook key="clientAreaLinkLoad"><![CDATA[{"type":"C","class":"\\IPS\\Data\\Store\\Database"}]]></hook>
|
||||
<hook key="register"><![CDATA[{"type":"C","class":"\\IPS\\core\\modules\\front\\system\\register"}]]></hook>
|
||||
<hook key="clientAreaLink"><![CDATA[{"type":"S","class":"\\IPS\\Theme\\class_core_front_global"}]]></hook>
|
||||
<hook key="Database"><![CDATA[{"type":"C","class":"\\IPS\\Data\\Store\\Database"}]]></hook>
|
||||
<hook key="DispatcherAdmin"><![CDATA[{"type":"C","class":"\\IPS\\Dispatcher\\Admin"}]]></hook>
|
||||
<themesetting key="cm_store_view"><![CDATA[{"sc_key":"cm_store_view","sc_type":"Select","sc_multiple":0,"sc_content":"[{\"key\":\"grid\",\"value\":\"cm_store_view_grid\"},{\"key\":\"list\",\"value\":\"cm_store_view_list\"}]","sc_app":"nexus","sc_default":"grid","sc_tab_key":"custom","sc_show_in_vse":0,"sc_title":"themesetting_cm_store_view","sc_order":12,"sc_condition":null}]]></themesetting>
|
||||
<acpsearch key="app=nexus&module=payments&controller=paymentsettings"><![CDATA[{"lang_key":"acpsearch__nexus_payments_paymentsettings","restriction":"paymentsettings_overview","keywords":["payment","gateway","paypal","stripe"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=store&controller=filters"><![CDATA[{"lang_key":"menu__nexus_store_filters","restriction":"packages_manage","keywords":["product","filters","store","package"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=store&controller=settings"><![CDATA[{"lang_key":"acpsearch__nexus_store_settings","restriction":"settings_manage","keywords":["store","store setting"]}]]></acpsearch>
|
||||
<acpsearch key="app=nexus&module=reports&controller=donations"><![CDATA[{"lang_key":"acpsearch__nexus_reports_donations","restriction":"donations_stats_manage","keywords":["donation","goal"]}]]></acpsearch>
|
||||
<themeeditorsetting key="layout_store_view"><![CDATA[{"key":"layout_store_view","type":"select","name":"Store View","desc":"Default layout for the store categories","refresh":true,"options":[["list","List"],["grid","Grid"]],"default":"grid","cat":"pageLayouts"}]]></themeeditorsetting>
|
||||
</build>
|
||||
File renamed without changes.
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief {class}
|
||||
* @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}
|
||||
* @since {date}
|
||||
*/
|
||||
|
||||
namespace IPS\{app}\extensions\nexus\Gateway;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
|
||||
use IPS\nexus\Customer;
|
||||
use IPS\nexus\Gateway;
|
||||
use IPS\nexus\Invoice;
|
||||
use IPS\nexus\Money;
|
||||
use IPS\nexus\Transaction;
|
||||
use IPS\Helpers\Form;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use LogicException;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* {class}
|
||||
*/
|
||||
class {class} extends Gateway
|
||||
{
|
||||
public static string $gatewayKey = '{class}';
|
||||
|
||||
/* !Features */
|
||||
|
||||
const SUPPORTS_REFUNDS = TRUE;
|
||||
const SUPPORTS_PARTIAL_REFUNDS = TRUE;
|
||||
|
||||
/**
|
||||
* Capture
|
||||
*
|
||||
* @param Transaction $transaction Transaction
|
||||
* @return void
|
||||
* @throws LogicException
|
||||
*/
|
||||
public function capture( Transaction $transaction ): void
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Refund
|
||||
*
|
||||
* @param Transaction $transaction Transaction to be refunded
|
||||
* @param mixed|NULL $amount Amount to refund (NULL for full amount - always in same currency as transaction)
|
||||
* @param string|null $reason
|
||||
* @return mixed Gateway reference ID for refund, if applicable
|
||||
* @throws Exception
|
||||
*/
|
||||
public function refund( Transaction $transaction, mixed $amount = NULL, ?string $reason = NULL): mixed
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refund Reasons that the gateway understands, if the gateway supports this
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function refundReasons(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings
|
||||
*
|
||||
* @param Form $form The form
|
||||
* @return void
|
||||
*/
|
||||
public function settings( Form $form ): void
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Settings
|
||||
*
|
||||
* @param array $settings Settings
|
||||
* @return array
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function testSettings( array $settings=array() ): array
|
||||
{
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Payment Screen Fields
|
||||
*
|
||||
* @param Invoice $invoice Invoice
|
||||
* @param Money $amount The amount to pay now
|
||||
* @param Customer|null $member The member the payment screen is for (if in the ACP charging to a member's card) or NULL for currently logged in member
|
||||
* @param array $recurrings Details about recurring costs
|
||||
* @param string $type 'checkout' means the cusotmer is doing this on the normal checkout screen, 'admin' means the admin is doing this in the ACP, 'card' means the user is just adding a card
|
||||
* @return array
|
||||
*/
|
||||
public function paymentScreen( Invoice $invoice, Money $amount, ?Customer $member = NULL, array $recurrings = [], string $type = 'checkout' ): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -12,45 +12,51 @@
|
||||
namespace IPS\{app}\extensions\nexus\Item;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\nexus\Invoice;
|
||||
use IPS\nexus\Invoice\Item;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* {class}
|
||||
*/
|
||||
class _{class} extends \IPS\nexus\Invoice\Item\Charge // or \IPS\nexus\Invoice\Item\Purchase
|
||||
class {class} extends Item\{itemType}
|
||||
{
|
||||
/**
|
||||
* @brief Application
|
||||
*/
|
||||
public static $application = '{app}';
|
||||
public static string $application = '{app}';
|
||||
|
||||
/**
|
||||
* @brief Application
|
||||
*/
|
||||
public static $type = '';
|
||||
public static string $type = '{type}';
|
||||
|
||||
/**
|
||||
* @brief Icon
|
||||
*/
|
||||
public static $icon = '';
|
||||
public static string $icon = '';
|
||||
|
||||
/**
|
||||
* @brief Title
|
||||
*/
|
||||
public static $title = '';
|
||||
public static string $title = '';
|
||||
|
||||
/**
|
||||
* Generate Invoice Form
|
||||
*
|
||||
* @param \IPS\Helpers\Form $form The form
|
||||
* @param \IPS\nexus\Invoice $invoice The invoice
|
||||
* @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
|
||||
{
|
||||
|
||||
}
|
||||
@@ -59,10 +65,10 @@ class _{class} extends \IPS\nexus\Invoice\Item\Charge // or \IPS\nexus\Invoice\I
|
||||
* Create From Form
|
||||
*
|
||||
* @param array $values Values from form
|
||||
* @param \IPS\nexus\Invoice $invoice The invoice
|
||||
* @return \IPS\nexus\extensions\nexus\Item\MiscellaneousCharge
|
||||
* @param Invoice $invoice The invoice
|
||||
* @return static
|
||||
*/
|
||||
public static function createFromForm( array $values, \IPS\nexus\Invoice $invoice )
|
||||
public static function createFromForm( array $values, Invoice $invoice ) : static
|
||||
{
|
||||
|
||||
}
|
||||
@@ -70,10 +76,10 @@ class _{class} extends \IPS\nexus\Invoice\Item\Charge // or \IPS\nexus\Invoice\I
|
||||
/**
|
||||
* On Paid
|
||||
*
|
||||
* @param \IPS\nexus\Invoice $invoice The invoice
|
||||
* @param Invoice $invoice The invoice
|
||||
* @return void
|
||||
*/
|
||||
public function onPaid( \IPS\nexus\Invoice $invoice )
|
||||
public function onPaid( Invoice $invoice ): void
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief {class}
|
||||
* @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}
|
||||
* @since {date}
|
||||
*/
|
||||
|
||||
namespace IPS\{app}\extensions\nexus\LicenseKey;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
|
||||
use IPS\nexus\Purchase\LicenseKey;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* {class}
|
||||
*/
|
||||
class {class} extends LicenseKey
|
||||
{
|
||||
public static string $keyType = '{class}';
|
||||
|
||||
/**
|
||||
* Generates a License Key
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function generateKey() : string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief {class}
|
||||
* @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}
|
||||
* @since {date}
|
||||
*/
|
||||
|
||||
namespace IPS\{app}\extensions\nexus\Payout;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
|
||||
use IPS\nexus\Payout;
|
||||
use DomainException;
|
||||
use Exception;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* {class}
|
||||
*/
|
||||
class {class} extends Payout
|
||||
{
|
||||
public static string $gatewayKey = '{class}';
|
||||
|
||||
/**
|
||||
* ACP Settings
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function settings() : array
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Payout Form
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function form() :array
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data and validate
|
||||
*
|
||||
* @param array $values Values from form
|
||||
* @return mixed
|
||||
* @throws DomainException
|
||||
*/
|
||||
public function getData( array $values ) : mixed
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the payout
|
||||
* Return the new status for this payout record
|
||||
*
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
public function process() : string
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,156 +1,139 @@
|
||||
{
|
||||
"core": {
|
||||
"IncomingEmail": {
|
||||
"Support": "IPS\\nexus\\extensions\\core\\IncomingEmail\\Support"
|
||||
"AchievementAction": {
|
||||
"Donation": "IPS\\nexus\\extensions\\core\\AchievementAction\\Donation",
|
||||
"Package": "IPS\\nexus\\extensions\\core\\AchievementAction\\Package",
|
||||
"Subscription": "IPS\\nexus\\extensions\\core\\AchievementAction\\Subscription"
|
||||
},
|
||||
"AdminNotifications": {
|
||||
"Shipment": "IPS\\nexus\\extensions\\core\\AdminNotifications\\Shipment",
|
||||
"Transaction": "IPS\\nexus\\extensions\\core\\AdminNotifications\\Transaction",
|
||||
"Support": "IPS\\nexus\\extensions\\core\\AdminNotifications\\Support",
|
||||
"Advertisement": "IPS\\nexus\\extensions\\core\\AdminNotifications\\Advertisement",
|
||||
"Withdrawal": "IPS\\nexus\\extensions\\core\\AdminNotifications\\Withdrawal",
|
||||
"ConfigurationError": "IPS\\nexus\\extensions\\core\\AdminNotifications\\ConfigurationError",
|
||||
"Maxmind": "IPS\\nexus\\extensions\\core\\AdminNotifications\\Maxmind",
|
||||
"ConfigurationError": "IPS\\nexus\\extensions\\core\\AdminNotifications\\ConfigurationError"
|
||||
"Transaction": "IPS\\nexus\\extensions\\core\\AdminNotifications\\Transaction",
|
||||
"Withdrawal": "IPS\\nexus\\extensions\\core\\AdminNotifications\\Withdrawal"
|
||||
},
|
||||
"CommunityEnhancements": {
|
||||
"MaxMind": "IPS\\nexus\\extensions\\core\\CommunityEnhancements\\MaxMind"
|
||||
},
|
||||
"ContentRouter": {
|
||||
"Reviews": "IPS\\nexus\\extensions\\core\\ContentRouter\\Reviews"
|
||||
},
|
||||
"MemberACPProfileBlocks": {
|
||||
"Support": "IPS\\nexus\\extensions\\core\\MemberACPProfileBlocks\\Support",
|
||||
"AccountInformation": "IPS\\nexus\\extensions\\core\\MemberACPProfileBlocks\\AccountInformation",
|
||||
"Notes": "IPS\\nexus\\extensions\\core\\MemberACPProfileBlocks\\Notes",
|
||||
"Statistics": "IPS\\nexus\\extensions\\core\\MemberACPProfileBlocks\\Statistics",
|
||||
"Invoices": "IPS\\nexus\\extensions\\core\\MemberACPProfileBlocks\\Invoices",
|
||||
"Purchases": "IPS\\nexus\\extensions\\core\\MemberACPProfileBlocks\\Purchases",
|
||||
"ParentAccounts": "IPS\\nexus\\extensions\\core\\MemberACPProfileBlocks\\ParentAccounts"
|
||||
"Dashboard": {
|
||||
"Income": "IPS\\nexus\\extensions\\core\\Dashboard\\Income",
|
||||
"PendingActions": "IPS\\nexus\\extensions\\core\\Dashboard\\PendingActions"
|
||||
},
|
||||
"MemberExportPersonalInformation": {
|
||||
"Customer": "IPS\\nexus\\extensions\\core\\MemberExportPersonalInformation\\Customer"
|
||||
},
|
||||
"AchievementAction": {
|
||||
"Subscription": "IPS\\nexus\\extensions\\core\\AchievementAction\\Subscription",
|
||||
"Package": "IPS\\nexus\\extensions\\core\\AchievementAction\\Package"
|
||||
},
|
||||
"LiveSearch": {
|
||||
"Nexus": "IPS\\nexus\\extensions\\core\\LiveSearch\\Nexus"
|
||||
"EditorLocations": {
|
||||
"Admin": "IPS\\nexus\\extensions\\core\\EditorLocations\\Admin",
|
||||
"Customer": "IPS\\nexus\\extensions\\core\\EditorLocations\\Customer",
|
||||
"Purchases": "IPS\\nexus\\extensions\\core\\EditorLocations\\Purchases",
|
||||
"Store": "IPS\\nexus\\extensions\\core\\EditorLocations\\Store"
|
||||
},
|
||||
"FileStorage": {
|
||||
"Ads": "IPS\\nexus\\extensions\\core\\FileStorage\\Ads",
|
||||
"Support": "IPS\\nexus\\extensions\\core\\FileStorage\\Support",
|
||||
"PurchaseFields": "IPS\\nexus\\extensions\\core\\FileStorage\\PurchaseFields",
|
||||
"Customer": "IPS\\nexus\\extensions\\core\\FileStorage\\Customer",
|
||||
"Gateways": "IPS\\nexus\\extensions\\core\\FileStorage\\Gateways",
|
||||
"PackageGroups": "IPS\\nexus\\extensions\\core\\FileStorage\\PackageGroups",
|
||||
"Products": "IPS\\nexus\\extensions\\core\\FileStorage\\Products"
|
||||
"Products": "IPS\\nexus\\extensions\\core\\FileStorage\\Products",
|
||||
"PurchaseFields": "IPS\\nexus\\extensions\\core\\FileStorage\\PurchaseFields"
|
||||
},
|
||||
"MFAArea": {
|
||||
"Alternatives": "IPS\\nexus\\extensions\\core\\MFAArea\\Alternatives",
|
||||
"AccountCredit": "IPS\\nexus\\extensions\\core\\MFAArea\\AccountCredit",
|
||||
"BillingAgreements": "IPS\\nexus\\extensions\\core\\MFAArea\\BillingAgreements",
|
||||
"Cards": "IPS\\nexus\\extensions\\core\\MFAArea\\Cards",
|
||||
"BillingInfo": "IPS\\nexus\\extensions\\core\\MFAArea\\BillingInfo",
|
||||
"Addresses": "IPS\\nexus\\extensions\\core\\MFAArea\\Addresses"
|
||||
"FrontNavigation": {
|
||||
"Addresses": "IPS\\nexus\\extensions\\core\\FrontNavigation\\Addresses",
|
||||
"Alternatives": "IPS\\nexus\\extensions\\core\\FrontNavigation\\Alternatives",
|
||||
"BillingAgreements": "IPS\\nexus\\extensions\\core\\FrontNavigation\\BillingAgreements",
|
||||
"Cards": "IPS\\nexus\\extensions\\core\\FrontNavigation\\Cards",
|
||||
"Credit": "IPS\\nexus\\extensions\\core\\FrontNavigation\\Credit",
|
||||
"Donations": "IPS\\nexus\\extensions\\core\\FrontNavigation\\Donations",
|
||||
"Gifts": "IPS\\nexus\\extensions\\core\\FrontNavigation\\Gifts",
|
||||
"Info": "IPS\\nexus\\extensions\\core\\FrontNavigation\\Info",
|
||||
"Orders": "IPS\\nexus\\extensions\\core\\FrontNavigation\\Orders",
|
||||
"Purchases": "IPS\\nexus\\extensions\\core\\FrontNavigation\\Purchases",
|
||||
"Store": "IPS\\nexus\\extensions\\core\\FrontNavigation\\Store",
|
||||
"Subscriptions": "IPS\\nexus\\extensions\\core\\FrontNavigation\\Subscriptions"
|
||||
},
|
||||
"GroupForm": {
|
||||
"PreventDeletion": "IPS\\nexus\\extensions\\core\\GroupForm\\PreventDeletion"
|
||||
},
|
||||
"EditorLocations": {
|
||||
"Support": "IPS\\nexus\\extensions\\core\\EditorLocations\\Support",
|
||||
"Store": "IPS\\nexus\\extensions\\core\\EditorLocations\\Store",
|
||||
"Customer": "IPS\\nexus\\extensions\\core\\EditorLocations\\Customer",
|
||||
"Purchases": "IPS\\nexus\\extensions\\core\\EditorLocations\\Purchases",
|
||||
"Admin": "IPS\\nexus\\extensions\\core\\EditorLocations\\Admin"
|
||||
"IpAddresses": {
|
||||
"Payouts": "IPS\\nexus\\extensions\\core\\IpAddresses\\Payouts",
|
||||
"Transactions": "IPS\\nexus\\extensions\\core\\IpAddresses\\Transactions"
|
||||
},
|
||||
"MemberHistory": {
|
||||
"Nexus": "IPS\\nexus\\extensions\\core\\MemberHistory\\Nexus"
|
||||
"LiveSearch": {
|
||||
"Nexus": "IPS\\nexus\\extensions\\core\\LiveSearch\\Nexus"
|
||||
},
|
||||
"Dashboard": {
|
||||
"PendingActions": "IPS\\nexus\\extensions\\core\\Dashboard\\PendingActions",
|
||||
"Income": "IPS\\nexus\\extensions\\core\\Dashboard\\Income"
|
||||
"MFAArea": {
|
||||
"AccountCredit": "IPS\\nexus\\extensions\\core\\MFAArea\\AccountCredit",
|
||||
"Addresses": "IPS\\nexus\\extensions\\core\\MFAArea\\Addresses",
|
||||
"Alternatives": "IPS\\nexus\\extensions\\core\\MFAArea\\Alternatives",
|
||||
"BillingAgreements": "IPS\\nexus\\extensions\\core\\MFAArea\\BillingAgreements",
|
||||
"BillingInfo": "IPS\\nexus\\extensions\\core\\MFAArea\\BillingInfo",
|
||||
"Cards": "IPS\\nexus\\extensions\\core\\MFAArea\\Cards"
|
||||
},
|
||||
"Uninstall": {
|
||||
"DisablePOP": "IPS\\nexus\\extensions\\core\\Uninstall\\DisablePOP"
|
||||
"MemberACPProfileBlocks": {
|
||||
"AccountInformation": "IPS\\nexus\\extensions\\core\\MemberACPProfileBlocks\\AccountInformation",
|
||||
"Invoices": "IPS\\nexus\\extensions\\core\\MemberACPProfileBlocks\\Invoices",
|
||||
"Notes": "IPS\\nexus\\extensions\\core\\MemberACPProfileBlocks\\Notes",
|
||||
"ParentAccounts": "IPS\\nexus\\extensions\\core\\MemberACPProfileBlocks\\ParentAccounts",
|
||||
"Purchases": "IPS\\nexus\\extensions\\core\\MemberACPProfileBlocks\\Purchases",
|
||||
"Statistics": "IPS\\nexus\\extensions\\core\\MemberACPProfileBlocks\\Statistics"
|
||||
},
|
||||
"MemberACPProfileTabs": {
|
||||
"Main": "IPS\\nexus\\extensions\\core\\MemberACPProfileTabs\\Main"
|
||||
},
|
||||
"MemberExportPersonalInformation": {
|
||||
"Customer": "IPS\\nexus\\extensions\\core\\MemberExportPersonalInformation\\Customer"
|
||||
},
|
||||
"MemberFilter": {
|
||||
"Donations": "IPS\\nexus\\extensions\\core\\MemberFilter\\Donations",
|
||||
"Purchases": "IPS\\nexus\\extensions\\core\\MemberFilter\\Purchases",
|
||||
"Subscriptions": "IPS\\nexus\\extensions\\core\\MemberFilter\\Subscriptions",
|
||||
"TotalSpend": "IPS\\nexus\\extensions\\core\\MemberFilter\\TotalSpend"
|
||||
},
|
||||
"MemberHistory": {
|
||||
"Nexus": "IPS\\nexus\\extensions\\core\\MemberHistory\\Nexus"
|
||||
},
|
||||
"OutputPlugins": {
|
||||
"Money": "IPS\\nexus\\extensions\\core\\OutputPlugins\\Money"
|
||||
},
|
||||
"OverviewStatistics": {
|
||||
"Products": "IPS\\nexus\\extensions\\core\\OverviewStatistics\\Products",
|
||||
"Subscriptions": "IPS\\nexus\\extensions\\core\\OverviewStatistics\\Subscriptions"
|
||||
},
|
||||
"ProfileSteps": {
|
||||
"CustomerFields": "IPS\\nexus\\extensions\\core\\ProfileSteps\\CustomerFields"
|
||||
},
|
||||
"ContactUs": {
|
||||
"SupportRequest": "IPS\\nexus\\extensions\\core\\ContactUs\\SupportRequest"
|
||||
},
|
||||
"CommunityEnhancements": {
|
||||
"MaxMind": "IPS\\nexus\\extensions\\core\\CommunityEnhancements\\MaxMind",
|
||||
"EasyPost": "IPS\\nexus\\extensions\\core\\CommunityEnhancements\\EasyPost"
|
||||
},
|
||||
"Queue": {
|
||||
"FixMissingAddresses": "IPS\\nexus\\extensions\\core\\Queue\\FixMissingAddresses",
|
||||
"RecountTotalSpend": "IPS\\nexus\\extensions\\core\\Queue\\RecountTotalSpend",
|
||||
"FixMissingSubscriptionPurchases": "IPS\\nexus\\extensions\\core\\Queue\\FixMissingSubscriptionPurchases",
|
||||
"FixRefundTransactions": "IPS\\nexus\\extensions\\core\\Queue\\FixRefundTransactions",
|
||||
"MassChangePurchases": "IPS\\nexus\\extensions\\core\\Queue\\MassChangePurchases",
|
||||
"MoveCustomerHistory": "IPS\\nexus\\extensions\\core\\Queue\\MoveCustomerHistory",
|
||||
"DeletePaymentMethod": "IPS\\nexus\\extensions\\core\\Queue\\DeletePaymentMethod",
|
||||
"DeleteSubscriptions": "IPS\\nexus\\extensions\\core\\Queue\\DeleteSubscriptions",
|
||||
"DeletePaymentMethod": "IPS\\nexus\\extensions\\core\\Queue\\DeletePaymentMethod"
|
||||
"FixMissingSubscriptionPurchases": "IPS\\nexus\\extensions\\core\\Queue\\FixMissingSubscriptionPurchases",
|
||||
"MassChangePurchases": "IPS\\nexus\\extensions\\core\\Queue\\MassChangePurchases",
|
||||
"RecountTotalSpend": "IPS\\nexus\\extensions\\core\\Queue\\RecountTotalSpend"
|
||||
},
|
||||
"MemberFilter": {
|
||||
"Subscriptions": "IPS\\nexus\\extensions\\core\\MemberFilter\\Subscriptions",
|
||||
"TotalSpend": "IPS\\nexus\\extensions\\core\\MemberFilter\\TotalSpend",
|
||||
"Purchases": "IPS\\nexus\\extensions\\core\\MemberFilter\\Purchases"
|
||||
},
|
||||
"OverviewStatistics": {
|
||||
"Subscriptions": "IPS\\nexus\\extensions\\core\\OverviewStatistics\\Subscriptions",
|
||||
"Products": "IPS\\nexus\\extensions\\core\\OverviewStatistics\\Products"
|
||||
},
|
||||
"IpAddresses": {
|
||||
"Payouts": "IPS\\nexus\\extensions\\core\\IpAddresses\\Payouts",
|
||||
"Support": "IPS\\nexus\\extensions\\core\\IpAddresses\\Support",
|
||||
"Transactions": "IPS\\nexus\\extensions\\core\\IpAddresses\\Transactions"
|
||||
},
|
||||
"FrontNavigation": {
|
||||
"Info": "IPS\\nexus\\extensions\\core\\FrontNavigation\\Info",
|
||||
"Alternatives": "IPS\\nexus\\extensions\\core\\FrontNavigation\\Alternatives",
|
||||
"Subscriptions": "IPS\\nexus\\extensions\\core\\FrontNavigation\\Subscriptions",
|
||||
"Support": "IPS\\nexus\\extensions\\core\\FrontNavigation\\Support",
|
||||
"BillingAgreements": "IPS\\nexus\\extensions\\core\\FrontNavigation\\BillingAgreements",
|
||||
"Gifts": "IPS\\nexus\\extensions\\core\\FrontNavigation\\Gifts",
|
||||
"Store": "IPS\\nexus\\extensions\\core\\FrontNavigation\\Store",
|
||||
"Cards": "IPS\\nexus\\extensions\\core\\FrontNavigation\\Cards",
|
||||
"Credit": "IPS\\nexus\\extensions\\core\\FrontNavigation\\Credit",
|
||||
"Purchases": "IPS\\nexus\\extensions\\core\\FrontNavigation\\Purchases",
|
||||
"Addresses": "IPS\\nexus\\extensions\\core\\FrontNavigation\\Addresses",
|
||||
"Donations": "IPS\\nexus\\extensions\\core\\FrontNavigation\\Donations",
|
||||
"Orders": "IPS\\nexus\\extensions\\core\\FrontNavigation\\Orders"
|
||||
},
|
||||
"OutputPlugins": {
|
||||
"Weight": "IPS\\nexus\\extensions\\core\\OutputPlugins\\Weight",
|
||||
"Money": "IPS\\nexus\\extensions\\core\\OutputPlugins\\Money",
|
||||
"Length": "IPS\\nexus\\extensions\\core\\OutputPlugins\\Length"
|
||||
},
|
||||
"MemberSync": {
|
||||
"Nexus": "IPS\\nexus\\extensions\\core\\MemberSync\\Nexus"
|
||||
"SearchContent": {
|
||||
"Packages": "IPS\\nexus\\extensions\\core\\SearchContent\\Packages"
|
||||
},
|
||||
"Statistics": {
|
||||
"Income": "IPS\\nexus\\extensions\\core\\Statistics\\Income",
|
||||
"Market": "IPS\\nexus\\extensions\\core\\Statistics\\Market",
|
||||
"Sales": "IPS\\nexus\\extensions\\core\\Statistics\\Sales",
|
||||
"Support": "IPS\\nexus\\extensions\\core\\Statistics\\Support"
|
||||
"Sales": "IPS\\nexus\\extensions\\core\\Statistics\\Sales"
|
||||
},
|
||||
"Uninstall": {
|
||||
"DisablePOP": "IPS\\nexus\\extensions\\core\\Uninstall\\DisablePOP"
|
||||
},
|
||||
"UserMenu": {
|
||||
"Store": "IPS\\nexus\\extensions\\core\\UserMenu\\Store"
|
||||
}
|
||||
},
|
||||
"nexus": {
|
||||
"Item": {
|
||||
"Subscription": "IPS\\nexus\\extensions\\nexus\\Item\\Subscription",
|
||||
"ShippingCharge": "IPS\\nexus\\extensions\\nexus\\Item\\ShippingCharge",
|
||||
"Package": "IPS\\nexus\\extensions\\nexus\\Item\\Package",
|
||||
"GiftVoucher": "IPS\\nexus\\extensions\\nexus\\Item\\GiftVoucher",
|
||||
"SubscriptionUpgrade": "IPS\\nexus\\extensions\\nexus\\Item\\SubscriptionUpgrade",
|
||||
"SupportCharge": "IPS\\nexus\\extensions\\nexus\\Item\\SupportCharge",
|
||||
"AccountCreditIncrease": "IPS\\nexus\\extensions\\nexus\\Item\\AccountCreditIncrease",
|
||||
"CouponDiscount": "IPS\\nexus\\extensions\\nexus\\Item\\CouponDiscount",
|
||||
"CustomPackage": "IPS\\nexus\\extensions\\nexus\\Item\\CustomPackage",
|
||||
"AccountCreditIncrease": "IPS\\nexus\\extensions\\nexus\\Item\\AccountCreditIncrease",
|
||||
"MiscellaneousCharge": "IPS\\nexus\\extensions\\nexus\\Item\\MiscellaneousCharge",
|
||||
"Donation": "IPS\\nexus\\extensions\\nexus\\Item\\Donation",
|
||||
"GiftVoucher": "IPS\\nexus\\extensions\\nexus\\Item\\GiftVoucher",
|
||||
"MiscellaneousCharge": "IPS\\nexus\\extensions\\nexus\\Item\\MiscellaneousCharge",
|
||||
"Package": "IPS\\nexus\\extensions\\nexus\\Item\\Package",
|
||||
"Subscription": "IPS\\nexus\\extensions\\nexus\\Item\\Subscription",
|
||||
"SubscriptionUpgrade": "IPS\\nexus\\extensions\\nexus\\Item\\SubscriptionUpgrade",
|
||||
"UpgradeCharge": "IPS\\nexus\\extensions\\nexus\\Item\\UpgradeCharge"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,3 @@
|
||||
/**
|
||||
* Friendly URL Structure
|
||||
*
|
||||
* For each value in the $furl array:
|
||||
* The key should be the "SEO Template" - an identifier which you'll use when displaying a URL.
|
||||
* The value should be an associative array with two or three elements: 'friendly' and 'real', and optionally 'verify':
|
||||
* 'friendly'
|
||||
* The friendly URL to use - encase variables in {curly braces} containing a symbol, followed by the name of the parameter that matches in the "real" URL
|
||||
* The symbol should be # for numbers or @ for strings
|
||||
* For example, if the "real" URL contains id=XXX, where XXX is a number, you should include {#id} somewhere in the friendly URL.
|
||||
* You can also use the tag {?} for the "SEO Title" (that is, any variables that shouldn't be part of the real URL, such as the name of the topipc being viewed).
|
||||
* If you want to support more than one SEO Title, you can give them zero-indexed keys like so: {?0} {?1} {?2}
|
||||
* 'real'
|
||||
* This should be the base of the real URL. You should not include parameters which will be parsed out from the friendly URL.
|
||||
* 'verify'
|
||||
* This should be the name of a class that contains a loadFromUrl() and an url() method. The dynamic URL (i.e. app=core&...) will be passed to loadFromUrl(), and the url()
|
||||
* method will subsequently be called to retrieve the correct URL, ideal with ActiveRecord pattern classes.
|
||||
*
|
||||
* IMPORTANT: Ensure values are listed with the most specific ones first. This is to ensure that non-FURL redirects are done correctly. For example, if you have these FURLs:
|
||||
* /index.php?app=myapp&module=mymodule&controller=mycontroller&do=myaction -> /myfolder/myaction
|
||||
* /index.php?app=myapp&module=mymodule&controller=mycontroller -> /myfolder
|
||||
* They must be provided in that order, otherwise the former will redirec to /myfolder/?do=myaction rather than /myfolder/myaction
|
||||
*/
|
||||
{
|
||||
"topLevel": "",
|
||||
"pages": {
|
||||
@@ -28,19 +5,6 @@
|
||||
"friendly": "checkout/{#id}",
|
||||
"real": "app=nexus&module=checkout&controller=checkout"
|
||||
},
|
||||
"support_create": {
|
||||
"friendly": "support/create",
|
||||
"real": "app=nexus&module=support&controller=home&do=create"
|
||||
},
|
||||
"support_view": {
|
||||
"friendly": "support/{#id}",
|
||||
"real": "app=nexus&module=support&controller=view",
|
||||
"verify": "\\IPS\\nexus\\Support\\Request"
|
||||
},
|
||||
"support": {
|
||||
"friendly": "support",
|
||||
"real": "app=nexus&module=support&controller=home"
|
||||
},
|
||||
"store_group": {
|
||||
"friendly": "store/category/{#cat}-{?}",
|
||||
"real": "app=nexus&module=store&controller=store",
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"clientAreaLinkLoad": {
|
||||
"type": "C",
|
||||
"class": "\\IPS\\Data\\Store\\Database"
|
||||
},
|
||||
"register": {
|
||||
"type": "C",
|
||||
"class": "\\IPS\\core\\modules\\front\\system\\register"
|
||||
},
|
||||
"clientAreaLink": {
|
||||
"type": "S",
|
||||
"class": "\\IPS\\Theme\\class_core_front_global"
|
||||
},
|
||||
"Database": {
|
||||
"type": "C",
|
||||
"class": "\\IPS\\Data\\Store\\Database"
|
||||
},
|
||||
"DispatcherAdmin": {
|
||||
"type": "C",
|
||||
"class": "\\IPS\\Dispatcher\\Admin"
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,4 @@
|
||||
{
|
||||
"nexus_status_1_front": "Open",
|
||||
"nexus_status_1_admin": "Open",
|
||||
"nexus_status_2_front": "On Hold",
|
||||
"nexus_status_2_admin": "Hold",
|
||||
"nexus_status_3_front": "Awaiting your reply",
|
||||
"nexus_status_3_admin": "Closed",
|
||||
"nexus_status_4_front": "Resolved",
|
||||
"nexus_status_4_admin": "Resolved",
|
||||
"nexus_status_4_set": "Mark Resolved",
|
||||
"nexus_status_5_front": "Marked as Spam - Reply if this is an error",
|
||||
"nexus_status_5_admin": "Spam",
|
||||
"nexus_status_6_front": "In Progress",
|
||||
"nexus_status_6_admin": "Working",
|
||||
"nexus_severity_1": "Normal",
|
||||
"cm_phone": "Phone Number",
|
||||
"nexus_ccfield_1": "Phone Number"
|
||||
}
|
||||
+100
-2238
File diff suppressed because it is too large.
Load diff
+70
-1001
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"Nexus": {
|
||||
"type": "MemberListenerType",
|
||||
"classname": "IPS\\nexus\\listeners\\Nexus",
|
||||
"extends": "IPS\\Member"
|
||||
}
|
||||
}
|
||||
@@ -10,21 +10,11 @@
|
||||
"protected": 1,
|
||||
"default": 0
|
||||
},
|
||||
"support": {
|
||||
"default_controller": "home",
|
||||
"protected": 0,
|
||||
"default": 0
|
||||
},
|
||||
"clients": {
|
||||
"default_controller": "purchases",
|
||||
"protected": 0,
|
||||
"default": 0
|
||||
},
|
||||
"promotion": {
|
||||
"default_controller": "",
|
||||
"protected": 0,
|
||||
"default": 0
|
||||
},
|
||||
"subscriptions": {
|
||||
"default_controller": "",
|
||||
"protected": 0,
|
||||
@@ -42,11 +32,6 @@
|
||||
"protected": 0,
|
||||
"default": 0
|
||||
},
|
||||
"support": {
|
||||
"default_controller": "",
|
||||
"protected": 0,
|
||||
"default": 0
|
||||
},
|
||||
"store": {
|
||||
"default_controller": "",
|
||||
"protected": 0,
|
||||
|
||||
+81
-3197
File diff suppressed because it is too large.
Load diff
@@ -29,51 +29,11 @@
|
||||
"default": "",
|
||||
"report": "bool"
|
||||
},
|
||||
{
|
||||
"key": "customer_fields",
|
||||
"default": "0",
|
||||
"report": "bool"
|
||||
},
|
||||
{
|
||||
"key": "donation_goals",
|
||||
"default": "0",
|
||||
"report": "bool"
|
||||
},
|
||||
{
|
||||
"key": "easypost_address",
|
||||
"default": "",
|
||||
"report": "bool"
|
||||
},
|
||||
{
|
||||
"key": "easypost_api_key",
|
||||
"default": "",
|
||||
"report": "bool"
|
||||
},
|
||||
{
|
||||
"key": "easypost_delivery_adjustment",
|
||||
"default": "0",
|
||||
"report": "full"
|
||||
},
|
||||
{
|
||||
"key": "easypost_phone",
|
||||
"default": "",
|
||||
"report": "bool"
|
||||
},
|
||||
{
|
||||
"key": "easypost_price_adjustment",
|
||||
"default": "",
|
||||
"report": "bool"
|
||||
},
|
||||
{
|
||||
"key": "easypost_show_rates",
|
||||
"default": "0",
|
||||
"report": "full"
|
||||
},
|
||||
{
|
||||
"key": "easypost_tax",
|
||||
"default": "0",
|
||||
"report": "bool"
|
||||
},
|
||||
{
|
||||
"key": "gateways_counts",
|
||||
"default": "{}",
|
||||
@@ -139,31 +99,6 @@
|
||||
"default": "0",
|
||||
"report": "bool"
|
||||
},
|
||||
{
|
||||
"key": "nexus_autoresolve_applicable",
|
||||
"default": "3",
|
||||
"report": "full"
|
||||
},
|
||||
{
|
||||
"key": "nexus_autoresolve_days",
|
||||
"default": "0",
|
||||
"report": "full"
|
||||
},
|
||||
{
|
||||
"key": "nexus_autoresolve_departments",
|
||||
"default": "*",
|
||||
"report": "bool"
|
||||
},
|
||||
{
|
||||
"key": "nexus_autoresolve_notify",
|
||||
"default": "24",
|
||||
"report": "full"
|
||||
},
|
||||
{
|
||||
"key": "nexus_autoresolve_status",
|
||||
"default": "4",
|
||||
"report": "full"
|
||||
},
|
||||
{
|
||||
"key": "nexus_checkreg_captcha",
|
||||
"default": "0",
|
||||
@@ -189,11 +124,6 @@
|
||||
"default": "USD",
|
||||
"report": "none"
|
||||
},
|
||||
{
|
||||
"key": "nexus_donate_loggedin",
|
||||
"default": "0",
|
||||
"report": "full"
|
||||
},
|
||||
{
|
||||
"key": "nexus_gift_vouchers",
|
||||
"default": "{}",
|
||||
@@ -284,26 +214,11 @@
|
||||
"default": "0",
|
||||
"report": "full"
|
||||
},
|
||||
{
|
||||
"key": "nexus_reg_group",
|
||||
"default": "0",
|
||||
"report": "bool"
|
||||
},
|
||||
{
|
||||
"key": "nexus_require_billing",
|
||||
"default": "product,giftvoucher,donation,other,subscriptions",
|
||||
"report": "bool"
|
||||
},
|
||||
{
|
||||
"key": "nexus_revw_sa",
|
||||
"default": "0",
|
||||
"report": "full"
|
||||
},
|
||||
{
|
||||
"key": "nexus_severities",
|
||||
"default": "1",
|
||||
"report": "full"
|
||||
},
|
||||
{
|
||||
"key": "nexus_show_renew_option_savings",
|
||||
"default": "amount",
|
||||
@@ -319,21 +234,6 @@
|
||||
"default": "0",
|
||||
"report": "full"
|
||||
},
|
||||
{
|
||||
"key": "nexus_sout_autoreply",
|
||||
"default": "0",
|
||||
"report": "full"
|
||||
},
|
||||
{
|
||||
"key": "nexus_sout_chrome",
|
||||
"default": "0",
|
||||
"report": "full"
|
||||
},
|
||||
{
|
||||
"key": "nexus_sout_from",
|
||||
"default": "staff",
|
||||
"report": "full"
|
||||
},
|
||||
{
|
||||
"key": "nexus_split_payments",
|
||||
"default": "0",
|
||||
@@ -384,11 +284,6 @@
|
||||
"default": "0",
|
||||
"report": "full"
|
||||
},
|
||||
{
|
||||
"key": "nexus_support_satisfaction",
|
||||
"default": "1",
|
||||
"report": "full"
|
||||
},
|
||||
{
|
||||
"key": "nexus_tac",
|
||||
"default": "none",
|
||||
@@ -398,10 +293,5 @@
|
||||
"key": "nexus_tac_link",
|
||||
"default": "",
|
||||
"report": "bool"
|
||||
},
|
||||
{
|
||||
"key": "reply_request_resolved",
|
||||
"default": "reopen",
|
||||
"report": "full"
|
||||
}
|
||||
]
|
||||
@@ -1 +1 @@
|
||||
{"capture":"P0Y0M0DT1H0M0S","sendInvoiceWarnings":"P0Y0M0DT1H0M0S","generateRenewalInvoices":"P0Y0M0DT0H30M0S","expirePurchases":"P0Y0M0DT1H0M0S","expireInvoices":"P0Y0M0DT1H0M0S","supportAutoresolve":"P0Y0M0DT1H0M0S","supportAssignedReminder":"P0Y0M1DT0H0M0S","cartCleanup":"P0Y0M1DT0H0M0S","billingAgreements":"P0Y0M0DT0H10M0S","gatewayPending":"P0Y0M0DT0H10M0S","payoutPending":"P0Y0M0DT0H10M0S"}
|
||||
{"capture":"P0Y0M0DT1H0M0S","sendInvoiceWarnings":"P0Y0M0DT1H0M0S","generateRenewalInvoices":"P0Y0M0DT0H30M0S","expirePurchases":"P0Y0M0DT1H0M0S","expireInvoices":"P0Y0M0DT1H0M0S","cartCleanup":"P0Y0M1DT0H0M0S","billingAgreements":"P0Y0M0DT0H10M0S","gatewayPending":"P0Y0M0DT0H10M0S","payoutPending":"P0Y0M0DT0H10M0S"}
|
||||
+4320
-9487
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"settings": {
|
||||
"layout_store_view": {
|
||||
"key": "layout_store_view",
|
||||
"type": "select",
|
||||
"name": "Store View",
|
||||
"desc": "Default layout for the store categories",
|
||||
"refresh": true,
|
||||
"options": [
|
||||
[
|
||||
"list",
|
||||
"List"
|
||||
],
|
||||
[
|
||||
"grid",
|
||||
"Grid"
|
||||
]
|
||||
],
|
||||
"default": "grid",
|
||||
"cat": "pageLayouts"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1 @@
|
||||
[
|
||||
{
|
||||
"sc_key": "cm_store_view",
|
||||
"sc_type": "Select",
|
||||
"sc_multiple": 0,
|
||||
"sc_content": "[{\"key\":\"grid\",\"value\":\"cm_store_view_grid\"},{\"key\":\"list\",\"value\":\"cm_store_view_list\"}]",
|
||||
"sc_app": "nexus",
|
||||
"sc_default": "grid",
|
||||
"sc_tab_key": "custom",
|
||||
"sc_show_in_vse": 0,
|
||||
"sc_title": "themesetting_cm_store_view",
|
||||
"sc_order": 12,
|
||||
"sc_condition": null
|
||||
}
|
||||
]
|
||||
[]
|
||||
@@ -1,388 +1,4 @@
|
||||
{
|
||||
"10000": "1.0 Alpha 1",
|
||||
"10001": "1.0 Alpha 2",
|
||||
"10002": "1.0 Alpha 3",
|
||||
"10003": "1.0 Alpha 4",
|
||||
"10004": "1.0 Alpha 5",
|
||||
"10005": "1.0 Alpha 6",
|
||||
"10006": "1.0 Beta 1",
|
||||
"10007": "1.0 Beta 2",
|
||||
"10008": "1.0 Beta 3",
|
||||
"10009": "1.0 Beta 4",
|
||||
"10010": "1.0 Beta 5",
|
||||
"10011": "1.0 Beta 6",
|
||||
"10012": "1.0 Beta 7",
|
||||
"10013": "1.0 Beta 8",
|
||||
"10014": "1.0.0",
|
||||
"10015": "1.0.1",
|
||||
"10016": "1.0.2",
|
||||
"10017": "1.0.3",
|
||||
"10100": "1.1.0 Alpha 1",
|
||||
"10101": "1.1.0 Alpha 2",
|
||||
"10102": "1.1.0 Alpha 3",
|
||||
"10103": "1.1.0 Alpha 4",
|
||||
"10104": "1.1.0 Alpha 5",
|
||||
"10105": "1.1.0 Beta 1",
|
||||
"11000": "1.1.0",
|
||||
"11001": "1.1.1",
|
||||
"11002": "1.1.2",
|
||||
"11003": "1.1.3",
|
||||
"11100": "1.2 Alpha 1",
|
||||
"11101": "1.2 Alpha 2",
|
||||
"11102": "1.2 Alpha 3",
|
||||
"11103": "1.2 Alpha 4",
|
||||
"11104": "1.2 Beta 1",
|
||||
"11105": "1.2 Beta 2",
|
||||
"11106": "1.2 Beta 3",
|
||||
"11107": "1.2 Beta 4",
|
||||
"11108": "1.2 Beta 5",
|
||||
"11109": "1.2.0",
|
||||
"12001": "1.2.1",
|
||||
"12002": "1.2.2",
|
||||
"12100": "1.3.0 Alpha 1",
|
||||
"13000": "1.3.0",
|
||||
"13001": "1.3.0 Beta 2",
|
||||
"13002": "1.3.0",
|
||||
"13003": "1.3.1",
|
||||
"13004": "1.3.2",
|
||||
"14000": "1.4.0 Beta 1",
|
||||
"14001": "1.4.0 Beta 2",
|
||||
"14002": "1.4.0",
|
||||
"14003": "1.4.1",
|
||||
"14004": "1.4.2",
|
||||
"15000": "1.5.0 Alpha 1",
|
||||
"15001": "1.5.0 Alpha 2",
|
||||
"15002": "1.5.0 Alpha 3",
|
||||
"15003": "1.5.0 Beta 1",
|
||||
"15004": "1.5.0 Beta 2",
|
||||
"15005": "1.5.0",
|
||||
"15006": "1.5.1",
|
||||
"15007": "1.5.2",
|
||||
"15008": "1.5.3",
|
||||
"15009": "1.5.4",
|
||||
"15010": "1.5.5",
|
||||
"15011": "1.5.6",
|
||||
"15012": "1.5.7",
|
||||
"15013": "1.5.8",
|
||||
"15014": "1.5.9",
|
||||
"40000": "4.0.0",
|
||||
"100000": "4.0.0 Beta 0",
|
||||
"100001": "4.0.0 Beta 1",
|
||||
"100002": "4.0.0 Beta 2",
|
||||
"100003": "4.0.0 Beta 3",
|
||||
"100004": "4.0.0 Beta 3a",
|
||||
"100005": "4.0.0 Beta 4",
|
||||
"100006": "4.0.0 Beta 4a",
|
||||
"100007": "4.0.0 Beta 4b",
|
||||
"100008": "4.0.0 Beta 5",
|
||||
"100009": "4.0.0 Beta 5a",
|
||||
"100010": "4.0.0 Beta 6",
|
||||
"100011": "4.0.0 Beta 7",
|
||||
"100012": "4.0.0 Beta 7a",
|
||||
"100013": "4.0.0 Beta 8",
|
||||
"100014": "4.0.0 RC1",
|
||||
"100015": "4.0.0 RC2",
|
||||
"100016": "4.0.0 RC3",
|
||||
"100017": "4.0.0 RC4",
|
||||
"100018": "4.0.0 RC5",
|
||||
"100019": "4.0.0 RC5a",
|
||||
"100020": "4.0.0 RC6",
|
||||
"100021": "4.0.0 RC7",
|
||||
"100022": "4.0.0 RC7a",
|
||||
"100023": "4.0.0",
|
||||
"100024": "4.0.1",
|
||||
"100025": "4.0.2",
|
||||
"100026": "4.0.3",
|
||||
"100027": "4.0.4",
|
||||
"100028": "4.0.5",
|
||||
"100029": "4.0.5.1",
|
||||
"100030": "4.0.6",
|
||||
"100031": "4.0.6.1",
|
||||
"100032": "4.0.7",
|
||||
"100033": "4.0.8",
|
||||
"100034": "4.0.8.1",
|
||||
"100035": "4.0.9",
|
||||
"100036": "4.0.9.1",
|
||||
"100037": "4.0.9.2",
|
||||
"100038": "4.0.10",
|
||||
"100039": "4.0.10.1",
|
||||
"100040": "4.0.10.2",
|
||||
"100041": "4.0.11",
|
||||
"100042": "4.0.12",
|
||||
"100043": "4.0.12.1",
|
||||
"100044": "4.0.13",
|
||||
"100045": "4.0.13.1",
|
||||
"101000": "4.1.0 Beta 1",
|
||||
"101001": "4.1.0 Beta 2",
|
||||
"101002": "4.1.0 Beta 3",
|
||||
"101003": "4.1.0 Beta 4",
|
||||
"101004": "4.1.0 Beta 5",
|
||||
"101005": "4.1.0 Beta 6",
|
||||
"101006": "4.1.0 Beta 7",
|
||||
"101007": "4.1.0 Beta 8",
|
||||
"101008": "4.1.0 Beta 9",
|
||||
"101009": "4.1.0 Beta 10",
|
||||
"101010": "4.1.0",
|
||||
"101011": "4.1.1",
|
||||
"101012": "4.1.2",
|
||||
"101013": "4.1.3",
|
||||
"101014": "4.1.3.1",
|
||||
"101015": "4.1.3.2",
|
||||
"101016": "4.1.4",
|
||||
"101017": "4.1.4.1",
|
||||
"101018": "4.1.5",
|
||||
"101019": "4.1.5.1",
|
||||
"101020": "4.1.5.2",
|
||||
"101021": "4.1.6",
|
||||
"101022": "4.1.6.1",
|
||||
"101023": "4.1.7",
|
||||
"101024": "4.1.8",
|
||||
"101025": "4.1.8.1",
|
||||
"101026": "4.1.9",
|
||||
"101027": "4.1.10",
|
||||
"101028": "4.1.11",
|
||||
"101029": "4.1.11.1",
|
||||
"101030": "4.1.12",
|
||||
"101031": "4.1.12.1",
|
||||
"101032": "4.1.12.2",
|
||||
"101033": "4.1.12.3",
|
||||
"101034": "4.1.13 Beta 1",
|
||||
"101035": "4.1.13 Beta 2",
|
||||
"101036": "4.1.13",
|
||||
"101037": "4.1.13",
|
||||
"101038": "4.1.13.1",
|
||||
"101040": "4.1.13.2",
|
||||
"101041": "4.1.13.2",
|
||||
"101042": "4.1.14 Beta 1",
|
||||
"101043": "4.1.14 Beta 2",
|
||||
"101044": "4.1.14 Beta 3",
|
||||
"101045": "4.1.14 Beta 4",
|
||||
"101046": "4.1.14 Beta 5",
|
||||
"101049": "4.1.14 Beta 6",
|
||||
"101050": "4.1.14 Beta 7",
|
||||
"101051": "4.1.14 RC",
|
||||
"101052": "4.1.14",
|
||||
"101053": "4.1.14.1",
|
||||
"101054": "4.1.14.2",
|
||||
"101055": "4.1.14.3",
|
||||
"101056": "4.1.15",
|
||||
"101057": "4.1.15 Beta 1",
|
||||
"101058": "4.1.15 Beta 2",
|
||||
"101059": "4.1.15 Beta 2a",
|
||||
"101060": "4.1.15 Beta 3",
|
||||
"101061": "4.1.15",
|
||||
"101062": "4.1.15",
|
||||
"101063": "4.1.15",
|
||||
"101064": "4.1.16 Beta 1",
|
||||
"101065": "4.1.16 Beta 2",
|
||||
"101066": "4.1.16 Beta 3",
|
||||
"101067": "4.1.16 Beta 4",
|
||||
"101068": "4.1.16 Beta 5",
|
||||
"101069": "4.1.16",
|
||||
"101070": "4.1.16.1",
|
||||
"101071": "4.1.17 Beta 1",
|
||||
"101072": "4.1.17 Beta 1a",
|
||||
"101073": "4.1.17 Beta 1b",
|
||||
"101074": "4.1.17 Beta 2",
|
||||
"101075": "4.1.17 Beta 3",
|
||||
"101076": "4.1.17 Beta 3",
|
||||
"101077": "4.1.17",
|
||||
"101078": "4.1.17.1",
|
||||
"101079": "4.1.18 Beta 1",
|
||||
"101082": "4.1.18 Beta 1b",
|
||||
"101083": "4.1.18 Beta 2",
|
||||
"101084": "4.1.18 Beta 3",
|
||||
"101085": "4.1.18",
|
||||
"101088": "4.1.18.1",
|
||||
"101089": "4.1.18.2",
|
||||
"101090": "4.1.19 Beta 1",
|
||||
"101091": "4.1.19 Beta 2",
|
||||
"101092": "4.1.19 Beta 3",
|
||||
"101093": "4.1.19",
|
||||
"101094": "4.1.19.1",
|
||||
"101095": "4.1.19.2 Beta 1",
|
||||
"101096": "4.1.19.2",
|
||||
"101097": "4.1.19.2",
|
||||
"101098": "4.1.19.3",
|
||||
"101099": "4.1.19.4",
|
||||
"101100": "4.2.0 Beta 1",
|
||||
"101101": "4.2.0 Beta 1",
|
||||
"101102": "4.2.0 Beta 1",
|
||||
"101103": "4.2.0 Beta 1",
|
||||
"101104": "4.2.0 Beta 2",
|
||||
"101105": "4.2.0 Beta 3",
|
||||
"101106": "4.2.0 Beta 3a",
|
||||
"101107": "4.2.0 Beta 4",
|
||||
"101108": "4.2.0 Beta 4",
|
||||
"101109": "4.2.0 Beta 5",
|
||||
"101110": "4.2.0 Beta 5a",
|
||||
"101111": "4.2.0 Beta 6",
|
||||
"101112": "4.2.0 Beta 6a",
|
||||
"101113": "4.2.0 Beta 6a",
|
||||
"101114": "4.2.0 Beta 7",
|
||||
"101115": "4.2.0 Beta 7a",
|
||||
"101116": "4.2.0 Beta 8",
|
||||
"101117": "4.2.0 Beta 8",
|
||||
"102000": "4.2.0",
|
||||
"102001": "4.2.0",
|
||||
"102002": "4.2.0",
|
||||
"102003": "4.2.0",
|
||||
"102004": "4.2.1",
|
||||
"102005": "4.2.2 Beta 1",
|
||||
"102006": "4.2.2 Beta 2",
|
||||
"102007": "4.2.2",
|
||||
"102008": "4.2.2",
|
||||
"102009": "4.2.2",
|
||||
"102010": "4.2.3 Beta 1",
|
||||
"102011": "4.2.3",
|
||||
"102012": "4.2.3",
|
||||
"102013": "4.2.3",
|
||||
"102014": "4.2.4 Beta 1",
|
||||
"102015": "4.2.4 Beta 2",
|
||||
"102016": "4.2.4",
|
||||
"102017": "4.2.4",
|
||||
"102018": "4.2.4",
|
||||
"102019": "4.2.4",
|
||||
"102020": "4.2.4",
|
||||
"102021": "4.2.5 Beta 1",
|
||||
"102022": "4.2.5 Beta 2",
|
||||
"102023": "4.2.5 Beta 3",
|
||||
"102024": "4.2.5",
|
||||
"102025": "4.2.5",
|
||||
"102026": "4.2.5",
|
||||
"102027": "4.2.5",
|
||||
"102028": "4.2.5",
|
||||
"102029": "4.2.5",
|
||||
"102030": "4.2.6 Beta 1",
|
||||
"102031": "4.2.6 Beta 1",
|
||||
"102032": "4.2.6 Beta 2",
|
||||
"102033": "4.2.6 Beta 3",
|
||||
"102034": "4.2.6",
|
||||
"102035": "4.2.6",
|
||||
"102036": "4.2.6",
|
||||
"102037": "4.2.7 Beta 1",
|
||||
"102038": "4.2.7 Beta 2",
|
||||
"102039": "4.2.7 Beta 3",
|
||||
"102040": "4.2.7 Beta 4",
|
||||
"102041": "4.2.7 Beta 5",
|
||||
"102042": "4.2.7",
|
||||
"102043": "4.2.7",
|
||||
"102044": "4.2.7",
|
||||
"102045": "4.2.7",
|
||||
"102046": "4.2.7",
|
||||
"102047": "4.2.8",
|
||||
"102048": "4.2.8",
|
||||
"102049": "4.2.9",
|
||||
"103000": "4.3.0 Beta 1",
|
||||
"103002": "4.3.0 Beta 2",
|
||||
"103003": "4.3.0 Beta 3",
|
||||
"103004": "4.3.0 Beta 4",
|
||||
"103005": "4.3.0",
|
||||
"103006": "4.3.1",
|
||||
"103007": "4.3.1",
|
||||
"103008": "4.3.1",
|
||||
"103009": "4.3.2",
|
||||
"103010": "4.3.2",
|
||||
"103011": "4.3.3",
|
||||
"103012": "4.3.3",
|
||||
"103013": "4.3.3",
|
||||
"103014": "4.3.3",
|
||||
"103015": "4.3.3",
|
||||
"103016": "4.3.3",
|
||||
"103017": "4.3.3",
|
||||
"103018": "4.3.3",
|
||||
"103019": "4.3.3",
|
||||
"103020": "4.3.3",
|
||||
"103021": "4.3.4",
|
||||
"103022": "4.3.4",
|
||||
"103023": "4.3.4",
|
||||
"103024": "4.3.4",
|
||||
"103025": "4.3.4",
|
||||
"103026": "4.3.5 Beta 1",
|
||||
"103027": "4.3.5 Beta 2",
|
||||
"103028": "4.3.5",
|
||||
"103029": "4.3.5",
|
||||
"103030": "4.3.5",
|
||||
"103031": "4.3.5",
|
||||
"103032": "4.3.5",
|
||||
"103033": "4.3.6 Beta 1",
|
||||
"103034": "4.3.6 Beta 2",
|
||||
"103035": "4.3.6",
|
||||
"103036": "4.3.6",
|
||||
"103037": "4.3.6",
|
||||
"103038": "4.3.6",
|
||||
"103039": "4.3.6",
|
||||
"104000": "4.4.0 Beta 1",
|
||||
"104001": "4.4.0 Beta 2",
|
||||
"104002": "4.4.0 Beta 3",
|
||||
"104004": "4.4.0 Beta 4",
|
||||
"104003": "4.4.0 Beta 4",
|
||||
"104005": "4.4.0",
|
||||
"104006": "4.4.0",
|
||||
"104007": "4.4.0",
|
||||
"104008": "4.4.0",
|
||||
"104009": "4.4.1",
|
||||
"104010": "4.4.1 Beta 2",
|
||||
"104011": "4.4.1",
|
||||
"104012": "4.4.1",
|
||||
"104013": "4.4.1",
|
||||
"104014": "4.4.1",
|
||||
"104015": "4.4.2 Beta 1",
|
||||
"104016": "4.4.2",
|
||||
"104017": "4.4.2",
|
||||
"104018": "4.4.2",
|
||||
"104019": "4.4.2",
|
||||
"104020": "4.4.2",
|
||||
"104021": "4.4.3 Beta 1",
|
||||
"104022": "4.4.3 Beta 2",
|
||||
"104023": "4.4.3",
|
||||
"104024": "4.4.3",
|
||||
"104025": "4.4.3",
|
||||
"104026": "4.4.4 Beta 1",
|
||||
"104027": "4.4.4",
|
||||
"104028": "4.4.4",
|
||||
"104029": "4.4.4",
|
||||
"104030": "4.4.5 Beta 1",
|
||||
"104031": "4.4.5 Beta 2",
|
||||
"104032": "4.4.5 Beta 2",
|
||||
"104033": "4.4.5",
|
||||
"104034": "4.4.5",
|
||||
"104035": "4.4.5",
|
||||
"104036": "4.4.5",
|
||||
"104037": "4.4.5",
|
||||
"104038": "4.4.6",
|
||||
"104039": "4.4.6",
|
||||
"104040": "4.4.6",
|
||||
"104041": "4.4.7 Beta 1",
|
||||
"104042": "4.4.7 Beta 2",
|
||||
"104043": "4.4.7 Beta 3",
|
||||
"104044": "4.4.7",
|
||||
"104045": "4.4.8 Beta 1",
|
||||
"104046": "4.4.8 Beta 2",
|
||||
"104047": "4.4.8",
|
||||
"104048": "4.4.9 Beta 1",
|
||||
"104049": "4.4.9",
|
||||
"104050": "4.4.9",
|
||||
"104051": "4.4.9",
|
||||
"104052": "4.4.9",
|
||||
"104053": "4.4.9.1",
|
||||
"104054": "4.4.9.1",
|
||||
"104055": "4.4.9.2",
|
||||
"104056": "4.4.9.2",
|
||||
"104057": "4.4.10 Beta 1",
|
||||
"104058": "4.4.10 Beta 2",
|
||||
"104059": "4.4.10 Beta 3",
|
||||
"104060": "4.4.10 Beta 4",
|
||||
"104061": "4.4.10",
|
||||
"104062": "4.4.10",
|
||||
"104063": "4.4.10",
|
||||
"104064": "4.4.10",
|
||||
"104065": "4.4.10",
|
||||
"104066": "4.4.10",
|
||||
"104067": "4.4.10",
|
||||
"104068": "4.4.10",
|
||||
"104069": "4.4.10",
|
||||
"104070": "4.4.11",
|
||||
"105013": "4.5.0 Beta 1",
|
||||
"105014": "4.5.0 Beta 1",
|
||||
"105015": "4.5.0 Beta 2",
|
||||
@@ -634,41 +250,30 @@
|
||||
"107751": "4.7.16",
|
||||
"107760": "4.7.17 Beta 1",
|
||||
"107761": "4.7.17 Beta 2",
|
||||
"107762": "4.7.17 Beta 3",
|
||||
"107763": "4.7.17",
|
||||
"107764": "4.7.17",
|
||||
"107765": "4.7.17",
|
||||
"107770": "4.7.18 Beta 1",
|
||||
"107771": "4.7.18 Beta 2",
|
||||
"107772": "4.7.18 Beta 3",
|
||||
"107773": "4.7.18",
|
||||
"107774": "4.7.18",
|
||||
"107775": "4.7.18",
|
||||
"107780": "4.7.19 Beta 1",
|
||||
"107781": "4.7.19 Beta 2",
|
||||
"107782": "4.7.19 Beta 3",
|
||||
"107783": "4.7.19 Beta 4",
|
||||
"107784": "4.7.19",
|
||||
"107785": "4.7.19",
|
||||
"107786": "4.7.19",
|
||||
"107787": "4.7.19",
|
||||
"107795": "4.7.20 Beta 1",
|
||||
"107796": "4.7.20 Beta 2",
|
||||
"107797": "4.7.20 Beta 3",
|
||||
"107798": "4.7.20 Beta 4",
|
||||
"107799": "4.7.20 Beta 5",
|
||||
"107800": "4.7.20",
|
||||
"107801": "4.7.20",
|
||||
"107802": "4.7.20",
|
||||
"107803": "4.7.20",
|
||||
"107810": "4.7.21 Beta 1",
|
||||
"107811": "4.7.21",
|
||||
"107815": "4.7.22 Beta 1",
|
||||
"107816": "4.7.22 Beta 2",
|
||||
"107817": "4.7.22",
|
||||
"107818": "4.7.22",
|
||||
"107819": "4.7.22",
|
||||
"107820": "4.7.22",
|
||||
"107826": "4.7.23 Beta 1",
|
||||
"107827": "4.7.23"
|
||||
"500001": "5.0.0 Alpha 1",
|
||||
"500002": "5.0.0 Alpha 2",
|
||||
"5000003": "5.0.0 Alpha 3",
|
||||
"5000004": "5.0.0 Alpha 4",
|
||||
"5000005": "5.0.0 Alpha 5",
|
||||
"5000006": "5.0.0 Alpha 5",
|
||||
"5000007": "5.0.0 Alpha 5",
|
||||
"5000008": "5.0.0 Alpha 5",
|
||||
"5000009": "5.0.0 Alpha 6",
|
||||
"5000010": "5.0.0 Alpha 7",
|
||||
"5000011": "5.0.0 Alpha 8",
|
||||
"5000012": "5.0.0 Alpha 9",
|
||||
"5000013": "5.0.0 Alpha 9",
|
||||
"5000014": "5.0.0 Alpha 9",
|
||||
"5000015": "5.0.0 Alpha 10",
|
||||
"5000016": "5.0.0 Alpha 11",
|
||||
"5000017": "5.0.0 Alpha 11",
|
||||
"5000018": "5.0.0 Alpha 12",
|
||||
"5000019": "5.0.0 Alpha 12",
|
||||
"5000020": "5.0.0 Alpha 12",
|
||||
"5000021": "5.0.0 Alpha 13",
|
||||
"5000022": "5.0.0 Alpha 14",
|
||||
"5000023": "5.0.0 Alpha 15",
|
||||
"5000024": "5.0.0 Alpha 16",
|
||||
"5000025": "5.0.0 Alpha 16",
|
||||
"5000026": "5.0.0 Beta 1"
|
||||
}
|
||||
@@ -0,0 +1,301 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Achievement Action Extension
|
||||
* @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/
|
||||
* @subpackage Commerce
|
||||
* @since 16 Mar 2023
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\AchievementAction;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
|
||||
use IPS\core\Achievements\Actions\AchievementActionAbstract;
|
||||
use IPS\core\Achievements\Rule;
|
||||
use IPS\Db;
|
||||
use IPS\Db\Select;
|
||||
use IPS\Helpers\Form\Node;
|
||||
use IPS\Helpers\Form\Number;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\nexus\Donation\Goal;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
use function is_array;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ($_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0') . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Achievement Action Extension
|
||||
*/
|
||||
class Donation extends AchievementActionAbstract // NOTE: Other classes exist to provided bases for common situations, like where node-based filters will be required
|
||||
{
|
||||
/**
|
||||
* Get filter form elements
|
||||
*
|
||||
* @param array|NULL $filters Current filter values (if editing)
|
||||
* @param Url $url The URL the form is being shown on
|
||||
* @return array
|
||||
*/
|
||||
public function filters( ?array $filters, Url $url ): array
|
||||
{
|
||||
$return = array();
|
||||
|
||||
$return['nodes'] = new Node( 'achievement_filter_Donation_nodes', ( $filters and isset( $filters['nodes'] ) and $filters['nodes'] ) ? $filters['nodes'] : 0, FALSE, [
|
||||
'url' => $url,
|
||||
'class' => 'IPS\nexus\Donation\Goal',
|
||||
'showAllNodes' => TRUE,
|
||||
'multiple' => TRUE,
|
||||
], NULL, Member::loggedIn()->language()->addToStack( 'achievement_filter_NewContentItem_node_prefix', FALSE, [ 'sprintf' => [
|
||||
Member::loggedIn()->language()->addToStack( 'donation_lc', FALSE ),
|
||||
Member::loggedIn()->language()->addToStack( 'goals_sg', FALSE, [ 'strtolower' => TRUE ] )
|
||||
] ] ) );
|
||||
$return['nodes']->label = Member::loggedIn()->language()->addToStack( 'achievement_filter_NewContentItem_node', FALSE, [ 'sprintf' => [ Member::loggedIn()->language()->addToStack( 'goals_sg', FALSE, [ 'strtolower' => TRUE ] ) ] ] );
|
||||
|
||||
$return['milestone'] = new Number( 'achievement_filter_Donation_nth', ( $filters and isset( $filters['milestone'] ) and $filters['milestone'] ) ? $filters['milestone'] : 0, FALSE, [], NULL, Member::loggedIn()->language()->addToStack('achievement_filter_nth_their'), Member::loggedIn()->language()->addToStack('achievement_filter_Donation_nth_suffix') );
|
||||
$return['milestone']->label = Member::loggedIn()->language()->addToStack('achievement_filter_NewContentItem_nth');
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format filter form values
|
||||
*
|
||||
* @param array $values The values from the form
|
||||
* @return array
|
||||
*/
|
||||
public function formatFilterValues( array $values ): array
|
||||
{
|
||||
$return = [];
|
||||
if ( isset( $values['achievement_filter_Donation_nodes'] ) )
|
||||
{
|
||||
$return['nodes'] = array_keys( $values['achievement_filter_Donation_nodes'] );
|
||||
}
|
||||
if ( isset( $values['achievement_filter_Donation_nth'] ) )
|
||||
{
|
||||
$return['milestone'] = $values['achievement_filter_Donation_nth'];
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Work out if the filters applies for a given action
|
||||
*
|
||||
* Important note for milestones: consider the context. This method is called by \IPS\Member::achievementAction(). If your code
|
||||
* calls that BEFORE making its change in the database (or there is read/write separation), you will need to add
|
||||
* 1 to the value being considered for milestones
|
||||
*
|
||||
* @param Member $subject The subject member
|
||||
* @param array $filters The value returned by formatFilterValues()
|
||||
* @param mixed $extra Any additional information about what is happening (e.g. if a post is being made: the post object)
|
||||
* @return bool
|
||||
*/
|
||||
public function filtersMatch( Member $subject, array $filters, mixed $extra = NULL ): bool
|
||||
{
|
||||
if ( isset( $filters['nodes'] ) )
|
||||
{
|
||||
if ( !in_array( $extra->_id, $filters['nodes'] ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $filters['milestone'] ) )
|
||||
{
|
||||
$query = $this->getQuery( 'COUNT(*)', [ [ 'dl_member=?', $subject->member_id ] ], NULL, NULL, $filters );
|
||||
|
||||
if ( $query->first() + 1 < $filters['milestone'] )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the labels for the people this action might give awards to
|
||||
*
|
||||
* @param array|NULL $filters Current filter values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function awardOptions( ?array $filters ): array
|
||||
{
|
||||
return [
|
||||
'subject' => 'achievement_filter_Donation_donor',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get identifier to prevent the member being awarded points for the same action twice
|
||||
* Must be unique within within of this domain, must not exceed 32 chars.
|
||||
*
|
||||
* @param Member $subject The subject member
|
||||
* @param mixed $extra Any additional information about what is happening (e.g. if a post is being made: the post object)
|
||||
* @return string
|
||||
*/
|
||||
public function identifier( Member $subject, mixed $extra = NULL ): string
|
||||
{
|
||||
return 'Donation:' . $extra->id . ':' . $subject->member_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a description for this action to show in the log
|
||||
*
|
||||
* @param string $identifier The identifier as returned by identifier()
|
||||
* @param array $actor If the member was the "subject", "other", or both
|
||||
* @return string
|
||||
*/
|
||||
public function logRow( string $identifier, array $actor ): string
|
||||
{
|
||||
$exploded = explode( ':', $identifier );
|
||||
|
||||
try
|
||||
{
|
||||
$goal = Goal::load( $exploded[1] );
|
||||
$sprintf = [ 'htmlsprintf' => [
|
||||
Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $goal->url(), TRUE, '@todo goal title', FALSE )
|
||||
] ];
|
||||
}
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
$sprintf = [ 'sprintf' => [ Member::loggedIn()->language()->addToStack('modcp_deleted') ] ];
|
||||
}
|
||||
|
||||
return Member::loggedIn()->language()->addToStack( 'AchievementAction__Donation_log', FALSE, $sprintf );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get "description" for rule
|
||||
*
|
||||
* @param Rule $rule The rule
|
||||
* @return string|NULL
|
||||
*/
|
||||
public function ruleDescription( Rule $rule ): ?string
|
||||
{
|
||||
$conditions = [];
|
||||
if ( isset( $rule->filters['milestone'] ) )
|
||||
{
|
||||
$conditions[] = Member::loggedIn()->language()->addToStack( 'achievements_title_filter_milestone', FALSE, [
|
||||
'htmlsprintf' => [
|
||||
Theme::i()->getTemplate( 'achievements' )->ruleDescriptionBadge( 'milestone', Member::loggedIn()->language()->addToStack( 'achievements_title_filter_milestone_nth', FALSE, [ 'pluralize' => [ $rule->filters['milestone'] ] ] ) )
|
||||
],
|
||||
'sprintf' => [ Member::loggedIn()->language()->addToStack('donation_lc') ]
|
||||
] );
|
||||
}
|
||||
if ( $nodeCondition = $this->_nodeFilterDescription( $rule ) )
|
||||
{
|
||||
$conditions[] = $nodeCondition;
|
||||
}
|
||||
|
||||
return Theme::i()->getTemplate( 'achievements' )->ruleDescription(
|
||||
Member::loggedIn()->language()->addToStack( 'AchievementAction__Donation_title' ),
|
||||
$conditions
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get "description" for rule (usually a description of the rule's filters)
|
||||
*
|
||||
* @param Rule $rule The rule
|
||||
* @return string|NULL
|
||||
*/
|
||||
protected function _nodeFilterDescription( Rule $rule ): ?string
|
||||
{
|
||||
if ( isset( $rule->filters['nodes'] ) )
|
||||
{
|
||||
$nodeNames = [];
|
||||
foreach ( $rule->filters['nodes'] as $id )
|
||||
{
|
||||
try
|
||||
{
|
||||
$nodeNames[] = Goal::load( $id )->_title; //@todo
|
||||
}
|
||||
catch ( OutOfRangeException ) {}
|
||||
}
|
||||
if ( $nodeNames )
|
||||
{
|
||||
return Member::loggedIn()->language()->addToStack( 'achievements_title_filter_location', FALSE, [
|
||||
'htmlsprintf' => [
|
||||
Theme::i()->getTemplate( 'achievements' )->ruleDescriptionBadge( 'location',
|
||||
count( $nodeNames ) === 1 ? $nodeNames[0] : Member::loggedIn()->language()->addToStack( 'achievements_title_filter_location_val', FALSE, [ 'sprintf' => [
|
||||
count( $nodeNames ),
|
||||
Member::loggedIn()->language()->addToStack( 'goals', FALSE, [ 'strtolower' => TRUE ] ) //@todo
|
||||
] ] ),
|
||||
count( $nodeNames ) === 1 ? NULL : $nodeNames
|
||||
)
|
||||
],
|
||||
] );
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a query to use for multiple methods within this extension
|
||||
* @param string $select Select for the query
|
||||
* @param array|NULL $where Where for the query
|
||||
* @param int|NULL $limit Limit for the query
|
||||
* @param string|NULL $order Order by for the query
|
||||
* @param array $filters Rule filters
|
||||
* @return Select
|
||||
*/
|
||||
public function getQuery( string $select, ?array $where, ?int $limit, ?string $order, array $filters ): Select
|
||||
{
|
||||
$joinContainers = FALSE;
|
||||
$extraJoinCondition = NULL;
|
||||
$where = is_array( $where ) ? $where : array();
|
||||
|
||||
/* Limit by node */
|
||||
if ( isset( $filters['nodes'] ) )
|
||||
{
|
||||
$joinContainers = TRUE;
|
||||
$extraJoinCondition = ' AND ' . Db::i()->in( 'nexus_donate_logs.dl_goal', $filters['nodes'] );
|
||||
}
|
||||
|
||||
$query = Db::i()->select( $select, 'nexus_donate_logs', $where, $order, $limit );
|
||||
|
||||
if ( $joinContainers )
|
||||
{
|
||||
$query->join( 'nexus_donate_goals', 'nexus_donate_logs.dl_goal=nexus_donate_goals.d_id' . $extraJoinCondition, 'INNER' );
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rebuild data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static public function rebuildData(): array
|
||||
{
|
||||
return [ [
|
||||
'table' => 'nexus_donate_logs',
|
||||
'pkey' => 'dl_id'
|
||||
] ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the rebuild row
|
||||
*
|
||||
* @param array $row Row from database
|
||||
* @param array $data Data collected when starting rebuild [table, pkey...]
|
||||
* @return void
|
||||
*/
|
||||
public static function rebuildRow( array $row, array $data ) : void
|
||||
{
|
||||
Member::load( $row['dl_member'] )->achievementAction( 'nexus', 'Donation', [ Goal::load( $row['dl_goal'] ) ] );
|
||||
}
|
||||
}
|
||||
@@ -11,41 +11,58 @@
|
||||
namespace IPS\nexus\extensions\core\AchievementAction;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\core\Achievements\Actions\AchievementActionAbstract;
|
||||
use IPS\core\Achievements\Rule;
|
||||
use IPS\Db;
|
||||
use IPS\Helpers\Form\Node;
|
||||
use IPS\Helpers\Form\Number;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\nexus\Package as NexusPackage;
|
||||
use IPS\nexus\Package\Group;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
use function is_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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Achievement Action Extension
|
||||
*/
|
||||
class _Package extends \IPS\core\Achievements\Actions\AbstractAchievementAction // NOTE: Other classes exist to provided bases for common situations, like where node-based filters will be required
|
||||
class Package extends AchievementActionAbstract // NOTE: Other classes exist to provided bases for common situations, like where node-based filters will be required
|
||||
{
|
||||
/**
|
||||
* Get filter form elements
|
||||
*
|
||||
* @param array|NULL $filters Current filter values (if editing)
|
||||
* @param \IPS\Http\Url $url The URL the form is being shown on
|
||||
* @param Url $url The URL the form is being shown on
|
||||
* @return array
|
||||
*/
|
||||
public function filters( ?array $filters, \IPS\Http\Url $url ): array
|
||||
public function filters( ?array $filters, Url $url ): array
|
||||
{
|
||||
$return = array();
|
||||
|
||||
$return['nodes'] = new \IPS\Helpers\Form\Node( 'achievement_filter_Package', ( $filters and isset( $filters['nodes'] ) and $filters['nodes'] ) ? $filters['nodes'] : 0, FALSE, [
|
||||
$return['nodes'] = new Node( 'achievement_filter_Package', ( $filters and isset( $filters['nodes'] ) and $filters['nodes'] ) ? $filters['nodes'] : 0, FALSE, [
|
||||
'url' => $url,
|
||||
'class' => 'IPS\nexus\Package\Group',
|
||||
'subnodes' => FALSE,
|
||||
'showAllNodes' => TRUE,
|
||||
'multiple' => TRUE
|
||||
], NULL, \IPS\Member::loggedIn()->language()->addToStack( 'achievement_filter_Package_node_prefix', FALSE, [ 'sprintf' => [
|
||||
\IPS\Member::loggedIn()->language()->addToStack( 'nexus_sub_package_id', FALSE ),
|
||||
\IPS\Member::loggedIn()->language()->addToStack( 'purchase_groups_lc', FALSE )
|
||||
], NULL, Member::loggedIn()->language()->addToStack( 'achievement_filter_Package_node_prefix', FALSE, [ 'sprintf' => [
|
||||
Member::loggedIn()->language()->addToStack( 'nexus_sub_package_id', FALSE ),
|
||||
Member::loggedIn()->language()->addToStack( 'purchase_groups_lc', FALSE )
|
||||
] ] ) );
|
||||
|
||||
$return['milestone'] = new \IPS\Helpers\Form\Number( 'achievement_filter_Package_nth', ( $filters and isset( $filters['milestone'] ) and $filters['milestone'] ) ? $filters['milestone'] : 0, FALSE, [], NULL, \IPS\Member::loggedIn()->language()->addToStack('achievement_filter_nth_their'), \IPS\Member::loggedIn()->language()->addToStack('achievement_filter_Package_nth_suffix') );
|
||||
$return['milestone']->label = \IPS\Member::loggedIn()->language()->addToStack('achievement_filter_NewContentItem_nth');
|
||||
$return['milestone'] = new Number( 'achievement_filter_Package_nth', ( $filters and isset( $filters['milestone'] ) and $filters['milestone'] ) ? $filters['milestone'] : 0, FALSE, [], NULL, Member::loggedIn()->language()->addToStack('achievement_filter_nth_their'), Member::loggedIn()->language()->addToStack('achievement_filter_Package_nth_suffix') );
|
||||
$return['milestone']->label = Member::loggedIn()->language()->addToStack('achievement_filter_NewContentItem_nth');
|
||||
|
||||
return $return;
|
||||
}
|
||||
@@ -63,7 +80,7 @@ class _Package extends \IPS\core\Achievements\Actions\AbstractAchievementAction
|
||||
{
|
||||
$return['nodes'] = [];
|
||||
|
||||
if ( \is_array( $values['achievement_filter_Package'] ) )
|
||||
if ( is_array( $values['achievement_filter_Package'] ) )
|
||||
{
|
||||
foreach ( $values['achievement_filter_Package'] as $node )
|
||||
{
|
||||
@@ -85,16 +102,16 @@ class _Package extends \IPS\core\Achievements\Actions\AbstractAchievementAction
|
||||
* calls that BEFORE making its change in the database (or there is read/write separation), you will need to add
|
||||
* 1 to the value being considered for milestones
|
||||
*
|
||||
* @param \IPS\Member $subject The subject member
|
||||
* @param Member $subject The subject member
|
||||
* @param array $filters The value returned by formatFilterValues()
|
||||
* @param mixed $extra Any additional information about what is happening (e.g. if a post is being made: the post object)
|
||||
* @return bool
|
||||
*/
|
||||
public function filtersMatch( \IPS\Member $subject, array $filters, $extra = NULL ): bool
|
||||
public function filtersMatch( Member $subject, array $filters, mixed $extra = NULL ): bool
|
||||
{
|
||||
if ( isset( $filters['nodes'] ) and \is_array( $filters['nodes'] ) and \count( $filters['nodes'] ) )
|
||||
if ( isset( $filters['nodes'] ) and is_array( $filters['nodes'] ) and count( $filters['nodes'] ) )
|
||||
{
|
||||
if ( !\in_array( $extra->item()->container()->_id, $filters['nodes'] ) )
|
||||
if ( !in_array( $extra->item()->container()->_id, $filters['nodes'] ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -102,7 +119,7 @@ class _Package extends \IPS\core\Achievements\Actions\AbstractAchievementAction
|
||||
|
||||
if ( isset( $filters['milestone'] ) )
|
||||
{
|
||||
if ( \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', [ 'ps_cancelled !=1 AND ps_member=?', $subject->member_id ] )->first() < $filters['milestone'] )
|
||||
if ( Db::i()->select( 'COUNT(*)', 'nexus_purchases', [ 'ps_cancelled !=1 AND ps_member=?', $subject->member_id ] )->first() < $filters['milestone'] )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -115,11 +132,11 @@ class _Package extends \IPS\core\Achievements\Actions\AbstractAchievementAction
|
||||
* Get identifier to prevent the member being awarded points for the same action twice
|
||||
* Must be unique within within of this domain, must not exceed 32 chars.
|
||||
*
|
||||
* @param \IPS\Member $subject The subject member
|
||||
* @param Member $subject The subject member
|
||||
* @param mixed $extra Any additional information about what is happening (e.g. if a post is being made: the post object)
|
||||
* @return string
|
||||
*/
|
||||
public function identifier( \IPS\Member $subject, $extra = NULL ): string
|
||||
public function identifier( Member $subject, mixed $extra = NULL ): string
|
||||
{
|
||||
return $extra->id . '.' . $subject->member_id;
|
||||
}
|
||||
@@ -136,35 +153,35 @@ class _Package extends \IPS\core\Achievements\Actions\AbstractAchievementAction
|
||||
try
|
||||
{
|
||||
list( $identifier, $memberId ) = explode( '.', $identifier );
|
||||
$package = \IPS\nexus\Package::load( $identifier );
|
||||
$package = NexusPackage::load( $identifier );
|
||||
$sprintf = [ 'htmlsprintf' => [
|
||||
\IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $package->url(), TRUE, $package->_title, FALSE )
|
||||
Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $package->url(), TRUE, $package->_title, FALSE )
|
||||
] ];
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
$sprintf = [ 'sprintf' => [ \IPS\Member::loggedIn()->language()->addToStack('modcp_deleted') ] ];
|
||||
$sprintf = [ 'sprintf' => [ Member::loggedIn()->language()->addToStack('modcp_deleted') ] ];
|
||||
}
|
||||
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'AchievementAction__Package_log', FALSE, $sprintf );
|
||||
return Member::loggedIn()->language()->addToStack( 'AchievementAction__Package_log', FALSE, $sprintf );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get "description" for rule
|
||||
*
|
||||
* @param \IPS\core\Achievements\Rule $rule The rule
|
||||
* @param Rule $rule The rule
|
||||
* @return string|NULL
|
||||
*/
|
||||
public function ruleDescription( \IPS\core\Achievements\Rule $rule ): ?string
|
||||
public function ruleDescription( Rule $rule ): ?string
|
||||
{
|
||||
$conditions = [];
|
||||
if ( isset( $rule->filters['milestone'] ) )
|
||||
{
|
||||
$conditions[] = \IPS\Member::loggedIn()->language()->addToStack( 'achievements_title_filter_milestone', FALSE, [
|
||||
$conditions[] = Member::loggedIn()->language()->addToStack( 'achievements_title_filter_milestone', FALSE, [
|
||||
'htmlsprintf' => [
|
||||
\IPS\Theme::i()->getTemplate( 'achievements' )->ruleDescriptionBadge( 'milestone', \IPS\Member::loggedIn()->language()->addToStack( 'achievements_title_filter_milestone_nth', FALSE, [ 'pluralize' => [ $rule->filters['milestone'] ] ] ) )
|
||||
Theme::i()->getTemplate( 'achievements' )->ruleDescriptionBadge( 'milestone', Member::loggedIn()->language()->addToStack( 'achievements_title_filter_milestone_nth', FALSE, [ 'pluralize' => [ $rule->filters['milestone'] ] ] ) )
|
||||
],
|
||||
'sprintf' => [ \IPS\Member::loggedIn()->language()->addToStack('AchievementAction__Package_title_generic') ]
|
||||
'sprintf' => [ Member::loggedIn()->language()->addToStack('AchievementAction__Package_title_generic') ]
|
||||
] );
|
||||
}
|
||||
|
||||
@@ -173,8 +190,8 @@ class _Package extends \IPS\core\Achievements\Actions\AbstractAchievementAction
|
||||
$conditions[] = $nodeCondition;
|
||||
}
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'achievements' )->ruleDescription(
|
||||
\IPS\Member::loggedIn()->language()->addToStack( 'AchievementAction__Package_title' ),
|
||||
return Theme::i()->getTemplate( 'achievements' )->ruleDescription(
|
||||
Member::loggedIn()->language()->addToStack( 'AchievementAction__Package_title' ),
|
||||
$conditions
|
||||
);
|
||||
}
|
||||
@@ -182,10 +199,10 @@ class _Package extends \IPS\core\Achievements\Actions\AbstractAchievementAction
|
||||
/**
|
||||
* Get "description" for rule (usually a description of the rule's filters)
|
||||
*
|
||||
* @param \IPS\core\Achievements\Rule $rule The rule
|
||||
* @param Rule $rule The rule
|
||||
* @return string|NULL
|
||||
*/
|
||||
protected function _nodeFilterDescription( \IPS\core\Achievements\Rule $rule ): ?string
|
||||
protected function _nodeFilterDescription( Rule $rule ): ?string
|
||||
{
|
||||
if ( isset( $rule->filters['nodes'] ) )
|
||||
{
|
||||
@@ -194,20 +211,20 @@ class _Package extends \IPS\core\Achievements\Actions\AbstractAchievementAction
|
||||
{
|
||||
try
|
||||
{
|
||||
$nodeNames[] = \IPS\nexus\Package\Group::load( $id )->_title;
|
||||
$nodeNames[] = Group::load( $id )->_title;
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) {}
|
||||
catch ( OutOfRangeException ) {}
|
||||
}
|
||||
if ( $nodeNames )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'achievements_title_filter_location', FALSE, [
|
||||
return Member::loggedIn()->language()->addToStack( 'achievements_title_filter_location', FALSE, [
|
||||
'htmlsprintf' => [
|
||||
\IPS\Theme::i()->getTemplate( 'achievements' )->ruleDescriptionBadge( 'location',
|
||||
\count( $nodeNames ) === 1 ? $nodeNames[0] : \IPS\Member::loggedIn()->language()->addToStack( 'achievements_title_filter_location_val', FALSE, [ 'sprintf' => [
|
||||
\count( $nodeNames ),
|
||||
\IPS\Member::loggedIn()->language()->addToStack( 'purchase_groups_lc', FALSE )
|
||||
Theme::i()->getTemplate( 'achievements' )->ruleDescriptionBadge( 'location',
|
||||
count( $nodeNames ) === 1 ? $nodeNames[0] : Member::loggedIn()->language()->addToStack( 'achievements_title_filter_location_val', FALSE, [ 'sprintf' => [
|
||||
count( $nodeNames ),
|
||||
Member::loggedIn()->language()->addToStack( 'purchase_groups_lc', FALSE )
|
||||
] ] ),
|
||||
\count( $nodeNames ) === 1 ? NULL : $nodeNames
|
||||
count( $nodeNames ) === 1 ? NULL : $nodeNames
|
||||
)
|
||||
],
|
||||
] );
|
||||
@@ -222,7 +239,7 @@ class _Package extends \IPS\core\Achievements\Actions\AbstractAchievementAction
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static public function rebuildData()
|
||||
static public function rebuildData(): array
|
||||
{
|
||||
return [ [
|
||||
'table' => 'nexus_purchases',
|
||||
@@ -239,9 +256,9 @@ class _Package extends \IPS\core\Achievements\Actions\AbstractAchievementAction
|
||||
* @param array $data Data collected when starting rebuild [table, pkey...]
|
||||
* @return void
|
||||
*/
|
||||
public static function rebuildRow( $row, $data )
|
||||
public static function rebuildRow( array $row, array $data ) : void
|
||||
{
|
||||
\IPS\Member::load( $row['ps_member'] )->achievementAction( 'nexus', 'Package', \IPS\nexus\Package::load( $row['ps_item_id'] ) );
|
||||
Member::load( $row['ps_member'] )->achievementAction( 'nexus', 'Package', NexusPackage::load( $row['ps_item_id'] ) );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,16 +11,32 @@
|
||||
namespace IPS\nexus\extensions\core\AchievementAction;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\core\Achievements\Actions\AchievementActionAbstract;
|
||||
use IPS\core\Achievements\Rule;
|
||||
use IPS\Helpers\Form\Node;
|
||||
use IPS\Helpers\Form\YesNo;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\nexus\Subscription as NexusSubscription;
|
||||
use IPS\nexus\Subscription\Package;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use function count;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Achievement Action Extension
|
||||
*/
|
||||
class _Subscription extends \IPS\core\Achievements\Actions\AbstractAchievementAction // NOTE: Other classes exist to provided bases for common situations, like where node-based filters will be required
|
||||
class Subscription extends AchievementActionAbstract // NOTE: Other classes exist to provided bases for common situations, like where node-based filters will be required
|
||||
{
|
||||
/**
|
||||
* Can use this rule?
|
||||
@@ -29,32 +45,32 @@ class _Subscription extends \IPS\core\Achievements\Actions\AbstractAchievementAc
|
||||
*/
|
||||
public function canUse(): bool
|
||||
{
|
||||
return (bool) parent::canUse() and \IPS\Settings::i()->nexus_subs_enabled;
|
||||
return parent::canUse() and Settings::i()->nexus_subs_enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get filter form elements
|
||||
*
|
||||
* @param array|NULL $filters Current filter values (if editing)
|
||||
* @param \IPS\Http\Url $url The URL the form is being shown on
|
||||
* @param Url $url The URL the form is being shown on
|
||||
* @return array
|
||||
*/
|
||||
public function filters( ?array $filters, \IPS\Http\Url $url ): array
|
||||
public function filters( ?array $filters, Url $url ): array
|
||||
{
|
||||
$return = array();
|
||||
|
||||
$return['subscriptions'] = new \IPS\Helpers\Form\Node( 'achievement_filter_Subscriptions', ( $filters and isset( $filters['subscriptions'] ) and $filters['subscriptions'] ) ? $filters['subscriptions'] : 0, FALSE, [
|
||||
$return['subscriptions'] = new Node( 'achievement_filter_Subscriptions', ( $filters and isset( $filters['subscriptions'] ) and $filters['subscriptions'] ) ? $filters['subscriptions'] : 0, FALSE, [
|
||||
'url' => $url,
|
||||
'class' => 'IPS\nexus\Subscription\Package',
|
||||
'showAllNodes' => TRUE,
|
||||
'multiple' => TRUE,
|
||||
], NULL, \IPS\Member::loggedIn()->language()->addToStack( 'achievement_filter_Subscriptions_node_prefix', FALSE, [ 'sprintf' => [
|
||||
\IPS\Member::loggedIn()->language()->addToStack( 'nexus_sub_package_id', FALSE ),
|
||||
\IPS\Member::loggedIn()->language()->addToStack( 'calendars_sg', FALSE, [ 'strtolower' => TRUE ] )
|
||||
], NULL, Member::loggedIn()->language()->addToStack( 'achievement_filter_Subscriptions_node_prefix', FALSE, [ 'sprintf' => [
|
||||
Member::loggedIn()->language()->addToStack( 'nexus_sub_package_id', FALSE ),
|
||||
Member::loggedIn()->language()->addToStack( 'calendars_sg', FALSE, [ 'strtolower' => TRUE ] )
|
||||
] ] ) );
|
||||
|
||||
$return['subscriptions_active'] = new \IPS\Helpers\Form\YesNo( 'achievement_filter_Subscriptions_active', $filters and isset( $filters['subscriptions_active'] ) and $filters['subscriptions_active'], FALSE, [],NULL,
|
||||
\IPS\Member::loggedIn()->language()->addToStack( 'nexus_sub_active', FALSE )
|
||||
$return['subscriptions_active'] = new YesNo( 'achievement_filter_Subscriptions_active', $filters and isset( $filters['subscriptions_active'] ) and $filters['subscriptions_active'], FALSE, [],NULL,
|
||||
Member::loggedIn()->language()->addToStack( 'nexus_sub_active', FALSE )
|
||||
);
|
||||
|
||||
return $return;
|
||||
@@ -87,16 +103,16 @@ class _Subscription extends \IPS\core\Achievements\Actions\AbstractAchievementAc
|
||||
* calls that BEFORE making its change in the database (or there is read/write separation), you will need to add
|
||||
* 1 to the value being considered for milestones
|
||||
*
|
||||
* @param \IPS\Member $subject The subject member
|
||||
* @param Member $subject The subject member
|
||||
* @param array $filters The value returned by formatFilterValues()
|
||||
* @param mixed $extra Any additional information about what is happening (e.g. if a post is being made: the post object)
|
||||
* @return bool
|
||||
*/
|
||||
public function filtersMatch( \IPS\Member $subject, array $filters, $extra = NULL ): bool
|
||||
public function filtersMatch( Member $subject, array $filters, mixed $extra = NULL ): bool
|
||||
{
|
||||
if ( isset( $filters['subscriptions'] ) )
|
||||
{
|
||||
if ( !\in_array( $extra->package_id, $filters['subscriptions'] ) )
|
||||
if ( !in_array( $extra->package_id, $filters['subscriptions'] ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -108,12 +124,12 @@ class _Subscription extends \IPS\core\Achievements\Actions\AbstractAchievementAc
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\nexus\Subscription::loadByMemberAndPackage( $subject, \IPS\nexus\Subscription\Package::load( $id ), TRUE );
|
||||
NexusSubscription::loadByMemberAndPackage( $subject, Package::load( $id ), TRUE );
|
||||
|
||||
/* Still here? */
|
||||
return TRUE;
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
catch ( OutOfRangeException ) { }
|
||||
}
|
||||
|
||||
/* No active matches */
|
||||
@@ -127,11 +143,11 @@ class _Subscription extends \IPS\core\Achievements\Actions\AbstractAchievementAc
|
||||
* Get identifier to prevent the member being awarded points for the same action twice
|
||||
* Must be unique within within of this domain, must not exceed 32 chars.
|
||||
*
|
||||
* @param \IPS\Member $subject The subject member
|
||||
* @param Member $subject The subject member
|
||||
* @param mixed $extra Any additional information about what is happening (e.g. if a post is being made: the post object)
|
||||
* @return string
|
||||
*/
|
||||
public function identifier( \IPS\Member $subject, $extra = NULL ): string
|
||||
public function identifier( Member $subject, mixed $extra = NULL ): string
|
||||
{
|
||||
return (string) $extra->id;
|
||||
}
|
||||
@@ -151,20 +167,20 @@ class _Subscription extends \IPS\core\Achievements\Actions\AbstractAchievementAc
|
||||
/**
|
||||
* Get "description" for rule
|
||||
*
|
||||
* @param \IPS\core\Achievements\Rule $rule The rule
|
||||
* @param Rule $rule The rule
|
||||
* @return string|NULL
|
||||
*/
|
||||
public function ruleDescription( \IPS\core\Achievements\Rule $rule ): ?string
|
||||
public function ruleDescription( Rule $rule ): ?string
|
||||
{
|
||||
$conditions = [];
|
||||
|
||||
if ( isset( $rule->filters['subscriptions_active'] ) AND $rule->filters['subscriptions_active'] )
|
||||
{
|
||||
$conditions[] = \IPS\Member::loggedIn()->language()->addToStack( 'achievement_filter_Subscriptions_active');
|
||||
$conditions[] = Member::loggedIn()->language()->addToStack( 'achievement_filter_Subscriptions_active');
|
||||
}
|
||||
else
|
||||
{
|
||||
$conditions[] = \IPS\Member::loggedIn()->language()->addToStack( 'achievement_filter_Subscriptions_node_prefix');
|
||||
$conditions[] = Member::loggedIn()->language()->addToStack( 'achievement_filter_Subscriptions_node_prefix');
|
||||
}
|
||||
|
||||
if ( $nodeCondition = $this->_nodeFilterDescription( $rule ) )
|
||||
@@ -172,8 +188,8 @@ class _Subscription extends \IPS\core\Achievements\Actions\AbstractAchievementAc
|
||||
$conditions[] = $nodeCondition;
|
||||
}
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'achievements' )->ruleDescription(
|
||||
\IPS\Member::loggedIn()->language()->addToStack( 'AchievementAction__Subscription_title' ),
|
||||
return Theme::i()->getTemplate( 'achievements' )->ruleDescription(
|
||||
Member::loggedIn()->language()->addToStack( 'AchievementAction__Subscription_title' ),
|
||||
$conditions
|
||||
);
|
||||
}
|
||||
@@ -181,10 +197,10 @@ class _Subscription extends \IPS\core\Achievements\Actions\AbstractAchievementAc
|
||||
/**
|
||||
* Get "description" for rule (usually a description of the rule's filters)
|
||||
*
|
||||
* @param \IPS\core\Achievements\Rule $rule The rule
|
||||
* @param Rule $rule The rule
|
||||
* @return string|NULL
|
||||
*/
|
||||
protected function _nodeFilterDescription( \IPS\core\Achievements\Rule $rule ): ?string
|
||||
protected function _nodeFilterDescription( Rule $rule ): ?string
|
||||
{
|
||||
if ( isset( $rule->filters['subscriptions'] ) )
|
||||
{
|
||||
@@ -193,21 +209,21 @@ class _Subscription extends \IPS\core\Achievements\Actions\AbstractAchievementAc
|
||||
{
|
||||
try
|
||||
{
|
||||
$nodeNames[] = \IPS\nexus\Subscription\Package::load( $id )->_title;
|
||||
$nodeNames[] = Package::load( $id )->_title;
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) {}
|
||||
catch ( OutOfRangeException ) {}
|
||||
}
|
||||
|
||||
if ( $nodeNames )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'achievements_filter_Subscription_type', FALSE, [
|
||||
return Member::loggedIn()->language()->addToStack( 'achievements_filter_Subscription_type', FALSE, [
|
||||
'htmlsprintf' => [
|
||||
\IPS\Theme::i()->getTemplate( 'achievements' )->ruleDescriptionBadge( 'achievements_filter_Subscription_type',
|
||||
\count( $nodeNames ) === 1 ? $nodeNames[0] : \IPS\Member::loggedIn()->language()->addToStack( 'achievements_filter_Subscription_pl', FALSE, [ 'sprintf' => [
|
||||
\count( $nodeNames ),
|
||||
\IPS\Member::loggedIn()->language()->addToStack( 'nexus_sub_package_id', FALSE, [ 'strtolower' => TRUE ] )
|
||||
Theme::i()->getTemplate( 'achievements' )->ruleDescriptionBadge( 'achievements_filter_Subscription_type',
|
||||
count( $nodeNames ) === 1 ? $nodeNames[0] : Member::loggedIn()->language()->addToStack( 'achievements_filter_Subscription_pl', FALSE, [ 'sprintf' => [
|
||||
count( $nodeNames ),
|
||||
Member::loggedIn()->language()->addToStack( 'nexus_sub_package_id', FALSE, [ 'strtolower' => TRUE ] )
|
||||
] ] ),
|
||||
\count( $nodeNames ) === 1 ? NULL : $nodeNames
|
||||
count( $nodeNames ) === 1 ? NULL : $nodeNames
|
||||
)
|
||||
],
|
||||
] );
|
||||
@@ -222,7 +238,7 @@ class _Subscription extends \IPS\core\Achievements\Actions\AbstractAchievementAc
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static public function rebuildData()
|
||||
static public function rebuildData(): array
|
||||
{
|
||||
return [ [
|
||||
'table' => 'nexus_member_subscriptions',
|
||||
@@ -239,9 +255,9 @@ class _Subscription extends \IPS\core\Achievements\Actions\AbstractAchievementAc
|
||||
* @param array $data Data collected when starting rebuild [table, pkey...]
|
||||
* @return void
|
||||
*/
|
||||
public static function rebuildRow( $row, $data )
|
||||
public static function rebuildRow( array $row, array $data ) : void
|
||||
{
|
||||
\IPS\Member::load( $row['sub_member_id'] )->achievementAction( 'nexus', 'Subscription', \IPS\nexus\Subscription::load( $row['sub_id'] ) );
|
||||
Member::load( $row['sub_member_id'] )->achievementAction( 'nexus', 'Subscription', NexusSubscription::load( $row['sub_id'] ) );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,38 +11,48 @@
|
||||
namespace IPS\nexus\extensions\core\AdminNotifications;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\core\AdminNotification;
|
||||
use IPS\core\modules\admin\promotion\advertisements;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use UnderflowException;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* ACP Notification: Advertisements Requiring Approval
|
||||
*/
|
||||
class _Advertisement extends \IPS\core\AdminNotification
|
||||
class Advertisement extends AdminNotification
|
||||
{
|
||||
/**
|
||||
* @brief Identifier for what to group this notification type with on the settings form
|
||||
*/
|
||||
public static $group = 'commerce';
|
||||
public static string $group = 'commerce';
|
||||
|
||||
/**
|
||||
* @brief Priority 1-5 (1 being highest) for this group compared to others
|
||||
*/
|
||||
public static $groupPriority = 4;
|
||||
public static int $groupPriority = 4;
|
||||
|
||||
/**
|
||||
* @brief Priority 1-5 (1 being highest) for this notification type compared to others in the same group
|
||||
*/
|
||||
public static $itemPriority = 4;
|
||||
public static int $itemPriority = 4;
|
||||
|
||||
/**
|
||||
* Title for settings
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function settingsTitle()
|
||||
public static function settingsTitle(): string
|
||||
{
|
||||
return 'acp_notification_Advertisement';
|
||||
}
|
||||
@@ -50,9 +60,9 @@ class _Advertisement extends \IPS\core\AdminNotification
|
||||
/**
|
||||
* Is this type of notification ever optional (controls if it will be selectable as "viewable" in settings)
|
||||
*
|
||||
* @return string
|
||||
* @return bool
|
||||
*/
|
||||
public static function mayBeOptional()
|
||||
public static function mayBeOptional(): bool
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -62,7 +72,7 @@ class _Advertisement extends \IPS\core\AdminNotification
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function mayRecur()
|
||||
public static function mayRecur(): bool
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -70,18 +80,18 @@ class _Advertisement extends \IPS\core\AdminNotification
|
||||
/**
|
||||
* @brief Current count
|
||||
*/
|
||||
protected $count = NULL;
|
||||
protected ?int $count = NULL;
|
||||
|
||||
/**
|
||||
* Get count
|
||||
*
|
||||
* @return bool
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
public function count(): int
|
||||
{
|
||||
if ( $this->count === NULL )
|
||||
{
|
||||
$this->count = \IPS\Db::i()->select( 'COUNT(*)', 'core_advertisements', array( 'ad_active=-1' ) )->first();
|
||||
$this->count = Db::i()->select( 'COUNT(*)', 'core_advertisements', array( 'ad_active=-1' ) )->first();
|
||||
}
|
||||
return $this->count;
|
||||
}
|
||||
@@ -89,12 +99,12 @@ class _Advertisement extends \IPS\core\AdminNotification
|
||||
/**
|
||||
* Can a member access this type of notification?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param Member $member The member
|
||||
* @return bool
|
||||
*/
|
||||
public static function permissionCheck( \IPS\Member $member )
|
||||
public static function permissionCheck( Member $member ): bool
|
||||
{
|
||||
return $member->hasAcpRestriction( 'core', 'promotion', 'advertisements_manage' ) and \IPS\Db::i()->select( 'COUNT(*)', 'nexus_packages_ads' )->first();
|
||||
return $member->hasAcpRestriction( 'core', 'promotion', 'advertisements_manage' ) and Db::i()->select( 'COUNT(*)', 'nexus_packages_ads' )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,23 +112,23 @@ class _Advertisement extends \IPS\core\AdminNotification
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
public function title(): string
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'acpNotification_nexusAdvertisements', FALSE, array( 'pluralize' => array( $this->count() ) ) );
|
||||
return Member::loggedIn()->language()->addToStack( 'acpNotification_nexusAdvertisements', FALSE, array( 'pluralize' => array( $this->count() ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Subtitle (no HTML)
|
||||
*
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function subtitle()
|
||||
public function subtitle(): ?string
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\DateTime::ts( \IPS\Db::i()->select( 'ad_start', 'core_advertisements', array( 'ad_active=-1' ), 'ad_start asc', 1 )->first() )->relative();
|
||||
return DateTime::ts( Db::i()->select( 'ad_start', 'core_advertisements', array( 'ad_active=-1' ), 'ad_start asc', 1 )->first() )->relative();
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
catch ( UnderflowException )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -127,15 +137,15 @@ class _Advertisement extends \IPS\core\AdminNotification
|
||||
/**
|
||||
* Notification Body (full HTML, must be escaped where necessary)
|
||||
*
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function body()
|
||||
public function body(): ?string
|
||||
{
|
||||
$table = \IPS\core\modules\admin\promotion\advertisements::table( \IPS\Http\Url::internal('app=core&module=overview&controller=notifications&_table=nexus_Advertisement') );
|
||||
$table = advertisements::table( Url::internal('app=core&module=overview&controller=notifications&_table=nexus_Advertisement') );
|
||||
$table->limit = 10;
|
||||
$table->filters = array();
|
||||
$table->quickSearch = NULL;
|
||||
$table->advancedSearch = NULL;
|
||||
$table->advancedSearch = [];
|
||||
$table->where[] = array( 'ad_active=-1' );
|
||||
|
||||
return (string) $table;
|
||||
@@ -146,7 +156,7 @@ class _Advertisement extends \IPS\core\AdminNotification
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function severity()
|
||||
public function severity(): string
|
||||
{
|
||||
return static::SEVERITY_OPTIONAL;
|
||||
}
|
||||
@@ -156,7 +166,7 @@ class _Advertisement extends \IPS\core\AdminNotification
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function dismissible()
|
||||
public function dismissible(): string
|
||||
{
|
||||
return static::DISMISSIBLE_NO;
|
||||
}
|
||||
@@ -164,9 +174,9 @@ class _Advertisement extends \IPS\core\AdminNotification
|
||||
/**
|
||||
* Style
|
||||
*
|
||||
* @return bool
|
||||
* @return string
|
||||
*/
|
||||
public function style()
|
||||
public function style(): string
|
||||
{
|
||||
return static::STYLE_INFORMATION;
|
||||
}
|
||||
@@ -174,11 +184,11 @@ class _Advertisement extends \IPS\core\AdminNotification
|
||||
/**
|
||||
* Quick link from popup menu
|
||||
*
|
||||
* @return bool
|
||||
* @return Url
|
||||
*/
|
||||
public function link()
|
||||
public function link(): Url
|
||||
{
|
||||
return \IPS\Http\Url::internal('app=core&module=promotion&controller=advertisements&filter=ad_filters_pending');
|
||||
return Url::internal('app=core&module=promotion&controller=advertisements&filter=ad_filters_pending');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,7 +197,7 @@ class _Advertisement extends \IPS\core\AdminNotification
|
||||
* @note This is checked every time the notification shows. Should be lightweight.
|
||||
* @return bool
|
||||
*/
|
||||
public function selfDismiss()
|
||||
public function selfDismiss(): bool
|
||||
{
|
||||
return !$this->count();
|
||||
}
|
||||
|
||||
@@ -11,38 +11,49 @@
|
||||
namespace IPS\nexus\extensions\core\AdminNotifications;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\core\AdminNotification;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\nexus\Gateway;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function substr;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* ACP Notification Extension
|
||||
*/
|
||||
class _ConfigurationError extends \IPS\core\AdminNotification
|
||||
class ConfigurationError extends AdminNotification
|
||||
{
|
||||
/**
|
||||
* @brief Identifier for what to group this notification type with on the settings form
|
||||
*/
|
||||
public static $group = 'commerce';
|
||||
public static string $group = 'commerce';
|
||||
|
||||
/**
|
||||
* @brief Priority 1-5 (1 being highest) for this group compared to others
|
||||
*/
|
||||
public static $groupPriority = 4;
|
||||
public static int $groupPriority = 4;
|
||||
|
||||
/**
|
||||
* @brief Priority 1-5 (1 being highest) for this notification type compared to others in the same group
|
||||
*/
|
||||
public static $itemPriority = 5;
|
||||
public static int $itemPriority = 5;
|
||||
|
||||
/**
|
||||
* Title for settings
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function settingsTitle()
|
||||
public static function settingsTitle(): string
|
||||
{
|
||||
return 'acp_notification_ConfigurationError';
|
||||
}
|
||||
@@ -50,10 +61,10 @@ class _ConfigurationError extends \IPS\core\AdminNotification
|
||||
/**
|
||||
* Can a member access this type of notification?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param Member $member The member
|
||||
* @return bool
|
||||
*/
|
||||
public static function permissionCheck( \IPS\Member $member )
|
||||
public static function permissionCheck( Member $member ): bool
|
||||
{
|
||||
return $member->hasAcpRestriction( 'nexus', 'payments', 'gateways_manage' );
|
||||
}
|
||||
@@ -61,9 +72,9 @@ class _ConfigurationError extends \IPS\core\AdminNotification
|
||||
/**
|
||||
* Is this type of notification ever optional (controls if it will be selectable as "viewable" in settings)
|
||||
*
|
||||
* @return string
|
||||
* @return bool
|
||||
*/
|
||||
public static function mayBeOptional()
|
||||
public static function mayBeOptional(): bool
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -73,7 +84,7 @@ class _ConfigurationError extends \IPS\core\AdminNotification
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function mayRecur()
|
||||
public static function mayRecur(): bool
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -83,64 +94,62 @@ class _ConfigurationError extends \IPS\core\AdminNotification
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
public function title(): string
|
||||
{
|
||||
if( mb_substr( $this->extra, 0, 2 ) === 'pm' )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('acp_notification_nexus_config_error_paymethod');
|
||||
return Member::loggedIn()->language()->addToStack('acp_notification_nexus_config_error_paymethod');
|
||||
}
|
||||
elseif( mb_substr( $this->extra, 0, 2 ) === 'po' )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'acp_notification_nexus_config_error_payoutmethod' );
|
||||
return Member::loggedIn()->language()->addToStack( 'acp_notification_nexus_config_error_payoutmethod' );
|
||||
}
|
||||
else
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'acpNotification_nexusBACancelErrors', FALSE, array( 'pluralize' => array( \count( json_decode( $this->extra, TRUE ) ) ) ) );
|
||||
return Member::loggedIn()->language()->addToStack( 'acpNotification_nexusBACancelErrors', FALSE, array( 'pluralize' => array( count( json_decode( $this->extra, TRUE ) ) ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Subtitle (no HTML)
|
||||
*
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function subtitle()
|
||||
public function subtitle(): ?string
|
||||
{
|
||||
if( mb_substr( $this->extra, 0, 2 ) === 'pm' )
|
||||
{
|
||||
try
|
||||
{
|
||||
$method = \IPS\nexus\Gateway::load( \substr( $this->extra, 2 ) );
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'acp_notification_nexus_config_error_paymethod_desc', FALSE, array( 'sprintf' => array( $method->_title ) ) );
|
||||
$method = Gateway::load( substr( $this->extra, 2 ) );
|
||||
return Member::loggedIn()->language()->addToStack( 'acp_notification_nexus_config_error_paymethod_desc', FALSE, array( 'sprintf' => array( $method->_title ) ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
catch ( OutOfRangeException ) { }
|
||||
}
|
||||
elseif( mb_substr( $this->extra, 0, 2 ) === 'po' )
|
||||
{
|
||||
$gateway = mb_substr( $this->extra, 2 );
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'acp_notification_nexus_config_error_payoutmethod_desc', FALSE, array( 'sprintf' => array( $gateway ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return '';
|
||||
return Member::loggedIn()->language()->addToStack( 'acp_notification_nexus_config_error_payoutmethod_desc', FALSE, array( 'sprintf' => array( $gateway ) ) );
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Body (full HTML, must be escaped where necessary)
|
||||
*
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function body()
|
||||
public function body(): ?string
|
||||
{
|
||||
if( mb_substr( $this->extra, 0, 2 ) === 'pm' )
|
||||
{
|
||||
try
|
||||
{
|
||||
$method = \IPS\nexus\Gateway::load( \substr( $this->extra, 2 ) );
|
||||
return \IPS\Theme::i()->getTemplate( 'notifications', 'nexus', 'admin' )->paymentMethodError( $method );
|
||||
$method = Gateway::load( substr( $this->extra, 2 ) );
|
||||
return Theme::i()->getTemplate( 'notifications', 'nexus', 'admin' )->paymentMethodError( $method );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
@@ -148,11 +157,11 @@ class _ConfigurationError extends \IPS\core\AdminNotification
|
||||
elseif( mb_substr( $this->extra, 0, 2 ) === 'po' )
|
||||
{
|
||||
$gateway = mb_substr( $this->extra, 2 );
|
||||
return \IPS\Theme::i()->getTemplate( 'notifications', 'nexus', 'admin' )->payoutSettingsError( $gateway );
|
||||
return Theme::i()->getTemplate( 'notifications', 'nexus', 'admin' )->payoutSettingsError( $gateway );
|
||||
}
|
||||
else
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'notifications', 'nexus', 'admin' )->baCancellationError( json_decode( $this->extra, TRUE ) );
|
||||
return Theme::i()->getTemplate( 'notifications', 'nexus', 'admin' )->baCancellationError( json_decode( $this->extra, TRUE ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +170,7 @@ class _ConfigurationError extends \IPS\core\AdminNotification
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function severity()
|
||||
public function severity(): string
|
||||
{
|
||||
return ( mb_substr( $this->extra, 0, 2 ) === 'pm' OR mb_substr( $this->extra, 0, 2 ) === 'po' ) ? static::SEVERITY_CRITICAL : static::SEVERITY_OPTIONAL;
|
||||
}
|
||||
@@ -171,7 +180,7 @@ class _ConfigurationError extends \IPS\core\AdminNotification
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function dismissible()
|
||||
public function dismissible(): string
|
||||
{
|
||||
return ( mb_substr( $this->extra, 0, 2 ) === 'pm' OR mb_substr( $this->extra, 0, 2 ) === 'po' ) ? static::DISMISSIBLE_NO : static::DISMISSIBLE_PERMANENT;
|
||||
}
|
||||
@@ -182,16 +191,16 @@ class _ConfigurationError extends \IPS\core\AdminNotification
|
||||
* @note This is checked every time the notification shows. Should be lightweight.
|
||||
* @return bool
|
||||
*/
|
||||
public function selfDismiss()
|
||||
public function selfDismiss(): bool
|
||||
{
|
||||
if( mb_substr( $this->extra, 0, 2 ) === 'pm' )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\nexus\Gateway::load( \substr( $this->extra, 2 ) );
|
||||
Gateway::load( substr( $this->extra, 2 ) );
|
||||
return FALSE;
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -205,9 +214,9 @@ class _ConfigurationError extends \IPS\core\AdminNotification
|
||||
/**
|
||||
* Style
|
||||
*
|
||||
* @return bool
|
||||
* @return string
|
||||
*/
|
||||
public function style()
|
||||
public function style(): string
|
||||
{
|
||||
return ( mb_substr( $this->extra, 0, 2 ) === 'pm' OR mb_substr( $this->extra, 0, 2 ) === 'po' ) ? static::STYLE_ERROR : static::STYLE_WARNING;
|
||||
}
|
||||
@@ -215,19 +224,19 @@ class _ConfigurationError extends \IPS\core\AdminNotification
|
||||
/**
|
||||
* Quick link from popup menu
|
||||
*
|
||||
* @return \IPS\Http\Url
|
||||
* @return Url|null
|
||||
*/
|
||||
public function link()
|
||||
public function link(): Url|null
|
||||
{
|
||||
if( mb_substr( $this->extra, 0, 2 ) === 'pm' )
|
||||
{
|
||||
return \IPS\Http\Url::internal( 'app=nexus&module=payments&controller=paymentsettings&tab=gateways&do=form&id=' . \substr( $this->extra, 2 ) );
|
||||
return Url::internal( 'app=nexus&module=payments&controller=paymentsettings&tab=gateways&do=form&id=' . substr( $this->extra, 2 ) );
|
||||
}
|
||||
elseif( mb_substr( $this->extra, 0, 2 ) === 'po' )
|
||||
{
|
||||
return \IPS\Http\Url::internal( 'app=nexus&module=payments&controller=payouts&do=settings' );
|
||||
return Url::internal( 'app=nexus&module=payments&controller=payouts&do=settings' );
|
||||
}
|
||||
|
||||
parent::link();
|
||||
return parent::link();
|
||||
}
|
||||
}
|
||||
@@ -11,38 +11,45 @@
|
||||
namespace IPS\nexus\extensions\core\AdminNotifications;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\core\AdminNotification;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Theme;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* ACP Notification Extension
|
||||
*/
|
||||
class _Maxmind extends \IPS\core\AdminNotification
|
||||
class Maxmind extends AdminNotification
|
||||
{
|
||||
/**
|
||||
* @brief Identifier for what to group this notification type with on the settings form
|
||||
*/
|
||||
public static $group = 'commerce';
|
||||
public static string $group = 'commerce';
|
||||
|
||||
/**
|
||||
* @brief Priority 1-5 (1 being highest) for this group compared to others
|
||||
*/
|
||||
public static $groupPriority = 3;
|
||||
public static int $groupPriority = 3;
|
||||
|
||||
/**
|
||||
* @brief Priority 1-5 (1 being highest) for this notification type compared to others in the same group
|
||||
*/
|
||||
public static $itemPriority = 1;
|
||||
public static int $itemPriority = 1;
|
||||
|
||||
/**
|
||||
* Title for settings
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function settingsTitle()
|
||||
public static function settingsTitle(): string
|
||||
{
|
||||
return 'acp_notification_Maxmind';
|
||||
}
|
||||
@@ -50,10 +57,10 @@ class _Maxmind extends \IPS\core\AdminNotification
|
||||
/**
|
||||
* Can a member access this type of notification?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param Member $member The member
|
||||
* @return bool
|
||||
*/
|
||||
public static function permissionCheck( \IPS\Member $member )
|
||||
public static function permissionCheck( Member $member ): bool
|
||||
{
|
||||
return true;// $member->hasAcpRestriction( ... );
|
||||
}
|
||||
@@ -61,9 +68,9 @@ class _Maxmind extends \IPS\core\AdminNotification
|
||||
/**
|
||||
* Is this type of notification ever optional (controls if it will be selectable as "viewable" in settings)
|
||||
*
|
||||
* @return string
|
||||
* @return bool
|
||||
*/
|
||||
public static function mayBeOptional()
|
||||
public static function mayBeOptional(): bool
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -73,7 +80,7 @@ class _Maxmind extends \IPS\core\AdminNotification
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function mayRecur()
|
||||
public static function mayRecur(): bool
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -83,29 +90,29 @@ class _Maxmind extends \IPS\core\AdminNotification
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
public function title(): string
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('acp_notification_nexus_maxmind');
|
||||
return Member::loggedIn()->language()->addToStack('acp_notification_nexus_maxmind');
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Subtitle (no HTML)
|
||||
*
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function subtitle()
|
||||
public function subtitle(): ?string
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'acp_notification_nexus_maxmind_sub', FALSE );
|
||||
return Member::loggedIn()->language()->addToStack( 'acp_notification_nexus_maxmind_sub', FALSE );
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Body (full HTML, must be escaped where necessary)
|
||||
*
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function body()
|
||||
public function body(): ?string
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'notifications', 'nexus', 'admin' )->maxmind();
|
||||
return Theme::i()->getTemplate( 'notifications', 'nexus', 'admin' )->maxmind();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,7 +120,7 @@ class _Maxmind extends \IPS\core\AdminNotification
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function severity()
|
||||
public function severity(): string
|
||||
{
|
||||
return static::SEVERITY_HIGH;
|
||||
}
|
||||
@@ -123,7 +130,7 @@ class _Maxmind extends \IPS\core\AdminNotification
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function dismissible()
|
||||
public function dismissible(): string
|
||||
{
|
||||
return static::DISMISSIBLE_TEMPORARY;
|
||||
}
|
||||
@@ -131,9 +138,9 @@ class _Maxmind extends \IPS\core\AdminNotification
|
||||
/**
|
||||
* Style
|
||||
*
|
||||
* @return bool
|
||||
* @return string
|
||||
*/
|
||||
public function style()
|
||||
public function style(): string
|
||||
{
|
||||
return static::STYLE_ERROR;
|
||||
}
|
||||
@@ -141,9 +148,9 @@ class _Maxmind extends \IPS\core\AdminNotification
|
||||
/**
|
||||
* Quick link from popup menu
|
||||
*
|
||||
* @return \IPS\Http\Url
|
||||
* @return Url|null
|
||||
*/
|
||||
public function link()
|
||||
public function link(): Url|null
|
||||
{
|
||||
return parent::link(); // \IPS\Http\Url::internal( '...' );
|
||||
}
|
||||
|
||||
@@ -1,194 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief ACP Notification: Pending Shipping Orders
|
||||
* @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
|
||||
* @since 26 Jul 2018
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\AdminNotifications;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* ACP Notification: Pending Shipping Orders
|
||||
*/
|
||||
class _Shipment extends \IPS\core\AdminNotification
|
||||
{
|
||||
/**
|
||||
* @brief Identifier for what to group this notification type with on the settings form
|
||||
*/
|
||||
public static $group = 'commerce';
|
||||
|
||||
/**
|
||||
* @brief Priority 1-5 (1 being highest) for this group compared to others
|
||||
*/
|
||||
public static $groupPriority = 4;
|
||||
|
||||
/**
|
||||
* @brief Priority 1-5 (1 being highest) for this notification type compared to others in the same group
|
||||
*/
|
||||
public static $itemPriority = 3;
|
||||
|
||||
/**
|
||||
* Title for settings
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function settingsTitle()
|
||||
{
|
||||
return 'acp_notification_Shipments';
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this type of notification ever optional (controls if it will be selectable as "viewable" in settings)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function mayBeOptional()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this type of notification might recur (controls what options will be available for the email setting)
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function mayRecur()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Current count
|
||||
*/
|
||||
protected $count = NULL;
|
||||
|
||||
/**
|
||||
* Get count
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
if ( $this->count === NULL )
|
||||
{
|
||||
$this->count = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_ship_orders', array( 'o_status=?', 'pend' ) )->first();
|
||||
}
|
||||
return $this->count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can a member access this type of notification?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @return bool
|
||||
*/
|
||||
public static function permissionCheck( \IPS\Member $member )
|
||||
{
|
||||
return $member->hasAcpRestriction( 'nexus', 'payments', 'shiporders_manage' ) and \IPS\Db::i()->select( 'COUNT(*)', 'nexus_shipping' )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Title (full HTML, must be escaped where necessary)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'acpNotification_nexusShipments', FALSE, array( 'pluralize' => array( $this->count() ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Subtitle (no HTML)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function subtitle()
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\DateTime::ts( \IPS\Db::i()->select( 'o_date', 'nexus_ship_orders', array( 'o_status=?', 'pend' ), 'o_date asc', 1 )->first() )->relative();
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Body (full HTML, must be escaped where necessary)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function body()
|
||||
{
|
||||
$table = \IPS\nexus\Shipping\Order::table( \IPS\Http\Url::internal('app=core&module=overview&controller=notifications&_table=nexus_Shipment') );
|
||||
$table->limit = 10;
|
||||
$table->filters = array();
|
||||
$table->quickSearch = NULL;
|
||||
$table->advancedSearch = NULL;
|
||||
$table->where[] = array( 'o_status=?', 'pend' );
|
||||
|
||||
return $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Severity
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function severity()
|
||||
{
|
||||
return static::SEVERITY_OPTIONAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dismissible?
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function dismissible()
|
||||
{
|
||||
return static::DISMISSIBLE_NO;
|
||||
}
|
||||
|
||||
/**
|
||||
* Style
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function style()
|
||||
{
|
||||
return static::STYLE_INFORMATION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick link from popup menu
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function link()
|
||||
{
|
||||
return \IPS\Http\Url::internal('app=nexus&module=payments&controller=shipping');
|
||||
}
|
||||
|
||||
/**
|
||||
* Should this notification dismiss itself?
|
||||
*
|
||||
* @note This is checked every time the notification shows. Should be lightweight.
|
||||
* @return bool
|
||||
*/
|
||||
public function selfDismiss()
|
||||
{
|
||||
return !$this->count();
|
||||
}
|
||||
}
|
||||
@@ -1,268 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief ACP Notification: Open Support Requests
|
||||
* @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
|
||||
* @since 26 Jul 2018
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\AdminNotifications;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* ACP Notification: Open Support Requests
|
||||
*/
|
||||
class _Support extends \IPS\core\AdminNotification
|
||||
{
|
||||
/**
|
||||
* @brief Identifier for what to group this notification type with on the settings form
|
||||
*/
|
||||
public static $group = 'commerce';
|
||||
|
||||
/**
|
||||
* @brief Priority 1-5 (1 being highest) for this group compared to others
|
||||
*/
|
||||
public static $groupPriority = 4;
|
||||
|
||||
/**
|
||||
* @brief Priority 1-5 (1 being highest) for this notification type compared to others in the same group
|
||||
*/
|
||||
public static $itemPriority = 1;
|
||||
|
||||
/**
|
||||
* Title for settings
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function settingsTitle()
|
||||
{
|
||||
return 'acp_notification_Support';
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this type of notification ever optional (controls if it will be selectable as "viewable" in settings)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function mayBeOptional()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this type of notification might recur (controls what options will be available for the email setting)
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function mayRecur()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Current count (that this admin can see)
|
||||
*/
|
||||
protected $count = NULL;
|
||||
|
||||
/**
|
||||
* Get count
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @return bool
|
||||
*/
|
||||
public function count( \IPS\Member $member = NULL )
|
||||
{
|
||||
if ( $this->count === NULL )
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
$where = array();
|
||||
|
||||
$openStatuses = array();
|
||||
foreach ( \IPS\nexus\Support\Status::roots() as $status )
|
||||
{
|
||||
if ( $status->open )
|
||||
{
|
||||
$openStatuses[] = $status->_id;
|
||||
}
|
||||
}
|
||||
$where[] = array( \IPS\Db::i()->in( 'r_status', $openStatuses ) );
|
||||
|
||||
$departments = array_keys( iterator_to_array( \IPS\nexus\Support\Department::departmentsWithPermission( $member ) ) );
|
||||
if ( $departments )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 'r_department', $departments ) );
|
||||
}
|
||||
|
||||
$this->count = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_support_requests', $where )->first();
|
||||
}
|
||||
return $this->count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can a member access this type of notification?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @return bool
|
||||
*/
|
||||
public static function permissionCheck( \IPS\Member $member )
|
||||
{
|
||||
return $member->hasAcpRestriction( 'nexus', 'support', 'requests_manage' ) and \count( \IPS\nexus\Support\Department::departmentsWithPermission( $member ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Title (full HTML, must be escaped where necessary)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'acpNotification_nexusSupport', FALSE, array( 'pluralize' => array( $this->count() ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Subtitle (no HTML)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function subtitle()
|
||||
{
|
||||
try
|
||||
{
|
||||
$where = array();
|
||||
|
||||
$openStatuses = array();
|
||||
foreach ( \IPS\nexus\Support\Status::roots() as $status )
|
||||
{
|
||||
if ( $status->open )
|
||||
{
|
||||
$openStatuses[] = $status->_id;
|
||||
}
|
||||
}
|
||||
$where[] = array( \IPS\Db::i()->in( 'r_status', $openStatuses ) );
|
||||
|
||||
$departments = array_keys( iterator_to_array( \IPS\nexus\Support\Department::departmentsWithPermission( \IPS\Member::loggedIn() ) ) );
|
||||
if ( $departments )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 'r_department', $departments ) );
|
||||
}
|
||||
|
||||
return \IPS\DateTime::ts( \IPS\Db::i()->select( 'r_started', 'nexus_support_requests', $where, 'r_started asc', 1 )->first() )->relative();
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Body (full HTML, must be escaped where necessary)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function body()
|
||||
{
|
||||
$sortBy = ( isset( \IPS\Request::i()->cookie['support_sort'] ) and \in_array( \IPS\Request::i()->cookie['support_sort'], array( 'r_started', 'r_last_new_reply', 'r_last_reply', 'r_last_staff_reply' ) ) ) ? \IPS\Request::i()->cookie['support_sort'] : 'r_last_new_reply';
|
||||
$sortDir = ( isset( \IPS\Request::i()->cookie['support_order'] ) and \in_array( \IPS\Request::i()->cookie['support_order'], array( 'ASC', 'DESC' ) ) ) ? \IPS\Request::i()->cookie['support_order'] : 'ASC';
|
||||
|
||||
$i = 0;
|
||||
$results = array();
|
||||
$allIds = array();
|
||||
foreach ( \IPS\nexus\Support\Stream::myStreams( \IPS\Member::loggedIn() ) as $stream )
|
||||
{
|
||||
$results[ $stream->id ] = $stream->results( \IPS\Member::loggedIn(), "{$sortBy} {$sortDir}", 1, 3 );
|
||||
$allIds += array_keys( iterator_to_array( $results[ $stream->id ] ) );
|
||||
|
||||
$i++;
|
||||
if ( $i >= 3 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$tracked = iterator_to_array( \IPS\Db::i()->select( array( 'request_id', 'notify' ), 'nexus_support_tracker', array( array( 'member_id=?', \IPS\Member::loggedIn()->member_id ), array( \IPS\Db::i()->in( 'request_id', $allIds ) ) ) )->setKeyField( 'request_id' )->setValueField( 'notify' ) );
|
||||
$participatedIn = iterator_to_array( \IPS\Db::i()->select( 'DISTINCT reply_request', 'nexus_support_replies', array( array( 'reply_member=?', \IPS\Member::loggedIn()->member_id ), array( \IPS\Db::i()->in( 'reply_request', $allIds ) ) ) ) );
|
||||
|
||||
$resultsHtml = array();
|
||||
foreach ( $results as $streamId => $resultSet )
|
||||
{
|
||||
$resultsHtml[ $streamId ] = \IPS\Theme::i()->getTemplate( 'support', 'nexus' )->requestsTableResults( $resultSet, NULL, FALSE, $tracked, $participatedIn, FALSE );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'support.css', 'nexus', 'admin' ) );
|
||||
return \IPS\Theme::i()->getTemplate( 'notifications', 'nexus' )->support( $resultsHtml );
|
||||
}
|
||||
|
||||
/**
|
||||
* Severity
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function severity()
|
||||
{
|
||||
return static::SEVERITY_DYNAMIC;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dismissible?
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function dismissible()
|
||||
{
|
||||
return static::DISMISSIBLE_NO;
|
||||
}
|
||||
|
||||
/**
|
||||
* Style
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function style()
|
||||
{
|
||||
return static::STYLE_INFORMATION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick link from popup menu
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function link()
|
||||
{
|
||||
return \IPS\Http\Url::internal('app=nexus&module=support&controller=requests');
|
||||
}
|
||||
|
||||
/**
|
||||
* For dynamic notifications: should this show for this member?
|
||||
*
|
||||
* @note This is checked every time the notification shows. Should be lightweight.
|
||||
* @param \IPS\Member $member The member
|
||||
* @return bool
|
||||
*/
|
||||
public function dynamicShow( \IPS\Member $member )
|
||||
{
|
||||
return (bool) $this->count( $member );
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom per-admin setting for if email shoild be sent for this notification
|
||||
*
|
||||
* @param string $key Setting field key
|
||||
* @param mixed $value Current value
|
||||
* @return \IPS\Helpers\Form\FormAbstract|NULL
|
||||
*/
|
||||
public static function customEmailConfigurationSetting( $key, $value )
|
||||
{
|
||||
return new \IPS\Helpers\Form\Custom( $key, NULL, FALSE, array( 'getHtml' => function() {
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( \IPS\Http\Url::internal('app=nexus&module=support&controller=requests&do=preferences'), TRUE, \IPS\Member::loggedIn()->language()->addToStack('acp_notifications_email_configure') );
|
||||
} ) );
|
||||
}
|
||||
}
|
||||
@@ -11,31 +11,45 @@
|
||||
namespace IPS\nexus\extensions\core\AdminNotifications;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\core\AdminNotification;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\nexus\Transaction as NexusTransaction;
|
||||
use IPS\Output;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
use IPS\Theme;
|
||||
use UnderflowException;
|
||||
use function count;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* ACP Notification: Transactions Requiring Attention
|
||||
*/
|
||||
class _Transaction extends \IPS\core\AdminNotification
|
||||
class Transaction extends AdminNotification
|
||||
{
|
||||
/**
|
||||
* @brief Identifier for what to group this notification type with on the settings form
|
||||
*/
|
||||
public static $group = 'commerce';
|
||||
public static string $group = 'commerce';
|
||||
|
||||
/**
|
||||
* @brief Priority 1-5 (1 being highest) for this group compared to others
|
||||
*/
|
||||
public static $groupPriority = 4;
|
||||
public static int $groupPriority = 4;
|
||||
|
||||
/**
|
||||
* @brief Priority 1-5 (1 being highest) for this notification type compared to others in the same group
|
||||
*/
|
||||
public static $itemPriority = 2;
|
||||
public static int $itemPriority = 2;
|
||||
|
||||
/**
|
||||
* Get queue HTML
|
||||
@@ -43,13 +57,13 @@ class _Transaction extends \IPS\core\AdminNotification
|
||||
* @param string $status Status to show
|
||||
* @return string
|
||||
*/
|
||||
public static function queueHtml( $status )
|
||||
public static function queueHtml( string $status ) : string
|
||||
{
|
||||
$select = \IPS\Db::i()->select( '*', 'nexus_transactions', array( 't_status=?', $status ), 't_date ASC', array( 0, 12 ) );
|
||||
$select = Db::i()->select( '*', 'nexus_transactions', array( 't_status=?', $status ), 't_date ASC', array( 0, 12 ) );
|
||||
|
||||
if ( \count( $select ) )
|
||||
if ( count( $select ) )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'notifications', 'nexus' )->transactions( new \IPS\Patterns\ActiveRecordIterator( $select, 'IPS\nexus\Transaction' ) );
|
||||
return Theme::i()->getTemplate( 'notifications', 'nexus' )->transactions( new ActiveRecordIterator( $select, 'IPS\nexus\Transaction' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -62,7 +76,7 @@ class _Transaction extends \IPS\core\AdminNotification
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function settingsTitle()
|
||||
public static function settingsTitle(): string
|
||||
{
|
||||
return 'acp_notification_Transaction';
|
||||
}
|
||||
@@ -70,9 +84,9 @@ class _Transaction extends \IPS\core\AdminNotification
|
||||
/**
|
||||
* Is this type of notification ever optional (controls if it will be selectable as "viewable" in settings)
|
||||
*
|
||||
* @return string
|
||||
* @return bool
|
||||
*/
|
||||
public static function mayBeOptional()
|
||||
public static function mayBeOptional(): bool
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -82,7 +96,7 @@ class _Transaction extends \IPS\core\AdminNotification
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function mayRecur()
|
||||
public static function mayRecur(): bool
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -90,18 +104,18 @@ class _Transaction extends \IPS\core\AdminNotification
|
||||
/**
|
||||
* @brief Current count
|
||||
*/
|
||||
protected $count = NULL;
|
||||
protected ?int $count = NULL;
|
||||
|
||||
/**
|
||||
* Get count
|
||||
*
|
||||
* @return bool
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
public function count(): int
|
||||
{
|
||||
if ( $this->count === NULL )
|
||||
{
|
||||
$this->count = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_transactions', array( 't_status=?', $this->extra ) )->first();
|
||||
$this->count = Db::i()->select( 'COUNT(*)', 'nexus_transactions', array( 't_status=?', $this->extra ) )->first();
|
||||
}
|
||||
return $this->count;
|
||||
}
|
||||
@@ -109,10 +123,10 @@ class _Transaction extends \IPS\core\AdminNotification
|
||||
/**
|
||||
* Can a member access this type of notification?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param Member $member The member
|
||||
* @return bool
|
||||
*/
|
||||
public static function permissionCheck( \IPS\Member $member )
|
||||
public static function permissionCheck( Member $member ): bool
|
||||
{
|
||||
return $member->hasAcpRestriction( 'nexus', 'payments', 'transactions_manage' );
|
||||
}
|
||||
@@ -122,23 +136,23 @@ class _Transaction extends \IPS\core\AdminNotification
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
public function title(): string
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'acpNotification_nexusTransaction_' . $this->extra, FALSE, array( 'pluralize' => array( $this->count() ) ) );
|
||||
return Member::loggedIn()->language()->addToStack( 'acpNotification_nexusTransaction_' . $this->extra, FALSE, array( 'pluralize' => array( $this->count() ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Subtitle (no HTML)
|
||||
*
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function subtitle()
|
||||
public function subtitle(): ?string
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\DateTime::ts( \IPS\Db::i()->select( 't_date', 'nexus_transactions', array( 't_status=?', $this->extra ), 't_date asc', 1 )->first() )->relative();
|
||||
return DateTime::ts( Db::i()->select( 't_date', 'nexus_transactions', array( 't_status=?', $this->extra ), 't_date asc', 1 )->first() )->relative();
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
catch ( UnderflowException )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -147,11 +161,11 @@ class _Transaction extends \IPS\core\AdminNotification
|
||||
/**
|
||||
* Notification Body (full HTML, must be escaped where necessary)
|
||||
*
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function body()
|
||||
public function body(): ?string
|
||||
{
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js('admin_notifications.js', 'nexus') );
|
||||
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js('admin_notifications.js', 'nexus') );
|
||||
|
||||
return static::queueHtml( $this->extra );
|
||||
}
|
||||
@@ -161,7 +175,7 @@ class _Transaction extends \IPS\core\AdminNotification
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function severity()
|
||||
public function severity(): string
|
||||
{
|
||||
return static::SEVERITY_OPTIONAL;
|
||||
}
|
||||
@@ -171,7 +185,7 @@ class _Transaction extends \IPS\core\AdminNotification
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function dismissible()
|
||||
public function dismissible(): string
|
||||
{
|
||||
return static::DISMISSIBLE_NO;
|
||||
}
|
||||
@@ -179,11 +193,11 @@ class _Transaction extends \IPS\core\AdminNotification
|
||||
/**
|
||||
* Style
|
||||
*
|
||||
* @return bool
|
||||
* @return string
|
||||
*/
|
||||
public function style()
|
||||
public function style(): string
|
||||
{
|
||||
if ( $this->extra === \IPS\nexus\Transaction::STATUS_DISPUTED )
|
||||
if ( $this->extra === NexusTransaction::STATUS_DISPUTED )
|
||||
{
|
||||
return static::STYLE_WARNING;
|
||||
}
|
||||
@@ -196,11 +210,11 @@ class _Transaction extends \IPS\core\AdminNotification
|
||||
/**
|
||||
* Quick link from popup menu
|
||||
*
|
||||
* @return bool
|
||||
* @return Url
|
||||
*/
|
||||
public function link()
|
||||
public function link(): Url
|
||||
{
|
||||
return \IPS\Http\Url::internal('app=nexus&module=payments&controller=transactions&attn=1');
|
||||
return Url::internal('app=nexus&module=payments&controller=transactions&attn=1');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -209,7 +223,7 @@ class _Transaction extends \IPS\core\AdminNotification
|
||||
* @note This is checked every time the notification shows. Should be lightweight.
|
||||
* @return bool
|
||||
*/
|
||||
public function selfDismiss()
|
||||
public function selfDismiss(): bool
|
||||
{
|
||||
return !$this->count();
|
||||
}
|
||||
|
||||
@@ -11,38 +11,49 @@
|
||||
namespace IPS\nexus\extensions\core\AdminNotifications;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\core\AdminNotification;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\nexus\Payout;
|
||||
use IPS\Settings;
|
||||
use UnderflowException;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* ACP Notification: Pending Credit Withdrawals
|
||||
*/
|
||||
class _Withdrawal extends \IPS\core\AdminNotification
|
||||
class Withdrawal extends AdminNotification
|
||||
{
|
||||
/**
|
||||
* @brief Identifier for what to group this notification type with on the settings form
|
||||
*/
|
||||
public static $group = 'commerce';
|
||||
public static string $group = 'commerce';
|
||||
|
||||
/**
|
||||
* @brief Priority 1-5 (1 being highest) for this group compared to others
|
||||
*/
|
||||
public static $groupPriority = 4;
|
||||
public static int $groupPriority = 4;
|
||||
|
||||
/**
|
||||
* @brief Priority 1-5 (1 being highest) for this notification type compared to others in the same group
|
||||
*/
|
||||
public static $itemPriority = 4;
|
||||
public static int $itemPriority = 4;
|
||||
|
||||
/**
|
||||
* Title for settings
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function settingsTitle()
|
||||
public static function settingsTitle(): string
|
||||
{
|
||||
return 'acp_notification_Withdrawals';
|
||||
}
|
||||
@@ -50,9 +61,9 @@ class _Withdrawal extends \IPS\core\AdminNotification
|
||||
/**
|
||||
* Is this type of notification ever optional (controls if it will be selectable as "viewable" in settings)
|
||||
*
|
||||
* @return string
|
||||
* @return bool
|
||||
*/
|
||||
public static function mayBeOptional()
|
||||
public static function mayBeOptional(): bool
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -62,7 +73,7 @@ class _Withdrawal extends \IPS\core\AdminNotification
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function mayRecur()
|
||||
public static function mayRecur(): bool
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -70,18 +81,18 @@ class _Withdrawal extends \IPS\core\AdminNotification
|
||||
/**
|
||||
* @brief Current count
|
||||
*/
|
||||
protected $count = NULL;
|
||||
protected ?int $count = NULL;
|
||||
|
||||
/**
|
||||
* Get count
|
||||
*
|
||||
* @return bool
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
public function count(): int
|
||||
{
|
||||
if ( $this->count === NULL )
|
||||
{
|
||||
$this->count = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_payouts', array( 'po_status=?', \IPS\nexus\Payout::STATUS_PENDING ) )->first();
|
||||
$this->count = Db::i()->select( 'COUNT(*)', 'nexus_payouts', array( 'po_status=?', Payout::STATUS_PENDING ) )->first();
|
||||
}
|
||||
return $this->count;
|
||||
}
|
||||
@@ -89,12 +100,12 @@ class _Withdrawal extends \IPS\core\AdminNotification
|
||||
/**
|
||||
* Can a member access this type of notification?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param Member $member The member
|
||||
* @return bool
|
||||
*/
|
||||
public static function permissionCheck( \IPS\Member $member )
|
||||
public static function permissionCheck( Member $member ): bool
|
||||
{
|
||||
return \IPS\Settings::i()->nexus_payout and $member->hasAcpRestriction( 'nexus', 'payments', 'payouts_manage' );
|
||||
return Settings::i()->nexus_payout and $member->hasAcpRestriction( 'nexus', 'payments', 'payouts_manage' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,23 +113,23 @@ class _Withdrawal extends \IPS\core\AdminNotification
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
public function title(): string
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'acpNotification_nexusWithdrawals', FALSE, array( 'pluralize' => array( $this->count() ) ) );
|
||||
return Member::loggedIn()->language()->addToStack( 'acpNotification_nexusWithdrawals', FALSE, array( 'pluralize' => array( $this->count() ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Subtitle (no HTML)
|
||||
*
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function subtitle()
|
||||
public function subtitle(): ?string
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\DateTime::ts( \IPS\Db::i()->select( 'po_date', 'nexus_payouts', array( 'po_status=?', \IPS\nexus\Payout::STATUS_PENDING ), 'po_date asc', 1 )->first() )->relative();
|
||||
return DateTime::ts( Db::i()->select( 'po_date', 'nexus_payouts', array( 'po_status=?', Payout::STATUS_PENDING ), 'po_date asc', 1 )->first() )->relative();
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
catch ( UnderflowException )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -127,15 +138,15 @@ class _Withdrawal extends \IPS\core\AdminNotification
|
||||
/**
|
||||
* Notification Body (full HTML, must be escaped where necessary)
|
||||
*
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function body()
|
||||
public function body(): ?string
|
||||
{
|
||||
$table = \IPS\nexus\Payout::table( array( 'po_status=?', 'pend' ), \IPS\Http\Url::internal('app=nexus&module=payments&controller=payouts&filter=postatus_pend') );
|
||||
$table = Payout::table( array( 'po_status=?', 'pend' ), Url::internal('app=nexus&module=payments&controller=payouts&filter=postatus_pend') );
|
||||
$table->limit = 10;
|
||||
$table->filters = array();
|
||||
$table->quickSearch = NULL;
|
||||
$table->advancedSearch = NULL;
|
||||
$table->advancedSearch = [];
|
||||
|
||||
return $table;
|
||||
}
|
||||
@@ -145,7 +156,7 @@ class _Withdrawal extends \IPS\core\AdminNotification
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function severity()
|
||||
public function severity(): string
|
||||
{
|
||||
return static::SEVERITY_OPTIONAL;
|
||||
}
|
||||
@@ -155,7 +166,7 @@ class _Withdrawal extends \IPS\core\AdminNotification
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function dismissible()
|
||||
public function dismissible(): string
|
||||
{
|
||||
return static::DISMISSIBLE_NO;
|
||||
}
|
||||
@@ -163,9 +174,9 @@ class _Withdrawal extends \IPS\core\AdminNotification
|
||||
/**
|
||||
* Style
|
||||
*
|
||||
* @return bool
|
||||
* @return string
|
||||
*/
|
||||
public function style()
|
||||
public function style(): string
|
||||
{
|
||||
return static::STYLE_INFORMATION;
|
||||
}
|
||||
@@ -173,11 +184,11 @@ class _Withdrawal extends \IPS\core\AdminNotification
|
||||
/**
|
||||
* Quick link from popup menu
|
||||
*
|
||||
* @return bool
|
||||
* @return Url
|
||||
*/
|
||||
public function link()
|
||||
public function link(): Url
|
||||
{
|
||||
return \IPS\Http\Url::internal('app=nexus&module=payments&controller=payouts&filter=postatus_pend');
|
||||
return Url::internal('app=nexus&module=payments&controller=payouts&filter=postatus_pend');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,7 +197,7 @@ class _Withdrawal extends \IPS\core\AdminNotification
|
||||
* @note This is checked every time the notification shows. Should be lightweight.
|
||||
* @return bool
|
||||
*/
|
||||
public function selfDismiss()
|
||||
public function selfDismiss(): bool
|
||||
{
|
||||
return !$this->count();
|
||||
}
|
||||
|
||||
@@ -1,297 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Community Enhancements: EasyPost
|
||||
* @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 18 Jun 2014
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\CommunityEnhancements;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Community Enhancement: EasyPost
|
||||
*/
|
||||
class _EasyPost
|
||||
{
|
||||
/**
|
||||
* @brief Enhancement is enabled?
|
||||
*/
|
||||
public $enabled = FALSE;
|
||||
|
||||
/**
|
||||
* @brief IPS-provided enhancement?
|
||||
*/
|
||||
public $ips = FALSE;
|
||||
|
||||
/**
|
||||
* @brief Enhancement has configuration options?
|
||||
*/
|
||||
public $hasOptions = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Icon data
|
||||
*/
|
||||
public $icon = "easypost.png";
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->enabled = (bool) \IPS\Settings::i()->easypost_api_key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->test ) )
|
||||
{
|
||||
return $this->_test();
|
||||
}
|
||||
|
||||
$haveSiteAddress = ( \IPS\Settings::i()->site_address and \IPS\Settings::i()->site_address != 'null' );
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'easypost_enable', (bool) \IPS\Settings::i()->easypost_api_key, FALSE, array( 'togglesOn' => array( 'easypost_api_key', ( $haveSiteAddress ? 'easypost_address_select' : 'easypost_address_custom' ), 'easypost_phone', 'easypost_show_rates' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'easypost_api_key', \IPS\Settings::i()->easypost_api_key, FALSE, array(), NULL, NULL, NULL, 'easypost_api_key' ) );
|
||||
if ( $haveSiteAddress )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'easypost_address_select', \IPS\Settings::i()->easypost_address ? 1 : 0, FALSE, array( 'options' => array( 0 => 'easypost_address_default', 1 => 'easypost_address_choose' ), 'toggles' => array( 1 => array( 'easypost_address_custom' ) ) ), NULL, NULL, NULL, 'easypost_address_select' ) );
|
||||
\IPS\Member::loggedIn()->language()->words['easypost_address_default'] = sprintf( \IPS\Member::loggedIn()->language()->get( 'easypost_address_default' ), \IPS\GeoLocation::buildFromJson( \IPS\Settings::i()->site_address ) );
|
||||
}
|
||||
$form->add( new \IPS\Helpers\Form\Address( 'easypost_address_custom', \IPS\Settings::i()->easypost_address ? \IPS\GeoLocation::buildFromJson( \IPS\Settings::i()->easypost_address ) : NULL, FALSE, array(), NULL, NULL, NULL, 'easypost_address_custom' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Tel( 'easypost_phone', \IPS\Settings::i()->easypost_phone, FALSE, array(), NULL, NULL, NULL, 'easypost_phone' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'easypost_show_rates', \IPS\Settings::i()->easypost_show_rates, FALSE, array(
|
||||
'options' => array( 1 => 'easypost_show_rates_1', 0 => 'easypost_show_rates_0' ),
|
||||
'toggles' => array( 1 => array( 'easypost_tax', 'easypost_price_adjustment', 'easypost_delivery_adjustment' ) )
|
||||
), NULL, NULL, NULL, 'easypost_show_rates' ) );
|
||||
|
||||
$taxClass = NULL;
|
||||
|
||||
if( \IPS\Settings::i()->easypost_tax )
|
||||
{
|
||||
try
|
||||
{
|
||||
$taxClass = \IPS\nexus\Tax::load( \IPS\Settings::i()->easypost_tax );
|
||||
}
|
||||
catch( \OutOfRangeException $e ){}
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'easypost_tax', $taxClass, FALSE, array( 'class' => '\IPS\nexus\Tax', 'zeroVal' => 'do_not_tax' ), NULL, NULL, NULL, 'easypost_tax' ) );
|
||||
$form->add( new \IPS\nexus\Form\Money( 'easypost_price_adjustment', \IPS\Settings::i()->easypost_price_adjustment, FALSE, array(), NULL, NULL, NULL, 'easypost_price_adjustment' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Interval( 'easypost_delivery_adjustment', \IPS\Settings::i()->easypost_delivery_adjustment, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::DAYS, 'min' => NULL ), NULL, NULL, NULL, 'easypost_delivery_adjustment' ) );
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$values['easypost_tax'] = $values['easypost_tax'] ? $values['easypost_tax']->_id : 0;
|
||||
$values['easypost_price_adjustment'] = json_encode( $values['easypost_price_adjustment'] );
|
||||
$values['easypost_address'] = ( !$haveSiteAddress or $values['easypost_address_select'] ) ? json_encode( $values['easypost_address_custom'] ) : '';
|
||||
|
||||
if( $haveSiteAddress )
|
||||
{
|
||||
unset( $values['easypost_address_select'] );
|
||||
}
|
||||
|
||||
unset( $values['easypost_address_custom'] );
|
||||
|
||||
try
|
||||
{
|
||||
if ( $values['easypost_enable'] )
|
||||
{
|
||||
unset( $values['easypost_enable'] );
|
||||
$this->testSettings( $values['easypost_api_key'] );
|
||||
$form->saveAsSettings( $values );
|
||||
}
|
||||
else
|
||||
{
|
||||
unset( $values['easypost_enable'] );
|
||||
$values['easypost_api_key'] = '';
|
||||
$form->saveAsSettings( $values );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->inlineMessage = \IPS\Member::loggedIn()->language()->addToStack('saved');
|
||||
}
|
||||
catch ( \LogicException $e )
|
||||
{
|
||||
$form->error = $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->sidebar['actions'] = array(
|
||||
'help' => array(
|
||||
'title' => 'learn_more',
|
||||
'icon' => 'question-circle',
|
||||
'link' => \IPS\Http\Url::ips( 'docs/easypost' ),
|
||||
'target' => '_blank'
|
||||
),
|
||||
'test' => array(
|
||||
'title' => 'easypost_test',
|
||||
'icon' => 'cog',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=applications&controller=enhancements&do=edit&id=nexus_EasyPost&test=1' ),
|
||||
),
|
||||
);
|
||||
|
||||
\IPS\Output::i()->output = $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/Disable
|
||||
*
|
||||
* @param $enabled bool Enable/Disable
|
||||
* @return void
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function toggle( $enabled )
|
||||
{
|
||||
if ( $enabled )
|
||||
{
|
||||
throw new \LogicException;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Settings::i()->changeValues( array( 'easypost_api_key' => '' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Settings (on save to check if API key is valid)
|
||||
*
|
||||
* @param string|NULL $key Key to check
|
||||
* @return void
|
||||
* @throws \LogicException
|
||||
*/
|
||||
protected function testSettings( $key=NULL )
|
||||
{
|
||||
$response = \IPS\Http\Url::external( 'https://api.easypost.com/v2/addresses' )->request()->login( $key, '' )->get();
|
||||
if ( $response->httpResponseCode != 200 )
|
||||
{
|
||||
throw new \LogicException( \IPS\Member::loggedIn()->language()->addToStack('easypost_bad_api_key') );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Settings (full test)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _test()
|
||||
{
|
||||
if( !\IPS\Settings::i()->site_address or \IPS\Settings::i()->site_address == 'null' )
|
||||
{
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'easypost_test_no_site_address' ) );
|
||||
}
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->addMessage( 'easypost_test_blurb' );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'easypost_test_method', \IPS\Settings::i()->easypost_show_rates, TRUE, array(
|
||||
'options' => array( 1 => 'easypost_test_method_1', 0 => 'easypost_test_method_0' ),
|
||||
'toggles' => array(
|
||||
1 => array( 'easypost_test_products' ),
|
||||
0 => array( 'easypost_test_length', 'easypost_test_width', 'easypost_test_height', 'easypost_test_weight' )
|
||||
)
|
||||
) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'easypost_test_products', NULL, NULL, array( 'class' => 'IPS\nexus\Package\Group', 'multiple' => TRUE, 'permissionCheck' => function( $node )
|
||||
{
|
||||
if ( !( $node instanceof \IPS\nexus\Package\Product ) or !$node->physical )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
} ), function( $val )
|
||||
{
|
||||
if ( \IPS\Request::i()->easypost_test_method )
|
||||
{
|
||||
if ( empty( $val ) )
|
||||
{
|
||||
throw new \DomainException('form_required');
|
||||
}
|
||||
foreach ( $val as $package )
|
||||
{
|
||||
if ( !$package->physical )
|
||||
{
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'easypost_test_not_physical', FALSE, array( 'sprintf' => array( $package->_title ) ) ) );
|
||||
}
|
||||
foreach ( array( 'width', 'height', 'length' ) as $k )
|
||||
{
|
||||
if ( !$package->$k )
|
||||
{
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'easypost_test_no_' . $k, FALSE, array( 'sprintf' => array( $package->_title ) ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, NULL, NULL, 'easypost_test_products' ) );
|
||||
$form->add( new \IPS\nexus\Form\Length( 'easypost_test_length', NULL, NULL, array(), NULL, NULL, NULL, 'easypost_test_length' ) );
|
||||
$form->add( new \IPS\nexus\Form\Length( 'easypost_test_width', NULL, NULL, array(), NULL, NULL, NULL, 'easypost_test_width' ) );
|
||||
$form->add( new \IPS\nexus\Form\Length( 'easypost_test_height', NULL, NULL, array(), NULL, NULL, NULL, 'easypost_test_height' ) );
|
||||
$form->add( new \IPS\nexus\Form\Weight( 'easypost_test_weight', NULL, NULL, array(), NULL, NULL, NULL, 'easypost_test_weight' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Member( 'easypost_test_customer', \IPS\Member::loggedIn(), TRUE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Address( 'easypost_test_address', NULL, TRUE ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
if ( $values['easypost_test_method'] )
|
||||
{
|
||||
$lengthInInches = 0;
|
||||
$widthInInches = 0;
|
||||
$heightInInches = 0;
|
||||
$weightInOz = 0;
|
||||
foreach ( $values['easypost_test_products'] as $package )
|
||||
{
|
||||
$weight = new \IPS\nexus\Shipping\Weight( $package->weight );
|
||||
$weightInOz += $weight->float('oz');
|
||||
|
||||
foreach ( array( 'length', 'width', 'height' ) as $k )
|
||||
{
|
||||
$length = new \IPS\nexus\Shipping\Length( $package->$k );
|
||||
|
||||
$v = "{$k}InInches";
|
||||
$$v += $length->float('in');
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$lengthInInches = $values['easypost_test_length']->float('in');
|
||||
$widthInInches = $values['easypost_test_width']->float('in');
|
||||
$heightInInches = $values['easypost_test_height']->float('in');
|
||||
$weightInOz = $values['easypost_test_weight']->float('oz');
|
||||
}
|
||||
|
||||
$customer = \IPS\nexus\Customer::load( $values['easypost_test_customer']->member_id );
|
||||
|
||||
try
|
||||
{
|
||||
$rates = \IPS\nexus\Shipping\EasyPostRate::getRates( $lengthInInches, $widthInInches, $heightInInches, $weightInOz, $customer, $values['easypost_test_address'], $customer->defaultCurrency() );
|
||||
if ( isset( $rates['error'] ) )
|
||||
{
|
||||
\IPS\Output::i()->error( $rates['error']['message'], $rates['error']['code'] );
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
\IPS\Output::i()->error( $e->getMessage(), $e->getCode() );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'shiporders', 'nexus' )->easypostTest( $rates );
|
||||
return;
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = $form;
|
||||
}
|
||||
}
|
||||
@@ -12,36 +12,54 @@
|
||||
namespace IPS\nexus\extensions\core\CommunityEnhancements;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\core\AdminNotification;
|
||||
use IPS\Extensions\CommunityEnhancementsAbstract;
|
||||
use IPS\GeoLocation;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Node;
|
||||
use IPS\Helpers\Form\Radio;
|
||||
use IPS\Helpers\Form\Text;
|
||||
use IPS\Helpers\Form\YesNo;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Settings;
|
||||
use LogicException;
|
||||
use function defined;
|
||||
use function is_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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Community Enhancement
|
||||
*/
|
||||
class _MaxMind
|
||||
class MaxMind extends CommunityEnhancementsAbstract
|
||||
{
|
||||
/**
|
||||
* @brief Enhancement is enabled?
|
||||
*/
|
||||
public $enabled = FALSE;
|
||||
public bool $enabled = FALSE;
|
||||
|
||||
/**
|
||||
* @brief IPS-provided enhancement?
|
||||
*/
|
||||
public $ips = FALSE;
|
||||
public bool $ips = FALSE;
|
||||
|
||||
/**
|
||||
* @brief Enhancement has configuration options?
|
||||
*/
|
||||
public $hasOptions = TRUE;
|
||||
public bool $hasOptions = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Icon data
|
||||
*/
|
||||
public $icon = "maxmind.png";
|
||||
public string $icon = "maxmind.png";
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -50,7 +68,7 @@ class _MaxMind
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->enabled = (bool) \IPS\Settings::i()->maxmind_key;
|
||||
$this->enabled = (bool) Settings::i()->maxmind_key;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,15 +76,15 @@ class _MaxMind
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function edit()
|
||||
public function edit() : void
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'maxmind_enable', (bool) \IPS\Settings::i()->maxmind_key, FALSE, array( 'togglesOn' => array( 'maxmind_key', 'maxmind_gateways', 'maxmind_error' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'maxmind_id', \IPS\Settings::i()->maxmind_id, FALSE, array(), NULL, NULL, NULL, 'maxmind_id' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'maxmind_key', \IPS\Settings::i()->maxmind_key, FALSE, array(), NULL, NULL, NULL, 'maxmind_key' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'maxmind_gateways', ( !\IPS\Settings::i()->maxmind_gateways or \IPS\Settings::i()->maxmind_gateways === '*' ) ? 0 : explode( ',', \IPS\Settings::i()->maxmind_gateways ), FALSE, array( 'class' => 'IPS\nexus\Gateway', 'multiple' => TRUE, 'zeroVal' => 'all' ), NULL, NULL, NULL, 'maxmind_gateways' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'maxmind_error', \IPS\Settings::i()->maxmind_error, FALSE, array( 'options' => array( 'okay' => 'maxmind_error_okay', 'hold' => 'maxmind_error_hold' ) ), NULL, NULL, NULL, 'maxmind_error' ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'maxmind_tracking_code', (bool) \IPS\Settings::i()->maxmind_tracking_code, FALSE, array(), NULL, NULL, NULL, 'maxmind_tracking_code' ) );
|
||||
$form = new Form;
|
||||
$form->add( new YesNo( 'maxmind_enable', (bool) Settings::i()->maxmind_key, FALSE, array( 'togglesOn' => array( 'maxmind_key', 'maxmind_gateways', 'maxmind_error' ) ) ) );
|
||||
$form->add( new Text( 'maxmind_id', Settings::i()->maxmind_id, FALSE, array(), NULL, NULL, NULL, 'maxmind_id' ) );
|
||||
$form->add( new Text( 'maxmind_key', Settings::i()->maxmind_key, FALSE, array(), NULL, NULL, NULL, 'maxmind_key' ) );
|
||||
$form->add( new Node( 'maxmind_gateways', ( !Settings::i()->maxmind_gateways or Settings::i()->maxmind_gateways === '*' ) ? 0 : explode( ',', Settings::i()->maxmind_gateways ), FALSE, array( 'class' => 'IPS\nexus\Gateway', 'multiple' => TRUE, 'zeroVal' => 'all' ), NULL, NULL, NULL, 'maxmind_gateways' ) );
|
||||
$form->add( new Radio( 'maxmind_error', Settings::i()->maxmind_error, FALSE, array( 'options' => array( 'okay' => 'maxmind_error_okay', 'hold' => 'maxmind_error_hold' ) ), NULL, NULL, NULL, 'maxmind_error' ) );
|
||||
$form->add( new YesNo( 'maxmind_tracking_code', (bool) Settings::i()->maxmind_tracking_code, FALSE, array(), NULL, NULL, NULL, 'maxmind_tracking_code' ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
@@ -76,7 +94,7 @@ class _MaxMind
|
||||
{
|
||||
unset( $values['maxmind_enable'] );
|
||||
$this->testSettings( $values['maxmind_key'], $values['maxmind_id'] );
|
||||
$values['maxmind_gateways'] = \is_array( $values['maxmind_gateways'] ) ? implode( ',', array_keys( $values['maxmind_gateways'] ) ) : '*';
|
||||
$values['maxmind_gateways'] = is_array( $values['maxmind_gateways'] ) ? implode( ',', array_keys( $values['maxmind_gateways'] ) ) : '*';
|
||||
$form->saveAsSettings( $values );
|
||||
}
|
||||
else
|
||||
@@ -88,25 +106,25 @@ class _MaxMind
|
||||
$form->saveAsSettings( $values );
|
||||
}
|
||||
|
||||
\IPS\core\AdminNotification::remove( 'nexus', 'Maxmind' );
|
||||
\IPS\Output::i()->inlineMessage = \IPS\Member::loggedIn()->language()->addToStack('saved');
|
||||
AdminNotification::remove( 'nexus', 'Maxmind' );
|
||||
Output::i()->inlineMessage = Member::loggedIn()->language()->addToStack('saved');
|
||||
}
|
||||
catch ( \LogicException $e )
|
||||
catch ( LogicException $e )
|
||||
{
|
||||
$form->error = $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->sidebar['actions'] = array(
|
||||
Output::i()->sidebar['actions'] = array(
|
||||
'help' => array(
|
||||
'title' => 'learn_more',
|
||||
'icon' => 'question-circle',
|
||||
'link' => \IPS\Http\Url::ips( 'docs/maxmind' ),
|
||||
'link' => Url::ips( 'docs/maxmind' ),
|
||||
'target' => '_blank'
|
||||
),
|
||||
);
|
||||
|
||||
\IPS\Output::i()->output = $form;
|
||||
Output::i()->output = $form;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,32 +132,32 @@ class _MaxMind
|
||||
*
|
||||
* @param $enabled bool Enable/Disable
|
||||
* @return void
|
||||
* @throws \LogicException
|
||||
* @throws LogicException
|
||||
*/
|
||||
public function toggle( $enabled )
|
||||
public function toggle( bool $enabled ) : void
|
||||
{
|
||||
if ( $enabled )
|
||||
{
|
||||
throw new \LogicException;
|
||||
throw new LogicException;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Settings::i()->changeValues( array( 'maxmind_key' => '', 'maxmind_id' => '' ) );
|
||||
\IPS\core\AdminNotification::remove( 'nexus', 'Maxmind' );
|
||||
Settings::i()->changeValues( array( 'maxmind_key' => '', 'maxmind_id' => '' ) );
|
||||
AdminNotification::remove( 'nexus', 'Maxmind' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Settings
|
||||
*
|
||||
* @param string|NULL $key Key to check
|
||||
* @param string|NULL $id ID to check
|
||||
* @param string|null $key Key to check
|
||||
* @param string|null $id ID to check
|
||||
* @return void
|
||||
* @throws \LogicException
|
||||
* @throws LogicException
|
||||
*/
|
||||
protected function testSettings( $key=NULL, $id=NULL )
|
||||
protected function testSettings( string $key=NULL, string $id=NULL ) : void
|
||||
{
|
||||
$testAddress = new \IPS\GeoLocation;
|
||||
$testAddress = new GeoLocation;
|
||||
$testAddress->addressLines = array( 'Invision Power Services, Inc.', 'PO Box 2365' );
|
||||
$testAddress->city = 'Forest';
|
||||
$testAddress->region = 'VA';
|
||||
@@ -147,13 +165,13 @@ class _MaxMind
|
||||
$testAddress->postalCode = '24551';
|
||||
|
||||
$maxMind = new \IPS\nexus\Fraud\MaxMind\Request( FALSE, $key, $id );
|
||||
$maxMind->setIpAddress( \IPS\Request::i()->ipAddress() );
|
||||
$maxMind->setIpAddress( Request::i()->ipAddress() );
|
||||
$maxMind->setBillingAddress( $testAddress );
|
||||
$maxMind = $maxMind->request();
|
||||
|
||||
if ( $maxMind->error )
|
||||
{
|
||||
throw new \LogicException( $maxMind->error );
|
||||
throw new LogicException( $maxMind->error );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,130 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Contact Us extension
|
||||
* @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
|
||||
* @since 29 Sep 2016
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\ContactUs;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contact Us extension
|
||||
*/
|
||||
class _SupportRequest
|
||||
{
|
||||
/**
|
||||
* Process Form
|
||||
*
|
||||
* @param \IPS\Helpers\Form $form The form
|
||||
* @param array $formFields Additional Configuration Formfields
|
||||
* @param array $options Type Radio Form Options
|
||||
* @param array $toggles Type Radio Form Toggles
|
||||
* @param array $disabled Type Radio Form Disabled Options
|
||||
* @return void
|
||||
*/
|
||||
public function process( &$form, &$formFields, &$options, &$toggles, &$disabled )
|
||||
{
|
||||
if ( \count( \IPS\nexus\Support\Department::roots() ) )
|
||||
{
|
||||
$options['contact_nexus_department'] = 'contact_nexus_department';
|
||||
}
|
||||
else
|
||||
{
|
||||
$options['contact_nexus_no_departments'] = 'contact_nexus_no_departments';
|
||||
$disabled['contact_nexus_no_departments'] = 'contact_nexus_no_departments';
|
||||
}
|
||||
$toggles['contact_nexus_department'] = array( 'contact_nexus' );
|
||||
|
||||
if ( \count( \IPS\nexus\Support\Department::roots() ) )
|
||||
{
|
||||
$formFields[] = new \IPS\Helpers\Form\Node( 'contact_nexus_department', \IPS\Settings::i()->contact_nexus_department , FALSE, array( 'class' => 'IPS\nexus\Support\Department' ), function( $value ){
|
||||
if( !$value AND \IPS\Request::i()->contact_type == 'contact_nexus_department' )
|
||||
{
|
||||
throw new \DomainException( 'form_required' );
|
||||
}
|
||||
}, NULL, NULL, 'contact_nexus' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Form
|
||||
*
|
||||
* @param array $values Values from form
|
||||
* @return bool
|
||||
*/
|
||||
public function handleForm( $values )
|
||||
{
|
||||
if ( \IPS\Settings::i()->contact_type == 'contact_nexus_department' )
|
||||
{
|
||||
$fromEmail = ( \IPS\Member::loggedIn()->member_id ) ? \IPS\Member::loggedIn()->email : $values['email_address'];
|
||||
$content = $values['contact_text'];
|
||||
if ( isset( $values['contact_referrer'] ) AND $values['contact_referrer'] )
|
||||
{
|
||||
$content .= \IPS\Theme::i()->getTemplate( 'system', 'core', 'front' )->contactFormReferrer( $values['contact_referrer'] );
|
||||
}
|
||||
|
||||
$department = \IPS\nexus\Support\Department::load( \IPS\Settings::i()->contact_nexus_department );
|
||||
$member = \IPS\Member::loggedIn();
|
||||
|
||||
$request = new \IPS\nexus\Support\Request;
|
||||
$request->status = \IPS\nexus\Support\Status::load( TRUE, 'status_default_member' );
|
||||
$request->severity = \IPS\nexus\Support\Severity::load( TRUE, 'sev_default' );
|
||||
$request->last_reply = time();
|
||||
$request->last_reply_by = (int) $member->member_id;
|
||||
$request->last_new_reply = time();
|
||||
$request->started = time();
|
||||
$request->replies = 1;
|
||||
$request->title = ( isset( $values['contact_name'] ) AND $values['contact_name'] ) ? sprintf( \IPS\Member::loggedIn()->language()->get( 'contact_nexus_title_with_name' ), $values['contact_name'] ) : \IPS\Member::loggedIn()->language()->get( 'contact_nexus_title' );
|
||||
|
||||
if ( \IPS\Member::loggedIn()->member_id)
|
||||
{
|
||||
$request->member = \IPS\Member::loggedIn()->member_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$request->email = $fromEmail;
|
||||
}
|
||||
$request->department = $department;
|
||||
$request->save();
|
||||
|
||||
$reply = new \IPS\nexus\Support\Reply;
|
||||
$reply->request = $request->id;
|
||||
$reply->member = (int) \IPS\Member::loggedIn()->member_id;
|
||||
$reply->post = $content;
|
||||
$reply->type = \IPS\Member::loggedIn()->member_id ? $reply::REPLY_MEMBER : $reply::REPLY_EMAIL;
|
||||
$reply->date = time();
|
||||
$reply->email = $fromEmail;
|
||||
$reply->ip_address = \IPS\Request::i()->ipAddress();
|
||||
$reply->save();
|
||||
$request->processAfterCreate( $reply, $values );
|
||||
$request->sendNotifications();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows extensions to do something before the form is shown... e.g. add your own custom fields, or redirect the page
|
||||
*
|
||||
* @param \IPS\Helpers\Form $form The form
|
||||
* @return void
|
||||
*/
|
||||
public function runBeforeFormOutput( &$form )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Whitespace-only changes.
@@ -12,36 +12,33 @@
|
||||
namespace IPS\nexus\extensions\core\ContentRouter;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Application\Module;
|
||||
use IPS\Extensions\ContentRouterAbstract;
|
||||
use IPS\Member;
|
||||
use IPS\Member\Group;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Content Router extension: Products & Reviews
|
||||
*/
|
||||
class _Reviews
|
||||
class Reviews extends ContentRouterAbstract
|
||||
{
|
||||
/**
|
||||
* @brief Content Item Classes
|
||||
*/
|
||||
public $classes = array();
|
||||
|
||||
/**
|
||||
* @brief Can be shown in similar content
|
||||
*/
|
||||
public $similarContent = FALSE;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \IPS\Member|IPS\Member\Group|NULL $member If checking access, the member/group to check for, or NULL to not check access
|
||||
* @param Member|Group|null $member If checking access, the member/group to check for, or NULL to not check access
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( $member = NULL )
|
||||
public function __construct( Member|Group|null $member = NULL )
|
||||
{
|
||||
if ( ( $member === NULL or $member->canAccessModule( \IPS\Application\Module::get( 'nexus', 'store', 'front' ) ) ) )
|
||||
if ( ( $member === NULL or $member->canAccessModule( Module::get( 'nexus', 'store', 'front' ) ) ) )
|
||||
{
|
||||
$this->classes[] = 'IPS\nexus\Package\Item';
|
||||
}
|
||||
|
||||
@@ -12,25 +12,36 @@
|
||||
namespace IPS\nexus\extensions\core\Dashboard;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use DateInterval;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Extensions\DashboardAbstract;
|
||||
use IPS\Helpers\Chart;
|
||||
use IPS\Member;
|
||||
use IPS\nexus\Money;
|
||||
use IPS\nexus\Transaction;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dashboard extension: Income
|
||||
*/
|
||||
class _Income
|
||||
class Income extends DashboardAbstract
|
||||
{
|
||||
/**
|
||||
* Can the current user view this dashboard item?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canView()
|
||||
public function canView(): bool
|
||||
{
|
||||
return \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus' , 'transactions', 'transactions_manage' );
|
||||
return Member::loggedIn()->hasAcpRestriction( 'nexus' , 'transactions', 'transactions_manage' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,20 +49,20 @@ class _Income
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBlock()
|
||||
public function getBlock(): string
|
||||
{
|
||||
$chart = new \IPS\Helpers\Chart;
|
||||
$chart = new Chart;
|
||||
|
||||
$chart->addHeader( "Day", 'date' );
|
||||
foreach ( \IPS\nexus\Money::currencies() as $currency )
|
||||
foreach ( Money::currencies() as $currency )
|
||||
{
|
||||
$chart->addHeader( $currency, 'number' );
|
||||
}
|
||||
|
||||
$thirtyDaysAgo = \IPS\DateTime::create()->sub( new \DateInterval('P30D') );
|
||||
$thirtyDaysAgo = DateTime::create()->sub( new DateInterval('P30D') );
|
||||
|
||||
$results = array();
|
||||
foreach( \IPS\Db::i()->select( "t_currency, DATE_FORMAT( FROM_UNIXTIME( t_date ), '%e %c %Y' ) AS date, SUM(t_amount)-SUM(t_partial_refund) AS amount", 'nexus_transactions', array( 't_date>? AND (t_status=? OR t_status=?) AND t_method>0', $thirtyDaysAgo->getTimestamp(), \IPS\nexus\Transaction::STATUS_PAID, \IPS\nexus\Transaction::STATUS_PART_REFUNDED ), NULL, NULL, array( 't_currency', 'date' ) ) as $result )
|
||||
foreach( Db::i()->select( "t_currency, DATE_FORMAT( FROM_UNIXTIME( t_date ), '%e %c %Y' ) AS date, SUM(t_amount)-SUM(t_partial_refund) AS amount", 'nexus_transactions', array( 't_date>? AND (t_status=? OR t_status=?) AND t_method>0', $thirtyDaysAgo->getTimestamp(), Transaction::STATUS_PAID, Transaction::STATUS_PART_REFUNDED ), NULL, NULL, array( 't_currency', 'date' ) ) as $result )
|
||||
{
|
||||
$results[ $result['date'] ][ $result['t_currency'] ] = $result['amount'];
|
||||
}
|
||||
@@ -59,16 +70,16 @@ class _Income
|
||||
$monthAndYear = date( 'n' ) . ' ' . date( 'Y' );
|
||||
foreach ( range( 30, 0 ) as $daysAgo )
|
||||
{
|
||||
$datetime = new \IPS\DateTime;
|
||||
$datetime->setTime( 0, 0, 0 );
|
||||
$datetime->sub( new \DateInterval( 'P' . $daysAgo . 'D' ) );
|
||||
$datetime = new DateTime;
|
||||
$datetime->setTime( 0, 0 );
|
||||
$datetime->sub( new DateInterval( 'P' . $daysAgo . 'D' ) );
|
||||
$resultString = $datetime->format('j n Y');
|
||||
|
||||
if ( isset( $results[ $resultString ] ) )
|
||||
{
|
||||
$row = array( $datetime );
|
||||
|
||||
foreach ( \IPS\nexus\Money::currencies() as $currency )
|
||||
foreach ( Money::currencies() as $currency )
|
||||
{
|
||||
if ( !isset( $results[ $resultString ][ $currency ] ) )
|
||||
{
|
||||
@@ -85,7 +96,7 @@ class _Income
|
||||
else
|
||||
{
|
||||
$row = array( $datetime );
|
||||
foreach ( \IPS\nexus\Money::currencies() as $currency )
|
||||
foreach ( Money::currencies() as $currency )
|
||||
{
|
||||
$row[] = 0;
|
||||
}
|
||||
@@ -101,24 +112,4 @@ class _Income
|
||||
'areaOpacity' => 0.4,
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the block information
|
||||
*
|
||||
* @return array array( 'name' => 'Block title', 'key' => 'unique_key', 'size' => [1,2,3], 'by' => 'Author name' )
|
||||
*/
|
||||
public function getInfo()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the block data submitted. This method is only necessary if your block accepts some sort of submitted data to save (such as the 'admin notes' block).
|
||||
*
|
||||
* @return void
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function saveBlock()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -12,31 +12,40 @@
|
||||
namespace IPS\nexus\extensions\core\Dashboard;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Db;
|
||||
use IPS\Extensions\DashboardAbstract;
|
||||
use IPS\Member;
|
||||
use IPS\nexus\Payout;
|
||||
use IPS\nexus\Transaction;
|
||||
use IPS\Output;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Dashboard extension: PendingActions
|
||||
*/
|
||||
class _PendingActions
|
||||
class PendingActions extends DashboardAbstract
|
||||
{
|
||||
/**
|
||||
* Can the current user view this dashboard item?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canView()
|
||||
public function canView(): bool
|
||||
{
|
||||
return ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'transactions_manage' )
|
||||
return ( Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'transactions_manage' )
|
||||
or
|
||||
\IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'shiporders_manage' )
|
||||
Member::loggedIn()->hasAcpRestriction( 'core', 'promotion', 'advertisements_manage' )
|
||||
or
|
||||
\IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'promotion', 'advertisements_manage' )
|
||||
or
|
||||
\IPS\Settings::i()->nexus_payout and \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'payouts_manage' ) );
|
||||
Settings::i()->nexus_payout and Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'payouts_manage' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,36 +53,25 @@ class _PendingActions
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBlock()
|
||||
public function getBlock(): string
|
||||
{
|
||||
/* Pending transactions *might* happen some weird way, so always get the count... but only show the count if we have fraud rules set up */
|
||||
$pendingTransactions = NULL;
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'transactions_manage' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'transactions_manage' ) )
|
||||
{
|
||||
$pendingTransactions = \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();
|
||||
if ( !$pendingTransactions and !\IPS\Db::i()->select( 'COUNT(*)', 'nexus_fraud_rules' )->first() )
|
||||
$pendingTransactions = 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();
|
||||
if ( !$pendingTransactions and !Db::i()->select( 'COUNT(*)', 'nexus_fraud_rules' )->first() )
|
||||
{
|
||||
$pendingTransactions = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Same with shipments */
|
||||
$pendingShipments = NULL;
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'shiporders_manage' ) )
|
||||
{
|
||||
$pendingShipments = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_ship_orders', array( 'o_status=?', \IPS\nexus\Shipping\Order::STATUS_PENDING ) )->first();
|
||||
if ( !$pendingShipments and !\IPS\Db::i()->select( 'COUNT(*)', 'nexus_packages_products', 'p_physical=1' )->first() )
|
||||
{
|
||||
$pendingShipments = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* And advertisements */
|
||||
$pendingAdvertisements = NULL;
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'promotion', 'advertisements_manage' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'promotion', 'advertisements_manage' ) )
|
||||
{
|
||||
$pendingAdvertisements = \IPS\Db::i()->select( 'COUNT(*)', 'core_advertisements', array( 'ad_active=-1' ) )->first();
|
||||
if ( !$pendingAdvertisements and !\IPS\Db::i()->select( 'COUNT(*)', 'nexus_packages_ads' )->first() )
|
||||
$pendingAdvertisements = Db::i()->select( 'COUNT(*)', 'core_advertisements', array( 'ad_active=-1' ) )->first();
|
||||
if ( !$pendingAdvertisements and !Db::i()->select( 'COUNT(*)', 'nexus_packages_ads' )->first() )
|
||||
{
|
||||
$pendingAdvertisements = NULL;
|
||||
}
|
||||
@@ -81,41 +79,13 @@ class _PendingActions
|
||||
|
||||
/* Withdrawals will only be if enabled */
|
||||
$pendingWithdrawals = NULL;
|
||||
if ( \IPS\Settings::i()->nexus_payout and \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'payouts_manage' ) )
|
||||
if ( Settings::i()->nexus_payout and Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'payouts_manage' ) )
|
||||
{
|
||||
$pendingWithdrawals = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_payouts', array( 'po_status=?', \IPS\nexus\Payout::STATUS_PENDING ) )->first();
|
||||
$pendingWithdrawals = Db::i()->select( 'COUNT(*)', 'nexus_payouts', array( 'po_status=?', Payout::STATUS_PENDING ) )->first();
|
||||
}
|
||||
|
||||
/* Show support if there are departments we can see */
|
||||
$openSupportRequests = NULL;
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'support', 'requests_manage' ) and \IPS\Db::i()->select( '*', 'nexus_support_departments', array( "( dpt_staff='*' OR " . \IPS\Db::i()->findInSet( 'dpt_staff', \IPS\nexus\Support\Department::staffDepartmentPerms() ) . ')' ) ) )
|
||||
{
|
||||
$myStream = \IPS\nexus\Support\Stream::myStream();
|
||||
$openSupportRequests = $myStream->count( \IPS\Member::loggedIn() );
|
||||
}
|
||||
Output::i()->cssFiles = array_merge( Output::i()->cssFiles, Theme::i()->css( 'widgets.css', 'nexus', 'front' ) );
|
||||
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'widgets.css', 'nexus', 'front' ) );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'dashboard', 'nexus' )->pendingActions( $pendingTransactions, $pendingShipments, $pendingWithdrawals, $openSupportRequests, $pendingAdvertisements );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the block information
|
||||
*
|
||||
* @return array array( 'name' => 'Block title', 'key' => 'unique_key', 'size' => [1,2,3], 'by' => 'Author name' )
|
||||
*/
|
||||
public function getInfo()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the block data submitted. This method is only necessary if your block accepts some sort of submitted data to save (such as the 'admin notes' block).
|
||||
*
|
||||
* @return void
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function saveBlock()
|
||||
{
|
||||
return Theme::i()->getTemplate( 'dashboard', 'nexus' )->pendingActions( $pendingTransactions, $pendingWithdrawals, $pendingAdvertisements );
|
||||
}
|
||||
}
|
||||
@@ -12,48 +12,54 @@
|
||||
namespace IPS\nexus\extensions\core\EditorLocations;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use InvalidArgumentException;
|
||||
use IPS\Content;
|
||||
use IPS\Db;
|
||||
use IPS\Extensions\EditorLocationsAbstract;
|
||||
use IPS\Helpers\Form\Editor;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\nexus\Customer;
|
||||
use IPS\nexus\extensions\nexus\Item\Package;
|
||||
use IPS\nexus\Package\Item;
|
||||
use IPS\nexus\Purchase;
|
||||
use IPS\Node\Model;
|
||||
use IPS\Request;
|
||||
use IPS\Settings;
|
||||
use IPS\Text\Parser;
|
||||
use LogicException;
|
||||
use OutOfRangeException;
|
||||
use function count;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor Extension: Admin
|
||||
*/
|
||||
class _Admin
|
||||
class Admin extends EditorLocationsAbstract
|
||||
{
|
||||
/**
|
||||
* Can we use HTML in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canUseHtml( $member )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can we use attachments in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param \IPS\Helpers\Form\Editor $field The editor field
|
||||
* @param Member $member The member
|
||||
* @param Editor $field The editor field
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canAttach( $member, $field )
|
||||
public function canAttach( Member $member, Editor $field ): ?bool
|
||||
{
|
||||
if ( mb_substr( $field->options['autoSaveKey'], -6 ) == '-email' )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permission check for attachments
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param Member $member The member
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
@@ -61,7 +67,7 @@ class _Admin
|
||||
* @param bool $viewOnly If true, just check if the user can see the attachment rather than download it
|
||||
* @return bool
|
||||
*/
|
||||
public function attachmentPermissionCheck( $member, $id1, $id2, $id3, $attachment, $viewOnly=FALSE )
|
||||
public function attachmentPermissionCheck( Member $member, ?int $id1, ?int $id2, ?string $id3, array $attachment, bool $viewOnly=FALSE ): bool
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -70,28 +76,39 @@ class _Admin
|
||||
case 'pkg':
|
||||
case 'pkg-assoc':
|
||||
case 'pkg-email':
|
||||
return \IPS\nexus\Package\Item::load( $id1 )->canView( $member );
|
||||
return Item::load( $id1 )->canView( $member );
|
||||
|
||||
case 'custom-pg':
|
||||
try
|
||||
{
|
||||
$package = \IPS\nexus\Package::load( $id1 );
|
||||
return $package->custom == $member->member_id;
|
||||
}
|
||||
catch( OutOfRangeException )
|
||||
{
|
||||
throw new LogicException;
|
||||
}
|
||||
|
||||
case 'pkg-pg':
|
||||
$customer = \IPS\nexus\Customer::load( $member->member_id );
|
||||
if ( \count( \IPS\nexus\extensions\nexus\Item\Package::getPurchases( $customer, $id1, FALSE ) ) )
|
||||
$customer = Customer::load( $member->member_id );
|
||||
if ( count( Package::getPurchases( $customer, $id1, FALSE ) ) )
|
||||
{
|
||||
$options = array( 'type' => 'attach', 'id' => $attachment['attach_id'], 'name' => $attachment['attach_file'] );
|
||||
if ( \IPS\Request::i()->referrer() )
|
||||
if ( Request::i()->referrer() )
|
||||
{
|
||||
try
|
||||
{
|
||||
$purchase = \IPS\nexus\Purchase::loadFromUrl( \IPS\Request::i()->referrer() );
|
||||
$purchase = Purchase::loadFromUrl( Request::i()->referrer() );
|
||||
|
||||
if( !$purchase->can( 'view', $member ) )
|
||||
{
|
||||
throw new \LogicException;
|
||||
throw new LogicException;
|
||||
}
|
||||
|
||||
$options['ps_id'] = $purchase->id;
|
||||
$options['ps_name'] = $purchase->name;
|
||||
}
|
||||
catch ( \LogicException $e ) { }
|
||||
catch ( LogicException ) { }
|
||||
}
|
||||
|
||||
$customer->log( 'download', $options );
|
||||
@@ -108,10 +125,10 @@ class _Admin
|
||||
return TRUE;
|
||||
|
||||
case 'network_status_text':
|
||||
return (bool) \IPS\Settings::i()->network_status;
|
||||
};
|
||||
return (bool) Settings::i()->network_status;
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -125,10 +142,10 @@ class _Admin
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
* @return \IPS\Http\Url|\IPS\Content|\IPS\Node\Model
|
||||
* @throws \LogicException
|
||||
* @return Url|Content|Model|Member|null
|
||||
* @throws LogicException
|
||||
*/
|
||||
public function attachmentLookup( $id1, $id2, $id3 )
|
||||
public function attachmentLookup( int $id1=NULL, int $id2=NULL, string $id3=NULL ): Model|Content|Url|Member|null
|
||||
{
|
||||
switch ( $id3 )
|
||||
{
|
||||
@@ -136,35 +153,19 @@ class _Admin
|
||||
case 'pkg-assoc':
|
||||
case 'pkg-pg':
|
||||
case 'pkg-email':
|
||||
return \IPS\Http\Url::internal( "app=nexus&module=store&controller=packages&subnode=1&do=form&id={$id1}", 'admin' );
|
||||
return Url::internal( "app=nexus&module=store&controller=packages&subnode=1&do=form&id={$id1}", 'admin' );
|
||||
|
||||
case 'pgroup':
|
||||
return \IPS\Http\Url::internal( "app=nexus&module=store&controller=packages&do=form&id={$id1}", 'admin' );
|
||||
return Url::internal( "app=nexus&module=store&controller=packages&do=form&id={$id1}", 'admin' );
|
||||
|
||||
case 'invoice-header';
|
||||
case 'invoice-footer':
|
||||
return \IPS\Http\Url::internal( 'app=nexus&module=payments&controller=invoices&do=settings', 'admin' );
|
||||
};
|
||||
}
|
||||
return Url::internal( 'app=nexus&module=payments&controller=invoices&do=settings', 'admin' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild attachment images in non-content item areas
|
||||
*
|
||||
* @param int|null $offset Offset to start from
|
||||
* @param int|null $max Maximum to parse
|
||||
* @return int Number completed
|
||||
* @note This method is optional and will only be called if it exists
|
||||
*/
|
||||
public function rebuildAttachmentImages( $offset, $max )
|
||||
{
|
||||
return $this->performRebuild( $offset, $max, array( 'IPS\Text\Parser', 'rebuildAttachmentUrls' ) );
|
||||
throw new LogicException;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Use the cached image URL instead of the original URL
|
||||
*/
|
||||
protected $proxyUrl = FALSE;
|
||||
|
||||
/**
|
||||
* Rebuild content to add or remove image proxy
|
||||
*
|
||||
@@ -174,44 +175,25 @@ class _Admin
|
||||
* @return int Number completed
|
||||
* @note This method is optional and will only be called if it exists
|
||||
*/
|
||||
public function rebuildImageProxy( $offset, $max, $proxyUrl = FALSE )
|
||||
public function rebuildImageProxy( ?int $offset, ?int $max, bool $proxyUrl = FALSE ): int
|
||||
{
|
||||
$this->proxyUrl = $proxyUrl;
|
||||
return $this->performRebuild( $offset, $max, 'parseImageProxy' );
|
||||
$callback = function( $value ) use ( $proxyUrl ) {
|
||||
return Parser::removeImageProxy( $value, $proxyUrl );
|
||||
};
|
||||
return $this->performRebuild( $offset, $max, $callback );
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild content post-upgrade
|
||||
*
|
||||
* @param int|null $offset Offset to start from
|
||||
* @param int|null $max Maximum to parse
|
||||
* @return int Number completed
|
||||
* @note This method is optional and will only be called if it exists
|
||||
*/
|
||||
public function rebuildContent( $offset, $max )
|
||||
{
|
||||
return $this->performRebuild( $offset, $max, array( 'IPS\Text\LegacyParser', 'parseStatic' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Store lazy loading status ( true = enabled )
|
||||
*/
|
||||
protected $_lazyLoadStatus = null;
|
||||
|
||||
/**
|
||||
* Rebuild content to add or remove lazy loading
|
||||
*
|
||||
* @param int|null $offset Offset to start from
|
||||
* @param int|null $max Maximum to parse
|
||||
* @param bool $status Enable/Disable lazy loading
|
||||
* @return int Number completed
|
||||
* @note This method is optional and will only be called if it exists
|
||||
*/
|
||||
public function rebuildLazyLoad( $offset, $max, $status=TRUE )
|
||||
public function rebuildLazyLoad( ?int $offset, ?int $max ): int
|
||||
{
|
||||
$this->_lazyLoadStatus = $status;
|
||||
|
||||
return $this->performRebuild( $offset, $max, 'parseLazyLoad' );
|
||||
return $this->performRebuild( $offset, $max, [ 'IPS\Text\Parser', 'parseLazyLoad' ] );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -222,30 +204,23 @@ class _Admin
|
||||
* @param callable $callback Method to call to rebuild content
|
||||
* @return int Number completed
|
||||
*/
|
||||
protected function performRebuild( $offset, $max, $callback )
|
||||
protected function performRebuild( ?int $offset, ?int $max, callable $callback ): int
|
||||
{
|
||||
/* We will do everything except pages first */
|
||||
if( !$offset )
|
||||
{
|
||||
/* Language bits */
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_sys_lang_words', \IPS\Db::i()->in( 'word_key', array( 'nexus_com_rules_val', 'network_status_text_val' ) ) . " OR word_key LIKE 'nexus_donategoal_%_desc' OR word_key LIKE 'nexus_gateway_%_ins' OR word_key LIKE 'nexus_pgroup_%_desc' OR word_key LIKE 'nexus_package_%_desc' OR word_key LIKE 'nexus_package_%_page' OR word_key LIKE 'nexus_department_%_desc'", 'word_id ASC', array( $offset, $max ) ) as $word )
|
||||
foreach( Db::i()->select( '*', 'core_sys_lang_words', Db::i()->in( 'word_key', array( 'nexus_com_rules_val', 'network_status_text_val' ) ) . " OR word_key LIKE 'nexus_donategoal_%_desc' OR word_key LIKE 'nexus_gateway_%_ins' OR word_key LIKE 'nexus_pgroup_%_desc' OR word_key LIKE 'nexus_package_%_desc' OR word_key LIKE 'nexus_package_%_page' OR word_key LIKE 'nexus_department_%_desc'", 'word_id ASC', array( $offset, $max ) ) as $word )
|
||||
{
|
||||
$rebuilt = FALSE;
|
||||
try
|
||||
{
|
||||
if( $callback == 'parseImageProxy' )
|
||||
{
|
||||
$rebuilt = \IPS\Text\Parser::removeImageProxy( $word['word_custom'], $this->proxyUrl );
|
||||
}
|
||||
elseif( $callback == 'parseLazyLoad' )
|
||||
{
|
||||
$rebuilt = \IPS\Text\Parser::parseLazyLoad( $word['word_custom'], $this->_lazyLoadStatus );
|
||||
}
|
||||
else
|
||||
if( !empty( $word['word_custom'] ) )
|
||||
{
|
||||
$rebuilt = $callback( $word['word_custom'] );
|
||||
}
|
||||
}
|
||||
catch( \InvalidArgumentException $e )
|
||||
catch( InvalidArgumentException $e )
|
||||
{
|
||||
if( $callback[1] == 'parseStatic' AND $e->getcode() == 103014 )
|
||||
{
|
||||
@@ -259,33 +234,26 @@ class _Admin
|
||||
|
||||
if( $rebuilt !== FALSE )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_sys_lang_words', array( 'word_custom' => $rebuilt ), 'word_id=' . $word['word_id'] );
|
||||
Db::i()->update( 'core_sys_lang_words', array( 'word_custom' => $rebuilt ), 'word_id=' . $word['word_id'] );
|
||||
}
|
||||
}
|
||||
|
||||
/* Settings */
|
||||
foreach ( array( 'nexus_invoice_header', 'nexus_invoice_footer' ) as $k )
|
||||
{
|
||||
$newMessage = FALSE;
|
||||
try
|
||||
{
|
||||
if( $callback == 'parseImageProxy' )
|
||||
if( !empty( Settings::i()->$k ) )
|
||||
{
|
||||
$newMessage = \IPS\Text\Parser::removeImageProxy( \IPS\Settings::i()->$k );
|
||||
}
|
||||
elseif( $callback == 'parseLazyLoad' )
|
||||
{
|
||||
$newMessage = \IPS\Text\Parser::parseLazyLoad( \IPS\Settings::i()->$k, $this->_lazyLoadStatus );
|
||||
}
|
||||
else
|
||||
{
|
||||
$newMessage = $callback( \IPS\Settings::i()->$k );
|
||||
$newMessage = $callback( Settings::i()->$k );
|
||||
}
|
||||
}
|
||||
catch( \InvalidArgumentException $e )
|
||||
catch( InvalidArgumentException $e )
|
||||
{
|
||||
if( $callback[1] == 'parseStatic' AND $e->getcode() == 103014 )
|
||||
{
|
||||
$newMessage = preg_replace( "#\[/?([^\]]+?)\]#", '', \IPS\Settings::i()->$k );
|
||||
$newMessage = preg_replace( "#\[/?([^\]]+?)\]#", '', Settings::i()->$k );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -295,7 +263,7 @@ class _Admin
|
||||
|
||||
if( $newMessage !== FALSE )
|
||||
{
|
||||
\IPS\Settings::i()->changeValues( array( $k => $newMessage ) );
|
||||
Settings::i()->changeValues( array( $k => $newMessage ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -303,27 +271,24 @@ class _Admin
|
||||
/* Now do packages */
|
||||
$did = 0;
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_packages', null, 'p_id ASC', array( $offset, $max ) ) as $package )
|
||||
foreach( Db::i()->select( '*', 'nexus_packages', null, 'p_id ASC', array( $offset, $max ) ) as $package )
|
||||
{
|
||||
$did++;
|
||||
$rebuilt = FALSE;
|
||||
|
||||
/* Update */
|
||||
try
|
||||
{
|
||||
if( $callback == 'parseImageProxy' )
|
||||
{
|
||||
$rebuilt = \IPS\Text\Parser::removeImageProxy( $package['p_page'] );
|
||||
}
|
||||
elseif( $callback == 'parseLazyLoad' )
|
||||
{
|
||||
$rebuilt = \IPS\Text\Parser::parseLazyLoad( $package['p_page'], $this->_lazyLoadStatus );
|
||||
}
|
||||
else
|
||||
if( is_string( $package['p_page'] ) AND $callback[1] == 'parseStatic' )
|
||||
{
|
||||
$rebuilt = $callback( $package['p_page'], NULL, FALSE, 'nexus_Admin', $package['p_id'], NULL, 'pkg-pg' );
|
||||
}
|
||||
elseif( is_string( $package['p_page'] ) )
|
||||
{
|
||||
$rebuilt = $callback( $package['p_page'] );
|
||||
}
|
||||
}
|
||||
catch( \InvalidArgumentException $e )
|
||||
catch( InvalidArgumentException $e )
|
||||
{
|
||||
if( $callback[1] == 'parseStatic' AND $e->getcode() == 103014 )
|
||||
{
|
||||
@@ -337,7 +302,7 @@ class _Admin
|
||||
|
||||
if( $rebuilt !== FALSE )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_packages', array( 'p_page' => $rebuilt ), array( 'p_id=?', $package['p_id'] ) );
|
||||
Db::i()->update( 'nexus_packages', array( 'p_page' => $rebuilt ), array( 'p_id=?', $package['p_id'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,13 +314,13 @@ class _Admin
|
||||
*
|
||||
* @return int Total Count
|
||||
*/
|
||||
public function contentCount()
|
||||
public function contentCount(): int
|
||||
{
|
||||
$count = 2;
|
||||
|
||||
$count += \IPS\Db::i()->select( 'COUNT(*) as count', 'core_sys_lang_words', \IPS\Db::i()->in( 'word_key', array( 'nexus_com_rules_val', 'network_status_text_val' ) ) . " OR word_key LIKE 'nexus_donategoal_%_desc' OR word_key LIKE 'nexus_gateway_%_ins' OR word_key LIKE 'nexus_pgroup_%_desc' OR word_key LIKE 'nexus_package_%_desc' OR word_key LIKE 'nexus_package_%_page' OR word_key LIKE 'nexus_department_%_desc'" )->first();
|
||||
$count += Db::i()->select( 'COUNT(*) as count', 'core_sys_lang_words', Db::i()->in( 'word_key', array( 'nexus_com_rules_val', 'network_status_text_val' ) ) . " OR word_key LIKE 'nexus_donategoal_%_desc' OR word_key LIKE 'nexus_gateway_%_ins' OR word_key LIKE 'nexus_pgroup_%_desc' OR word_key LIKE 'nexus_package_%_desc' OR word_key LIKE 'nexus_package_%_page' OR word_key LIKE 'nexus_department_%_desc'" )->first();
|
||||
|
||||
$count += \IPS\Db::i()->select( 'COUNT(*) as count', 'nexus_packages' )->first();
|
||||
$count += Db::i()->select( 'COUNT(*) as count', 'nexus_packages' )->first();
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
@@ -12,38 +12,43 @@
|
||||
namespace IPS\nexus\extensions\core\EditorLocations;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use InvalidArgumentException;
|
||||
use IPS\Content;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Extensions\EditorLocationsAbstract;
|
||||
use IPS\Helpers\Form\Editor;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\nexus\Customer as NexusCustomer;
|
||||
use IPS\Node\Model;
|
||||
use IPS\Text\Parser;
|
||||
use LogicException;
|
||||
use function count;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor Extension: Customer Fields
|
||||
*/
|
||||
class _Customer
|
||||
class Customer extends EditorLocationsAbstract
|
||||
{
|
||||
/**
|
||||
* Can we use HTML in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canUseHtml( $member )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can we use attachments in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param \IPS\Helpers\Form\Editor $editor The editor instance
|
||||
* @param Member $member The member
|
||||
* @param Editor $field The editor instance
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canAttach( $member, $editor )
|
||||
public function canAttach( Member $member, Editor $field ): ?bool
|
||||
{
|
||||
if( !$editor->options['allowAttachments'] )
|
||||
if( !$field->options['allowAttachments'] )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -54,7 +59,7 @@ class _Customer
|
||||
/**
|
||||
* Permission check for attachments
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param Member $member The member
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
@@ -62,7 +67,7 @@ class _Customer
|
||||
* @param bool $viewOnly If true, just check if the user can see the attachment rather than download it
|
||||
* @return bool
|
||||
*/
|
||||
public function attachmentPermissionCheck( $member, $id1, $id2, $id3, $attachment, $viewOnly=FALSE )
|
||||
public function attachmentPermissionCheck( Member $member, ?int $id1, ?int $id2, ?string $id3, array $attachment, bool $viewOnly=FALSE ): bool
|
||||
{
|
||||
if ( ( $id3 !== 'note' and $member->member_id == $id1 ) or $member->hasAcpRestriction( 'nexus', 'customers', 'customers_view' ) )
|
||||
{
|
||||
@@ -77,33 +82,21 @@ class _Customer
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
* @return \IPS\Http\Url|\IPS\Content|\IPS\Node\Model
|
||||
* @throws \LogicException
|
||||
* @return Url|Content|Model|Member|null
|
||||
* @throws LogicException
|
||||
*/
|
||||
public function attachmentLookup( $id1, $id2, $id3 )
|
||||
public function attachmentLookup( int $id1=NULL, int $id2=NULL, string $id3=NULL ): Model|Content|Url|Member|null
|
||||
{
|
||||
if ( \IPS\Dispatcher::i()->controllerLocation === 'admin' )
|
||||
if ( Dispatcher::i()->controllerLocation === 'admin' )
|
||||
{
|
||||
return \IPS\nexus\Customer::load( $id1 )->acpUrl();
|
||||
return NexusCustomer::load( $id1 )->acpUrl();
|
||||
}
|
||||
else
|
||||
{
|
||||
return \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=info', 'front', 'clientsinfo' );
|
||||
return Url::internal( 'app=nexus&module=clients&controller=info', 'front', 'clientsinfo' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild attachment images in non-content item areas
|
||||
*
|
||||
* @param int|null $offset Offset to start from
|
||||
* @param int|null $max Maximum to parse
|
||||
* @return int Number completed
|
||||
*/
|
||||
public function rebuildAttachmentImages( $offset, $max )
|
||||
{
|
||||
return $this->performRebuild( $offset, $max, array( 'IPS\Text\Parser', 'rebuildAttachmentUrls' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild content post-upgrade
|
||||
*
|
||||
@@ -112,16 +105,11 @@ class _Customer
|
||||
* @return int Number completed
|
||||
* @note This method is optional and will only be called if it exists
|
||||
*/
|
||||
public function rebuildContent( $offset, $max )
|
||||
public function rebuildContent( ?int $offset, ?int $max ): int
|
||||
{
|
||||
return $this->performRebuild( $offset, $max, array( 'IPS\Text\LegacyParser', 'parseStatic' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Use the cached image URL instead of the original URL
|
||||
*/
|
||||
protected $proxyUrl = FALSE;
|
||||
|
||||
/**
|
||||
* Rebuild content to add or remove image proxy
|
||||
*
|
||||
@@ -131,31 +119,25 @@ class _Customer
|
||||
* @return int Number completed
|
||||
* @note This method is optional and will only be called if it exists
|
||||
*/
|
||||
public function rebuildImageProxy( $offset, $max, $proxyUrl = FALSE )
|
||||
public function rebuildImageProxy( ?int $offset, ?int $max, bool $proxyUrl = FALSE ): int
|
||||
{
|
||||
$this->proxyUrl = $proxyUrl;
|
||||
return $this->performRebuild( $offset, $max, 'parseImageProxy' );
|
||||
$callback = function( $value ) use ( $proxyUrl ) {
|
||||
return Parser::removeImageProxy( $value, $proxyUrl );
|
||||
};
|
||||
return $this->performRebuild( $offset, $max, $callback );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Store lazy loading status ( true = enabled )
|
||||
*/
|
||||
protected $_lazyLoadStatus = null;
|
||||
|
||||
/**
|
||||
* Rebuild content to add or remove lazy loading
|
||||
*
|
||||
* @param int|null $offset Offset to start from
|
||||
* @param int|null $max Maximum to parse
|
||||
* @param bool $status Enable/Disable lazy loading
|
||||
* @return int Number completed
|
||||
* @note This method is optional and will only be called if it exists
|
||||
*/
|
||||
public function rebuildLazyLoad( $offset, $max, $status=TRUE )
|
||||
public function rebuildLazyLoad( ?int $offset, ?int $max ): int
|
||||
{
|
||||
$this->_lazyLoadStatus = $status;
|
||||
|
||||
return $this->performRebuild( $offset, $max, 'parseLazyLoad' );
|
||||
return $this->performRebuild( $offset, $max, [ 'IPS\Text\Parser', 'parseLazyLoad' ] );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,25 +148,25 @@ class _Customer
|
||||
* @param callable $callback Method to call to rebuild content
|
||||
* @return int Number completed
|
||||
*/
|
||||
protected function performRebuild( $offset, $max, $callback )
|
||||
protected function performRebuild( ?int $offset, ?int $max, callable $callback ): int
|
||||
{
|
||||
$did = 0;
|
||||
|
||||
/* Get editor fields */
|
||||
$editorFields = array();
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_customer_fields', "f_type='Editor'" ) as $field )
|
||||
foreach( Db::i()->select( '*', 'nexus_customer_fields', "f_type='Editor'" ) as $field )
|
||||
{
|
||||
$editorFields[] = 'field_' . $field['f_id'];
|
||||
}
|
||||
|
||||
if( !\count( $editorFields ) )
|
||||
if( !count( $editorFields ) )
|
||||
{
|
||||
return $did;
|
||||
}
|
||||
|
||||
/* Now update the content */
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_customers', implode( " IS NOT NULL OR ", $editorFields ) . " IS NOT NULL", 'member_id ASC', array( $offset, $max ) ) as $member )
|
||||
foreach( Db::i()->select( '*', 'nexus_customers', implode( " IS NOT NULL OR ", $editorFields ) . " IS NOT NULL", 'member_id ASC', array( $offset, $max ) ) as $member )
|
||||
{
|
||||
$did++;
|
||||
|
||||
@@ -193,22 +175,19 @@ class _Customer
|
||||
|
||||
foreach( $editorFields as $fieldId )
|
||||
{
|
||||
$rebuilt = FALSE;
|
||||
try
|
||||
{
|
||||
if( $callback == 'parseImageProxy' )
|
||||
if( $callback[1] == 'parseStatic' )
|
||||
{
|
||||
$rebuilt = \IPS\Text\Parser::removeImageProxy( $member[ $fieldId ], $this->proxyUrl );
|
||||
}
|
||||
elseif( $callback == 'parseLazyLoad' )
|
||||
{
|
||||
$rebuilt = \IPS\Text\Parser::parseLazyLoad( $member[ $fieldId ], $this->_lazyLoadStatus );
|
||||
$rebuilt = $callback( $member[ $fieldId ], Member::load( $member['member_id'] ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$rebuilt = $callback( $member[ $fieldId ], \IPS\Member::load( $member['member_id'] ) );
|
||||
$rebuilt = $callback( $member[ $fieldId ] );
|
||||
}
|
||||
}
|
||||
catch( \InvalidArgumentException $e )
|
||||
catch( InvalidArgumentException $e )
|
||||
{
|
||||
if( $callback[1] == 'parseStatic' AND $e->getcode() == 103014 )
|
||||
{
|
||||
@@ -226,9 +205,9 @@ class _Customer
|
||||
}
|
||||
}
|
||||
|
||||
if( \count( $toUpdate ) )
|
||||
if( count( $toUpdate ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_customers', $toUpdate, array( 'member_id=?', $member['member_id'] ) );
|
||||
Db::i()->update( 'nexus_customers', $toUpdate, array( 'member_id=?', $member['member_id'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,21 +219,21 @@ class _Customer
|
||||
*
|
||||
* @return int Total Count
|
||||
*/
|
||||
public function contentCount()
|
||||
public function contentCount(): int
|
||||
{
|
||||
/* Get editor fields */
|
||||
$editorFields = array();
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_customer_fields', "f_type='Editor'" ) as $field )
|
||||
foreach( Db::i()->select( '*', 'nexus_customer_fields', "f_type='Editor'" ) as $field )
|
||||
{
|
||||
$editorFields[] = 'field_' . $field['f_id'];
|
||||
}
|
||||
|
||||
if( !\count( $editorFields ) )
|
||||
if( !count( $editorFields ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return \IPS\Db::i()->select( 'COUNT(*) as count', 'nexus_customers', implode( " IS NOT NULL OR ", $editorFields ) . " IS NOT NULL" )->first();
|
||||
return Db::i()->select( 'COUNT(*) as count', 'nexus_customers', implode( " IS NOT NULL OR ", $editorFields ) . " IS NOT NULL" )->first();
|
||||
}
|
||||
}
|
||||
@@ -12,36 +12,40 @@
|
||||
namespace IPS\nexus\extensions\core\EditorLocations;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Content;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Extensions\EditorLocationsAbstract;
|
||||
use IPS\Helpers\Form\Editor;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\nexus\Invoice;
|
||||
use IPS\nexus\Purchase;
|
||||
use IPS\Node\Model;
|
||||
use LogicException;
|
||||
use OutOfRangeException;
|
||||
use function defined;
|
||||
use function intval;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor Extension: Support
|
||||
* Editor Extension: Purchases
|
||||
*/
|
||||
class _Purchases
|
||||
class Purchases extends EditorLocationsAbstract
|
||||
{
|
||||
/**
|
||||
* Can we use HTML in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canUseHtml( $member )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can we use attachments in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param \IPS\Helpers\Form\Editor $field The editor field
|
||||
* @param Member $member The member
|
||||
* @param Editor $field The editor field
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canAttach( $member, $field )
|
||||
public function canAttach( Member $member, Editor $field ): ?bool
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -49,7 +53,7 @@ class _Purchases
|
||||
/**
|
||||
* Permission check for attachments
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param Member $member The member
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
@@ -57,7 +61,7 @@ class _Purchases
|
||||
* @param bool $viewOnly If true, just check if the user can see the attachment rather than download it
|
||||
* @return bool
|
||||
*/
|
||||
public function attachmentPermissionCheck( $member, $id1, $id2, $id3, $attachment, $viewOnly=FALSE )
|
||||
public function attachmentPermissionCheck( Member $member, ?int $id1, ?int $id2, ?string $id3, array $attachment, bool $viewOnly=FALSE ): bool
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -72,19 +76,19 @@ class _Purchases
|
||||
/* If it's in an invoice, we can check that */
|
||||
if ( mb_substr( $id3, 0, 7 ) == 'invoice' )
|
||||
{
|
||||
return \IPS\nexus\Invoice::load( \intval( mb_substr( $id3, 7 ) ) )->canView( $member );
|
||||
return Invoice::load( intval( mb_substr( $id3, 7 ) ) )->canView( $member );
|
||||
}
|
||||
|
||||
/* If it's in an purchase, we can link to that */
|
||||
if ( $id3 == 'purchase' )
|
||||
{
|
||||
return \IPS\nexus\Purchase::load( $id1 )->canView( $member );
|
||||
return Purchase::load( $id1 )->canView( $member );
|
||||
}
|
||||
|
||||
/* Still here? Return false */
|
||||
return FALSE;
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -96,31 +100,31 @@ class _Purchases
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
* @return \IPS\Http\Url|\IPS\Content|\IPS\Node\Model
|
||||
* @throws \LogicException
|
||||
* @return Url|Content|Model|Member|null
|
||||
* @throws LogicException
|
||||
*/
|
||||
public function attachmentLookup( $id1, $id2, $id3 )
|
||||
public function attachmentLookup( int $id1=NULL, int $id2=NULL, string $id3=NULL ): Model|Content|Url|Member|null
|
||||
{
|
||||
/* If it's in the cart, wer obviously can't link to that */
|
||||
if ( $id3 == 'cart' )
|
||||
{
|
||||
throw new \LogicException;
|
||||
throw new LogicException;
|
||||
}
|
||||
|
||||
/* If it's in an invoice, we can link to that */
|
||||
if ( mb_substr( $id3, 0, 8 ) == 'invoice-' )
|
||||
{
|
||||
$invoice = \IPS\nexus\Invoice::load( \intval( mb_substr( $id3, 8 ) ) );
|
||||
return \IPS\Dispatcher::i()->controllerLocation == 'admin' ? $invoice->acpUrl() : $invoice->url();
|
||||
$invoice = Invoice::load( intval( mb_substr( $id3, 8 ) ) );
|
||||
return Dispatcher::i()->controllerLocation == 'admin' ? $invoice->acpUrl() : $invoice->url();
|
||||
}
|
||||
|
||||
/* If it's in an purchase, we can link to that */
|
||||
if ( $id3 == 'purchase' )
|
||||
{
|
||||
return \IPS\nexus\Purchase::load( $id1 );
|
||||
return Purchase::load( $id1 );
|
||||
}
|
||||
|
||||
/* Still here? No idea */
|
||||
throw new \LogicException;
|
||||
throw new LogicException;
|
||||
}
|
||||
}
|
||||
@@ -12,36 +12,39 @@
|
||||
namespace IPS\nexus\extensions\core\EditorLocations;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Content;
|
||||
use IPS\Extensions\EditorLocationsAbstract;
|
||||
use IPS\Helpers\Form\Editor;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\nexus\Package\Item;
|
||||
use IPS\nexus\Package\Review;
|
||||
use IPS\Node\Model;
|
||||
use LogicException;
|
||||
use OutOfRangeException;
|
||||
use RuntimeException;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor Extension: Product Reviews
|
||||
*/
|
||||
class _Store
|
||||
class Store extends EditorLocationsAbstract
|
||||
{
|
||||
/**
|
||||
* Can we use HTML in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canUseHtml( $member )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can we use attachments in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param \IPS\Helpers\Form\Editor $field The editor field
|
||||
* @param Member $member The member
|
||||
* @param Editor $field The editor field
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canAttach( $member, $field )
|
||||
public function canAttach( Member $member, Editor $field ): ?bool
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -50,11 +53,11 @@ class _Store
|
||||
* Can whatever is posted in this editor be moderated?
|
||||
* If this returns TRUE, we must ensure the content is ran through word, link and image filters
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param \IPS\Helpers\Form\Editor $field The editor field
|
||||
* @param Member $member The member
|
||||
* @param Editor $field The editor field
|
||||
* @return bool
|
||||
*/
|
||||
public function canBeModerated( $member, $field )
|
||||
public function canBeModerated( Member $member, Editor $field ): bool
|
||||
{
|
||||
/* Creating/editing a review */
|
||||
if ( preg_match( '/^(?:editComment|review)\-nexus\/store\-\d+/', $field->options['autoSaveKey'] ) )
|
||||
@@ -66,16 +69,17 @@ class _Store
|
||||
{
|
||||
if ( \IPS\IN_DEV )
|
||||
{
|
||||
throw new \RuntimeException( 'Unknown canBeModerated: ' . $field->options['autoSaveKey'] );
|
||||
throw new RuntimeException( 'Unknown canBeModerated: ' . $field->options['autoSaveKey'] );
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
return parent::canBeModerated( $member, $field );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Permission check for attachments
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param Member $member The member
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
@@ -83,13 +87,13 @@ class _Store
|
||||
* @param bool $viewOnly If true, just check if the user can see the attachment rather than download it
|
||||
* @return bool
|
||||
*/
|
||||
public function attachmentPermissionCheck( $member, $id1, $id2, $id3, $attachment, $viewOnly=FALSE )
|
||||
public function attachmentPermissionCheck( Member $member, ?int $id1, ?int $id2, ?string $id3, array $attachment, bool $viewOnly=FALSE ): bool
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\nexus\Package\Item::load( $id1 )->canView( $member );
|
||||
return Item::load( $id1 )->canView( $member );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -101,12 +105,12 @@ class _Store
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
* @return \IPS\Http\Url|\IPS\Content|\IPS\Node\Model
|
||||
* @throws \LogicException
|
||||
* @return Url|Content|Model|Member|null
|
||||
* @throws LogicException
|
||||
*/
|
||||
public function attachmentLookup( $id1, $id2, $id3 )
|
||||
public function attachmentLookup( int $id1=NULL, int $id2=NULL, string $id3=NULL ): Model|Content|Url|Member|null
|
||||
{
|
||||
return \IPS\nexus\Package\Review::load( $id2 );
|
||||
return Review::load( $id2 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Editor Extension: Support
|
||||
* @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 09 Apr 2014
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\EditorLocations;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor Extension: Support
|
||||
*/
|
||||
class _Support
|
||||
{
|
||||
/**
|
||||
* Can we use HTML in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canUseHtml( $member )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can we use attachments in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param \IPS\Helpers\Form\Editor $field The editor field
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canAttach( $member, $field )
|
||||
{
|
||||
if ( $field->options['autoSaveKey'] == 'default_content' )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if( !$field->options['allowAttachments'] )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permission check for attachments
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
* @param array $attachment The attachment data
|
||||
* @param bool $viewOnly If true, just check if the user can see the attachment rather than download it
|
||||
* @return bool
|
||||
*/
|
||||
public function attachmentPermissionCheck( $member, $id1, $id2, $id3, $attachment, $viewOnly=FALSE )
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\nexus\Support\Request::load( $id1 )->canView( $member );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attachment lookup
|
||||
*
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
* @return \IPS\Http\Url|\IPS\Content|\IPS\Node\Model
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function attachmentLookup( $id1, $id2, $id3 )
|
||||
{
|
||||
return \IPS\nexus\Support\Reply::load( $id2 );
|
||||
}
|
||||
}
|
||||
@@ -12,25 +12,34 @@
|
||||
namespace IPS\nexus\extensions\core\FileStorage;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use IPS\Db;
|
||||
use IPS\Extensions\FileStorageAbstract;
|
||||
use IPS\File;
|
||||
use UnderflowException;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor Extension: Advertisement Images
|
||||
*/
|
||||
class _Ads
|
||||
class Ads extends FileStorageAbstract
|
||||
{
|
||||
/**
|
||||
* Count stored files
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
public function count(): int
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'core_advertisements', array( 'ad_member<>0 or ad_member IS NULL' ) )->first();
|
||||
return Db::i()->select( 'COUNT(*)', 'core_advertisements', array( 'ad_member<>0 or ad_member IS NULL' ) )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,70 +48,47 @@ class _Ads
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @param int $storageConfiguration New storage configuration ID
|
||||
* @param int|NULL $oldConfiguration Old storage configuration ID
|
||||
* @throws \Underflowexception When file record doesn't exist. Indicating there are no more files to move
|
||||
* @throws Underflowexception When file record doesn't exist. Indicating there are no more files to move
|
||||
* @return void
|
||||
*/
|
||||
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
|
||||
public function move( int $offset, int $storageConfiguration, int $oldConfiguration=NULL ) : void
|
||||
{
|
||||
$record = \IPS\Db::i()->select( '*', 'core_advertisements', array( 'ad_member<>0 or ad_member IS NULL' ), 'ad_id', array( $offset, 1 ) )->first();
|
||||
$record = Db::i()->select( '*', 'core_advertisements', array( 'ad_member<>0 or ad_member IS NULL' ), 'ad_id', array( $offset, 1 ) )->first();
|
||||
|
||||
$images = json_decode( $record['ad_images'], TRUE );
|
||||
foreach ( $images as $key => $location )
|
||||
{
|
||||
try
|
||||
{
|
||||
$images[ $key ] = (string) \IPS\File::get( $oldConfiguration ?: 'nexus_Ads', $location )->move( $storageConfiguration );
|
||||
$images[ $key ] = (string) File::get( $oldConfiguration ?: 'nexus_Ads', $location )->move( $storageConfiguration );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception )
|
||||
{
|
||||
/* Any issues are logged */
|
||||
}
|
||||
}
|
||||
\IPS\Db::i()->update( 'core_advertisements', array( 'ad_images' => json_encode( $images ) ), array( 'ad_id=?', $record['ad_id'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix all URLs
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @return void
|
||||
*/
|
||||
public function fixUrls( $offset )
|
||||
{
|
||||
$record = \IPS\Db::i()->select( '*', 'core_advertisements', array( 'ad_member<>0 or ad_member IS NULL' ), 'ad_id', array( $offset, 1 ) )->first();
|
||||
|
||||
$images = json_decode( $record['ad_images'], TRUE );
|
||||
|
||||
foreach ( $images as $key => $location )
|
||||
{
|
||||
if ( $new = \IPS\File::repairUrl( $location ) )
|
||||
{
|
||||
$images[ $key ] = $new;
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( 'core_advertisements', array( 'ad_images' => json_encode( $images ) ), array( 'ad_id=?', $record['ad_id'] ) );
|
||||
Db::i()->update( 'core_advertisements', array( 'ad_images' => json_encode( $images ) ), array( 'ad_id=?', $record['ad_id'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file is valid
|
||||
*
|
||||
* @param string $file The file path to check
|
||||
* @param File|string $file The file path to check
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidFile( $file )
|
||||
public function isValidFile( File|string $file ): bool
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_advertisements', array( 'ad_member<>0 or ad_member IS NULL' ) ) as $ad )
|
||||
foreach ( Db::i()->select( '*', 'core_advertisements', array( 'ad_member<>0 or ad_member IS NULL' ) ) as $ad )
|
||||
{
|
||||
if ( \in_array( (string) $file, json_decode( $ad['ad_images'], TRUE ) ) )
|
||||
if ( in_array( (string) $file, json_decode( $ad['ad_images'], TRUE ) ) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( \UnderflowException $e ) { }
|
||||
catch ( UnderflowException ) { }
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@@ -112,17 +98,17 @@ class _Ads
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
public function delete() : void
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_advertisements', array( 'ad_member<>0 or ad_member IS NULL' ) ) as $ad )
|
||||
foreach( Db::i()->select( '*', 'core_advertisements', array( 'ad_member<>0 or ad_member IS NULL' ) ) as $ad )
|
||||
{
|
||||
foreach ( json_decode( $ad['ad_images'], TRUE ) as $key => $location )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'nexus_Products', $location )->delete();
|
||||
File::get( 'nexus_Products', $location )->delete();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
catch( Exception ){}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,35 +12,45 @@
|
||||
namespace IPS\nexus\extensions\core\FileStorage;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use IPS\Db;
|
||||
use IPS\Extensions\FileStorageAbstract;
|
||||
use IPS\File;
|
||||
use IPS\nexus\Customer\CustomField;
|
||||
use Underflowexception;
|
||||
use function count;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* File Storage Extension: Customer Fields
|
||||
*/
|
||||
class _Customer
|
||||
class Customer extends FileStorageAbstract
|
||||
{
|
||||
/**
|
||||
* Count stored files
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
public function count(): int
|
||||
{
|
||||
$where = array();
|
||||
foreach ( \IPS\nexus\Customer\CustomField::roots( NULL, NULL, array( 'f_type=?', 'Upload' ) ) as $field )
|
||||
foreach ( CustomField::roots( NULL, NULL, array( 'f_type=?', 'Upload' ) ) as $field )
|
||||
{
|
||||
$where[] = "field_{$field->id}<>''";
|
||||
}
|
||||
if ( !\count( $where ) )
|
||||
if ( !count( $where ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_customers', implode( ' OR ', $where ) )->first();
|
||||
return Db::i()->select( 'COUNT(*)', 'nexus_customers', implode( ' OR ', $where ) )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,38 +59,38 @@ class _Customer
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @param int $storageConfiguration New storage configuration ID
|
||||
* @param int|NULL $oldConfiguration Old storage configuration ID
|
||||
* @throws \Underflowexception When file record doesn't exist. Indicating there are no more files to move
|
||||
* @throws Underflowexception When file record doesn't exist. Indicating there are no more files to move
|
||||
* @return void
|
||||
*/
|
||||
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
|
||||
public function move( int $offset, int $storageConfiguration, int $oldConfiguration=NULL ) : void
|
||||
{
|
||||
$ids = array();
|
||||
$where = array();
|
||||
foreach ( \IPS\nexus\Customer\CustomField::roots( NULL, NULL, array( 'f_type=?', 'Upload' ) ) as $field )
|
||||
foreach ( CustomField::roots( NULL, NULL, array( 'f_type=?', 'Upload' ) ) as $field )
|
||||
{
|
||||
$ids[] = $field->id;
|
||||
$where[] = "field_{$field->id}<>''";
|
||||
}
|
||||
if ( !\count( $where ) )
|
||||
if ( !count( $where ) )
|
||||
{
|
||||
throw new \Underflowexception;
|
||||
throw new Underflowexception;
|
||||
}
|
||||
|
||||
$customer = \IPS\Db::i()->select( '*', 'nexus_customers', implode( ' OR ', $where ) )->first();
|
||||
$customer = Db::i()->select( '*', 'nexus_customers', implode( ' OR ', $where ) )->first();
|
||||
$update = array();
|
||||
foreach ( $ids as $id )
|
||||
{
|
||||
try
|
||||
{
|
||||
$update[ 'field_' . $id ] = (string) \IPS\File::get( $oldConfiguration ?: 'nexus_Customer', $update[ 'field_' . $id ] )->move( $storageConfiguration );
|
||||
$update[ 'field_' . $id ] = (string) File::get( $oldConfiguration ?: 'nexus_Customer', $update[ 'field_' . $id ] )->move( $storageConfiguration );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception )
|
||||
{
|
||||
/* Any issues are logged */
|
||||
}
|
||||
}
|
||||
|
||||
if ( \count( $update ) )
|
||||
if ( count( $update ) )
|
||||
{
|
||||
foreach( $update as $k => $v )
|
||||
{
|
||||
@@ -90,48 +100,9 @@ class _Customer
|
||||
}
|
||||
}
|
||||
|
||||
if ( \count( $update ) )
|
||||
if ( count( $update ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_customers', $update, array( 'member_id=?', $customer['member_id'] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix all URLs
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @return void
|
||||
*/
|
||||
public function fixUrls( $offset )
|
||||
{
|
||||
$ids = array();
|
||||
$where = array();
|
||||
foreach ( \IPS\nexus\Customer\CustomField::roots( NULL, NULL, array( 'f_type=?', 'Upload' ) ) as $field )
|
||||
{
|
||||
$ids[] = $field->id;
|
||||
$where[] = "field_{$field->id}<>''";
|
||||
}
|
||||
if ( !\count( $where ) )
|
||||
{
|
||||
throw new \Underflowexception;
|
||||
}
|
||||
|
||||
$customer = \IPS\Db::i()->select( '*', 'nexus_customers', implode( ' OR ', $where ) )->first();
|
||||
$update = array();
|
||||
foreach ( $ids as $id )
|
||||
{
|
||||
if ( $new = \IPS\File::repairUrl( $customer[ 'field_' . $id ] ) )
|
||||
{
|
||||
$update[ 'field_' . $id ] = $new;
|
||||
}
|
||||
}
|
||||
|
||||
if ( \count( $update ) )
|
||||
{
|
||||
if ( \count( $update ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_customers', $update, array( 'member_id=?', $customer['member_id'] ) );
|
||||
Db::i()->update( 'nexus_customers', $update, array( 'member_id=?', $customer['member_id'] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,25 +110,25 @@ class _Customer
|
||||
/**
|
||||
* Check if a file is valid
|
||||
*
|
||||
* @param string $file The file path to check
|
||||
* @param File|string $file The file path to check
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidFile( $file )
|
||||
public function isValidFile( File|string $file ): bool
|
||||
{
|
||||
$_where = array();
|
||||
foreach ( \IPS\nexus\Customer\CustomField::roots( NULL, NULL, array( 'f_type=?', 'Upload' ) ) as $field )
|
||||
foreach ( CustomField::roots( NULL, NULL, array( 'f_type=?', 'Upload' ) ) as $field )
|
||||
{
|
||||
$_where[] = "field_{$field->id}=?";
|
||||
}
|
||||
if ( !\count( $_where ) )
|
||||
if ( !count( $_where ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$where = array_fill( 0, \count( $_where ), (string) $file );
|
||||
$where = array_fill( 0, count( $_where ), (string) $file );
|
||||
array_unshift( $where, implode( ' OR ', $_where ) );
|
||||
|
||||
return (bool) \IPS\Db::i()->select( 'COUNT(*)', 'nexus_customers', $where )->first();
|
||||
return (bool) Db::i()->select( 'COUNT(*)', 'nexus_customers', $where )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,29 +136,29 @@ class _Customer
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
public function delete() : void
|
||||
{
|
||||
$ids = array();
|
||||
$where = array();
|
||||
foreach ( \IPS\nexus\Customer\CustomField::roots( NULL, NULL, array( 'f_type=?', 'Upload' ) ) as $field )
|
||||
foreach ( CustomField::roots( NULL, NULL, array( 'f_type=?', 'Upload' ) ) as $field )
|
||||
{
|
||||
$ids[] = $field->id;
|
||||
$where[] = "field_{$field->id}<>''";
|
||||
}
|
||||
if ( !\count( $where ) )
|
||||
if ( !count( $where ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ( \IPS\Db::i()->select( '*', 'nexus_customers', implode( ' OR ', $where ) ) as $customer )
|
||||
foreach ( Db::i()->select( '*', 'nexus_customers', implode( ' OR ', $where ) ) as $customer )
|
||||
{
|
||||
foreach ( $ids as $id )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'nexus_Customer', $customer[ 'field_' . $id ] )->delete();
|
||||
File::get( 'nexus_Customer', $customer[ 'field_' . $id ] )->delete();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
catch( Exception ){}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,25 +12,33 @@
|
||||
namespace IPS\nexus\extensions\core\FileStorage;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use IPS\Db;
|
||||
use IPS\Extensions\FileStorageAbstract;
|
||||
use IPS\File;
|
||||
use UnderflowException;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* File Storage Extension: Gateways
|
||||
*/
|
||||
class _Gateways
|
||||
class Gateways extends FileStorageAbstract
|
||||
{
|
||||
/**
|
||||
* Count stored files
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
public function count(): int
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_paymethods', array( 'm_validationfile<>?', '' ) )->first();
|
||||
return Db::i()->select( 'COUNT(*)', 'nexus_paymethods', array( 'm_validationfile<>?', '' ) )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,23 +47,23 @@ class _Gateways
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @param int $storageConfiguration New storage configuration ID
|
||||
* @param int|NULL $oldConfiguration Old storage configuration ID
|
||||
* @throws \UnderflowException When file record doesn't exist. Indicating there are no more files to move
|
||||
* @return void|int An offset integer to use on the next cycle, or nothing
|
||||
* @throws UnderflowException When file record doesn't exist. Indicating there are no more files to move
|
||||
* @return void
|
||||
*/
|
||||
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
|
||||
public function move( int $offset, int $storageConfiguration, int $oldConfiguration=NULL ) : void
|
||||
{
|
||||
$record = \IPS\Db::i()->select( '*', 'nexus_paymethods', array( 'm_validationfile<>?', '' ), 'm_id', array( $offset, 1 ) )->first();
|
||||
$record = Db::i()->select( '*', 'nexus_paymethods', array( 'm_validationfile<>?', '' ), 'm_id', array( $offset, 1 ) )->first();
|
||||
|
||||
try
|
||||
{
|
||||
$file = \IPS\File::get( $oldConfiguration ?: 'nexus_Gateways', $record['m_id'] )->move( $storageConfiguration );
|
||||
$file = File::get( $oldConfiguration ?: 'nexus_Gateways', $record['m_id'] )->move( $storageConfiguration );
|
||||
|
||||
if ( (string) $file != $record['m_validationfile'] )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_paymethods', array( 'm_validationfile' => (string) $file ), array( 'm_id=?', $record['m_id'] ) );
|
||||
Db::i()->update( 'nexus_paymethods', array( 'm_validationfile' => (string) $file ), array( 'm_id=?', $record['m_id'] ) );
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception )
|
||||
{
|
||||
/* Any issues are logged */
|
||||
}
|
||||
@@ -64,17 +72,17 @@ class _Gateways
|
||||
/**
|
||||
* Check if a file is valid
|
||||
*
|
||||
* @param string $file The file path to check
|
||||
* @param File|string $file The file path to check
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidFile( $file )
|
||||
public function isValidFile( File|string $file ): bool
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->select( '*', 'nexus_paymethods', array( 'm_validationfile=?', (string) $file ) )->first();
|
||||
Db::i()->select( '*', 'nexus_paymethods', array( 'm_validationfile=?', $file ) )->first();
|
||||
return TRUE;
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
catch ( UnderflowException )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -85,15 +93,15 @@ class _Gateways
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
public function delete() : void
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_paymethods', array( 'm_validationfile<>?', '' ) ) as $product )
|
||||
foreach( Db::i()->select( '*', 'nexus_paymethods', array( 'm_validationfile<>?', '' ) ) as $product )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'nexus_Gateways', $product['m_validationfile'] )->delete();
|
||||
File::get( 'nexus_Gateways', $product['m_validationfile'] )->delete();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
catch( Exception ){}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,25 +12,33 @@
|
||||
namespace IPS\nexus\extensions\core\FileStorage;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use IPS\Db;
|
||||
use IPS\Extensions\FileStorageAbstract;
|
||||
use IPS\File;
|
||||
use UnderflowException;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* File Storage Extension: Package Groups
|
||||
*/
|
||||
class _PackageGroups
|
||||
class PackageGroups extends FileStorageAbstract
|
||||
{
|
||||
/**
|
||||
* Count stored files
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
public function count(): int
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_package_groups', array( 'pg_image<>?', '' ) )->first();
|
||||
return Db::i()->select( 'COUNT(*)', 'nexus_package_groups', array( 'pg_image<>?', '' ) )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,58 +47,42 @@ class _PackageGroups
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @param int $storageConfiguration New storage configuration ID
|
||||
* @param int|NULL $oldConfiguration Old storage configuration ID
|
||||
* @throws \Underflowexception When file record doesn't exist. Indicating there are no more files to move
|
||||
* @throws Underflowexception When file record doesn't exist. Indicating there are no more files to move
|
||||
* @return void
|
||||
*/
|
||||
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
|
||||
public function move( int $offset, int $storageConfiguration, int $oldConfiguration=NULL ) : void
|
||||
{
|
||||
$record = \IPS\Db::i()->select( '*', 'nexus_package_groups', array( 'pg_image<>?', '' ), 'pg_id', array( $offset, 1 ) )->first();
|
||||
$record = Db::i()->select( '*', 'nexus_package_groups', array( 'pg_image<>?', '' ), 'pg_id', array( $offset, 1 ) )->first();
|
||||
|
||||
try
|
||||
{
|
||||
$file = \IPS\File::get( $oldConfiguration ?: 'nexus_PackageGroups', $record['pg_image'] )->move( $storageConfiguration );
|
||||
$file = File::get( $oldConfiguration ?: 'nexus_PackageGroups', $record['pg_image'] )->move( $storageConfiguration );
|
||||
|
||||
if ( (string) $file != $record['pg_image'] )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_package_groups', array( 'pg_image' => (string) $file ), array( 'pg_id=?', $record['pg_id'] ) );
|
||||
Db::i()->update( 'nexus_package_groups', array( 'pg_image' => (string) $file ), array( 'pg_id=?', $record['pg_id'] ) );
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception )
|
||||
{
|
||||
/* Any issues are logged */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix all URLs
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @return void
|
||||
*/
|
||||
public function fixUrls( $offset )
|
||||
{
|
||||
$record = \IPS\Db::i()->select( '*', 'nexus_package_groups', array( 'pg_image<>?', '' ), 'pg_id', array( $offset, 1 ) )->first();
|
||||
|
||||
if ( $new = \IPS\File::repairUrl( $record['pg_image'] ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_package_groups', array( 'pg_image' => $new ), array( 'pg_id=?', $record['pg_id'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file is valid
|
||||
*
|
||||
* @param string $file The file path to check
|
||||
* @param File|string $file The file path to check
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidFile( $file )
|
||||
public function isValidFile( File|string $file ): bool
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->select( '*', 'nexus_package_groups', array( 'pg_image=?', (string) $file ) )->first();
|
||||
Db::i()->select( '*', 'nexus_package_groups', array( 'pg_image=?', (string) $file ) )->first();
|
||||
return TRUE;
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
catch ( UnderflowException )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -101,15 +93,15 @@ class _PackageGroups
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
public function delete() : void
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_package_groups', array( 'pg_image<>?', '' ) ) as $product )
|
||||
foreach( Db::i()->select( '*', 'nexus_package_groups', array( 'pg_image<>?', '' ) ) as $product )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'nexus_PackageGroups', $product['pg_image'] )->delete();
|
||||
File::get( 'nexus_PackageGroups', $product['pg_image'] )->delete();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
catch( Exception ){}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,25 +12,33 @@
|
||||
namespace IPS\nexus\extensions\core\FileStorage;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use IPS\Db;
|
||||
use IPS\Extensions\FileStorageAbstract;
|
||||
use IPS\File;
|
||||
use UnderflowException;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* File Storage Extension: Package Images
|
||||
*/
|
||||
class _Products
|
||||
class Products extends FileStorageAbstract
|
||||
{
|
||||
/**
|
||||
* Count stored files
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
public function count(): int
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_package_images' )->first();
|
||||
return Db::i()->select( 'COUNT(*)', 'nexus_package_images' )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,58 +47,42 @@ class _Products
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @param int $storageConfiguration New storage configuration ID
|
||||
* @param int|NULL $oldConfiguration Old storage configuration ID
|
||||
* @throws \Underflowexception When file record doesn't exist. Indicating there are no more files to move
|
||||
* @throws Underflowexception When file record doesn't exist. Indicating there are no more files to move
|
||||
* @return void
|
||||
*/
|
||||
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
|
||||
public function move( int $offset, int $storageConfiguration, int $oldConfiguration=NULL ) : void
|
||||
{
|
||||
$record = \IPS\Db::i()->select( '*', 'nexus_package_images', array(), 'image_id', array( $offset, 1 ) )->first();
|
||||
$record = Db::i()->select( '*', 'nexus_package_images', array(), 'image_id', array( $offset, 1 ) )->first();
|
||||
|
||||
try
|
||||
{
|
||||
$file = \IPS\File::get( $oldConfiguration ?: 'nexus_Products', $record['image_location'] )->move( $storageConfiguration );
|
||||
$file = File::get( $oldConfiguration ?: 'nexus_Products', $record['image_location'] )->move( $storageConfiguration );
|
||||
|
||||
if ( (string) $file != $record['image_location'] )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_package_images', array( 'image_location' => (string) $file ), array( 'image_id=?', $record['image_id'] ) );
|
||||
Db::i()->update( 'nexus_package_images', array( 'image_location' => (string) $file ), array( 'image_id=?', $record['image_id'] ) );
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception )
|
||||
{
|
||||
/* Any issues are logged */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix all URLs
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @return void
|
||||
*/
|
||||
public function fixUrls( $offset )
|
||||
{
|
||||
$record = \IPS\Db::i()->select( '*', 'nexus_package_images', array(), 'image_id', array( $offset, 1 ) )->first();
|
||||
|
||||
if ( $new = \IPS\File::repairUrl( $record['image_location'] ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_package_images', array( 'image_location' => $new ), array( 'image_id=?', $record['image_id'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file is valid
|
||||
*
|
||||
* @param string $file The file path to check
|
||||
* @param File|string $file The file path to check
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidFile( $file )
|
||||
public function isValidFile( File|string $file ): bool
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->select( '*', 'nexus_package_images', array( 'image_location=?', (string) $file ) )->first();
|
||||
Db::i()->select( '*', 'nexus_package_images', array( 'image_location=?', (string) $file ) )->first();
|
||||
return TRUE;
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
catch ( UnderflowException )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -101,15 +93,15 @@ class _Products
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
public function delete() : void
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_package_images', "image_location IS NOT NULL" ) as $product )
|
||||
foreach( Db::i()->select( '*', 'nexus_package_images', "image_location IS NOT NULL" ) as $product )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'nexus_Products', $product['image_location'] )->delete();
|
||||
File::get( 'nexus_Products', $product['image_location'] )->delete();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
catch( Exception ){}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,25 +12,35 @@
|
||||
namespace IPS\nexus\extensions\core\FileStorage;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use IPS\Db;
|
||||
use IPS\Extensions\FileStorageAbstract;
|
||||
use IPS\File;
|
||||
use IPS\nexus\Package\CustomField;
|
||||
use UnderflowException;
|
||||
use function count;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* File Storage Extension: Purchase Custom Fields
|
||||
*/
|
||||
class _PurchaseFields
|
||||
class PurchaseFields extends FileStorageAbstract
|
||||
{
|
||||
/**
|
||||
* Count stored files
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
public function count(): int
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_package_fields', array( 'cf_type=?', 'upload' ) )->first();
|
||||
return Db::i()->select( 'COUNT(*)', 'nexus_package_fields', array( 'cf_type=?', 'upload' ) )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,13 +49,13 @@ class _PurchaseFields
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @param int $storageConfiguration New storage configuration ID
|
||||
* @param int|NULL $oldConfiguration Old storage configuration ID
|
||||
* @throws \Underflowexception When file record doesn't exist. Indicating there are no more files to move
|
||||
* @throws Underflowexception When file record doesn't exist. Indicating there are no more files to move
|
||||
* @return void
|
||||
*/
|
||||
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
|
||||
public function move( int $offset, int $storageConfiguration, int $oldConfiguration=NULL ) : void
|
||||
{
|
||||
$customFields = \IPS\nexus\Package\CustomField::roots( NULL, NULL, array( 'cf_type=?', 'upload' ) );
|
||||
if ( \count( $customFields ) )
|
||||
$customFields = CustomField::roots( NULL, NULL, array( 'cf_type=?', 'upload' ) );
|
||||
if ( count( $customFields ) )
|
||||
{
|
||||
$packages = array();
|
||||
foreach ( $customFields as $field )
|
||||
@@ -56,10 +66,10 @@ class _PurchaseFields
|
||||
}
|
||||
}
|
||||
|
||||
$purchase = \IPS\Db::i()->select( '*', 'nexus_purchases', array(
|
||||
$purchase = Db::i()->select( '*', 'nexus_purchases', array(
|
||||
array( 'ps_app=?', 'nexus' ),
|
||||
array( 'ps_type=?', 'package' ),
|
||||
array( \IPS\Db::i()->in( 'ps_item_id', array_unique( $packages ) ) )
|
||||
array( Db::i()->in( 'ps_item_id', array_unique( $packages ) ) )
|
||||
), 'ps_id', array( $offset, 1 ) )->first();
|
||||
|
||||
$fieldValues = json_decode( $purchase['ps_custom_fields'], TRUE );
|
||||
@@ -69,77 +79,33 @@ class _PurchaseFields
|
||||
{
|
||||
try
|
||||
{
|
||||
$fieldValues[ $k ] = \IPS\File::get( $oldConfiguration ?: 'nexus_PurchaseFields', $fieldValues[ $k ] )->move( $storageConfiguration );
|
||||
$fieldValues[ $k ] = File::get( $oldConfiguration ?: 'nexus_PurchaseFields', $fieldValues[ $k ] )->move( $storageConfiguration );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception )
|
||||
{
|
||||
/* Any issues are logged */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( 'nexus_purchases', array( 'ps_custom_fields' => json_encode( $fieldValues ) ), array( 'ps_id=?', $purchase['ps_id'] ) );
|
||||
Db::i()->update( 'nexus_purchases', array( 'ps_custom_fields' => json_encode( $fieldValues ) ), array( 'ps_id=?', $purchase['ps_id'] ) );
|
||||
}
|
||||
|
||||
throw new \UnderflowException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix all URLs
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @return void
|
||||
*/
|
||||
public function fixUrls( $offset )
|
||||
{
|
||||
$customFields = \IPS\nexus\Package\CustomField::roots( NULL, NULL, array( 'cf_type=?', 'upload' ) );
|
||||
if ( \count( $customFields ) )
|
||||
{
|
||||
$packages = array();
|
||||
foreach ( $customFields as $field )
|
||||
{
|
||||
if ( $field->packages )
|
||||
{
|
||||
$packages = array_merge( $packages, explode( ',', $field->packages ) );
|
||||
}
|
||||
}
|
||||
|
||||
$purchase = \IPS\Db::i()->select( '*', 'nexus_purchases', array(
|
||||
array( 'ps_app=?', 'nexus' ),
|
||||
array( 'ps_type=?', 'package' ),
|
||||
array( \IPS\Db::i()->in( 'ps_item_id', array_unique( $packages ) ) )
|
||||
), 'ps_id', array( $offset, 1 ) )->first();
|
||||
|
||||
$fieldValues = json_decode( $purchase['ps_custom_fields'], TRUE );
|
||||
foreach ( $fieldValues as $k => $v )
|
||||
{
|
||||
if ( array_key_exists( $k, $customFields ) )
|
||||
{
|
||||
if ( $new = \IPS\File::repairUrl( $fieldValues[ $k ] ) )
|
||||
{
|
||||
$fieldValues[ $k ] = $new;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( 'nexus_purchases', array( 'ps_custom_fields' => json_encode( $fieldValues ) ), array( 'ps_id=?', $purchase['ps_id'] ) );
|
||||
}
|
||||
|
||||
throw new \UnderflowException;
|
||||
throw new UnderflowException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file is valid
|
||||
*
|
||||
* @param string $file The file path to check
|
||||
* @param File|string $file The file path to check
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidFile( $file )
|
||||
public function isValidFile( File|string $file ): bool
|
||||
{
|
||||
$customFields = \IPS\nexus\Package\CustomField::roots( NULL, NULL, array( 'cf_type=?', 'upload' ) );
|
||||
if ( \count( $customFields ) )
|
||||
$customFields = CustomField::roots( NULL, NULL, array( 'cf_type=?', 'upload' ) );
|
||||
if ( count( $customFields ) )
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'nexus_purchases', array( "ps_custom_fields LIKE ?", "%" . str_replace( '\\', '\\\\\\', trim( json_encode( (string) $file ), '"' ) . "%" ) ) ) as $purchase )
|
||||
foreach ( Db::i()->select( '*', 'nexus_purchases', array( "ps_custom_fields LIKE ?", "%" . str_replace( '\\', '\\\\\\', trim( json_encode( (string) $file ), '"' ) . "%" ) ) ) as $purchase )
|
||||
{
|
||||
$fieldValues = json_decode( $purchase['ps_custom_fields'], TRUE );
|
||||
foreach ( $customFields as $field )
|
||||
@@ -159,10 +125,10 @@ class _PurchaseFields
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
public function delete() : void
|
||||
{
|
||||
$customFields = \IPS\nexus\Package\CustomField::roots( NULL, NULL, array( 'cf_type=?', 'upload' ) );
|
||||
if ( \count( $customFields ) )
|
||||
$customFields = CustomField::roots( NULL, NULL, array( 'cf_type=?', 'upload' ) );
|
||||
if ( count( $customFields ) )
|
||||
{
|
||||
$packages = array();
|
||||
foreach ( $customFields as $field )
|
||||
@@ -176,10 +142,10 @@ class _PurchaseFields
|
||||
$where = array(
|
||||
array( 'ps_app=?', 'nexus' ),
|
||||
array( 'ps_type=?', 'package' ),
|
||||
array( \IPS\Db::i()->in( 'ps_item_id', array_unique( $packages ) ) )
|
||||
array( Db::i()->in( 'ps_item_id', array_unique( $packages ) ) )
|
||||
);
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_purchases', $where ) as $purchase )
|
||||
foreach( Db::i()->select( '*', 'nexus_purchases', $where ) as $purchase )
|
||||
{
|
||||
$fieldValues = json_decode( $purchase['ps_custom_fields'], TRUE );
|
||||
foreach ( $fieldValues as $k => $v )
|
||||
@@ -188,9 +154,9 @@ class _PurchaseFields
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'nexus_PurchaseFields', $fieldValues[ $k ] )->delete();
|
||||
File::get( 'nexus_PurchaseFields', $fieldValues[ $k ] )->delete();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
catch( Exception ){}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,216 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief File Storage Extension: Support Custom Fields
|
||||
* @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 17 Apr 2014
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\FileStorage;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* File Storage Extension: Support Custom Fields
|
||||
*/
|
||||
class _Support
|
||||
{
|
||||
/**
|
||||
* Count stored files
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_support_fields', array( 'sf_type=?', 'upload' ) )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Move stored files
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @param int $storageConfiguration New storage configuration ID
|
||||
* @param int|NULL $oldConfiguration Old storage configuration ID
|
||||
* @throws \Underflowexception When file record doesn't exist. Indicating there are no more files to move
|
||||
* @return void
|
||||
*/
|
||||
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
|
||||
{
|
||||
$customFields = \IPS\nexus\Support\CustomField::roots( NULL, NULL, array( 'sf_type=?', 'upload' ) );
|
||||
if ( \count( $customFields ) )
|
||||
{
|
||||
$where = array();
|
||||
$departments = array();
|
||||
foreach ( $customFields as $field )
|
||||
{
|
||||
if ( $field->departments and $field->departments !== '*' )
|
||||
{
|
||||
$departments = array_merge( $departments, explode( ',', $field->departments ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( $where !== NULL )
|
||||
{
|
||||
$where = \IPS\Db::i()->in( 'r_department', array_unique( $departments ) );
|
||||
}
|
||||
|
||||
$request = \IPS\Db::i()->select( '*', 'nexus_support_requests', $where, 'r_id', array( $offset, 1 ) )->first();
|
||||
|
||||
$fieldValues = json_decode( $request['r_cfields'], TRUE );
|
||||
foreach ( $fieldValues as $k => $v )
|
||||
{
|
||||
if ( array_key_exists( $k, $customFields ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$fieldValues[ $k ] = \IPS\File::get( $oldConfiguration ?: 'nexus_Support', $fieldValues[ $k ] )->move( $storageConfiguration );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
/* Any issues are logged */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( 'nexus_support_requests', array( 'r_cfields' => json_encode( $fieldValues ) ), array( 'r_id=?', $request['r_id'] ) );
|
||||
}
|
||||
|
||||
throw new \UnderflowException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix all URLs
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @return void
|
||||
*/
|
||||
public function fixUrls( $offset )
|
||||
{
|
||||
$customFields = \IPS\nexus\Support\CustomField::roots( NULL, NULL, array( 'sf_type=?', 'upload' ) );
|
||||
if ( \count( $customFields ) )
|
||||
{
|
||||
$where = array();
|
||||
$departments = array();
|
||||
foreach ( $customFields as $field )
|
||||
{
|
||||
if ( $field->departments and $field->departments !== '*' )
|
||||
{
|
||||
$departments = array_merge( $departments, explode( ',', $field->departments ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( $where !== NULL )
|
||||
{
|
||||
$where = \IPS\Db::i()->in( 'r_department', array_unique( $departments ) );
|
||||
}
|
||||
|
||||
$request = \IPS\Db::i()->select( '*', 'nexus_support_requests', $where, 'r_id', array( $offset, 1 ) )->first();
|
||||
|
||||
$fieldValues = json_decode( $request['r_cfields'], TRUE );
|
||||
foreach ( $fieldValues as $k => $v )
|
||||
{
|
||||
if ( array_key_exists( $k, $customFields ) )
|
||||
{
|
||||
if ( $new = \IPS\File::repairUrl( $fieldValues[ $k ] ) )
|
||||
{
|
||||
$fieldValues[ $k ] = $new;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( 'nexus_support_requests', array( 'r_cfields' => json_encode( $fieldValues ) ), array( 'r_id=?', $request['r_id'] ) );
|
||||
}
|
||||
|
||||
throw new \UnderflowException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file is valid
|
||||
*
|
||||
* @param string $file The file path to check
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidFile( $file )
|
||||
{
|
||||
$customFields = \IPS\nexus\Support\CustomField::roots( NULL, NULL, array( 'sf_type=?', 'upload' ) );
|
||||
if ( \count( $customFields ) )
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'nexus_support_requests', array( "r_cfields LIKE ?", "%" . str_replace( '\\', '\\\\\\', trim( json_encode( (string) $file ), '"' ) . "%" ) ) ) as $request )
|
||||
{
|
||||
$fieldValues = json_decode( $request['r_cfields'], TRUE );
|
||||
foreach ( $customFields as $field )
|
||||
{
|
||||
if ( $fieldValues[ $field->id ] == (string) $file )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all stored files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$customFields = \IPS\nexus\Support\CustomField::roots( NULL, NULL, array( 'sf_type=?', 'upload' ) );
|
||||
if ( \count( $customFields ) )
|
||||
{
|
||||
$where = array();
|
||||
$departments = array();
|
||||
foreach ( $customFields as $field )
|
||||
{
|
||||
if ( $field->departments and $field->departments !== '*' )
|
||||
{
|
||||
$departments = array_merge( $departments, explode( ',', $departments ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( $where !== NULL )
|
||||
{
|
||||
$where = \IPS\Db::i()->in( 'r_department', array_unique( $departments ) );
|
||||
}
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_support_requests', $where ) as $request )
|
||||
{
|
||||
$fieldValues = json_decode( $request['r_cfields'], TRUE );
|
||||
foreach ( $fieldValues as $k => $v )
|
||||
{
|
||||
if ( array_key_exists( $k, $customFields ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'nexus_Support', $fieldValues[ $k ] )->delete();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,64 +12,77 @@
|
||||
namespace IPS\nexus\extensions\core\FrontNavigation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Application\Module;
|
||||
use IPS\core\FrontNavigation\FrontNavigationAbstract;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Front Navigation Extension: Addresses
|
||||
*/
|
||||
class _Addresses extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
{
|
||||
class Addresses extends FrontNavigationAbstract
|
||||
{
|
||||
/**
|
||||
* @var string Default icon
|
||||
*/
|
||||
public string $defaultIcon = '\f3c5';
|
||||
|
||||
/**
|
||||
* Get Type Title which will display in the AdminCP Menu Manager
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function typeTitle()
|
||||
public static function typeTitle(): string
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('client_addresses');
|
||||
return Member::loggedIn()->language()->addToStack('client_addresses');
|
||||
}
|
||||
|
||||
/**
|
||||
* Can the currently logged in user access the content this item links to?
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function canAccessContent()
|
||||
public function canAccessContent(): bool
|
||||
{
|
||||
return ( \IPS\Member::loggedIn()->member_id AND \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'nexus', 'clients' ) ) );
|
||||
return ( Member::loggedIn()->member_id AND Member::loggedIn()->canAccessModule( Module::get( 'nexus', 'clients' ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return string
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
public function title(): string
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('client_addresses');
|
||||
return Member::loggedIn()->language()->addToStack('client_addresses');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Link
|
||||
*
|
||||
* @return \IPS\Http\Url
|
||||
* @return string|Url|null
|
||||
*/
|
||||
public function link()
|
||||
public function link(): Url|string|null
|
||||
{
|
||||
return \IPS\Http\Url::internal( "app=nexus&module=clients&controller=addresses", 'front', 'clientsaddresses' );
|
||||
return Url::internal( "app=nexus&module=clients&controller=addresses", 'front', 'clientsaddresses' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Active?
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function active()
|
||||
public function active(): bool
|
||||
{
|
||||
return \IPS\Dispatcher::i()->application->directory === 'nexus' and \IPS\Dispatcher::i()->module and \IPS\Dispatcher::i()->module->key === 'clients' and \IPS\Dispatcher::i()->controller == 'addresses';
|
||||
return Dispatcher::i()->application->directory === 'nexus' and Dispatcher::i()->module and Dispatcher::i()->module->key === 'clients' and Dispatcher::i()->controller == 'addresses';
|
||||
}
|
||||
}
|
||||
@@ -12,64 +12,77 @@
|
||||
namespace IPS\nexus\extensions\core\FrontNavigation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Application\Module;
|
||||
use IPS\core\FrontNavigation\FrontNavigationAbstract;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Front Navigation Extension: Alternative Contacts
|
||||
*/
|
||||
class _Alternatives extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
{
|
||||
class Alternatives extends FrontNavigationAbstract
|
||||
{
|
||||
/**
|
||||
* @var string Default icon
|
||||
*/
|
||||
public string $defaultIcon = '\f2b9';
|
||||
|
||||
/**
|
||||
* Get Type Title which will display in the AdminCP Menu Manager
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function typeTitle()
|
||||
public static function typeTitle(): string
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('client_alternatives');
|
||||
return Member::loggedIn()->language()->addToStack('client_alternatives');
|
||||
}
|
||||
|
||||
/**
|
||||
* Can the currently logged in user access the content this item links to?
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function canAccessContent()
|
||||
public function canAccessContent(): bool
|
||||
{
|
||||
return ( \IPS\Member::loggedIn()->member_id AND \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'nexus', 'clients' ) ) );
|
||||
return ( Member::loggedIn()->member_id AND Member::loggedIn()->canAccessModule( Module::get( 'nexus', 'clients' ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return string
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
public function title(): string
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('client_alternatives');
|
||||
return Member::loggedIn()->language()->addToStack('client_alternatives');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Link
|
||||
*
|
||||
* @return \IPS\Http\Url
|
||||
* @return string|Url|null
|
||||
*/
|
||||
public function link()
|
||||
public function link(): Url|string|null
|
||||
{
|
||||
return \IPS\Http\Url::internal( "app=nexus&module=clients&controller=alternatives", 'front', 'clientsalternatives' );
|
||||
return Url::internal( "app=nexus&module=clients&controller=alternatives", 'front', 'clientsalternatives' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Active?
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function active()
|
||||
public function active(): bool
|
||||
{
|
||||
return \IPS\Dispatcher::i()->application->directory === 'nexus' and \IPS\Dispatcher::i()->module and \IPS\Dispatcher::i()->module->key === 'clients' and \IPS\Dispatcher::i()->controller == 'alternatives';
|
||||
return Dispatcher::i()->application->directory === 'nexus' and Dispatcher::i()->module and Dispatcher::i()->module->key === 'clients' and Dispatcher::i()->controller == 'alternatives';
|
||||
}
|
||||
}
|
||||
@@ -12,25 +12,34 @@
|
||||
namespace IPS\nexus\extensions\core\FrontNavigation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Application\Module;
|
||||
use IPS\core\FrontNavigation\FrontNavigationAbstract;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Settings;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Front Navigation Extension: Billing Agreements
|
||||
*/
|
||||
class _BillingAgreements extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
class BillingAgreements extends FrontNavigationAbstract
|
||||
{
|
||||
/**
|
||||
* Get Type Title which will display in the AdminCP Menu Manager
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function typeTitle()
|
||||
public static function typeTitle(): string
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('client_billing_agreements');
|
||||
return Member::loggedIn()->language()->addToStack('client_billing_agreements');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,50 +47,50 @@ class _BillingAgreements extends \IPS\core\FrontNavigation\FrontNavigationAbstra
|
||||
* For example, if this will link to a particular feature which has been diabled, it should
|
||||
* not be available, even if the user has permission
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public static function isEnabled()
|
||||
public static function isEnabled() : bool
|
||||
{
|
||||
return \IPS\Settings::i()->billing_agreement_gateways;
|
||||
return Settings::i()->billing_agreement_gateways;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can the currently logged in user access the content this item links to?
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function canAccessContent()
|
||||
public function canAccessContent(): bool
|
||||
{
|
||||
return ( \IPS\Member::loggedIn()->member_id AND \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'nexus', 'clients' ) ) );
|
||||
return ( Member::loggedIn()->member_id AND Member::loggedIn()->canAccessModule( Module::get( 'nexus', 'clients' ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return string
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
public function title(): string
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('client_billing_agreements');
|
||||
return Member::loggedIn()->language()->addToStack('client_billing_agreements');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Link
|
||||
*
|
||||
* @return \IPS\Http\Url
|
||||
* @return string|Url|null
|
||||
*/
|
||||
public function link()
|
||||
public function link(): Url|string|null
|
||||
{
|
||||
return \IPS\Http\Url::internal( "app=nexus&module=clients&controller=billingagreements", 'front', 'clientsbillingagreements' );
|
||||
return Url::internal( "app=nexus&module=clients&controller=billingagreements", 'front', 'clientsbillingagreements' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Active?
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function active()
|
||||
public function active(): bool
|
||||
{
|
||||
return \IPS\Dispatcher::i()->application->directory === 'nexus' and \IPS\Dispatcher::i()->module and \IPS\Dispatcher::i()->module->key === 'clients' and \IPS\Dispatcher::i()->controller == 'billingagreements';
|
||||
return Dispatcher::i()->application->directory === 'nexus' and Dispatcher::i()->module and Dispatcher::i()->module->key === 'clients' and Dispatcher::i()->controller == 'billingagreements';
|
||||
}
|
||||
}
|
||||
@@ -12,25 +12,34 @@
|
||||
namespace IPS\nexus\extensions\core\FrontNavigation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Application\Module;
|
||||
use IPS\core\FrontNavigation\FrontNavigationAbstract;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Settings;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Front Navigation Extension: Cards
|
||||
*/
|
||||
class _Cards extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
class Cards extends FrontNavigationAbstract
|
||||
{
|
||||
/**
|
||||
* Get Type Title which will display in the AdminCP Menu Manager
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function typeTitle()
|
||||
public static function typeTitle(): string
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('client_cards');
|
||||
return Member::loggedIn()->language()->addToStack('client_cards');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,50 +47,50 @@ class _Cards extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
* For example, if this will link to a particular feature which has been diabled, it should
|
||||
* not be available, even if the user has permission
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public static function isEnabled()
|
||||
public static function isEnabled() : bool
|
||||
{
|
||||
return \IPS\Settings::i()->card_storage_gateways;
|
||||
return Settings::i()->card_storage_gateways;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can the currently logged in user access the content this item links to?
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function canAccessContent()
|
||||
public function canAccessContent(): bool
|
||||
{
|
||||
return ( \IPS\Member::loggedIn()->member_id AND \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'nexus', 'clients' ) ) );
|
||||
return ( Member::loggedIn()->member_id AND Member::loggedIn()->canAccessModule( Module::get( 'nexus', 'clients' ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return string
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
public function title(): string
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('client_cards');
|
||||
return Member::loggedIn()->language()->addToStack('client_cards');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Link
|
||||
*
|
||||
* @return \IPS\Http\Url
|
||||
* @return string|Url|null
|
||||
*/
|
||||
public function link()
|
||||
public function link(): Url|string|null
|
||||
{
|
||||
return \IPS\Http\Url::internal( "app=nexus&module=clients&controller=cards", 'front', 'clientscards' );
|
||||
return Url::internal( "app=nexus&module=clients&controller=cards", 'front', 'clientscards' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Active?
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function active()
|
||||
public function active(): bool
|
||||
{
|
||||
return \IPS\Dispatcher::i()->application->directory === 'nexus' and \IPS\Dispatcher::i()->module and \IPS\Dispatcher::i()->module->key === 'clients' and \IPS\Dispatcher::i()->controller == 'cards';
|
||||
return Dispatcher::i()->application->directory === 'nexus' and Dispatcher::i()->module and Dispatcher::i()->module->key === 'clients' and Dispatcher::i()->controller == 'cards';
|
||||
}
|
||||
}
|
||||
@@ -12,16 +12,27 @@
|
||||
namespace IPS\nexus\extensions\core\FrontNavigation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Application\Module;
|
||||
use IPS\core\FrontNavigation\FrontNavigationAbstract;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Settings;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function is_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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Front Navigation Extension: Account Credit
|
||||
*/
|
||||
class _Credit extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
class Credit extends FrontNavigationAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -29,9 +40,9 @@ class _Credit extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function typeTitle()
|
||||
public static function typeTitle(): string
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('client_credit');
|
||||
return Member::loggedIn()->language()->addToStack('client_credit');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,50 +50,50 @@ class _Credit extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
* For example, if this will link to a particular feature which has been diabled, it should
|
||||
* not be available, even if the user has permission
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public static function isEnabled()
|
||||
public static function isEnabled() : bool
|
||||
{
|
||||
return ( \IPS\Settings::i()->nexus_min_topup or ( \is_array( json_decode( \IPS\Settings::i()->nexus_payout, TRUE ) ) AND \count( json_decode( \IPS\Settings::i()->nexus_payout, TRUE ) ) ) );
|
||||
return ( Settings::i()->nexus_min_topup or ( is_array( json_decode( Settings::i()->nexus_payout, TRUE ) ) AND count( json_decode( Settings::i()->nexus_payout, TRUE ) ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Can the currently logged in user access the content this item links to?
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function canAccessContent()
|
||||
public function canAccessContent(): bool
|
||||
{
|
||||
return ( \IPS\Member::loggedIn()->member_id AND \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'nexus', 'clients' ) ) );
|
||||
return ( Member::loggedIn()->member_id AND Member::loggedIn()->canAccessModule( Module::get( 'nexus', 'clients' ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return string
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
public function title(): string
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('client_credit');
|
||||
return Member::loggedIn()->language()->addToStack('client_credit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Link
|
||||
*
|
||||
* @return \IPS\Http\Url
|
||||
* @return string|Url|null
|
||||
*/
|
||||
public function link()
|
||||
public function link(): Url|string|null
|
||||
{
|
||||
return \IPS\Http\Url::internal( "app=nexus&module=clients&controller=credit", 'front', 'clientscredit' );
|
||||
return Url::internal( "app=nexus&module=clients&controller=credit", 'front', 'clientscredit' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Active?
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function active()
|
||||
public function active(): bool
|
||||
{
|
||||
return \IPS\Dispatcher::i()->application->directory === 'nexus' and \IPS\Dispatcher::i()->module and \IPS\Dispatcher::i()->module->key === 'clients' and \IPS\Dispatcher::i()->controller == 'credit';
|
||||
return Dispatcher::i()->application->directory === 'nexus' and Dispatcher::i()->module and Dispatcher::i()->module->key === 'clients' and Dispatcher::i()->controller == 'credit';
|
||||
}
|
||||
}
|
||||
@@ -12,25 +12,39 @@
|
||||
namespace IPS\nexus\extensions\core\FrontNavigation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Application\Module;
|
||||
use IPS\core\FrontNavigation\FrontNavigationAbstract;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Settings;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Front Navigation Extension: Donations
|
||||
*/
|
||||
class _Donations extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
{
|
||||
class Donations extends FrontNavigationAbstract
|
||||
{
|
||||
/**
|
||||
* @var string Default icon
|
||||
*/
|
||||
public string $defaultIcon = '\f1cd';
|
||||
|
||||
/**
|
||||
* Get Type Title which will display in the AdminCP Menu Manager
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function typeTitle()
|
||||
public static function typeTitle(): string
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('client_donations');
|
||||
return Member::loggedIn()->language()->addToStack('client_donations');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,50 +52,50 @@ class _Donations extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
* For example, if this will link to a particular feature which has been diabled, it should
|
||||
* not be available, even if the user has permission
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public static function isEnabled()
|
||||
public static function isEnabled(): bool
|
||||
{
|
||||
return \IPS\Settings::i()->donation_goals;
|
||||
return Settings::i()->donation_goals;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can the currently logged in user access the content this item links to?
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function canAccessContent()
|
||||
public function canAccessContent(): bool
|
||||
{
|
||||
return \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'nexus', 'clients' ) );
|
||||
return Member::loggedIn()->canAccessModule( Module::get( 'nexus', 'clients' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return string
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
public function title(): string
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('client_donations');
|
||||
return Member::loggedIn()->language()->addToStack('client_donations');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Link
|
||||
*
|
||||
* @return \IPS\Http\Url
|
||||
* @return string|Url|null
|
||||
*/
|
||||
public function link()
|
||||
public function link(): Url|string|null
|
||||
{
|
||||
return \IPS\Http\Url::internal( "app=nexus&module=clients&controller=donations", 'front', 'clientsdonations' );
|
||||
return Url::internal( "app=nexus&module=clients&controller=donations", 'front', 'clientsdonations' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Active?
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function active()
|
||||
public function active(): bool
|
||||
{
|
||||
return \IPS\Dispatcher::i()->application->directory === 'nexus' and \IPS\Dispatcher::i()->module and \IPS\Dispatcher::i()->module->key === 'clients' and \IPS\Dispatcher::i()->controller == 'donations';
|
||||
return Dispatcher::i()->application->directory === 'nexus' and Dispatcher::i()->module and Dispatcher::i()->module->key === 'clients' and Dispatcher::i()->controller == 'donations';
|
||||
}
|
||||
}
|
||||
@@ -12,25 +12,34 @@
|
||||
namespace IPS\nexus\extensions\core\FrontNavigation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\core\FrontNavigation\FrontNavigationAbstract;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Settings;
|
||||
use function count;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Front Navigation Extension: Gift Cards
|
||||
*/
|
||||
class _Gifts extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
class Gifts extends FrontNavigationAbstract
|
||||
{
|
||||
/**
|
||||
* Get Type Title which will display in the AdminCP Menu Manager
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function typeTitle()
|
||||
public static function typeTitle(): string
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('gift_vouchers');
|
||||
return Member::loggedIn()->language()->addToStack('gift_vouchers');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,40 +47,40 @@ class _Gifts extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
* For example, if this will link to a particular feature which has been diabled, it should
|
||||
* not be available, even if the user has permission
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public static function isEnabled()
|
||||
public static function isEnabled(): bool
|
||||
{
|
||||
return ( ( $giftVouchers = json_decode( \IPS\Settings::i()->nexus_gift_vouchers, TRUE ) and \count( $giftVouchers ) ) or \IPS\Settings::i()->nexus_gift_vouchers_free );
|
||||
return ( ( $giftVouchers = json_decode( Settings::i()->nexus_gift_vouchers, TRUE ) and count( $giftVouchers ) ) or Settings::i()->nexus_gift_vouchers_free );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return string
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
public function title(): string
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('gift_vouchers');
|
||||
return Member::loggedIn()->language()->addToStack('gift_vouchers');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Link
|
||||
*
|
||||
* @return \IPS\Http\Url
|
||||
* @return string|Url|null
|
||||
*/
|
||||
public function link()
|
||||
public function link(): Url|string|null
|
||||
{
|
||||
return \IPS\Http\Url::internal( "app=nexus&module=store&controller=gifts", 'front', 'store_giftvouchers' );
|
||||
return Url::internal( "app=nexus&module=store&controller=gifts", 'front', 'store_giftvouchers' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Active?
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function active()
|
||||
public function active(): bool
|
||||
{
|
||||
return \IPS\Dispatcher::i()->application->directory === 'nexus' and \IPS\Dispatcher::i()->module and \IPS\Dispatcher::i()->module->key === 'store' and \IPS\Dispatcher::i()->controller == 'gifts';
|
||||
return Dispatcher::i()->application->directory === 'nexus' and Dispatcher::i()->module and Dispatcher::i()->module->key === 'store' and Dispatcher::i()->controller == 'gifts';
|
||||
}
|
||||
}
|
||||
@@ -12,64 +12,77 @@
|
||||
namespace IPS\nexus\extensions\core\FrontNavigation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Application\Module;
|
||||
use IPS\core\FrontNavigation\FrontNavigationAbstract;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Front Navigation Extension: Personal Information
|
||||
*/
|
||||
class _Info extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
{
|
||||
class Info extends FrontNavigationAbstract
|
||||
{
|
||||
/**
|
||||
* @var string Default icon
|
||||
*/
|
||||
public string $defaultIcon = '\f2c2';
|
||||
|
||||
/**
|
||||
* Get Type Title which will display in the AdminCP Menu Manager
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function typeTitle()
|
||||
public static function typeTitle(): string
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('client_info');
|
||||
return Member::loggedIn()->language()->addToStack('client_info');
|
||||
}
|
||||
|
||||
/**
|
||||
* Can the currently logged in user access the content this item links to?
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function canAccessContent()
|
||||
public function canAccessContent(): bool
|
||||
{
|
||||
return ( \IPS\Member::loggedIn()->member_id AND \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'nexus', 'clients' ) ) );
|
||||
return ( Member::loggedIn()->member_id AND Member::loggedIn()->canAccessModule( Module::get( 'nexus', 'clients' ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return string
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
public function title(): string
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('client_info');
|
||||
return Member::loggedIn()->language()->addToStack('client_info');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Link
|
||||
*
|
||||
* @return \IPS\Http\Url
|
||||
* @return string|Url|null
|
||||
*/
|
||||
public function link()
|
||||
public function link(): Url|string|null
|
||||
{
|
||||
return \IPS\Http\Url::internal( "app=nexus&module=clients&controller=info", 'front', 'clientsinfo' );
|
||||
return Url::internal( "app=nexus&module=clients&controller=info", 'front', 'clientsinfo' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Active?
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function active()
|
||||
public function active(): bool
|
||||
{
|
||||
return \IPS\Dispatcher::i()->application->directory === 'nexus' and \IPS\Dispatcher::i()->module and \IPS\Dispatcher::i()->module->key === 'clients' and \IPS\Dispatcher::i()->controller == 'info';
|
||||
return Dispatcher::i()->application->directory === 'nexus' and Dispatcher::i()->module and Dispatcher::i()->module->key === 'clients' and Dispatcher::i()->controller == 'info';
|
||||
}
|
||||
}
|
||||
@@ -12,64 +12,77 @@
|
||||
namespace IPS\nexus\extensions\core\FrontNavigation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Application\Module;
|
||||
use IPS\core\FrontNavigation\FrontNavigationAbstract;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Front Navigation Extension: Orders
|
||||
*/
|
||||
class _Orders extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
{
|
||||
class Orders extends FrontNavigationAbstract
|
||||
{
|
||||
/**
|
||||
* @var string Default icon
|
||||
*/
|
||||
public string $defaultIcon = '\f466';
|
||||
|
||||
/**
|
||||
* Get Type Title which will display in the AdminCP Menu Manager
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function typeTitle()
|
||||
public static function typeTitle(): string
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('client_invoices');
|
||||
return Member::loggedIn()->language()->addToStack('client_invoices');
|
||||
}
|
||||
|
||||
/**
|
||||
* Can the currently logged in user access the content this item links to?
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function canAccessContent()
|
||||
public function canAccessContent(): bool
|
||||
{
|
||||
return ( \IPS\Member::loggedIn()->member_id AND \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'nexus', 'clients' ) ) );
|
||||
return ( Member::loggedIn()->member_id AND Member::loggedIn()->canAccessModule( Module::get( 'nexus', 'clients' ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return string
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
public function title(): string
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('client_invoices');
|
||||
return Member::loggedIn()->language()->addToStack('client_invoices');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Link
|
||||
*
|
||||
* @return \IPS\Http\Url
|
||||
* @return string|Url|null
|
||||
*/
|
||||
public function link()
|
||||
public function link(): Url|string|null
|
||||
{
|
||||
return \IPS\Http\Url::internal( "app=nexus&module=clients&controller=invoices", 'front', 'clientsinvoices' );
|
||||
return Url::internal( "app=nexus&module=clients&controller=invoices", 'front', 'clientsinvoices' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Active?
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function active()
|
||||
public function active(): bool
|
||||
{
|
||||
return \IPS\Dispatcher::i()->application->directory === 'nexus' and \IPS\Dispatcher::i()->module and \IPS\Dispatcher::i()->module->key === 'clients' and ( !\IPS\Dispatcher::i()->controller or \IPS\Dispatcher::i()->controller == 'invoices' );
|
||||
return Dispatcher::i()->application->directory === 'nexus' and Dispatcher::i()->module and Dispatcher::i()->module->key === 'clients' and ( !Dispatcher::i()->controller or Dispatcher::i()->controller == 'invoices' );
|
||||
}
|
||||
}
|
||||
@@ -12,64 +12,78 @@
|
||||
namespace IPS\nexus\extensions\core\FrontNavigation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Application\Module;
|
||||
use IPS\core\FrontNavigation\FrontNavigationAbstract;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Front Navigation Extension: Orders
|
||||
*/
|
||||
class _Purchases extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
{
|
||||
class Purchases extends FrontNavigationAbstract
|
||||
{
|
||||
/**
|
||||
* @var string Default icon
|
||||
*/
|
||||
public string $defaultIcon = '\f571';
|
||||
|
||||
/**
|
||||
* Get Type Title which will display in the AdminCP Menu Manager
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function typeTitle()
|
||||
public static function typeTitle(): string
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('client_purchases');
|
||||
return Member::loggedIn()->language()->addToStack('client_purchases');
|
||||
}
|
||||
|
||||
/**
|
||||
* Can the currently logged in user access the content this item links to?
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function canAccessContent()
|
||||
public function canAccessContent(): bool
|
||||
{
|
||||
return ( \IPS\Member::loggedIn()->member_id AND \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'nexus', 'clients' ) ) and \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_member=? AND ps_show=1', \IPS\Member::loggedIn()->member_id ) ) );
|
||||
return ( Member::loggedIn()->member_id AND Member::loggedIn()->canAccessModule( Module::get( 'nexus', 'clients' ) ) and Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_member=? AND ps_show=1', Member::loggedIn()->member_id ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return string
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
public function title(): string
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('client_purchases');
|
||||
return Member::loggedIn()->language()->addToStack('client_purchases');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Link
|
||||
*
|
||||
* @return \IPS\Http\Url
|
||||
* @return string|Url|null
|
||||
*/
|
||||
public function link()
|
||||
public function link(): Url|string|null
|
||||
{
|
||||
return \IPS\Http\Url::internal( "app=nexus&module=clients&controller=purchases", 'front', 'clientspurchases' );
|
||||
return Url::internal( "app=nexus&module=clients&controller=purchases", 'front', 'clientspurchases' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Active?
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function active()
|
||||
public function active(): bool
|
||||
{
|
||||
return \IPS\Dispatcher::i()->application->directory === 'nexus' and \IPS\Dispatcher::i()->module and \IPS\Dispatcher::i()->module->key === 'clients' and \IPS\Dispatcher::i()->controller == 'purchases';
|
||||
return Dispatcher::i()->application->directory === 'nexus' and Dispatcher::i()->module and Dispatcher::i()->module->key === 'clients' and Dispatcher::i()->controller == 'purchases';
|
||||
}
|
||||
}
|
||||
@@ -12,64 +12,78 @@
|
||||
namespace IPS\nexus\extensions\core\FrontNavigation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Application\Module;
|
||||
use IPS\core\FrontNavigation\FrontNavigationAbstract;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Front Navigation Extension: Store
|
||||
*/
|
||||
class _Store extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
class Store extends FrontNavigationAbstract
|
||||
{
|
||||
/**
|
||||
* @var string Default icon
|
||||
*/
|
||||
public string $defaultIcon = '\f07a';
|
||||
|
||||
/**
|
||||
* Get Type Title which will display in the AdminCP Menu Manager
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function typeTitle()
|
||||
public static function typeTitle(): string
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('module__nexus_store');
|
||||
return Member::loggedIn()->language()->addToStack('module__nexus_store');
|
||||
}
|
||||
|
||||
/**
|
||||
* Can the currently logged in user access the content this item links to?
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function canAccessContent()
|
||||
public function canAccessContent(): bool
|
||||
{
|
||||
return \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'nexus', 'store' ) );
|
||||
return Member::loggedIn()->canAccessModule( Module::get( 'nexus', 'store' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return string
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
public function title(): string
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('module__nexus_store');
|
||||
return Member::loggedIn()->language()->addToStack('module__nexus_store');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Link
|
||||
*
|
||||
* @return \IPS\Http\Url
|
||||
* @return string|Url|null
|
||||
*/
|
||||
public function link()
|
||||
public function link(): Url|string|null
|
||||
{
|
||||
return \IPS\Http\Url::internal( "app=nexus&module=store&controller=store", 'front', 'store' );
|
||||
return Url::internal( "app=nexus&module=store&controller=store", 'front', 'store' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Active?
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function active()
|
||||
public function active(): bool
|
||||
{
|
||||
return \IPS\Dispatcher::i()->application->directory === 'nexus' and \IPS\Dispatcher::i()->module and \IPS\Dispatcher::i()->module->key === 'store' and \in_array( \IPS\Dispatcher::i()->controller, array( 'cart', 'product', 'store' ) );
|
||||
return Dispatcher::i()->application->directory === 'nexus' and Dispatcher::i()->module and Dispatcher::i()->module->key === 'store' and in_array( Dispatcher::i()->controller, array( 'cart', 'product', 'store' ) );
|
||||
}
|
||||
}
|
||||
@@ -12,25 +12,39 @@
|
||||
namespace IPS\nexus\extensions\core\FrontNavigation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Application\Module;
|
||||
use IPS\core\FrontNavigation\FrontNavigationAbstract;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Settings;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Front Navigation Extension: Subscriptions
|
||||
*/
|
||||
class _Subscriptions extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
{
|
||||
class Subscriptions extends FrontNavigationAbstract
|
||||
{
|
||||
/**
|
||||
* @var string Default icon
|
||||
*/
|
||||
public string $defaultIcon = '\f021';
|
||||
|
||||
/**
|
||||
* Get Type Title which will display in the AdminCP Menu Manager
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function typeTitle()
|
||||
public static function typeTitle(): string
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('nexus_subscriptions');
|
||||
return Member::loggedIn()->language()->addToStack('nexus_subscriptions');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,50 +52,50 @@ class _Subscriptions extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
* For example, if this will link to a particular feature which has been diabled, it should
|
||||
* not be available, even if the user has permission
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public static function isEnabled()
|
||||
public static function isEnabled() : bool
|
||||
{
|
||||
return \IPS\Settings::i()->nexus_subs_enabled;
|
||||
return Settings::i()->nexus_subs_enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can the currently logged in user access the content this item links to?
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function canAccessContent()
|
||||
public function canAccessContent(): bool
|
||||
{
|
||||
return \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'nexus', 'subscriptions' ) );
|
||||
return Member::loggedIn()->canAccessModule( Module::get( 'nexus', 'subscriptions' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return string
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
public function title(): string
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('nexus_subscriptions');
|
||||
return Member::loggedIn()->language()->addToStack('nexus_subscriptions');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Link
|
||||
*
|
||||
* @return \IPS\Http\Url
|
||||
* @return string|Url|null
|
||||
*/
|
||||
public function link()
|
||||
public function link(): Url|string|null
|
||||
{
|
||||
return \IPS\Http\Url::internal( "app=nexus&module=subscriptions&controller=subscriptions", 'front', 'nexus_subscriptions' );
|
||||
return Url::internal( "app=nexus&module=subscriptions&controller=subscriptions", 'front', 'nexus_subscriptions' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Active?
|
||||
*
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function active()
|
||||
public function active(): bool
|
||||
{
|
||||
return \IPS\Dispatcher::i()->application->directory === 'nexus' and \IPS\Dispatcher::i()->module and \IPS\Dispatcher::i()->module->key === 'subscriptions' and \IPS\Dispatcher::i()->controller == 'subscriptions';
|
||||
return Dispatcher::i()->application->directory === 'nexus' and Dispatcher::i()->module and Dispatcher::i()->module->key === 'subscriptions' and Dispatcher::i()->controller == 'subscriptions';
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Front Navigation Extension: Support
|
||||
* @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 08 Apr 2014
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\FrontNavigation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Front Navigation Extension: Support
|
||||
*/
|
||||
class _Support extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
{
|
||||
/**
|
||||
* Get Type Title which will display in the AdminCP Menu Manager
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function typeTitle()
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'frontnavigation_support' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Can the currently logged in user access the content this item links to?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canAccessContent()
|
||||
{
|
||||
return ( \IPS\Member::loggedIn()->member_id AND \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'nexus', 'support' ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'frontnavigation_support' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Link
|
||||
*
|
||||
* @return \IPS\Http\Url
|
||||
*/
|
||||
public function link()
|
||||
{
|
||||
return \IPS\Http\Url::internal( "app=nexus&module=support&controller=home", 'front', 'support' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Active?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function active()
|
||||
{
|
||||
return \IPS\Dispatcher::i()->application->directory === 'nexus' and \IPS\Dispatcher::i()->module and \IPS\Dispatcher::i()->module->key === 'support';
|
||||
}
|
||||
}
|
||||
@@ -12,25 +12,33 @@
|
||||
namespace IPS\nexus\extensions\core\GroupForm;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Db;
|
||||
use IPS\Extensions\GroupFormAbstract;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Member\Group;
|
||||
use UnderflowException;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin CP Group Form
|
||||
*/
|
||||
class _PreventDeletion
|
||||
class PreventDeletion extends GroupFormAbstract
|
||||
{
|
||||
/**
|
||||
* Process Form
|
||||
*
|
||||
* @param \IPS\Helpers\Form $form The form
|
||||
* @param \IPS\Member\Group $group Existing Group
|
||||
* @param Form $form The form
|
||||
* @param Group $group Existing Group
|
||||
* @return void
|
||||
*/
|
||||
public function process( &$form, $group )
|
||||
public function process( Form $form, Group $group ): void
|
||||
{
|
||||
|
||||
}
|
||||
@@ -39,10 +47,10 @@ class _PreventDeletion
|
||||
* Save
|
||||
*
|
||||
* @param array $values Values from form
|
||||
* @param \IPS\Member\Group $group The group
|
||||
* @param Group $group The group
|
||||
* @return void
|
||||
*/
|
||||
public function save( $values, &$group )
|
||||
public function save( array $values, Group $group ) : void
|
||||
{
|
||||
|
||||
}
|
||||
@@ -50,28 +58,28 @@ class _PreventDeletion
|
||||
/**
|
||||
* Can this group be deleted?
|
||||
*
|
||||
* @param \IPS\Member\Group $group The group
|
||||
* @return void
|
||||
* @param Group $group The group
|
||||
* @return bool
|
||||
*/
|
||||
public function canDelete( $group ) : bool
|
||||
public function canDelete( Group $group ) : bool
|
||||
{
|
||||
// Is this group used for group promotion after a product purchase?
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->select( '*', 'nexus_packages', ['p_primary_group=? OR ' . \IPS\Db::i()->findInSet('p_secondary_group', [$group->g_id] ), $group->g_id ] )->first();
|
||||
Db::i()->select( '*', 'nexus_packages', ['p_primary_group=? OR ' . Db::i()->findInSet('p_secondary_group', [$group->g_id] ), $group->g_id ] )->first();
|
||||
return FALSE;
|
||||
}
|
||||
catch(\UnderflowException $e )
|
||||
catch(UnderflowException )
|
||||
{
|
||||
}
|
||||
|
||||
// Is this group used for group promotion after a subscription purchase?
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->select( '*', 'nexus_member_subscription_packages', ['sp_primary_group=? OR ' . \IPS\Db::i()->findInSet('sp_secondary_group', [$group->g_id] ), $group->g_id ] )->first();
|
||||
Db::i()->select( '*', 'nexus_member_subscription_packages', ['sp_primary_group=? OR ' . Db::i()->findInSet('sp_secondary_group', [$group->g_id] ), $group->g_id ] )->first();
|
||||
return FALSE;
|
||||
}
|
||||
catch(\UnderflowException $e )
|
||||
catch(UnderflowException )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,551 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Nexus Incoming Email Handler
|
||||
* @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 07 Mar 2014
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\IncomingEmail;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Community Enhancement
|
||||
*/
|
||||
class _Support
|
||||
{
|
||||
/**
|
||||
* Handle email
|
||||
*
|
||||
* @param \IPS\Email\Incoming\Email $email The email
|
||||
* @return bool
|
||||
*/
|
||||
public function process( \IPS\Email\Incoming\Email $email )
|
||||
{
|
||||
/* Is it from an actual member? */
|
||||
$member = \IPS\Member::load( $email->from, 'email' );
|
||||
|
||||
/* Replying? */
|
||||
$request = $this->_emailIsReplyForRequest( $email );
|
||||
$department = $this->_getDepartment( $email );
|
||||
|
||||
if ( $request )
|
||||
{
|
||||
/* IS this request locked? */
|
||||
if ( $request->status->is_locked )
|
||||
{
|
||||
/* Figure out what we are doing */
|
||||
switch( \IPS\Settings::i()->reply_request_resolved )
|
||||
{
|
||||
case 'reject': // The reply is rejected - let the customer know
|
||||
$this->_processLocked( $email, $member, $request );
|
||||
return TRUE;
|
||||
break;
|
||||
|
||||
case 'create': // We are accepting the reply, however we are creating a new request from it rather than opening a new one.
|
||||
$this->_processNewRequest( $email, $member, $department, $request );
|
||||
return TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Still here? Normal reply, or we are just re-opening the request regardless of resolved status - do that */
|
||||
$this->_processReply( $email, $member, $request );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Still here? Make sure the department is valid */
|
||||
if ( !$department )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Create request */
|
||||
$this->_processNewRequest( $email, $member, $department );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Track a property in the reply-to header for reference later
|
||||
*/
|
||||
protected $_lastMessageId = NULL;
|
||||
|
||||
/**
|
||||
* Is reply?
|
||||
*
|
||||
* @param \IPS\Email\Incoming\Email $email The email
|
||||
* @return \IPS\nexus\Support\Request|NULL
|
||||
* @note The key may come in as quoted printable
|
||||
*/
|
||||
protected function _emailIsReplyForRequest( \IPS\Email\Incoming\Email $email )
|
||||
{
|
||||
/* Figure out if this email belongs to an existing request */
|
||||
if (
|
||||
/* Look at the In-Reply-To header */
|
||||
( isset( $email->headers['in-reply-to'] ) and preg_match( '/^<?IPS\-\d+\-SR(\d+)\.(.+?)(\.(\d+))?-/', $email->headers['in-reply-to'], $matches ) ) or
|
||||
|
||||
/* Look for [SRXX.XXX] in the raw content */
|
||||
preg_match( '/\[SR(\d+?)\.(.+?)(\.(\d+))?\]/', $email->raw, $matches ) or
|
||||
|
||||
/* Look for the same in the message */
|
||||
preg_match( '/\[SR(\d+?)\.(.+?)(\.(\d+))?\]/', $email->message, $matches ) or
|
||||
|
||||
/* If neither of those are found, look for the quoted printable version */
|
||||
preg_match( '/\=5BSR(\d+?)\.(.+?)(\.(\d+))?\=5D/', $email->raw, $matches )
|
||||
)
|
||||
{
|
||||
/* We have to store this now so we can inspect it later in _processReply() */
|
||||
if( isset( $matches[4] ) AND $matches[4] )
|
||||
{
|
||||
$this->_lastMessageId = $matches[4];
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$request = \IPS\nexus\Support\Request::load( $matches[1] );
|
||||
if ( $request->email_key === quoted_printable_decode( $matches[2] ) )
|
||||
{
|
||||
return $request;
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
|
||||
/* If the same email generated a new support request within the last 10 minutes and the department is the same, add this as a reply to that */
|
||||
try
|
||||
{
|
||||
$department = $this->_getDepartment( $email );
|
||||
$where = array();
|
||||
$where[] = array( 'r_email=?', $email->from );
|
||||
$where[] = array( 'r_started>?', time() - 600 );
|
||||
|
||||
if ( $department )
|
||||
{
|
||||
$where[] = array( 'r_department=?', $department->_id );
|
||||
}
|
||||
|
||||
$recentRequest = \IPS\Db::i()->select( '*', 'nexus_support_requests', $where )->first();
|
||||
return \IPS\nexus\Support\Request::constructFromData( $recentRequest );
|
||||
}
|
||||
catch ( \UnderflowException $e ) { }
|
||||
|
||||
/* Still here? It must be a new thing */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle reply to locked request
|
||||
*
|
||||
* @param \IPS\Email\Incoming\Email $email The email
|
||||
* @param \IPS\Member $member The member it's from
|
||||
* @param \IPS|nexus\Support\Request $request The support request
|
||||
* @return void
|
||||
*/
|
||||
protected function _processLocked( \IPS\Email\Incoming\Email $email, \IPS\Member $member, \IPS\nexus\Support\Request $request )
|
||||
{
|
||||
\IPS\Email::buildFromTemplate( 'nexus', 'replyRequestLocked', array( $request, $member ), \IPS\Email::TYPE_TRANSACTIONAL )->send( $member->member_id ? $member : $email->from );
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle reply
|
||||
*
|
||||
* @param \IPS\Email\Incoming\Email $email The email
|
||||
* @param \IPS\Member $member The member it's from
|
||||
* @param \IPS\nexus\Support\Request $request The support request to make it a reply of
|
||||
* @return void
|
||||
*/
|
||||
protected function _processReply( \IPS\Email\Incoming\Email $email, \IPS\Member $member, \IPS\nexus\Support\Request $request )
|
||||
{
|
||||
$staff = array_key_exists( $member->member_id, \IPS\nexus\Support\Request::staff() );
|
||||
|
||||
$pending = FALSE;
|
||||
$newMessage = NULL;
|
||||
if ( $staff and $this->_lastMessageId )
|
||||
{
|
||||
$newMessage = $request->comments( 1, 0, 'date', 'desc' );
|
||||
if ( $newMessage and $this->_lastMessageId != $newMessage->id )
|
||||
{
|
||||
$pending = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
$request->status = \IPS\nexus\Support\Status::load( TRUE, $staff ? 'status_default_staff' : 'status_default_member' );
|
||||
$request->last_reply = time();
|
||||
$request->last_reply_by = (int) $member->member_id;
|
||||
$request->replies++;
|
||||
$request->save();
|
||||
|
||||
$reply = new \IPS\nexus\Support\Reply;
|
||||
$reply->request = $request->id;
|
||||
$reply->member = (int) $member->member_id;
|
||||
$reply->type = $staff ? ( $pending ? $reply::REPLY_PENDING : $reply::REPLY_STAFF ) : $reply::REPLY_EMAIL;
|
||||
$reply->post = $email->message;
|
||||
$reply->date = time();
|
||||
$reply->email = $email->from;
|
||||
$reply->cc = implode( ',', $email->cc );
|
||||
$reply->raw = $email->raw;
|
||||
$reply->save();
|
||||
static::makeAndClaimAttachments( $email->attachments, $reply, $member );
|
||||
static::storeAttachmentMappings( $email->mappedAttachments, $reply, $member );
|
||||
|
||||
if ( $pending )
|
||||
{
|
||||
$notifyEmail = \IPS\Email::buildFromTemplate( 'nexus', 'staffReplyPending', array( $reply, $newMessage ), \IPS\Email::TYPE_TRANSACTIONAL );
|
||||
$notifyEmail->send( $member );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $staff )
|
||||
{
|
||||
$defaultRecipients = $request->getDefaultRecipients();
|
||||
$reply->sendCustomerNotifications( $defaultRecipients['to'], $defaultRecipients['cc'], $defaultRecipients['bcc'] );
|
||||
}
|
||||
$reply->sendNotifications();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get department
|
||||
*
|
||||
* @param \IPS\Email\Incoming\Email $email The email
|
||||
* @return \IPS\nexus\Support\Department
|
||||
*/
|
||||
protected function _getDepartment( \IPS\Email\Incoming\Email $email )
|
||||
{
|
||||
foreach ( $email->to as $to )
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\nexus\Support\Department::load( $to, 'dpt_email' );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
|
||||
foreach ( $email->cc as $to )
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\nexus\Support\Department::load( $to, 'dpt_email' );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle new requst
|
||||
*
|
||||
* @param \IPS\Email\Incoming\Email $email The email
|
||||
* @param \IPS\Member $member The member it's from
|
||||
* @param \IPS\nexus\Support\Department $department The department to put it in
|
||||
* @param \IPS\nexus\Support\Request|NULL $request If this is from a previous request, the request, otherwise NULL
|
||||
* @return void
|
||||
*/
|
||||
protected function _processNewRequest( \IPS\Email\Incoming\Email $email, \IPS\Member $member, \IPS\nexus\Support\Department $department, \IPS\nexus\Support\Request $previousRequest = NULL )
|
||||
{
|
||||
/* Make sure we're looking at the right department. */
|
||||
if ( !\is_null( $previousRequest ) )
|
||||
{
|
||||
/* Use the existing requests department instead. */
|
||||
$department = $previousRequest->department;
|
||||
}
|
||||
|
||||
/* Forwarded by a staff member? */
|
||||
if (
|
||||
preg_match( '/^FWD?: (.*)$/i', $email->subject, $matches ) // Was forwarded
|
||||
and $member->member_id and array_key_exists( $member->member_id, \IPS\nexus\Support\Request::staff() ) // By a staff member
|
||||
and $originallyFromEmail = $this->_originalSenderOfForwardedMessage( $email ) // And we can get the email address of the original sender
|
||||
) {
|
||||
list( $request, $reply ) = $this->_createRequestFromStaffForward( $email, $member, $department, $originallyFromEmail );
|
||||
}
|
||||
|
||||
/* Nope, normal request */
|
||||
else
|
||||
{
|
||||
list( $request, $reply ) = $this->_createNormalNewRequest( $email, $member, $department );
|
||||
}
|
||||
|
||||
/* Send staff notifications */
|
||||
$request->afterCreateLog( $reply );
|
||||
|
||||
if ( $previousRequest )
|
||||
{
|
||||
$request->log( 'previous_request', $previousRequest, NULL, ( $member->member_id ) ? $member : FALSE );
|
||||
$previousRequest->log( 'previous_request', NULL, $request, ( $member->member_id ) ? $member : FALSE );
|
||||
}
|
||||
|
||||
$request->sendNotifications();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle new request for an email that was forwarded by a staff member
|
||||
*
|
||||
* @param \IPS\Email\Incoming\Email $email The email
|
||||
* @param \IPS\Member $member The member it's from
|
||||
* @param \IPS\nexus\Support\Department $department The department to put it in
|
||||
* @param string $originallyFromEmail The email address of the original sender
|
||||
* @return [ \IPS\nexus\Support\Request, \IPS\nexus\Support\Reply ]
|
||||
*/
|
||||
protected function _createRequestFromStaffForward( \IPS\Email\Incoming\Email $email, \IPS\Member $member, \IPS\nexus\Support\Department $department, $originallyFromEmail )
|
||||
{
|
||||
/* Get the member for the original email */
|
||||
$originallyFrom = \IPS\Member::load( $originallyFromEmail, 'email' );
|
||||
|
||||
/* Init request */
|
||||
$request = $this->_initRequest( $member, $department );
|
||||
preg_match( '/^FWD?: (.*)$/i', $email->subject, $matches );
|
||||
$request->title = $matches[1];
|
||||
$request->member = (int) $originallyFrom->member_id;
|
||||
$request->email = $originallyFromEmail;
|
||||
$request->save();
|
||||
|
||||
/* Strip any headers from the forwarded message */
|
||||
$quoted = $email->quote;
|
||||
$haveInitialHeader = FALSE;
|
||||
$exploded = explode( '<br>', $quoted );
|
||||
foreach ( $exploded as $k => $line )
|
||||
{
|
||||
if ( $line )
|
||||
{
|
||||
if ( !$haveInitialHeader and preg_match( '/^.*:/', $line ) )
|
||||
{
|
||||
$haveInitialHeader = TRUE;
|
||||
}
|
||||
elseif ( !preg_match( '/^.*:.*$/', $line ) )
|
||||
{
|
||||
$quoted = implode( '<br>', array_splice( $exploded, $k ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$quoted = \IPS\Text\Parser::parseStatic( '<div>' . $quoted . '</div>' );
|
||||
|
||||
/* Create the reply */
|
||||
$reply = $this->_createReply( $email, $request, $member, $quoted, $originallyFromEmail );
|
||||
|
||||
/* Create a hidden note */
|
||||
if ( trim( $email->message ) or \count( $email->attachments ) )
|
||||
{
|
||||
$note = new \IPS\nexus\Support\Reply;
|
||||
$note->request = $request->id;
|
||||
$note->member = (int) $member->member_id;
|
||||
$note->type = $reply::REPLY_HIDDEN;
|
||||
$note->post = $email->message;
|
||||
$note->date = time();
|
||||
$note->email = $email->from;
|
||||
$note->save();
|
||||
|
||||
static::makeAndClaimAttachments( $email->attachments, $note, $member );
|
||||
static::storeAttachmentMappings( $email->mappedAttachments, $note, $member );
|
||||
}
|
||||
|
||||
/* Return */
|
||||
return array( $request, $reply );
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle new request from a normal email
|
||||
*
|
||||
* @param \IPS\Email\Incoming\Email $email The email
|
||||
* @param \IPS\Member $member The member it's from
|
||||
* @param \IPS\nexus\Support\Department $department The department to put it in
|
||||
* @return [ \IPS\nexus\Support\Request, \IPS\nexus\Support\Reply ]
|
||||
*/
|
||||
protected function _createNormalNewRequest( \IPS\Email\Incoming\Email $email, \IPS\Member $member, \IPS\nexus\Support\Department $department )
|
||||
{
|
||||
/* Init request */
|
||||
$request = $this->_initRequest( $member, $department );
|
||||
$request->title = $email->subject;
|
||||
$request->member = (int) $member->member_id;
|
||||
$request->email = $email->from;
|
||||
|
||||
/* Figure out who to notify for replies */
|
||||
$notify = array();
|
||||
foreach( $email->to as $to )
|
||||
{
|
||||
if ( $to !== $department->email )
|
||||
{
|
||||
$notify[] = array( 'type' => 'e', 'value' => $to );
|
||||
}
|
||||
}
|
||||
foreach( $email->cc as $cc )
|
||||
{
|
||||
if ( $cc !== $department->email )
|
||||
{
|
||||
$notify[] = array( 'type' => 'e', 'value' => $cc );
|
||||
}
|
||||
}
|
||||
|
||||
$request->notify = $notify;
|
||||
$request->save();
|
||||
|
||||
/* Create the reply */
|
||||
$reply = $this->_createReply( $email, $request, $member, $email->message . $email->quote, $email->from );
|
||||
static::makeAndClaimAttachments( $email->attachments, $reply, $member );
|
||||
static::storeAttachmentMappings( $email->mappedAttachments, $reply, $member );
|
||||
|
||||
/* Send confirmation email */
|
||||
if ( \IPS\Settings::i()->nexus_sout_autoreply )
|
||||
{
|
||||
$confirmationEmail = \IPS\Email::buildFromTemplate( 'nexus', 'emailConfirmation', array( $request ), \IPS\Email::TYPE_TRANSACTIONAL );
|
||||
switch ( \IPS\Settings::i()->nexus_sout_from )
|
||||
{
|
||||
case 'staff':
|
||||
case 'dpt':
|
||||
$fromName = $member->language()->get( 'nexus_department_' . $request->department->_id );
|
||||
break;
|
||||
default:
|
||||
$fromName = \IPS\Settings::i()->nexus_sout_from;
|
||||
break;
|
||||
}
|
||||
$confirmationEmail->send( $member->member_id ? $member : $email->from, [], [], $request->department->email, $fromName, [ 'Message-ID' => "<IPS-0-SR{$request->id}.{$request->email_key}-{$request->department->email}>" ] );
|
||||
}
|
||||
|
||||
/* Return */
|
||||
return array( $request, $reply );
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a basic support request object
|
||||
*
|
||||
* @param \IPS\Member $member The member it's from
|
||||
* @param \IPS\nexus\Support\Department $department The department to put it in
|
||||
* @return \IPS\nexus\Support\Request
|
||||
*/
|
||||
protected function _initRequest( \IPS\Member $member, \IPS\nexus\Support\Department $department )
|
||||
{
|
||||
$request = new \IPS\nexus\Support\Request;
|
||||
$request->department = $department;
|
||||
$request->status = \IPS\nexus\Support\Status::load( TRUE, 'status_default_member' );
|
||||
$request->severity = \IPS\nexus\Support\Severity::load( TRUE, 'sev_default' );
|
||||
$request->started = time();
|
||||
$request->last_reply = time();
|
||||
$request->last_reply_by = (int) $member->member_id;
|
||||
$request->last_new_reply = time();
|
||||
$request->replies = 1;
|
||||
return $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a basic support reply object
|
||||
*
|
||||
* @param \IPS\Email\Incoming\Email $email The email
|
||||
* @param \IPS\nexus\Support\Request $request The request it's for
|
||||
* @param \IPS\Member $member The member it's from
|
||||
* @param string $message The message body
|
||||
* @param string $emailFrom The email address it is from
|
||||
* @return \IPS\nexus\Support\Reply
|
||||
*/
|
||||
protected function _createReply( \IPS\Email\Incoming\Email $email, \IPS\nexus\Support\Request $request, \IPS\Member $member, $message, $emailFrom )
|
||||
{
|
||||
$reply = new \IPS\nexus\Support\Reply;
|
||||
$reply->request = $request->id;
|
||||
$reply->member = (int) $member->member_id;
|
||||
$reply->type = $reply::REPLY_EMAIL;
|
||||
$reply->post = $message;
|
||||
$reply->date = time();
|
||||
$reply->email = $emailFrom;
|
||||
$reply->cc = implode( ',', $email->cc );
|
||||
$reply->raw = $email->raw;
|
||||
$reply->save();
|
||||
return $reply;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this message was forwarded by a staff member, get the
|
||||
* email address it was sent to that staff member from (i.e.
|
||||
* the user who should show as creating the support request)
|
||||
*
|
||||
* @param \IPS\Email\Incoming\Email $email The email
|
||||
* @return bool
|
||||
*/
|
||||
protected function _originalSenderOfForwardedMessage( \IPS\Email\Incoming\Email $email )
|
||||
{
|
||||
$originallyFrom = NULL;
|
||||
if ( isset( $email->headers['original-recipient'] ) )
|
||||
{
|
||||
$originallyFrom = preg_replace( '/^.*;(.*)$/', '$1', $email->headers['original-recipient'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( preg_match( '/From:.+?(\b[A-Z0-9\._%+\-\']+@[A-Z0-9\.\-]+\.[A-Z]{2,9}\b)/i', $email->quote, $_matches ) )
|
||||
{
|
||||
$originallyFrom = $_matches[1];
|
||||
}
|
||||
}
|
||||
|
||||
return $originallyFrom;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make and claim attachments
|
||||
*
|
||||
* @param array $files \IPS\File objects
|
||||
* @param \IPS\nexus\Support\Reply $reply The support request reply
|
||||
* @param \IPS\Member $member The member it's from
|
||||
* @return void
|
||||
*/
|
||||
public static function makeAndClaimAttachments( array $files, \IPS\nexus\Support\Reply $reply, \IPS\Member $member )
|
||||
{
|
||||
$replacements = array();
|
||||
foreach ( $files as $file )
|
||||
{
|
||||
$attachment = $file->makeAttachment('', $member);
|
||||
if ( !$file->isImage() )
|
||||
{
|
||||
$replacements["<fileStore.core_Attachment>/{$file}"] = \IPS\Settings::i()->base_url . "applications/core/interface/file/attachment.php?id={$attachment['attach_id']}";
|
||||
if ( $attachment['attach_security_key'] )
|
||||
{
|
||||
$replacements["<fileStore.core_Attachment>/{$file}"] .= "&key={$attachment['attach_security_key']}";
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Db::i()->insert( 'core_attachments_map', array(
|
||||
'attachment_id' => $attachment['attach_id'],
|
||||
'location_key' => 'nexus_Support',
|
||||
'id1' => $reply->request,
|
||||
'id2' => $reply->id,
|
||||
) );
|
||||
}
|
||||
|
||||
if ( \count( $replacements ) )
|
||||
{
|
||||
foreach ( $replacements as $find => $replace )
|
||||
{
|
||||
$reply->post = str_replace( $find, $replace, $reply->post );
|
||||
}
|
||||
$reply->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store attachment mappings if a previous attachment was reused in this email
|
||||
*
|
||||
* @param array $attachments Attachment IDs
|
||||
* @param \IPS\nexus\Support\Reply $reply The support request reply
|
||||
* @param \IPS\Member $member The member it's from
|
||||
* @return void
|
||||
*/
|
||||
public static function storeAttachmentMappings( array $attachments, \IPS\nexus\Support\Reply $reply, \IPS\Member $member )
|
||||
{
|
||||
foreach ( $attachments as $id )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_attachments_map', array(
|
||||
'attachment_id' => $id,
|
||||
'location_key' => 'nexus_Support',
|
||||
'id1' => $reply->request,
|
||||
'id2' => $reply->id,
|
||||
) );
|
||||
}
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -12,28 +12,26 @@
|
||||
namespace IPS\nexus\extensions\core\IpAddresses;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Db;
|
||||
use IPS\Db\Select;
|
||||
use IPS\Extensions\IpAddressesAbstract;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\nexus\Payout;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* IP Address Lookup extension
|
||||
*/
|
||||
class _Payouts
|
||||
class Payouts extends IpAddressesAbstract
|
||||
{
|
||||
/**
|
||||
* Supported in the ACP IP address lookup tool?
|
||||
*
|
||||
* @return bool
|
||||
* @note If the method does not exist in an extension, the result is presumed to be TRUE
|
||||
*/
|
||||
public function supportedInAcp()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Supported in the ModCP IP address lookup tool?
|
||||
*
|
||||
@@ -49,18 +47,18 @@ class _Payouts
|
||||
* Find Records by IP
|
||||
*
|
||||
* @param string $ip The IP Address
|
||||
* @param \IPS\Http\Url $baseUrl URL table will be displayed on or NULL to return a count
|
||||
* @return \IPS\Helpers\Table|null
|
||||
* @param Url|null $baseUrl URL table will be displayed on or NULL to return a count
|
||||
* @return string|int|null
|
||||
*/
|
||||
public function findByIp( $ip, \IPS\Http\Url $baseUrl = NULL )
|
||||
public function findByIp( string $ip, ?Url $baseUrl = NULL ): string|int|null
|
||||
{
|
||||
/* Return count */
|
||||
if ( $baseUrl === NULL )
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_payouts', array( "po_ip LIKE ?", $ip ) )->first();
|
||||
return Db::i()->select( 'COUNT(*)', 'nexus_payouts', array( "po_ip LIKE ?", $ip ) )->first();
|
||||
}
|
||||
|
||||
$table = \IPS\nexus\Payout::table( array( "po_ip LIKE ?", $ip ), $baseUrl );
|
||||
$table = Payout::table( array( "po_ip LIKE ?", $ip ), $baseUrl );
|
||||
$table->include[] = 'po_ip';
|
||||
|
||||
return (string) $table;
|
||||
@@ -80,11 +78,11 @@ class _Payouts
|
||||
...
|
||||
);
|
||||
* @endcode
|
||||
* @param \IPS\Member $member The member
|
||||
* @return array|NULL
|
||||
* @param Member $member The member
|
||||
* @return array|Select
|
||||
*/
|
||||
public function findByMember( $member )
|
||||
public function findByMember( Member $member ): array|Select
|
||||
{
|
||||
return \IPS\Db::i()->select( "po_ip AS ip, count(*) AS count, MIN(po_date) AS first, MAX(po_date) AS last", 'nexus_payouts', array( "po_member=?", $member->member_id ), NULL, NULL, "po_ip" )->setKeyField( 'ip' );
|
||||
return Db::i()->select( "po_ip AS ip, count(*) AS count, MIN(po_date) AS first, MAX(po_date) AS last", 'nexus_payouts', array( "po_member=?", $member->member_id ), NULL, NULL, "po_ip" )->setKeyField( 'ip' );
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief IP Address Lookup extension
|
||||
* @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 18 Sep 2014
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\IpAddresses;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* IP Address Lookup extension
|
||||
*/
|
||||
class _Support
|
||||
{
|
||||
/**
|
||||
* Supported in the ACP IP address lookup tool?
|
||||
*
|
||||
* @return bool
|
||||
* @note If the method does not exist in an extension, the result is presumed to be TRUE
|
||||
*/
|
||||
public function supportedInAcp()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Supported in the ModCP IP address lookup tool?
|
||||
*
|
||||
* @return bool
|
||||
* @note If the method does not exist in an extension, the result is presumed to be TRUE
|
||||
*/
|
||||
public function supportedInModCp(): bool
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find Records by IP
|
||||
*
|
||||
* @param string $ip The IP Address
|
||||
* @param \IPS\Http\Url $baseUrl URL table will be displayed on or NULL to return a count
|
||||
* @return \IPS\Helpers\Table|null
|
||||
*/
|
||||
public function findByIp( $ip, \IPS\Http\Url $baseUrl = NULL )
|
||||
{
|
||||
/* Return count */
|
||||
if ( $baseUrl === NULL )
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_support_replies', array( "reply_ip_address LIKE ?", $ip ) )->first();
|
||||
}
|
||||
|
||||
$class = new \IPS\core\extensions\core\IpAddresses\Content;
|
||||
$class->class = 'IPS\nexus\Support\Reply';
|
||||
return $class->findByIp( $ip, $baseUrl );
|
||||
}
|
||||
|
||||
/**
|
||||
* Find IPs by Member
|
||||
*
|
||||
* @code
|
||||
return array(
|
||||
'::1' => array(
|
||||
'ip' => '::1'// string (IP Address)
|
||||
'count' => ... // int (number of times this member has used this IP)
|
||||
'first' => ... // int (timestamp of first use)
|
||||
'last' => ... // int (timestamp of most recent use)
|
||||
),
|
||||
...
|
||||
);
|
||||
* @endcode
|
||||
* @param \IPS\Member $member The member
|
||||
* @return array|NULL
|
||||
*/
|
||||
public function findByMember( $member )
|
||||
{
|
||||
$class = new \IPS\core\extensions\core\IpAddresses\Content;
|
||||
$class->class = 'IPS\nexus\Support\Reply';
|
||||
return $class->findByMember( $member );
|
||||
}
|
||||
}
|
||||
@@ -12,28 +12,26 @@
|
||||
namespace IPS\nexus\extensions\core\IpAddresses;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Db;
|
||||
use IPS\Db\Select;
|
||||
use IPS\Extensions\IpAddressesAbstract;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\nexus\Transaction;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* IP Address Lookup extension
|
||||
*/
|
||||
class _Transactions
|
||||
class Transactions extends IpAddressesAbstract
|
||||
{
|
||||
/**
|
||||
* Supported in the ACP IP address lookup tool?
|
||||
*
|
||||
* @return bool
|
||||
* @note If the method does not exist in an extension, the result is presumed to be TRUE
|
||||
*/
|
||||
public function supportedInAcp()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Supported in the ModCP IP address lookup tool?
|
||||
*
|
||||
@@ -49,18 +47,18 @@ class _Transactions
|
||||
* Find Records by IP
|
||||
*
|
||||
* @param string $ip The IP Address
|
||||
* @param \IPS\Http\Url $baseUrl URL table will be displayed on or NULL to return a count
|
||||
* @return \IPS\Helpers\Table|null
|
||||
* @param Url|null $baseUrl URL table will be displayed on or NULL to return a count
|
||||
* @return string|int|null
|
||||
*/
|
||||
public function findByIp( $ip, \IPS\Http\Url $baseUrl = NULL )
|
||||
public function findByIp( string $ip, ?Url $baseUrl = NULL ): string|int|null
|
||||
{
|
||||
/* Return count */
|
||||
if ( $baseUrl === NULL )
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_transactions', array( "t_ip LIKE ?", $ip ) )->first();
|
||||
return Db::i()->select( 'COUNT(*)', 'nexus_transactions', array( "t_ip LIKE ?", $ip ) )->first();
|
||||
}
|
||||
|
||||
$table = \IPS\nexus\Transaction::table( array( array( "t_ip LIKE ?", $ip ) ), $baseUrl );
|
||||
$table = Transaction::table( array( array( "t_ip LIKE ?", $ip ) ), $baseUrl );
|
||||
$table->include[] = 't_ip';
|
||||
|
||||
return (string) $table;
|
||||
@@ -80,11 +78,11 @@ class _Transactions
|
||||
...
|
||||
);
|
||||
* @endcode
|
||||
* @param \IPS\Member $member The member
|
||||
* @return array|NULL
|
||||
* @param Member $member The member
|
||||
* @return array|Select
|
||||
*/
|
||||
public function findByMember( $member )
|
||||
public function findByMember( Member $member ): array|Select
|
||||
{
|
||||
return \IPS\Db::i()->select( "t_ip AS ip, count(*) AS count, MIN(t_date) AS first, MAX(t_date) AS last", 'nexus_transactions', array( "t_member=?", $member->member_id ), NULL, NULL, "t_ip" )->setKeyField( 'ip' );
|
||||
return Db::i()->select( "t_ip AS ip, count(*) AS count, MIN(t_date) AS first, MAX(t_date) AS last", 'nexus_transactions', array( "t_member=?", $member->member_id ), NULL, NULL, "t_ip" )->setKeyField( 'ip' );
|
||||
}
|
||||
}
|
||||
@@ -12,30 +12,46 @@
|
||||
namespace IPS\nexus\extensions\core\LiveSearch;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\core\extensions\core\LiveSearch\Members;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Extensions\LiveSearchAbstract;
|
||||
use IPS\Member;
|
||||
use IPS\nexus\Customer;
|
||||
use IPS\nexus\Invoice;
|
||||
use IPS\nexus\Purchase;
|
||||
use IPS\nexus\Purchase\LicenseKey;
|
||||
use IPS\nexus\Transaction;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use function defined;
|
||||
use function is_numeric;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ACP Live Search Extension
|
||||
*/
|
||||
class _Nexus
|
||||
class Nexus extends LiveSearchAbstract
|
||||
{
|
||||
/**
|
||||
* Check we have access
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAccess()
|
||||
public function hasAccess(): bool
|
||||
{
|
||||
return \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'invoices_manage' )
|
||||
or \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'transactions_manage' )
|
||||
or \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'purchases_view' )
|
||||
or \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'support', 'requests_manage' )
|
||||
or \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customers_view' )
|
||||
or \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'lkeys_view' );
|
||||
return Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'invoices_manage' )
|
||||
or Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'transactions_manage' )
|
||||
or Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'purchases_view' )
|
||||
or Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customers_view' )
|
||||
or Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'lkeys_view' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,69 +60,55 @@ class _Nexus
|
||||
* @param string $searchTerm Search Term
|
||||
* @return array Array of results
|
||||
*/
|
||||
public function getResults( $searchTerm )
|
||||
public function getResults( string $searchTerm ): array
|
||||
{
|
||||
$results = array();
|
||||
|
||||
/* Numeric */
|
||||
if ( \is_numeric( $searchTerm ) )
|
||||
if ( is_numeric( $searchTerm ) )
|
||||
{
|
||||
/* Invoice */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'invoices_manage' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'invoices_manage' ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$results[] = \IPS\Theme::i()->getTemplate('livesearch', 'nexus')->invoice( \IPS\nexus\Invoice::load( $searchTerm ) );
|
||||
$results[] = Theme::i()->getTemplate('livesearch', 'nexus')->invoice( Invoice::load( $searchTerm ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
catch ( OutOfRangeException ) { }
|
||||
}
|
||||
|
||||
/* Transaction */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'transactions_manage' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'transactions_manage' ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$results[] = \IPS\Theme::i()->getTemplate('livesearch', 'nexus')->transaction( \IPS\nexus\Transaction::load( $searchTerm ) );
|
||||
$results[] = Theme::i()->getTemplate('livesearch', 'nexus')->transaction( Transaction::load( $searchTerm ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
catch ( OutOfRangeException ) { }
|
||||
}
|
||||
|
||||
/* Purchase */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'purchases_view' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'purchases_view' ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$results[] = \IPS\Theme::i()->getTemplate('livesearch', 'nexus')->purchase( \IPS\nexus\Purchase::load( $searchTerm ) );
|
||||
$results[] = Theme::i()->getTemplate('livesearch', 'nexus')->purchase( Purchase::load( $searchTerm ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
|
||||
/* Support */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'support', 'requests_manage' ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$supportRequest = \IPS\nexus\Support\Request::load( $searchTerm );
|
||||
if ( $supportRequest->canView() )
|
||||
{
|
||||
$results[] = \IPS\Theme::i()->getTemplate('livesearch', 'nexus')->support( $supportRequest );
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
catch ( OutOfRangeException ) { }
|
||||
}
|
||||
|
||||
/* Customer */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customers_view' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customers_view' ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$customer = \IPS\nexus\Customer::load( $searchTerm );
|
||||
$customer = Customer::load( $searchTerm );
|
||||
if ( $customer->member_id )
|
||||
{
|
||||
$results[] = \IPS\Theme::i()->getTemplate('livesearch', 'nexus')->customer( $customer );
|
||||
$results[] = Theme::i()->getTemplate('livesearch', 'nexus')->customer( $customer );
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
catch ( OutOfRangeException ) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,38 +116,38 @@ class _Nexus
|
||||
else
|
||||
{
|
||||
/* License Key */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'lkeys_view' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'lkeys_view' ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$results[] = \IPS\Theme::i()->getTemplate('livesearch', 'nexus')->licensekey( \IPS\nexus\Purchase\LicenseKey::load( $searchTerm ) );
|
||||
$results[] = Theme::i()->getTemplate('livesearch', 'nexus')->licensekey( LicenseKey::load( $searchTerm ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
catch ( OutOfRangeException ) { }
|
||||
}
|
||||
|
||||
/* Customers */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customers_view' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customers_view' ) )
|
||||
{
|
||||
if( \IPS\core\extensions\core\LiveSearch\Members::canPerformInlineSearch() )
|
||||
if( Members::canPerformInlineSearch() )
|
||||
{
|
||||
$query = \IPS\Db::i()->select( '*', 'nexus_customers', array( \IPS\Db::i()->like( array( 'core_members.name', 'core_members.email', "CONCAT( LOWER( nexus_customers.cm_first_name ), ' ', LOWER( nexus_customers.cm_last_name ) )" ), $searchTerm, TRUE, TRUE, TRUE ) ), NULL, 50 )->join( 'core_members', 'core_members.member_id=nexus_customers.member_id' );
|
||||
$query = Db::i()->select( '*', 'nexus_customers', array( Db::i()->like( array( 'core_members.name', 'core_members.email', "CONCAT( LOWER( nexus_customers.cm_first_name ), ' ', LOWER( nexus_customers.cm_last_name ) )" ), $searchTerm, TRUE, TRUE, TRUE ) ), NULL, 50 )->join( 'core_members', 'core_members.member_id=nexus_customers.member_id' );
|
||||
}
|
||||
else
|
||||
{
|
||||
$query = \IPS\Db::i()->select( '*', 'nexus_customers', array( \IPS\Db::i()->like( array( 'core_members.name', 'core_members.email', 'nexus_customers.cm_first_name', 'nexus_customers.cm_last_name', "CONCAT( LOWER( nexus_customers.cm_first_name ), ' ', LOWER( nexus_customers.cm_last_name ) )" ), $searchTerm, TRUE, TRUE, FALSE ) ), NULL, 50 )->join( 'core_members', 'core_members.member_id=nexus_customers.member_id' );
|
||||
$query = Db::i()->select( '*', 'nexus_customers', array( Db::i()->like( array( 'core_members.name', 'core_members.email', 'nexus_customers.cm_first_name', 'nexus_customers.cm_last_name', "CONCAT( LOWER( nexus_customers.cm_first_name ), ' ', LOWER( nexus_customers.cm_last_name ) )" ), $searchTerm ) ), NULL, 50 )->join( 'core_members', 'core_members.member_id=nexus_customers.member_id' );
|
||||
}
|
||||
|
||||
foreach ( new \IPS\Patterns\ActiveRecordIterator( $query, 'IPS\nexus\Customer' ) as $customer )
|
||||
foreach ( new ActiveRecordIterator( $query, 'IPS\nexus\Customer' ) as $customer )
|
||||
{
|
||||
$results[] = \IPS\Theme::i()->getTemplate('livesearch', 'nexus')->customer( $customer );
|
||||
$results[] = Theme::i()->getTemplate('livesearch', 'nexus')->customer( $customer );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* For either, search for transaction gateway IDs */
|
||||
foreach ( \IPS\Db::i()->select( '*', 'nexus_transactions', array( 't_gw_id=?', $searchTerm ) ) as $transactionData )
|
||||
foreach ( Db::i()->select( '*', 'nexus_transactions', array( 't_gw_id=?', $searchTerm ) ) as $transactionData )
|
||||
{
|
||||
$results[] = \IPS\Theme::i()->getTemplate( 'livesearch', 'nexus' )->transaction( \IPS\nexus\Transaction::constructFromData( $transactionData ) );
|
||||
$results[] = Theme::i()->getTemplate( 'livesearch', 'nexus' )->transaction( Transaction::constructFromData( $transactionData ) );
|
||||
}
|
||||
|
||||
/* Return */
|
||||
@@ -157,8 +159,8 @@ class _Nexus
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDefault()
|
||||
public function isDefault(): bool
|
||||
{
|
||||
return \IPS\Dispatcher::i()->application->directory == 'nexus';
|
||||
return Dispatcher::i()->application->directory == 'nexus';
|
||||
}
|
||||
}
|
||||
@@ -12,24 +12,30 @@
|
||||
namespace IPS\nexus\extensions\core\MFAArea;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Extensions\MFAAreaAbstract;
|
||||
use IPS\Settings;
|
||||
use function count;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Multi-Factor Authentication Area
|
||||
*/
|
||||
class _AccountCredit
|
||||
class AccountCredit extends MFAAreaAbstract
|
||||
{
|
||||
/**
|
||||
* Is this area available and should show in the ACP configuration?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEnabled()
|
||||
public function isEnabled(): bool
|
||||
{
|
||||
return ( \IPS\Settings::i()->nexus_min_topup or \count( json_decode( \IPS\Settings::i()->nexus_payout, TRUE ) ) );
|
||||
return ( Settings::i()->nexus_min_topup or count( json_decode( Settings::i()->nexus_payout, TRUE ) ) );
|
||||
}
|
||||
}
|
||||
@@ -12,23 +12,27 @@
|
||||
namespace IPS\nexus\extensions\core\MFAArea;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Extensions\MFAAreaAbstract;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Multi-Factor Authentication Area
|
||||
*/
|
||||
class _Addresses
|
||||
class Addresses extends MFAAreaAbstract
|
||||
{
|
||||
/**
|
||||
* Is this area available and should show in the ACP configuration?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEnabled()
|
||||
public function isEnabled(): bool
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -12,23 +12,27 @@
|
||||
namespace IPS\nexus\extensions\core\MFAArea;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Extensions\MFAAreaAbstract;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Multi-Factor Authentication Area
|
||||
*/
|
||||
class _Alternatives
|
||||
class Alternatives extends MFAAreaAbstract
|
||||
{
|
||||
/**
|
||||
* Is this area available and should show in the ACP configuration?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEnabled()
|
||||
public function isEnabled(): bool
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -12,24 +12,29 @@
|
||||
namespace IPS\nexus\extensions\core\MFAArea;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Extensions\MFAAreaAbstract;
|
||||
use IPS\Settings;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Multi-Factor Authentication Area
|
||||
*/
|
||||
class _BillingAgreements
|
||||
class BillingAgreements extends MFAAreaAbstract
|
||||
{
|
||||
/**
|
||||
* Is this area available and should show in the ACP configuration?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEnabled()
|
||||
public function isEnabled(): bool
|
||||
{
|
||||
return \IPS\Settings::i()->billing_agreement_gateways;
|
||||
return Settings::i()->billing_agreement_gateways;
|
||||
}
|
||||
}
|
||||
@@ -12,23 +12,27 @@
|
||||
namespace IPS\nexus\extensions\core\MFAArea;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Extensions\MFAAreaAbstract;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Multi-Factor Authentication Area
|
||||
*/
|
||||
class _BillingInfo
|
||||
class BillingInfo extends MFAAreaAbstract
|
||||
{
|
||||
/**
|
||||
* Is this area available and should show in the ACP configuration?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEnabled()
|
||||
public function isEnabled(): bool
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -12,24 +12,29 @@
|
||||
namespace IPS\nexus\extensions\core\MFAArea;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Extensions\MFAAreaAbstract;
|
||||
use IPS\Settings;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Multi-Factor Authentication Area
|
||||
*/
|
||||
class _Cards
|
||||
class Cards extends MFAAreaAbstract
|
||||
{
|
||||
/**
|
||||
* Is this area available and should show in the ACP configuration?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEnabled()
|
||||
public function isEnabled(): bool
|
||||
{
|
||||
return \IPS\Settings::i()->card_storage_gateways;
|
||||
return Settings::i()->card_storage_gateways;
|
||||
}
|
||||
}
|
||||
@@ -12,38 +12,65 @@
|
||||
namespace IPS\nexus\extensions\core\MemberACPProfileBlocks;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use DateInterval;
|
||||
use Exception;
|
||||
use IPS\core\MemberACPProfile\TabbedBlock;
|
||||
use IPS\DateTime;
|
||||
use IPS\Helpers\Chart;
|
||||
use IPS\Helpers\Table\Custom;
|
||||
use IPS\Helpers\Table\Db;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\nexus\Customer;
|
||||
use IPS\nexus\Gateway;
|
||||
use IPS\nexus\Money;
|
||||
use IPS\nexus\Purchase;
|
||||
use IPS\nexus\Subscription;
|
||||
use IPS\nexus\Transaction;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
use IPS\Request;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function is_null;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ACP Member Profile Block
|
||||
*
|
||||
* @property Customer $member
|
||||
*/
|
||||
class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
class AccountInformation extends TabbedBlock
|
||||
{
|
||||
/**
|
||||
* Get Tab Names
|
||||
*
|
||||
* @return string
|
||||
* @return array
|
||||
*/
|
||||
public function tabs()
|
||||
public function tabs(): array
|
||||
{
|
||||
$tabs = array(
|
||||
'overview' => array(
|
||||
'icon' => 'ellipsis-h',
|
||||
'icon' => 'address-card',
|
||||
'count' => 0
|
||||
)
|
||||
);
|
||||
if ( \count( \IPS\nexus\Gateway::cardStorageGateways() ) )
|
||||
if ( count( Gateway::cardStorageGateways() ) )
|
||||
{
|
||||
$tabs['cards'] = array(
|
||||
'icon' => 'credit-card',
|
||||
'count' => \IPS\Db::i()->select( 'COUNT(*)', 'nexus_customer_cards', array( 'card_member=?', $this->member->member_id ) )->first()
|
||||
);
|
||||
}
|
||||
if ( \count( \IPS\nexus\Gateway::billingAgreementGateways() ) )
|
||||
if ( count( Gateway::billingAgreementGateways() ) )
|
||||
{
|
||||
$tabs['paypal'] = array(
|
||||
'icon' => 'paypal',
|
||||
@@ -61,44 +88,44 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
/**
|
||||
* Get output: OVERVIEW
|
||||
*
|
||||
* @return string
|
||||
* @return mixed
|
||||
*/
|
||||
protected function _overview()
|
||||
protected function _overview(): mixed
|
||||
{
|
||||
/* Sparkline */
|
||||
$sparkline = NULL;
|
||||
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customers_view_statistics' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customers_view_statistics' ) )
|
||||
{
|
||||
$rows = array();
|
||||
$oneYearAgo = \IPS\DateTime::create()->sub( new \DateInterval( 'P1Y' ) );
|
||||
$oneYearAgo = DateTime::create()->sub( new DateInterval( 'P1Y' ) );
|
||||
$date = clone $oneYearAgo;
|
||||
$endOfLastMonth = mktime( 23, 59, 59, date( 'n' ) - 1, date( 't' ), date( 'Y' ) );
|
||||
while ( $date->getTimestamp() < $endOfLastMonth )
|
||||
{
|
||||
foreach ( \IPS\nexus\Money::currencies() as $currency )
|
||||
foreach ( Money::currencies() as $currency )
|
||||
{
|
||||
$rows[$date->format( 'n Y' )][$currency] = 0;
|
||||
}
|
||||
$date->add( new \DateInterval( 'P1M' ) );
|
||||
$date->add( new DateInterval( 'P1M' ) );
|
||||
}
|
||||
$sparkline = new \IPS\Helpers\Chart;
|
||||
foreach ( \IPS\Db::i()->select( 'DATE_FORMAT( FROM_UNIXTIME(t_date), \'%c %Y\' ) AS time, SUM(t_amount)-SUM(t_partial_refund) AS amount, t_currency', 'nexus_transactions', array(array("t_member=? AND ( t_status=? OR t_status=? ) AND t_method>0 AND t_date>? AND t_date<?", $this->member->member_id, \IPS\nexus\Transaction::STATUS_PAID, \IPS\nexus\Transaction::STATUS_PART_REFUNDED, $oneYearAgo->getTimestamp(), time())), NULL, NULL, array('time', 't_currency') ) as $row )
|
||||
$sparkline = new Chart;
|
||||
foreach ( \IPS\Db::i()->select( 'DATE_FORMAT( FROM_UNIXTIME(t_date), \'%c %Y\' ) AS time, SUM(t_amount)-SUM(t_partial_refund) AS amount, t_currency', 'nexus_transactions', array(array("t_member=? AND ( t_status=? OR t_status=? ) AND t_method>0 AND t_date>? AND t_date<?", $this->member->member_id, Transaction::STATUS_PAID, Transaction::STATUS_PART_REFUNDED, $oneYearAgo->getTimestamp(), time())), NULL, NULL, array('time', 't_currency') ) as $row )
|
||||
{
|
||||
if ( isset( $rows[$row['time']][$row['t_currency']] ) ) // Currency may no longer exist
|
||||
{
|
||||
$rows[$row['time']][$row['t_currency']] += $row['amount'];
|
||||
}
|
||||
}
|
||||
$sparkline->addHeader( \IPS\Member::loggedIn()->language()->addToStack( 'date' ), 'date' );
|
||||
foreach ( \IPS\nexus\Money::currencies() as $currency )
|
||||
$sparkline->addHeader( Member::loggedIn()->language()->addToStack( 'date' ), 'date' );
|
||||
foreach ( Money::currencies() as $currency )
|
||||
{
|
||||
$sparkline->addHeader( $currency, 'number' );
|
||||
}
|
||||
foreach ( $rows as $time => $row )
|
||||
{
|
||||
$datetime = new \IPS\DateTime;
|
||||
$datetime->setTime( 0, 0, 0 );
|
||||
$datetime = new DateTime;
|
||||
$datetime->setTime( 0, 0 );
|
||||
$exploded = explode( ' ', $time );
|
||||
$datetime->setDate( $exploded[1], $exploded[0], 1 );
|
||||
|
||||
@@ -145,20 +172,21 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
$addressCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_customer_addresses', array( '`member`=?', $this->member->member_id ) )->first();
|
||||
|
||||
/* Display */
|
||||
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->accountInformationOverview( $this->member, $sparkline, $primaryBillingAddress, $addressCount );
|
||||
return Theme::i()->getTemplate( 'customers', 'nexus' )->accountInformationOverview( $this->member, $sparkline, $primaryBillingAddress, $addressCount );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get output: STORED PAYMENT METHODS
|
||||
*
|
||||
* @param bool $edit Edit view?
|
||||
* @return string
|
||||
* @return mixed
|
||||
*/
|
||||
protected function _cards( $edit = FALSE )
|
||||
protected function _cards( bool $edit = FALSE ): mixed
|
||||
{
|
||||
$cards = array();
|
||||
foreach ( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_customer_cards', array( 'card_member=?', $this->member->member_id ), NULL, $edit ? NULL : 10 ), 'IPS\nexus\Customer\CreditCard' ) as $card )
|
||||
foreach ( new ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_customer_cards', array( 'card_member=?', $this->member->member_id ), NULL, $edit ? NULL : 10 ), 'IPS\nexus\Customer\CreditCard' ) as $card )
|
||||
{
|
||||
/* @var Customer\CreditCard $card */
|
||||
try
|
||||
{
|
||||
$cardData = $card->card;
|
||||
@@ -167,21 +195,21 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
'card_type' => $cardData->type,
|
||||
'card_member' => $card->member->member_id,
|
||||
'card_number' => $cardData->lastFour ?: $cardData->number,
|
||||
'card_expire' => ( !\is_null( $cardData->expMonth ) AND !\is_null( $cardData->expYear ) ) ? str_pad( $cardData->expMonth , 2, '0', STR_PAD_LEFT ). '/' . $cardData->expYear : NULL
|
||||
'card_expire' => ( !is_null( $cardData->expMonth ) AND !is_null( $cardData->expYear ) ) ? str_pad( $cardData->expMonth , 2, '0', STR_PAD_LEFT ). '/' . $cardData->expYear : NULL
|
||||
);
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
catch ( Exception ) { }
|
||||
}
|
||||
$cards = new \IPS\Helpers\Table\Custom( $cards, $this->member->acpUrl()->setQueryString( 'view', 'cards' ) );
|
||||
$cards = new Custom( $cards, $this->member->acpUrl()->setQueryString( 'view', 'cards' ) );
|
||||
|
||||
if ( \IPS\nexus\Gateway::cardStorageGateways( TRUE ) )
|
||||
if ( Gateway::cardStorageGateways( TRUE ) )
|
||||
{
|
||||
$cards->rootButtons = array(
|
||||
'add' => array(
|
||||
'link' => \IPS\Http\Url::internal("app=nexus&module=customers&controller=view&id={$this->member->member_id}")->setQueryString( 'do', 'addCard' ),
|
||||
'link' => Url::internal("app=nexus&module=customers&controller=view&id={$this->member->member_id}")->setQueryString( 'do', 'addCard' ),
|
||||
'title' => 'add',
|
||||
'icon' => 'plus',
|
||||
'data' => array( 'ipsDialog' => true, 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('add_card') )
|
||||
'data' => array( 'ipsDialog' => true, 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('add_card') )
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -189,7 +217,7 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
{
|
||||
return array(
|
||||
'delete' => array(
|
||||
'link' => \IPS\Http\Url::internal("app=nexus&module=customers&controller=view&id={$this->member->member_id}")->setQueryString( array( 'do' => 'deleteCard', 'card_id' => $row['id'] ) ),
|
||||
'link' => Url::internal("app=nexus&module=customers&controller=view&id={$this->member->member_id}")->setQueryString( array( 'do' => 'deleteCard', 'card_id' => $row['id'] ) ),
|
||||
'title' => 'delete',
|
||||
'icon' => 'times-circle',
|
||||
'data' => array( 'delete' => '' )
|
||||
@@ -199,18 +227,18 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
|
||||
if ( $edit )
|
||||
{
|
||||
$cards->tableTemplate = array( \IPS\Theme::i()->getTemplate( 'customers', 'nexus' ), 'cardsTable' );
|
||||
$cards->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'customers', 'nexus' ), 'cardsTableRows' );
|
||||
$cards->tableTemplate = array( Theme::i()->getTemplate( 'customers', 'nexus' ), 'cardsTable' );
|
||||
$cards->rowsTemplate = array( Theme::i()->getTemplate( 'customers', 'nexus' ), 'cardsTableRows' );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->customerPopup( $cards );
|
||||
return Theme::i()->getTemplate( 'customers', 'nexus' )->customerPopup( $cards );
|
||||
}
|
||||
else
|
||||
{
|
||||
$cards->tableTemplate = array( \IPS\Theme::i()->getTemplate( 'customers', 'nexus' ), 'cardsOverview' );
|
||||
$cards->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'customers', 'nexus' ), 'cardsOverviewRows' );
|
||||
$cards->tableTemplate = array( Theme::i()->getTemplate( 'customers', 'nexus' ), 'cardsOverview' );
|
||||
$cards->rowsTemplate = array( Theme::i()->getTemplate( 'customers', 'nexus' ), 'cardsOverviewRows' );
|
||||
|
||||
$cardCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_customer_cards', array( 'card_member=?', $this->member->member_id ) )->first();
|
||||
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->accountInformationTablePreview( $this->member, $cards, \IPS\Member::loggedIn()->language()->addToStack( 'num_credit_card', FALSE, array( 'pluralize' => array( $cardCount ) ) ), 'cards' );
|
||||
return Theme::i()->getTemplate( 'customers', 'nexus' )->accountInformationTablePreview( $this->member, $cards, Member::loggedIn()->language()->addToStack( 'num_credit_card', FALSE, array( 'pluralize' => array( $cardCount ) ) ), 'cards' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,9 +246,9 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
* Get output: BILLING AGREEMENTS
|
||||
*
|
||||
* @param bool $edit Edit view?
|
||||
* @return string
|
||||
* @return mixed
|
||||
*/
|
||||
protected function _paypal( $edit = FALSE )
|
||||
protected function _paypal( bool $edit = FALSE ): mixed
|
||||
{
|
||||
$billingAgreementCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_billing_agreements', array( 'ba_member=? AND ba_canceled=0', $this->member->member_id ) )->first();
|
||||
$billingAgreements = array();
|
||||
@@ -233,20 +261,20 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
'next_cycle' => $billingAgreement['ba_next_cycle'],
|
||||
);
|
||||
}
|
||||
$billingAgreements = new \IPS\Helpers\Table\Custom( $billingAgreements, $this->member->acpUrl()->setQueryString( 'view', 'billingagreements' ) );
|
||||
$billingAgreements = new Custom( $billingAgreements, $this->member->acpUrl()->setQueryString( 'view', 'billingagreements' ) );
|
||||
$billingAgreements->parsers = array(
|
||||
'started' => function( $val ) {
|
||||
return $val ? \IPS\DateTime::ts( $val )->relative() : null;
|
||||
return $val ? DateTime::ts( $val )->relative() : null;
|
||||
},
|
||||
'next_cycle' => function( $val ) {
|
||||
return $val ? \IPS\DateTime::ts( $val )->relative() : null;
|
||||
return $val ? DateTime::ts( $val )->relative() : null;
|
||||
},
|
||||
);
|
||||
$billingAgreements->rowButtons = function( $row, $id )
|
||||
{
|
||||
return array(
|
||||
'view' => array(
|
||||
'link' => \IPS\Http\Url::internal("app=nexus&module=payments&controller=billingagreements&id={$id}"),
|
||||
'link' => Url::internal("app=nexus&module=payments&controller=billingagreements&id={$id}"),
|
||||
'title' => 'view',
|
||||
'icon' => 'search',
|
||||
)
|
||||
@@ -256,14 +284,14 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
{
|
||||
$billingAgreements->exclude = array( 'id', 'last_transaction_currency' );
|
||||
$billingAgreements->langPrefix = 'ba_';
|
||||
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->customerPopup( $billingAgreements );
|
||||
return Theme::i()->getTemplate( 'customers', 'nexus' )->customerPopup( $billingAgreements );
|
||||
}
|
||||
else
|
||||
{
|
||||
$billingAgreements->tableTemplate = array( \IPS\Theme::i()->getTemplate( 'customers', 'nexus' ), 'billingAgreementsOverview' );
|
||||
$billingAgreements->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'customers', 'nexus' ), 'billingAgreementsOverviewRows' );
|
||||
$billingAgreements->tableTemplate = array( Theme::i()->getTemplate( 'customers', 'nexus' ), 'billingAgreementsOverview' );
|
||||
$billingAgreements->rowsTemplate = array( Theme::i()->getTemplate( 'customers', 'nexus' ), 'billingAgreementsOverviewRows' );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->accountInformationTablePreview( $this->member, $billingAgreements, \IPS\Member::loggedIn()->language()->addToStack( 'num_billing_agreements', FALSE, array( 'pluralize' => array( $billingAgreementCount ) ) ), 'paypal' );
|
||||
return Theme::i()->getTemplate( 'customers', 'nexus' )->accountInformationTablePreview( $this->member, $billingAgreements, Member::loggedIn()->language()->addToStack( 'num_billing_agreements', FALSE, array( 'pluralize' => array( $billingAgreementCount ) ) ), 'paypal' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,24 +299,24 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
* Get output: ALTERNATE CONTACTS
|
||||
*
|
||||
* @param bool $edit Edit view?
|
||||
* @return string
|
||||
* @return mixed
|
||||
*/
|
||||
protected function _alts( $edit = FALSE )
|
||||
protected function _alts( bool $edit = FALSE ): mixed
|
||||
{
|
||||
$altContactCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_alternate_contacts', array( 'main_id=?', $this->member->member_id ) )->first();
|
||||
$alternativeContacts = new \IPS\Helpers\Table\Db( 'nexus_alternate_contacts', $this->member->acpUrl()->setQueryString( 'view', 'alternatives' ), array( 'main_id=?', $this->member->member_id ) );
|
||||
$alternativeContacts = new Db( 'nexus_alternate_contacts', $this->member->acpUrl()->setQueryString( 'view', 'alternatives' ), array( 'main_id=?', $this->member->member_id ) );
|
||||
$alternativeContacts->langPrefix = 'altcontactTable_';
|
||||
$alternativeContacts->include = array( 'alt_id', 'purchases', 'billing', 'support' );
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customers_edit_details' ) )
|
||||
$alternativeContacts->include = array( 'alt_id', 'purchases', 'billing' );
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customers_edit_details' ) )
|
||||
{
|
||||
$alternativeContacts->parsers = array(
|
||||
'alt_id' => function( $val )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'nexus' )->userLink( \IPS\nexus\Customer::load( $val ) );
|
||||
return Theme::i()->getTemplate( 'global', 'nexus' )->userLink( Customer::load( $val ) );
|
||||
},
|
||||
'email' => function ( $val, $row )
|
||||
{
|
||||
return htmlspecialchars( \IPS\nexus\Customer::load( $row['alt_id'] )->email, ENT_DISALLOWED, 'UTF-8', FALSE );
|
||||
return htmlspecialchars( Customer::load( $row['alt_id'] )->email, ENT_DISALLOWED, 'UTF-8', FALSE );
|
||||
},
|
||||
'purchases' => function( $val )
|
||||
{
|
||||
@@ -296,9 +324,9 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'purchases', 'nexus' )->link( \IPS\nexus\Purchase::load( $id ) );
|
||||
return Theme::i()->getTemplate( 'purchases', 'nexus' )->link( Purchase::load( $id ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
@@ -306,33 +334,29 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
},
|
||||
'billing' => function( $val )
|
||||
{
|
||||
return $val ? "<i class='fa fa-check'></i>" : "<i class='fa fa-times'></i>";
|
||||
},
|
||||
'support' => function( $val )
|
||||
{
|
||||
return $val ? "<i class='fa fa-check'></i>" : "<i class='fa fa-times'></i>";
|
||||
return $val ? "<i class='fa-solid fa-check'></i>" : "<i class='fa-solid fa-xmark'></i>";
|
||||
}
|
||||
);
|
||||
|
||||
$alternativeContacts->rootButtons = array(
|
||||
'add' => array(
|
||||
'link' => \IPS\Http\Url::internal("app=nexus&module=customers&controller=view&id={$this->member->member_id}")->setQueryString( 'do', 'alternativeContactForm' ),
|
||||
'link' => Url::internal("app=nexus&module=customers&controller=view&id={$this->member->member_id}")->setQueryString( 'do', 'alternativeContactForm' ),
|
||||
'title' => 'add',
|
||||
'icon' => 'plus',
|
||||
'data' => array( 'ipsDialog' => true, 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('altcontact_add') )
|
||||
'data' => array( 'ipsDialog' => true, 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('altcontact_add') )
|
||||
)
|
||||
);
|
||||
$alternativeContacts->rowButtons = function( $row )
|
||||
{
|
||||
return array(
|
||||
'edit' => array(
|
||||
'link' => \IPS\Http\Url::internal("app=nexus&module=customers&controller=view&id={$this->member->member_id}")->setQueryString( array( 'do' => 'alternativeContactForm', 'alt_id' => $row['alt_id'] ) ),
|
||||
'link' => Url::internal("app=nexus&module=customers&controller=view&id={$this->member->member_id}")->setQueryString( array( 'do' => 'alternativeContactForm', 'alt_id' => $row['alt_id'] ) ),
|
||||
'title' => 'edit',
|
||||
'icon' => 'pencil',
|
||||
'data' => array( 'ipsDialog' => true )
|
||||
),
|
||||
'delete' => array(
|
||||
'link' => \IPS\Http\Url::internal("app=nexus&module=customers&controller=view&id={$this->member->member_id}")->setQueryString( array( 'do' => 'deleteAlternativeContact', 'alt_id' => $row['alt_id'] ) ),
|
||||
'link' => Url::internal("app=nexus&module=customers&controller=view&id={$this->member->member_id}")->setQueryString( array( 'do' => 'deleteAlternativeContact', 'alt_id' => $row['alt_id'] ) ),
|
||||
'title' => 'delete',
|
||||
'icon' => 'times-circle',
|
||||
'data' => array( 'delete' => '' )
|
||||
@@ -342,25 +366,26 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
}
|
||||
if ( $edit )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->customerPopup( $alternativeContacts );
|
||||
return Theme::i()->getTemplate( 'customers', 'nexus' )->customerPopup( $alternativeContacts );
|
||||
}
|
||||
else
|
||||
{
|
||||
$alternativeContacts->include[] = 'email';
|
||||
$alternativeContacts->limit = 2;
|
||||
$alternativeContacts->tableTemplate = array( \IPS\Theme::i()->getTemplate( 'customers', 'nexus' ), 'altContactsOverview' );
|
||||
$alternativeContacts->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'customers', 'nexus' ), 'altContactsOverviewRows' );
|
||||
$alternativeContacts->tableTemplate = array( Theme::i()->getTemplate( 'customers', 'nexus' ), 'altContactsOverview' );
|
||||
$alternativeContacts->rowsTemplate = array( Theme::i()->getTemplate( 'customers', 'nexus' ), 'altContactsOverviewRows' );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->accountInformationTablePreview( $this->member, $alternativeContacts, \IPS\Member::loggedIn()->language()->addToStack( 'num_alternate_contacts', FALSE, array( 'pluralize' => array( $altContactCount ) ) ), 'alts' );
|
||||
return Theme::i()->getTemplate( 'customers', 'nexus' )->accountInformationTablePreview( $this->member, $alternativeContacts, Member::loggedIn()->language()->addToStack( 'num_alternate_contacts', FALSE, array( 'pluralize' => array( $altContactCount ) ) ), 'alts' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get output
|
||||
*
|
||||
* @return string
|
||||
* @param string $tab
|
||||
* @return mixed
|
||||
*/
|
||||
public function tabOutput( $tab )
|
||||
public function tabOutput( string $tab ): mixed
|
||||
{
|
||||
$method = "_{$tab}";
|
||||
return $this->$method();
|
||||
@@ -371,11 +396,11 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function edit()
|
||||
public function edit(): string
|
||||
{
|
||||
if ( array_key_exists( \IPS\Request::i()->type, $this->tabs() ) )
|
||||
if ( array_key_exists( Request::i()->type, $this->tabs() ) )
|
||||
{
|
||||
$method = "_" . \IPS\Request::i()->type;
|
||||
$method = "_" . Request::i()->type;
|
||||
return $this->$method( TRUE );
|
||||
}
|
||||
return parent::edit();
|
||||
@@ -386,22 +411,22 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function output()
|
||||
public function output(): string
|
||||
{
|
||||
$tabs = $this->tabs();
|
||||
if ( !\count( $tabs ) )
|
||||
if ( !count( $tabs ) )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
$tabKeys = array_keys( $tabs );
|
||||
$activeTabKey = ( isset( \IPS\Request::i()->block['nexus_AccountInformation'] ) and array_key_exists( \IPS\Request::i()->block['nexus_AccountInformation'], $tabs ) ) ? \IPS\Request::i()->block['nexus_AccountInformation'] : array_shift( $tabKeys );
|
||||
$activeTabKey = ( isset( Request::i()->block['nexus_AccountInformation'] ) and array_key_exists( Request::i()->block['nexus_AccountInformation'], $tabs ) ) ? Request::i()->block['nexus_AccountInformation'] : array_shift( $tabKeys );
|
||||
|
||||
$activeSubscription = FALSE;
|
||||
if ( \IPS\Settings::i()->nexus_subs_enabled )
|
||||
if ( Settings::i()->nexus_subs_enabled )
|
||||
{
|
||||
$activeSubscription = \IPS\nexus\Subscription::loadActiveByMember( $this->member );
|
||||
$activeSubscription = Subscription::loadByMember( $this->member, TRUE );
|
||||
}
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->accountInformation( $this->member, $tabs, $activeTabKey, $this->tabOutput( $activeTabKey ), $activeSubscription );
|
||||
return (string) Theme::i()->getTemplate( 'customers', 'nexus' )->accountInformation( $this->member, $tabs, $activeTabKey, $this->tabOutput( $activeTabKey ), $activeSubscription );
|
||||
}
|
||||
}
|
||||
@@ -11,40 +11,49 @@
|
||||
namespace IPS\nexus\extensions\core\MemberACPProfileBlocks;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\core\MemberACPProfile\Block;
|
||||
use IPS\Db;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\nexus\Invoice;
|
||||
use IPS\Theme;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ACP Member Profile: Invoices
|
||||
*/
|
||||
class _Invoices extends \IPS\core\MemberACPProfile\Block
|
||||
class Invoices extends Block
|
||||
{
|
||||
/**
|
||||
* Get output
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function output()
|
||||
public function output(): string
|
||||
{
|
||||
$invoiceCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_invoices', array( 'i_member=?', $this->member->member_id ) )->first();
|
||||
$invoices = \IPS\nexus\Invoice::table( array( 'i_member=?', $this->member->member_id ), $this->member->acpUrl()->setQueryString( 'tab', 'invoices' ), 'c' );
|
||||
$invoiceCount = Db::i()->select( 'COUNT(*)', 'nexus_invoices', array( 'i_member=?', $this->member->member_id ) )->first();
|
||||
$invoices = Invoice::table( array( 'i_member=?', $this->member->member_id ), $this->member->acpUrl()->setQueryString( 'tab', 'invoices' ), 'c' );
|
||||
$invoices->limit = 15;
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'invoices_add' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'invoices_add' ) )
|
||||
{
|
||||
$invoices->rootButtons = array(
|
||||
'add' => array(
|
||||
'link' => \IPS\Http\Url::internal( "app=nexus&module=payments&controller=invoices&do=generate&member={$this->member->member_id}" ),
|
||||
'link' => Url::internal( "app=nexus&module=payments&controller=invoices&do=generate&member={$this->member->member_id}" ),
|
||||
'title' => 'add',
|
||||
'icon' => 'plus',
|
||||
)
|
||||
);
|
||||
}
|
||||
$invoices->tableTemplate = array( \IPS\Theme::i()->getTemplate( 'customers', 'nexus' ), 'invoicesTable' );
|
||||
$invoices->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'customers', 'nexus' ), 'invoicesTableRows' );
|
||||
$invoices->tableTemplate = array( Theme::i()->getTemplate( 'customers', 'nexus' ), 'invoicesTable' );
|
||||
$invoices->rowsTemplate = array( Theme::i()->getTemplate( 'customers', 'nexus' ), 'invoicesTableRows' );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->invoices( $this->member, $invoices, $invoiceCount );
|
||||
return (string) Theme::i()->getTemplate( 'customers', 'nexus' )->invoices( $this->member, $invoices, $invoiceCount );
|
||||
}
|
||||
}
|
||||
@@ -11,51 +11,59 @@
|
||||
namespace IPS\nexus\extensions\core\MemberACPProfileBlocks;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\core\MemberACPProfile\Block;
|
||||
use IPS\Helpers\Table\Db;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Theme;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ACP Member Profile: Notes
|
||||
*/
|
||||
class _Notes extends \IPS\core\MemberACPProfile\Block
|
||||
class Notes extends Block
|
||||
{
|
||||
/**
|
||||
* @brief Notes
|
||||
*/
|
||||
protected $notes;
|
||||
protected ?Db $notes = NULL;
|
||||
|
||||
/**
|
||||
* @brief Note Count
|
||||
*/
|
||||
protected $noteCount;
|
||||
protected ?int $noteCount = NULL;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \IPS\Member $member Member
|
||||
* @param Member $member Member
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( \IPS\Member $member )
|
||||
public function __construct( Member $member )
|
||||
{
|
||||
parent::__construct( $member );
|
||||
|
||||
$this->notes = NULL;
|
||||
$this->noteCount = 0;
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customer_notes_view' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customer_notes_view' ) )
|
||||
{
|
||||
$this->noteCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_notes', array( 'note_member=?', $this->member->member_id ) )->first();
|
||||
|
||||
$this->notes = new \IPS\Helpers\Table\Db( 'nexus_notes', $this->member->acpUrl()->setQueryString( array( 'view' => 'notes', 'support' => isset( \IPS\Request::i()->support ) ? \IPS\Request::i()->support : 0 ) ), array( 'note_member=?', $this->member->member_id ) );
|
||||
$this->notes->tableTemplate = array( \IPS\Theme::i()->getTemplate( 'customers', 'nexus' ), 'notes' );
|
||||
$this->notes = new Db( 'nexus_notes', $this->member->acpUrl()->setQueryString( array( 'view' => 'notes' ) ), array( 'note_member=?', $this->member->member_id ) );
|
||||
$this->notes->tableTemplate = array( Theme::i()->getTemplate( 'customers', 'nexus' ), 'notes' );
|
||||
$this->notes->sortBy = 'note_date';
|
||||
|
||||
$this->notes->parsers = array(
|
||||
'note_member' => function( $val )
|
||||
{
|
||||
return \IPS\Member::load( $val );
|
||||
return Member::load( $val );
|
||||
},
|
||||
'note_text' => function( $val )
|
||||
{
|
||||
@@ -66,30 +74,19 @@ class _Notes extends \IPS\core\MemberACPProfile\Block
|
||||
$this->notes->rowButtons = function( $row )
|
||||
{
|
||||
$return = array();
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customer_notes_edit' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customer_notes_edit' ) )
|
||||
{
|
||||
if ( !isset( \IPS\Request::i()->support ) or !\IPS\Request::i()->support )
|
||||
{
|
||||
$return['edit'] = array(
|
||||
'link' => \IPS\Http\Url::internal("app=nexus&module=customers&controller=view&id={$this->member->member_id}")->setQueryString( array( 'do' => 'noteForm', 'note_id' => $row['note_id'], 'support' => isset( \IPS\Request::i()->support ) ? \IPS\Request::i()->support : 0 ) ),
|
||||
'title' => 'edit',
|
||||
'icon' => 'pencil',
|
||||
'data' => array( 'ipsDialog' => true, 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('edit_note') )
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$return['edit'] = array(
|
||||
'link' => \IPS\Http\Url::internal("app=nexus&module=customers&controller=view&id={$this->member->member_id}")->setQueryString( array( 'do' => 'noteForm', 'note_id' => $row['note_id'], 'support' => isset( \IPS\Request::i()->support ) ? \IPS\Request::i()->support : 0 ) ),
|
||||
'title' => 'edit',
|
||||
'icon' => 'pencil',
|
||||
);
|
||||
}
|
||||
$return['edit'] = array(
|
||||
'link' => Url::internal("app=nexus&module=customers&controller=view&id={$this->member->member_id}")->setQueryString( array( 'do' => 'noteForm', 'note_id' => $row['note_id'] ) ),
|
||||
'title' => 'edit',
|
||||
'icon' => 'pencil',
|
||||
'data' => array( 'ipsDialog' => true, 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('edit_note') )
|
||||
);
|
||||
}
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customer_notes_delete' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customer_notes_delete' ) )
|
||||
{
|
||||
$return['delete'] = array(
|
||||
'link' => \IPS\Http\Url::internal("app=nexus&module=customers&controller=view&id={$this->member->member_id}")->setQueryString( array( 'do' => 'deleteNote', 'note_id' => $row['note_id'], 'support' => isset( \IPS\Request::i()->support ) ? \IPS\Request::i()->support : 0 ) )->csrf(),
|
||||
'link' => Url::internal("app=nexus&module=customers&controller=view&id={$this->member->member_id}")->setQueryString( array( 'do' => 'deleteNote', 'note_id' => $row['note_id'] ) )->csrf(),
|
||||
'title' => 'delete',
|
||||
'icon' => 'times-circle',
|
||||
'data' => array( 'confirm' => '' )
|
||||
@@ -98,14 +95,14 @@ class _Notes extends \IPS\core\MemberACPProfile\Block
|
||||
return $return;
|
||||
};
|
||||
|
||||
if ( ( !isset( \IPS\Request::i()->support ) or !\IPS\Request::i()->support ) and \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customer_notes_add' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customer_notes_add' ) )
|
||||
{
|
||||
$this->notes->rootButtons = array(
|
||||
'add' => array(
|
||||
'link' => \IPS\Http\Url::internal("app=nexus&module=customers&controller=view&id={$this->member->member_id}")->setQueryString( array( 'do' => 'noteForm', 'support' => isset( \IPS\Request::i()->support ) ? \IPS\Request::i()->support : 0 ) ),
|
||||
'link' => Url::internal("app=nexus&module=customers&controller=view&id={$this->member->member_id}")->setQueryString( array( 'do' => 'noteForm' ) ),
|
||||
'title' => 'add',
|
||||
'icon' => 'plus',
|
||||
'data' => array( 'ipsDialog' => true, 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('add_note') )
|
||||
'data' => array( 'ipsDialog' => true, 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('add_note') )
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -117,13 +114,13 @@ class _Notes extends \IPS\core\MemberACPProfile\Block
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function output()
|
||||
public function output(): string
|
||||
{
|
||||
$this->notes->limit = 2;
|
||||
$this->notes->tableTemplate = array( \IPS\Theme::i()->getTemplate( 'customers', 'nexus' ), 'notesOverview' );
|
||||
$this->notes->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'customers', 'nexus' ), 'notesOverviewRows' );
|
||||
$this->notes->tableTemplate = array( Theme::i()->getTemplate( 'customers', 'nexus' ), 'notesOverview' );
|
||||
$this->notes->rowsTemplate = array( Theme::i()->getTemplate( 'customers', 'nexus' ), 'notesOverviewRows' );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->notesBlock( $this->member, $this->noteCount, $this->notes );
|
||||
return (string) Theme::i()->getTemplate( 'customers', 'nexus' )->notesBlock( $this->member, $this->noteCount, $this->notes );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,8 +128,8 @@ class _Notes extends \IPS\core\MemberACPProfile\Block
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function lazyOutput()
|
||||
public function lazyOutput(): string
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->customerPopup( $this->notes );
|
||||
return (string) Theme::i()->getTemplate( 'customers', 'nexus' )->customerPopup( $this->notes );
|
||||
}
|
||||
}
|
||||
@@ -11,33 +11,43 @@
|
||||
namespace IPS\nexus\extensions\core\MemberACPProfileBlocks;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\core\MemberACPProfile\Block;
|
||||
use IPS\Db;
|
||||
use IPS\nexus\Customer;
|
||||
use IPS\Theme;
|
||||
use function count;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ACP Member Profile: Customer Statistics Block
|
||||
*/
|
||||
class _ParentAccounts extends \IPS\core\MemberACPProfile\Block
|
||||
class ParentAccounts extends Block
|
||||
{
|
||||
/**
|
||||
* Get output
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function output()
|
||||
public function output(): string
|
||||
{
|
||||
$parents = array();
|
||||
foreach ( \IPS\Db::i()->select( 'main_id', 'nexus_alternate_contacts', array( 'alt_id=?', $this->member->member_id ) ) as $row )
|
||||
foreach ( Db::i()->select( 'main_id', 'nexus_alternate_contacts', array( 'alt_id=?', $this->member->member_id ) ) as $row )
|
||||
{
|
||||
$parents[] = \IPS\nexus\Customer::load( $row );
|
||||
$parents[] = Customer::load( $row );
|
||||
}
|
||||
|
||||
if ( \count( $parents ) )
|
||||
if ( count( $parents ) )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->parentAccounts( $parents );
|
||||
return (string) Theme::i()->getTemplate( 'customers', 'nexus' )->parentAccounts( $parents );
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -11,44 +11,55 @@
|
||||
namespace IPS\nexus\extensions\core\MemberACPProfileBlocks;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\core\MemberACPProfile\TabbedBlock;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Helpers\Tree\Tree;
|
||||
use IPS\nexus\Purchase;
|
||||
use IPS\Request;
|
||||
use IPS\Theme;
|
||||
use function count;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ACP Member Profile: Purchases
|
||||
*/
|
||||
class _Purchases extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
class Purchases extends TabbedBlock
|
||||
{
|
||||
/**
|
||||
* Purchase tree
|
||||
*/
|
||||
protected $_purchases = NULL;
|
||||
protected ?Tree $_purchases = NULL;
|
||||
|
||||
/**
|
||||
* Get Tab Names
|
||||
*
|
||||
* @return string
|
||||
* @return array
|
||||
*/
|
||||
public function tabs()
|
||||
public function tabs(): array
|
||||
{
|
||||
$tabs = array();
|
||||
|
||||
$activeCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_member=? AND ps_show=1 AND ps_active=1 AND ps_parent = 0', $this->member->member_id ) )->first();
|
||||
$activeCount = Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_member=? AND ps_show=1 AND ps_active=1 AND ps_parent = 0', $this->member->member_id ) )->first();
|
||||
$tabs['active'] = array(
|
||||
'icon' => 'credit-card',
|
||||
'count' => $activeCount,
|
||||
);
|
||||
|
||||
$expiredCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_member=? AND ps_active = 0 AND ps_cancelled = 0 AND ps_parent = 0 AND ps_expire <?', $this->member->member_id, \IPS\DateTime::create()->getTimestamp() ) )->first();
|
||||
$expiredCount = Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_member=? AND ps_active = 0 AND ps_cancelled = 0 AND ps_parent = 0 AND ps_expire <?', $this->member->member_id, DateTime::create()->getTimestamp() ) )->first();
|
||||
$tabs['expired'] = array(
|
||||
'icon' => 'credit-card',
|
||||
'count' => $expiredCount,
|
||||
);
|
||||
|
||||
$canceledCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_member=? AND ps_cancelled=1 AND ps_parent = 0', $this->member->member_id ) )->first();
|
||||
$canceledCount = Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_member=? AND ps_cancelled=1 AND ps_parent = 0', $this->member->member_id ) )->first();
|
||||
$tabs['canceled'] = array(
|
||||
'icon' => 'credit-card',
|
||||
'count' => $canceledCount,
|
||||
@@ -62,32 +73,33 @@ class _Purchases extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function output()
|
||||
public function output(): string
|
||||
{
|
||||
$tabs = $this->tabs();
|
||||
if ( !\count( $tabs ) )
|
||||
if ( !count( $tabs ) )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
$tabKeys = array_keys( $tabs );
|
||||
$activeTabKey = ( isset( \IPS\Request::i()->block['nexus_Purchase'] ) and array_key_exists( \IPS\Request::i()->block['nexus_Purchases'], $tabs ) ) ? \IPS\Request::i()->block['nexus_Purchases'] : array_shift( $tabKeys );
|
||||
$activeTabKey = ( isset( Request::i()->block['nexus_Purchase'] ) and array_key_exists( Request::i()->block['nexus_Purchases'], $tabs ) ) ? Request::i()->block['nexus_Purchases'] : array_shift( $tabKeys );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->purchases( $this->member, $tabs, $activeTabKey, $this->tabOutput( $activeTabKey ) );
|
||||
return (string) Theme::i()->getTemplate( 'customers', 'nexus' )->purchases( $this->member, $tabs, $activeTabKey, $this->tabOutput( $activeTabKey ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get output
|
||||
*
|
||||
* @return string
|
||||
* @param string $tab
|
||||
* @return mixed
|
||||
*/
|
||||
public function tabOutput( $activeTabKey )
|
||||
public function tabOutput(string $tab ): mixed
|
||||
{
|
||||
if ( $this->_purchases === NULL )
|
||||
{
|
||||
$where = array();
|
||||
$where[] = array( 'ps_member=?', $this->member->member_id );
|
||||
|
||||
switch ( $activeTabKey )
|
||||
switch ( $tab )
|
||||
{
|
||||
case 'active':
|
||||
$where[] = array( 'ps_active=1' );
|
||||
@@ -96,11 +108,11 @@ class _Purchases extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
$where[] = array( 'ps_cancelled=1' );
|
||||
break;
|
||||
case 'expired':
|
||||
$where[] = array( 'ps_active = 0 and ps_cancelled = 0 and ps_expire <?', \IPS\DateTime::create()->getTimestamp() );
|
||||
$where[] = array( 'ps_active = 0 and ps_cancelled = 0 and ps_expire <?', DateTime::create()->getTimestamp() );
|
||||
break;
|
||||
}
|
||||
|
||||
$this->_purchases = \IPS\nexus\Purchase::tree( $this->member->acpUrl()->setQueryString( 'blockKey', 'nexus_Purchases' ), $where );
|
||||
$this->_purchases = Purchase::tree( $this->member->acpUrl()->setQueryString( 'blockKey', 'nexus_Purchases' ), $where );
|
||||
$this->_purchases->getTotalRoots = function()
|
||||
{
|
||||
return NULL;
|
||||
|
||||
@@ -11,36 +11,48 @@
|
||||
namespace IPS\nexus\extensions\core\MemberACPProfileBlocks;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\core\MemberACPProfile\LazyLoadingBlock;
|
||||
use IPS\Db;
|
||||
use IPS\Member;
|
||||
use IPS\nexus\Invoice;
|
||||
use IPS\nexus\Money;
|
||||
use IPS\nexus\Transaction;
|
||||
use IPS\Theme;
|
||||
use UnderflowException;
|
||||
use function defined;
|
||||
use function floatval;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ACP Member Profile: Customer Statistics Block
|
||||
*/
|
||||
class _Statistics extends \IPS\core\MemberACPProfile\LazyLoadingBlock
|
||||
class Statistics extends LazyLoadingBlock
|
||||
{
|
||||
/**
|
||||
* Get output
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function lazyOutput()
|
||||
public function lazyOutput(): string
|
||||
{
|
||||
$standing = array();
|
||||
$time = time();
|
||||
foreach ( \IPS\nexus\Money::currencies() as $currency )
|
||||
foreach ( Money::currencies() as $currency )
|
||||
{
|
||||
/* Total spent */
|
||||
$comparisons = \IPS\Db::i()->select( 'AVG(xval) AS avg, MAX(xval) AS max, MIN(xval) AS min', \IPS\Db::i()->select( "(SUM(t_amount)-SUM(t_partial_refund)) as xval", 'nexus_transactions', array( '( t_status=? OR t_status=? ) AND t_method>0 AND t_currency=? AND t_member<>0', \IPS\nexus\Transaction::STATUS_PAID, \IPS\nexus\Transaction::STATUS_PART_REFUNDED, $currency ), NULL, NULL, 't_member' ), 'xval>0' )->first();
|
||||
$val = \IPS\Db::i()->select( 'SUM(t_amount)-SUM(t_partial_refund)', 'nexus_transactions', array( 't_member=? AND ( t_status=? OR t_status=? ) AND t_method>0 AND t_currency=?', $this->member->member_id, \IPS\nexus\Transaction::STATUS_PAID, \IPS\nexus\Transaction::STATUS_PART_REFUNDED, $currency ) )->first();
|
||||
$standing[ \IPS\Member::loggedIn()->language()->addToStack( 'total_spent_currency', FALSE, array( 'sprintf' => array( $currency ) ) ) ] = array(
|
||||
'value' => new \IPS\nexus\Money( $val ?: '0', $currency ),
|
||||
'avg' => new \IPS\nexus\Money( $comparisons['avg'], $currency ),
|
||||
'highest' => new \IPS\nexus\Money( $comparisons['max'], $currency ),
|
||||
'lowest' => new \IPS\nexus\Money( $comparisons['min'], $currency ),
|
||||
$comparisons = Db::i()->select( 'AVG(xval) AS avg, MAX(xval) AS max, MIN(xval) AS min', Db::i()->select( "(SUM(t_amount)-SUM(t_partial_refund)) as xval", 'nexus_transactions', array( '( t_status=? OR t_status=? ) AND t_method>0 AND t_currency=? AND t_member<>0', Transaction::STATUS_PAID, Transaction::STATUS_PART_REFUNDED, $currency ), NULL, NULL, 't_member' ), 'xval>0' )->first();
|
||||
$val = Db::i()->select( 'SUM(t_amount)-SUM(t_partial_refund)', 'nexus_transactions', array( 't_member=? AND ( t_status=? OR t_status=? ) AND t_method>0 AND t_currency=?', $this->member->member_id, Transaction::STATUS_PAID, Transaction::STATUS_PART_REFUNDED, $currency ) )->first();
|
||||
$standing[ Member::loggedIn()->language()->addToStack( 'total_spent_currency', FALSE, array( 'sprintf' => array( $currency ) ) ) ] = array(
|
||||
'value' => new Money( $val ?: '0', $currency ),
|
||||
'avg' => new Money( $comparisons['avg'] ?: 0, $currency ),
|
||||
'highest' => new Money( $comparisons['max'] ?: 0, $currency ),
|
||||
'lowest' => new Money( $comparisons['min'] ?: 0, $currency ),
|
||||
'lowval' => $comparisons['min'],
|
||||
'highval' => $comparisons['max'],
|
||||
'avgval' => $comparisons['avg'],
|
||||
@@ -52,21 +64,21 @@ class _Statistics extends \IPS\core\MemberACPProfile\LazyLoadingBlock
|
||||
|
||||
/* Average monthly spend */
|
||||
$sum = "( SUM(t_amount) / ( ( {$time} - core_members.joined ) / 2592000 ) )";
|
||||
$where = array( array( "( t_status=? OR t_status=? ) AND ({$time} - core_members.joined > 2592000) AND t_currency=?", \IPS\nexus\Transaction::STATUS_PAID, \IPS\nexus\Transaction::STATUS_PART_REFUNDED, $currency ) );
|
||||
$where = array( array( "( t_status=? OR t_status=? ) AND ({$time} - core_members.joined > 2592000) AND t_currency=?", Transaction::STATUS_PAID, Transaction::STATUS_PART_REFUNDED, $currency ) );
|
||||
try
|
||||
{
|
||||
$val = \IPS\Db::i()->select( "{$sum} as sum", 'nexus_transactions', array_merge( $where, array( array( 't_member=?', $this->member->member_id ) ) ), 'joined', NULL, 'joined' )->join( 'core_members', 'member_id=t_member' )->first();
|
||||
$val = Db::i()->select( "{$sum} as sum", 'nexus_transactions', array_merge( $where, array( array( 't_member=?', $this->member->member_id ) ) ), 'joined', NULL, 'joined' )->join( 'core_members', 'member_id=t_member' )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException )
|
||||
{
|
||||
$val = 0;
|
||||
}
|
||||
$comparisons = \IPS\Db::i()->select( 'AVG(xval) AS avg, MAX(xval) AS max, MIN(xval) AS min', \IPS\Db::i()->select( "{$sum} as xval", 'nexus_transactions', array_merge( $where, array( array( 't_member<>0' ) ) ), NULL, NULL, array( 't_member', 'joined' ) ), 'xval>0' )->join( 'core_members', 'member_id=t_member' )->first();
|
||||
$standing[ \IPS\Member::loggedIn()->language()->addToStack( 'average_spend_currency', FALSE, array( 'sprintf' => array( $currency ) ) ) ] = array(
|
||||
'value' => new \IPS\nexus\Money( $val, $currency ),
|
||||
'avg' => new \IPS\nexus\Money( $comparisons['avg'], $currency ),
|
||||
'highest' => new \IPS\nexus\Money( $comparisons['max'], $currency ),
|
||||
'lowest' => new \IPS\nexus\Money( $comparisons['min'], $currency ),
|
||||
$comparisons = Db::i()->select( 'AVG(xval) AS avg, MAX(xval) AS max, MIN(xval) AS min', Db::i()->select( "{$sum} as xval", 'nexus_transactions', array_merge( $where, array( array( 't_member<>0' ) ) ), NULL, NULL, array( 't_member', 'joined' ) ), 'xval>0' )->join( 'core_members', 'member_id=t_member' )->first();
|
||||
$standing[ Member::loggedIn()->language()->addToStack( 'average_spend_currency', FALSE, array( 'sprintf' => array( $currency ) ) ) ] = array(
|
||||
'value' => new Money( $val ?: 0, $currency ),
|
||||
'avg' => new Money( $comparisons['avg'] ?: 0, $currency ),
|
||||
'highest' => new Money( $comparisons['max'] ?: 0, $currency ),
|
||||
'lowest' => new Money( $comparisons['min'] ?: 0, $currency ),
|
||||
'lowval' => $comparisons['min'],
|
||||
'highval' => $comparisons['max'],
|
||||
'avgval' => $comparisons['avg'],
|
||||
@@ -78,47 +90,24 @@ class _Statistics extends \IPS\core\MemberACPProfile\LazyLoadingBlock
|
||||
}
|
||||
|
||||
$sum = "ROUND( ( AVG( i_paid - i_date ) / 86400 ), 2 )";
|
||||
$where = array( array( "i_status=? AND i_date>0 AND i_paid>0", \IPS\nexus\Invoice::STATUS_PAID ) );
|
||||
$val = \IPS\Db::i()->select( "{$sum} as sum", 'nexus_invoices', array_merge( $where, array( array( 'i_member=?', $this->member->member_id ) ) ) )->join( 'core_members', 'member_id=i_member' )->first();
|
||||
$comparisons = \IPS\Db::i()->select( 'AVG(xval) AS avg, MAX(xval) AS max, MIN(xval) AS min', \IPS\Db::i()->select( "{$sum} as xval", 'nexus_invoices', array_merge( $where, array( array( 'i_member<>0' ) ) ), NULL, NULL, array( 'i_member', 'joined' ) ), 'xval>0' )->join( 'core_members', 'member_id=i_member' )->first();
|
||||
$standing[ \IPS\Member::loggedIn()->language()->addToStack( 'average_time_to_pay' ) ] = array(
|
||||
'value' => \IPS\Member::loggedIn()->language()->formatNumber( $val, 2 ) . ' ' . \IPS\Member::loggedIn()->language()->addToStack('days'),
|
||||
'avg' => \IPS\Member::loggedIn()->language()->formatNumber( $comparisons['avg'], 2 ) . ' ' . \IPS\Member::loggedIn()->language()->addToStack('days'),
|
||||
'highest' => \IPS\Member::loggedIn()->language()->formatNumber( $comparisons['max'], 2 ) . ' ' . \IPS\Member::loggedIn()->language()->addToStack('days'),
|
||||
'lowest' => \IPS\Member::loggedIn()->language()->formatNumber( $comparisons['min'], 2 ) . ' ' . \IPS\Member::loggedIn()->language()->addToStack('days'),
|
||||
$where = array( array( "i_status=? AND i_date>0 AND i_paid>0", Invoice::STATUS_PAID ) );
|
||||
$val = Db::i()->select( "{$sum} as sum", 'nexus_invoices', array_merge( $where, array( array( 'i_member=?', $this->member->member_id ) ) ) )->join( 'core_members', 'member_id=i_member' )->first();
|
||||
$comparisons = Db::i()->select( 'AVG(xval) AS avg, MAX(xval) AS max, MIN(xval) AS min', Db::i()->select( "{$sum} as xval", 'nexus_invoices', array_merge( $where, array( array( 'i_member<>0' ) ) ), NULL, NULL, array( 'i_member', 'joined' ) ), 'xval>0' )->join( 'core_members', 'member_id=i_member' )->first();
|
||||
$standing[ Member::loggedIn()->language()->addToStack( 'average_time_to_pay' ) ] = array(
|
||||
'value' => Member::loggedIn()->language()->formatNumber( $val, 2 ) . ' ' . Member::loggedIn()->language()->addToStack('days'),
|
||||
'avg' => Member::loggedIn()->language()->formatNumber( $comparisons['avg'], 2 ) . ' ' . Member::loggedIn()->language()->addToStack('days'),
|
||||
'highest' => Member::loggedIn()->language()->formatNumber( $comparisons['max'], 2 ) . ' ' . Member::loggedIn()->language()->addToStack('days'),
|
||||
'lowest' => Member::loggedIn()->language()->formatNumber( $comparisons['min'], 2 ) . ' ' . Member::loggedIn()->language()->addToStack('days'),
|
||||
'lowval' => $comparisons['min'],
|
||||
'highval' => $comparisons['max'],
|
||||
'avgval' => $comparisons['avg'],
|
||||
'thisval' => $val,
|
||||
'avgpct' => \floatval( $comparisons['max'] ) ? round( ( ( $comparisons['avg'] - $comparisons['min'] ) / $comparisons['max'] ) * 100, 1 ) : 0,
|
||||
'thispct' => \floatval( $comparisons['max'] ) ? round( ( ( $val - $comparisons['min'] ) / $comparisons['max'] ) * 100, 1 ) : 0,
|
||||
'avgpct' => floatval( $comparisons['max'] ) ? round( ( ( $comparisons['avg'] - $comparisons['min'] ) / $comparisons['max'] ) * 100, 1 ) : 0,
|
||||
'thispct' => floatval( $comparisons['max'] ) ? round( ( ( $val - $comparisons['min'] ) / $comparisons['max'] ) * 100, 1 ) : 0,
|
||||
'type' => 'timetopay'
|
||||
);
|
||||
|
||||
$sum = "LEAST( ( count(*) / ( ( {$time} - core_members.joined ) / 2592000 ) ), count(*) )";
|
||||
try
|
||||
{
|
||||
$val = \IPS\Db::i()->select( "{$sum} as sum", 'nexus_support_requests', array( 'r_member=?', $this->member->member_id ), 'joined', NULL, 'joined' )->join( 'core_members', 'member_id=r_member' )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
{
|
||||
$val = 0;
|
||||
}
|
||||
$comparisons = \IPS\Db::i()->select( 'AVG(xval) AS avg, MAX(xval) AS max, MIN(xval) AS min', \IPS\Db::i()->select( "{$sum} as xval", 'nexus_support_requests', 'r_member<>0', NULL, NULL, 'joined' ) )->join( 'core_members', 'member_id=r_member' )->first();
|
||||
$standing[ \IPS\Member::loggedIn()->language()->addToStack( 'average_monthly_support_requests' ) ] = array(
|
||||
'value' => \IPS\Member::loggedIn()->language()->formatNumber( $val, 2 ),
|
||||
'avg' => \IPS\Member::loggedIn()->language()->formatNumber( $comparisons['avg'], 2 ),
|
||||
'highest' => \IPS\Member::loggedIn()->language()->formatNumber( $comparisons['max'], 2 ),
|
||||
'lowest' => \IPS\Member::loggedIn()->language()->formatNumber( $comparisons['min'], 2 ),
|
||||
'lowval' => $comparisons['min'],
|
||||
'highval' => $comparisons['max'],
|
||||
'avgval' => $comparisons['avg'],
|
||||
'thisval' => $val,
|
||||
'avgpct' => $comparisons['max'] ? round( ( ( $comparisons['avg'] - $comparisons['min'] ) / $comparisons['max'] ) * 100, 1 ) : 0,
|
||||
'thispct' => $comparisons['max'] ? round( ( ( $val - $comparisons['min'] ) / $comparisons['max'] ) * 100, 1 ) : 0,
|
||||
'type' => 'support'
|
||||
);
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->standing( $standing );
|
||||
return (string) Theme::i()->getTemplate( 'customers', 'nexus' )->standing( $standing );
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief ACP Member Profile: Support
|
||||
* @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
|
||||
* @since 5 Dec 2017
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\MemberACPProfileBlocks;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ACP Member Profile: Support
|
||||
*/
|
||||
class _Support extends \IPS\core\MemberACPProfile\Block
|
||||
{
|
||||
/**
|
||||
* Get output
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function output()
|
||||
{
|
||||
$customerStream = \IPS\nexus\Support\Stream::customer( $this->member );
|
||||
$supportCount = $customerStream->count( \IPS\Member::loggedIn() );
|
||||
$results = $customerStream->results( \IPS\Member::loggedIn(), 'r_started DESC', 1, 15 );
|
||||
$supportRequestsInView = array_keys( iterator_to_array( $results ) );
|
||||
$tracked = iterator_to_array( \IPS\Db::i()->select( array( 'request_id', 'notify' ), 'nexus_support_tracker', array( array( 'member_id=?', \IPS\Member::loggedIn()->member_id ), array( \IPS\Db::i()->in( 'request_id', $supportRequestsInView ) ) ) )->setKeyField( 'request_id' )->setValueField( 'notify' ) );
|
||||
$participatedIn = iterator_to_array( \IPS\Db::i()->select( 'DISTINCT reply_request', 'nexus_support_replies', array( array( 'reply_member=?', \IPS\Member::loggedIn()->member_id ), array( \IPS\Db::i()->in( 'reply_request', $supportRequestsInView ) ) ) ) );
|
||||
$support = \IPS\Theme::i()->getTemplate( 'support', 'nexus' )->requestsTableResults( $results, NULL, FALSE, $tracked, $participatedIn, FALSE );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->support( $this->member, $support, $supportCount );
|
||||
}
|
||||
}
|
||||
@@ -11,26 +11,34 @@
|
||||
namespace IPS\nexus\extensions\core\MemberACPProfileTabs;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\core\MemberACPProfile\MainTab;
|
||||
use IPS\Member;
|
||||
use IPS\nexus\Customer;
|
||||
use IPS\Output;
|
||||
use IPS\Theme;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ACP Member Profile: Customer Tab
|
||||
*/
|
||||
class _Main extends \IPS\core\MemberACPProfile\MainTab
|
||||
class Main extends MainTab
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \IPS\Member $member Member
|
||||
* @param Member $member Member
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( \IPS\Member $member )
|
||||
public function __construct( Member $member )
|
||||
{
|
||||
$this->member = \IPS\nexus\Customer::load( $member->member_id );
|
||||
$this->member = Customer::load( $member->member_id );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,9 +46,9 @@ class _Main extends \IPS\core\MemberACPProfile\MainTab
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canView()
|
||||
public function canView(): bool
|
||||
{
|
||||
return (bool) \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customers_view' );
|
||||
return (bool) Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customers_view' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,7 +56,7 @@ class _Main extends \IPS\core\MemberACPProfile\MainTab
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function leftColumnBlocks()
|
||||
public function leftColumnBlocks(): array
|
||||
{
|
||||
return array(
|
||||
'IPS\nexus\extensions\core\MemberACPProfileBlocks\AccountInformation',
|
||||
@@ -60,37 +68,32 @@ class _Main extends \IPS\core\MemberACPProfile\MainTab
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function mainColumnBlocks()
|
||||
public function mainColumnBlocks(): array
|
||||
{
|
||||
$return = array();
|
||||
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customers_view_statistics' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customers_view_statistics' ) )
|
||||
{
|
||||
$return[] = 'IPS\nexus\extensions\core\MemberACPProfileBlocks\Statistics';
|
||||
}
|
||||
|
||||
$return[] = 'IPS\nexus\extensions\core\MemberACPProfileBlocks\ParentAccounts';
|
||||
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customer_notes_view' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customer_notes_view' ) )
|
||||
{
|
||||
$return[] = 'IPS\nexus\extensions\core\MemberACPProfileBlocks\Notes';
|
||||
}
|
||||
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'purchases_view' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'purchases_view' ) )
|
||||
{
|
||||
$return[] = 'IPS\nexus\extensions\core\MemberACPProfileBlocks\Purchases';
|
||||
}
|
||||
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'invoices_manage' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'invoices_manage' ) )
|
||||
{
|
||||
$return[] = 'IPS\nexus\extensions\core\MemberACPProfileBlocks\Invoices';
|
||||
}
|
||||
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'support', 'requests_manage' ) )
|
||||
{
|
||||
$return[] = 'IPS\nexus\extensions\core\MemberACPProfileBlocks\Support';
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
@@ -99,17 +102,10 @@ class _Main extends \IPS\core\MemberACPProfile\MainTab
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function output()
|
||||
public function output(): string
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'customer.css', 'nexus', 'admin' ) );
|
||||
|
||||
if ( \IPS\Theme::i()->settings['responsive'] )
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'customer_responsive.css', 'nexus', 'admin' ) );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'support.css', 'nexus', 'admin' ) );
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'admin_customer.js', 'nexus', 'admin' ) );
|
||||
Output::i()->cssFiles = array_merge( Output::i()->cssFiles, Theme::i()->css( 'customer.css', 'nexus', 'admin' ) );
|
||||
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'admin_customer.js', 'nexus', 'admin' ) );
|
||||
|
||||
return parent::output();
|
||||
}
|
||||
|
||||
@@ -11,30 +11,43 @@
|
||||
namespace IPS\nexus\extensions\core\MemberExportPersonalInformation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use IPS\Db;
|
||||
use IPS\Extensions\MemberExportPiiAbstract;
|
||||
use IPS\GeoLocation;
|
||||
use IPS\Member;
|
||||
use IPS\nexus\Customer as NexusCustomer;
|
||||
use IPS\nexus\Customer\CustomField;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
use OutOfRangeException;
|
||||
use function defined;
|
||||
use function is_null;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ACP Export Personal Information
|
||||
*/
|
||||
class _Customer
|
||||
class Customer extends MemberExportPiiAbstract
|
||||
{
|
||||
/**
|
||||
* Return data
|
||||
* @param \IPS\Member $member The member
|
||||
* @param Member $member The member
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getData( \IPS\Member $member )
|
||||
public function getData( Member $member ): array
|
||||
{
|
||||
$return = array();
|
||||
|
||||
try
|
||||
{
|
||||
$customer = \IPS\nexus\Customer::load( $member->member_id );
|
||||
$customer = NexusCustomer::load( $member->member_id );
|
||||
|
||||
/* Name and addresses */
|
||||
$return['customer'] = array(
|
||||
@@ -42,13 +55,13 @@ class _Customer
|
||||
'last_name' => $customer->cm_last_name
|
||||
);
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_customer_addresses', array( '`member`=?', $member->member_id ) ) as $address )
|
||||
foreach( Db::i()->select( '*', 'nexus_customer_addresses', array( '`member`=?', $member->member_id ) ) as $address )
|
||||
{
|
||||
$return['addresses'][] = \IPS\GeoLocation::buildFromJson( $address['address'] )->toString( "," );
|
||||
$return['addresses'][] = GeoLocation::buildFromJson( $address['address'] )->toString( "," );
|
||||
}
|
||||
|
||||
/* Customer custom fields */
|
||||
foreach ( \IPS\nexus\Customer\CustomField::roots() as $field )
|
||||
foreach ( CustomField::roots() as $field )
|
||||
{
|
||||
$column = $field->column;
|
||||
if ( $column )
|
||||
@@ -58,7 +71,7 @@ class _Customer
|
||||
}
|
||||
|
||||
/* Credit cards */
|
||||
foreach ( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_customer_cards', array( 'card_member=?', $member->member_id ) ), 'IPS\nexus\Customer\CreditCard' ) as $card )
|
||||
foreach ( new ActiveRecordIterator( Db::i()->select( '*', 'nexus_customer_cards', array( 'card_member=?', $member->member_id ) ), 'IPS\nexus\Customer\CreditCard' ) as $card )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -66,13 +79,13 @@ class _Customer
|
||||
$return['credit_cards'][ $card->id ] = array(
|
||||
'card_type' => $cardData->type,
|
||||
'card_number' => $cardData->lastFour,
|
||||
'card_expire' => ( !\is_null( $cardData->expMonth ) AND !\is_null( $cardData->expYear ) ) ? str_pad( $cardData->expMonth , 2, '0', STR_PAD_LEFT ). '/' . $cardData->expYear : NULL
|
||||
'card_expire' => ( !is_null( $cardData->expMonth ) AND !is_null( $cardData->expYear ) ) ? str_pad( $cardData->expMonth , 2, '0', STR_PAD_LEFT ). '/' . $cardData->expYear : NULL
|
||||
);
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
catch ( Exception ) {}
|
||||
}
|
||||
}
|
||||
catch( \OutOfRangeException $ex )
|
||||
catch( OutOfRangeException )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,185 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Member Filter Extension
|
||||
* @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 Commerce
|
||||
* @since 30 Jan 2024
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\MemberFilter;
|
||||
|
||||
use IPS\Db;
|
||||
use IPS\Db\Select;
|
||||
use IPS\Extensions\MemberFilterAbstract;
|
||||
use IPS\Helpers\Form\Custom;
|
||||
use IPS\Helpers\Form\Node;
|
||||
use IPS\Helpers\Form\Select as FormSelect;
|
||||
use IPS\nexus\Donation\Goal;
|
||||
use IPS\nexus\Money;
|
||||
use IPS\Theme;
|
||||
use LogicException;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Member Filter Extension
|
||||
*/
|
||||
class Donations extends MemberFilterAbstract
|
||||
{
|
||||
/**
|
||||
* Determine if the filter is available in a given area
|
||||
*
|
||||
* @param string $area Area to check (bulkmail, group_promotions, automatic_moderation, passwordreset)
|
||||
* @return bool
|
||||
*/
|
||||
public function availableIn( string $area ): bool
|
||||
{
|
||||
return in_array( $area, array( 'bulkmail', 'group_promotions' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Setting Field
|
||||
*
|
||||
* @param array $criteria Value returned from the save() method
|
||||
* @return array Array of form elements
|
||||
*/
|
||||
public function getSettingField( array $criteria ): array
|
||||
{
|
||||
return array(
|
||||
$this->_combine( 'nexus_bm_filters_total_donate', 'IPS\nexus\Form\Money', $criteria ),
|
||||
new Node( 'nexus_bm_filters_donate_goals', $criteria['donate_goals'] ?? 0, false, array( 'class' => Goal::class, 'multiple' => true, 'zeroVal' => 'any' ) )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the filter data
|
||||
*
|
||||
* @param array $post Form values
|
||||
* @return array False, or an array of data to use later when filtering the members
|
||||
* @throws LogicException
|
||||
*/
|
||||
public function save( array $post ): array
|
||||
{
|
||||
$amounts = array();
|
||||
|
||||
foreach( $post['nexus_bm_filters_total_donate'][1] as $amount )
|
||||
{
|
||||
$amounts[$amount->currency] = $amount->amount;
|
||||
}
|
||||
|
||||
return array(
|
||||
'total_donate_operator' => $post['nexus_bm_filters_total_donate'][0],
|
||||
'total_donate_amounts' => json_encode( $amounts ),
|
||||
'donate_goals' => ( is_array( $post['nexus_bm_filters_donate_goals'] ) and count( $post['nexus_bm_filters_donate_goals'] ) ) ? array_keys( $post['nexus_bm_filters_donate_goals'] ) : 0
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get where clause to add to the member retrieval database query
|
||||
*
|
||||
* @param array $data The array returned from the save() method
|
||||
* @return array|null Where clause
|
||||
*/
|
||||
public function getQueryWhereClause( array $data ): ?array
|
||||
{
|
||||
$where = array();
|
||||
|
||||
if ( ( isset( $data['total_donate_operator'] ) and $data['total_donate_operator'] !== 'any' ) and isset( $data['total_donate_amounts'] ) )
|
||||
{
|
||||
foreach( json_decode( $data['total_donate_amounts'], true ) as $currency => $amount )
|
||||
{
|
||||
switch ( $data['total_donate_operator'] )
|
||||
{
|
||||
case 'gt':
|
||||
$operator = ">";
|
||||
break;
|
||||
case 'lt':
|
||||
$operator = "<";
|
||||
break;
|
||||
}
|
||||
|
||||
$where[] = "(nexus_donate_logs.dl_amount{$operator}'{$amount}')";
|
||||
}
|
||||
|
||||
$where[] = array( implode( ' OR ', $where ) );
|
||||
}
|
||||
|
||||
if( isset( $data['donate_goals'] ) and $data['donate_goals'] !== 0 )
|
||||
{
|
||||
$where[] = array( Db::i()->in( 'dl_goal', $data['donate_goals'] ) );
|
||||
}
|
||||
|
||||
return count( $where ) ? $where : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for member retrieval database query
|
||||
* Can be used to set joins
|
||||
*
|
||||
* @param array $data The array returned from the save() method
|
||||
* @param Select $query The query
|
||||
* @return void
|
||||
*/
|
||||
public function queryCallback( array $data, Select $query ) : void
|
||||
{
|
||||
$currencies = Money::currencies();
|
||||
$defaultCurrency = array_shift( $currencies );
|
||||
|
||||
if (
|
||||
( ( isset( $data['total_donate_operator'] ) and $data['total_donate_operator'] !== 'any' ) and isset( $data['total_donate_amounts'] ) ) OR
|
||||
( isset( $data['donate_goals'] ) and $data['donate_goals'] !== 0 )
|
||||
)
|
||||
{
|
||||
$query->join( 'nexus_donate_logs', "core_members.member_id=nexus_donate_logs.dl_member" );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Combine two fields
|
||||
*
|
||||
* @param string $name Field name
|
||||
* @param string $field2Class Classname for second field
|
||||
* @param array $criteria Value returned from the save() method
|
||||
* @return Custom
|
||||
*/
|
||||
public function _combine( string $name, string $field2Class, array $criteria ) : Custom
|
||||
{
|
||||
$validate = NULL;
|
||||
|
||||
$options = array(
|
||||
'options' => array(
|
||||
'any' => 'any_value',
|
||||
'gt' => 'gt',
|
||||
'lt' => 'lt'
|
||||
),
|
||||
'toggles' => array(
|
||||
'gt' => array( $name . '_unit' ),
|
||||
'lt' => array( $name . '_unit' ),
|
||||
)
|
||||
);
|
||||
|
||||
$field1 = new FormSelect( $name . '_type', $criteria['total_donate_operator'] ?? '', FALSE, $options, NULL, NULL, NULL );
|
||||
$field2 = new $field2Class( $name . '_unit', $criteria['total_donate_amounts'] ?? NULL, FALSE, array() );
|
||||
|
||||
return new Custom( $name, array( "gt", NULL ), FALSE, array(
|
||||
'getHtml' => function() use ( $name, $field1, $field2 )
|
||||
{
|
||||
return Theme::i()->getTemplate( 'forms', 'nexus', 'global' )->combined( $name, $field1, $field2 );
|
||||
},
|
||||
'formatValue' => function() use ( $field1, $field2 )
|
||||
{
|
||||
return array( $field1->value, $field2->value );
|
||||
}
|
||||
) );
|
||||
}
|
||||
}
|
||||
Loaded 100 of 6736 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user