Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief ACP Notification: Advertisements Requiring Approval
|
||||
* @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 27 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: Advertisements Requiring Approval
|
||||
*/
|
||||
class _Advertisement 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 = 4;
|
||||
|
||||
/**
|
||||
* Title for settings
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function settingsTitle()
|
||||
{
|
||||
return 'acp_notification_Advertisement';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(*)', 'core_advertisements', array( 'ad_active=-1' ) )->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( 'core', 'promotion', 'advertisements_manage' ) and \IPS\Db::i()->select( 'COUNT(*)', 'nexus_packages_ads' )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Title (full HTML, must be escaped where necessary)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'acpNotification_nexusAdvertisements', FALSE, array( 'pluralize' => array( $this->count() ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Subtitle (no HTML)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function subtitle()
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\DateTime::ts( \IPS\Db::i()->select( 'ad_start', 'core_advertisements', array( 'ad_active=-1' ), 'ad_start 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\core\modules\admin\promotion\advertisements::table( \IPS\Http\Url::internal('app=core&module=overview&controller=notifications&_table=nexus_Advertisement') );
|
||||
$table->limit = 10;
|
||||
$table->filters = array();
|
||||
$table->quickSearch = NULL;
|
||||
$table->advancedSearch = NULL;
|
||||
$table->where[] = array( 'ad_active=-1' );
|
||||
|
||||
return (string) $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=core&module=promotion&controller=advertisements&filter=ad_filters_pending');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief ACP Notification 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 29 Oct 2019
|
||||
*/
|
||||
|
||||
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 Extension
|
||||
*/
|
||||
class _ConfigurationError 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 = 5;
|
||||
|
||||
/**
|
||||
* Title for settings
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function settingsTitle()
|
||||
{
|
||||
return 'acp_notification_ConfigurationError';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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', 'gateways_manage' );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Title (full HTML, must be escaped where necessary)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
{
|
||||
if( mb_substr( $this->extra, 0, 2 ) === 'pm' )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('acp_notification_nexus_config_error_paymethod');
|
||||
}
|
||||
else
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'acpNotification_nexusBACancelErrors', FALSE, array( 'pluralize' => array( \count( json_decode( $this->extra, TRUE ) ) ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Subtitle (no HTML)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function subtitle()
|
||||
{
|
||||
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 ) ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
else
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Body (full HTML, must be escaped where necessary)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function body()
|
||||
{
|
||||
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 );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'notifications', 'nexus', 'admin' )->baCancellationError( json_decode( $this->extra, TRUE ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Severity
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function severity()
|
||||
{
|
||||
return ( mb_substr( $this->extra, 0, 2 ) === 'pm' ) ? static::SEVERITY_CRITICAL : static::SEVERITY_OPTIONAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dismissible?
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function dismissible()
|
||||
{
|
||||
return ( mb_substr( $this->extra, 0, 2 ) === 'pm' ) ? static::DISMISSIBLE_NO : static::DISMISSIBLE_PERMANENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should this notification dismiss itself?
|
||||
*
|
||||
* @note This is checked every time the notification shows. Should be lightweight.
|
||||
* @return bool
|
||||
*/
|
||||
public function selfDismiss()
|
||||
{
|
||||
if( mb_substr( $this->extra, 0, 2 ) === 'pm' )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\nexus\Gateway::load( \substr( $this->extra, 2 ) );
|
||||
return FALSE;
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return parent::selfDismiss();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Style
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function style()
|
||||
{
|
||||
return ( mb_substr( $this->extra, 0, 2 ) === 'pm' ) ? static::STYLE_ERROR : static::STYLE_WARNING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick link from popup menu
|
||||
*
|
||||
* @return \IPS\Http\Url
|
||||
*/
|
||||
public function link()
|
||||
{
|
||||
return ( mb_substr( $this->extra, 0, 2 ) === 'pm' ) ? \IPS\Http\Url::internal( 'app=nexus&module=payments&controller=paymentsettings&tab=gateways&do=form&id=' . \substr( $this->extra, 2 ) ) : parent::link();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief ACP Notification: Hosting Errors
|
||||
* @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 27 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 _HostingError 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 = 5;
|
||||
|
||||
/**
|
||||
* Title for settings
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function settingsTitle()
|
||||
{
|
||||
return 'acp_notification_HostingError';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_hosting_errors' )->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', 'hosting', 'errors_manage' ) and \IPS\Db::i()->select( 'COUNT(*)', 'nexus_hosting_servers' )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Title (full HTML, must be escaped where necessary)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'acpNotification_nexusHostingErrors', FALSE, array( 'pluralize' => array( $this->count() ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Subtitle (no HTML)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function subtitle()
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\DateTime::ts( \IPS\Db::i()->select( 'e_time', 'nexus_hosting_errors', NULL, 'e_time 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\modules\admin\hosting\errors::table( \IPS\Http\Url::internal('app=core&module=overview&controller=notifications&_table=nexus_HostingError') );
|
||||
$table->limit = 10;
|
||||
|
||||
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_ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick link from popup menu
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function link()
|
||||
{
|
||||
return \IPS\Http\Url::internal('app=nexus&module=hosting&controller=errors');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
<?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') );
|
||||
} ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief ACP Notification: Transactions Requiring Attention
|
||||
* @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 25 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: Transactions Requiring Attention
|
||||
*/
|
||||
class _Transaction 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 = 2;
|
||||
|
||||
/**
|
||||
* Get queue HTML
|
||||
*
|
||||
* @param string $status Status to show
|
||||
* @return string
|
||||
*/
|
||||
public static function queueHtml( $status )
|
||||
{
|
||||
$select = \IPS\Db::i()->select( '*', 'nexus_transactions', array( 't_status=?', $status ), 't_date ASC', array( 0, 12 ) );
|
||||
|
||||
if ( \count( $select ) )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'notifications', 'nexus' )->transactions( new \IPS\Patterns\ActiveRecordIterator( $select, 'IPS\nexus\Transaction' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Title for settings
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function settingsTitle()
|
||||
{
|
||||
return 'acp_notification_Transaction';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_transactions', array( 't_status=?', $this->extra ) )->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', 'transactions_manage' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Title (full HTML, must be escaped where necessary)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'acpNotification_nexusTransaction_' . $this->extra, FALSE, array( 'pluralize' => array( $this->count() ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Subtitle (no HTML)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function subtitle()
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\DateTime::ts( \IPS\Db::i()->select( 't_date', 'nexus_transactions', array( 't_status=?', $this->extra ), 't_date asc', 1 )->first() )->relative();
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Body (full HTML, must be escaped where necessary)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function body()
|
||||
{
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js('admin_notifications.js', 'nexus') );
|
||||
|
||||
return static::queueHtml( $this->extra );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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()
|
||||
{
|
||||
if ( $this->extra === \IPS\nexus\Transaction::STATUS_DISPUTED )
|
||||
{
|
||||
return static::STYLE_WARNING;
|
||||
}
|
||||
else
|
||||
{
|
||||
return static::STYLE_INFORMATION;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick link from popup menu
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function link()
|
||||
{
|
||||
return \IPS\Http\Url::internal('app=nexus&module=payments&controller=transactions&attn=1');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief ACP Notification: Pending Credit Withdrawals
|
||||
* @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 Credit Withdrawals
|
||||
*/
|
||||
class _Withdrawal 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 = 4;
|
||||
|
||||
/**
|
||||
* Title for settings
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function settingsTitle()
|
||||
{
|
||||
return 'acp_notification_Withdrawals';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_payouts', array( 'po_status=?', \IPS\nexus\Payout::STATUS_PENDING ) )->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 \IPS\Settings::i()->nexus_payout and $member->hasAcpRestriction( 'nexus', 'payments', 'payouts_manage' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Title (full HTML, must be escaped where necessary)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'acpNotification_nexusWithdrawals', FALSE, array( 'pluralize' => array( $this->count() ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Subtitle (no HTML)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function subtitle()
|
||||
{
|
||||
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();
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Body (full HTML, must be escaped where necessary)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function body()
|
||||
{
|
||||
$table = \IPS\nexus\Payout::table( array( 'po_status=?', 'pend' ), \IPS\Http\Url::internal('app=nexus&module=payments&controller=payouts&filter=postatus_pend') );
|
||||
$table->limit = 10;
|
||||
$table->filters = array();
|
||||
$table->quickSearch = NULL;
|
||||
$table->advancedSearch = NULL;
|
||||
|
||||
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=payouts&filter=postatus_pend');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\CommunityEnhancements;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -81,14 +81,34 @@ class _EasyPost
|
||||
'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' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'easypost_tax', \IPS\Settings::i()->easypost_tax, FALSE, array( 'class' => '\IPS\nexus\Tax', 'zeroVal' => 'do_not_tax' ), NULL, NULL, NULL, 'easypost_tax' ) );
|
||||
|
||||
$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\Number( 'easypost_delivery_adjustment', \IPS\Settings::i()->easypost_delivery_adjustment, FALSE, array(), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('days'), 'easypost_delivery_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'] )
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\CommunityEnhancements;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\CommunityEnhancements;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -73,7 +73,7 @@ class _MaxMind
|
||||
{
|
||||
unset( $values['maxmind_enable'] );
|
||||
$this->testSettings( $values['maxmind_key'] );
|
||||
$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
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
namespace IPS\nexus\extensions\core\ContactUs;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -34,7 +34,7 @@ class _SupportRequest
|
||||
*/
|
||||
public function process( &$form, &$formFields, &$options, &$toggles, &$disabled )
|
||||
{
|
||||
if ( count( \IPS\nexus\Support\Department::roots() ) )
|
||||
if ( \count( \IPS\nexus\Support\Department::roots() ) )
|
||||
{
|
||||
$options['contact_nexus_department'] = 'contact_nexus_department';
|
||||
}
|
||||
@@ -45,7 +45,7 @@ class _SupportRequest
|
||||
}
|
||||
$toggles['contact_nexus_department'] = array( 'contact_nexus' );
|
||||
|
||||
if ( count( \IPS\nexus\Support\Department::roots() ) )
|
||||
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' )
|
||||
|
||||
File renamed without changes.
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\ContentRouter;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\Dashboard;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\Dashboard;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -52,7 +52,7 @@ class _PendingActions
|
||||
$pendingTransactions = NULL;
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'transactions_manage' ) )
|
||||
{
|
||||
$pendingTransactions = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_transactions', array( '( t_status=? OR t_status=? OR t_status=? )', \IPS\nexus\Transaction::STATUS_HELD, \IPS\nexus\Transaction::STATUS_REVIEW, \IPS\nexus\Transaction::STATUS_DISPUTED ) )->first();
|
||||
$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 = NULL;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\EditorLocations;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -74,14 +74,20 @@ class _Admin
|
||||
|
||||
case 'pkg-pg':
|
||||
$customer = \IPS\nexus\Customer::load( $member->member_id );
|
||||
if ( count( \IPS\nexus\extensions\nexus\Item\Package::getPurchases( $customer, $id1, FALSE ) ) )
|
||||
if ( \count( \IPS\nexus\extensions\nexus\Item\Package::getPurchases( $customer, $id1, FALSE ) ) )
|
||||
{
|
||||
$options = array( 'type' => 'attach', 'id' => $attachment['attach_id'], 'name' => $attachment['attach_file'] );
|
||||
if ( isset( $_SERVER['HTTP_REFERER'] ) )
|
||||
if ( \IPS\Request::i()->referrer() )
|
||||
{
|
||||
try
|
||||
{
|
||||
$purchase = \IPS\nexus\Purchase::loadFromUrl( \IPS\Http\Url\Friendly::createFromString( $_SERVER['HTTP_REFERER'] ) );
|
||||
$purchase = \IPS\nexus\Purchase::loadFromUrl( \IPS\Request::i()->referrer() );
|
||||
|
||||
if( !$purchase->can( 'view', $member ) )
|
||||
{
|
||||
throw new \LogicException;
|
||||
}
|
||||
|
||||
$options['ps_id'] = $purchase->id;
|
||||
$options['ps_name'] = $purchase->name;
|
||||
}
|
||||
@@ -158,23 +164,22 @@ class _Admin
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Store image proxy status ( true = enabled )
|
||||
* @brief Use the cached image URL instead of the original URL
|
||||
*/
|
||||
protected $_imageProxyStatus = null;
|
||||
protected $proxyUrl = FALSE;
|
||||
|
||||
/**
|
||||
* Rebuild content to add or remove image proxy
|
||||
*
|
||||
* @param int|null $offset Offset to start from
|
||||
* @param int|null $max Maximum to parse
|
||||
* @param bool $status Enable/Disable Image Proxy
|
||||
* @param bool $proxyUrl Use the cached image URL instead of the original URL
|
||||
* @return int Number completed
|
||||
* @note This method is optional and will only be called if it exists
|
||||
*/
|
||||
public function rebuildImageProxy( $offset, $max, $status=TRUE )
|
||||
public function rebuildImageProxy( $offset, $max, $proxyUrl = FALSE )
|
||||
{
|
||||
$this->_imageProxyStatus = $status;
|
||||
|
||||
$this->proxyUrl = $proxyUrl;
|
||||
return $this->performRebuild( $offset, $max, 'parseImageProxy' );
|
||||
}
|
||||
|
||||
@@ -191,6 +196,27 @@ class _Admin
|
||||
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 )
|
||||
{
|
||||
$this->_lazyLoadStatus = $status;
|
||||
|
||||
return $this->performRebuild( $offset, $max, 'parseLazyLoad' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform rebuild - abstracted as the call for rebuildContent() and rebuildAttachmentImages() is nearly identical
|
||||
*
|
||||
@@ -211,11 +237,15 @@ class _Admin
|
||||
{
|
||||
if( $callback == 'parseImageProxy' )
|
||||
{
|
||||
$rebuilt = \IPS\Text\Parser::parseImageProxy( $word['word_custom'], $this->_imageProxyStatus );
|
||||
$rebuilt = \IPS\Text\Parser::removeImageProxy( $word['word_custom'], $this->proxyUrl );
|
||||
}
|
||||
elseif( $callback == 'parseLazyLoad' )
|
||||
{
|
||||
$rebuilt = \IPS\Text\Parser::parseLazyLoad( $word['word_custom'], $this->_lazyLoadStatus );
|
||||
}
|
||||
else
|
||||
{
|
||||
$rebuilt = call_user_func( $callback, $word['word_custom'] );
|
||||
$rebuilt = $callback( $word['word_custom'] );
|
||||
}
|
||||
}
|
||||
catch( \InvalidArgumentException $e )
|
||||
@@ -243,11 +273,15 @@ class _Admin
|
||||
{
|
||||
if( $callback == 'parseImageProxy' )
|
||||
{
|
||||
$newMessage = \IPS\Text\Parser::parseImageProxy( \IPS\Settings::i()->$k, $this->_imageProxyStatus );
|
||||
$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 = call_user_func( $callback, \IPS\Settings::i()->$k );
|
||||
$newMessage = $callback( \IPS\Settings::i()->$k );
|
||||
}
|
||||
}
|
||||
catch( \InvalidArgumentException $e )
|
||||
@@ -281,11 +315,15 @@ class _Admin
|
||||
{
|
||||
if( $callback == 'parseImageProxy' )
|
||||
{
|
||||
$rebuild = \IPS\Text\Parser::parseImageProxy( $package['p_page'], $this->_imageProxyStatus );
|
||||
$rebuilt = \IPS\Text\Parser::removeImageProxy( $package['p_page'] );
|
||||
}
|
||||
elseif( $callback == 'parseLazyLoad' )
|
||||
{
|
||||
$rebuilt = \IPS\Text\Parser::parseLazyLoad( $package['p_page'], $this->_lazyLoadStatus );
|
||||
}
|
||||
else
|
||||
{
|
||||
$rebuilt = call_user_func( $callback, $package['p_page'], NULL, FALSE, 'nexus_Admin', $package['p_id'], NULL, 'pkg-pg' );
|
||||
$rebuilt = $callback( $package['p_page'], NULL, FALSE, 'nexus_Admin', $package['p_id'], NULL, 'pkg-pg' );
|
||||
}
|
||||
}
|
||||
catch( \InvalidArgumentException $e )
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\EditorLocations;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -118,26 +118,46 @@ class _Customer
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Store image proxy status ( true = enabled )
|
||||
* @brief Use the cached image URL instead of the original URL
|
||||
*/
|
||||
protected $_imageProxyStatus = null;
|
||||
protected $proxyUrl = FALSE;
|
||||
|
||||
/**
|
||||
* Rebuild content to add or remove image proxy
|
||||
*
|
||||
* @param int|null $offset Offset to start from
|
||||
* @param int|null $max Maximum to parse
|
||||
* @param bool $status Enable/Disable Image Proxy
|
||||
* @param bool $proxyUrl Use the cached image URL instead of the original URL
|
||||
* @return int Number completed
|
||||
* @note This method is optional and will only be called if it exists
|
||||
*/
|
||||
public function rebuildImageProxy( $offset, $max, $status=TRUE )
|
||||
public function rebuildImageProxy( $offset, $max, $proxyUrl = FALSE )
|
||||
{
|
||||
$this->_imageProxyStatus = $status;
|
||||
|
||||
$this->proxyUrl = $proxyUrl;
|
||||
return $this->performRebuild( $offset, $max, 'parseImageProxy' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 )
|
||||
{
|
||||
$this->_lazyLoadStatus = $status;
|
||||
|
||||
return $this->performRebuild( $offset, $max, 'parseLazyLoad' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform rebuild - abstracted as the call for rebuildContent() and rebuildAttachmentImages() is nearly identical
|
||||
*
|
||||
@@ -158,7 +178,7 @@ class _Customer
|
||||
$editorFields[] = 'field_' . $field['f_id'];
|
||||
}
|
||||
|
||||
if( !count( $editorFields ) )
|
||||
if( !\count( $editorFields ) )
|
||||
{
|
||||
return $did;
|
||||
}
|
||||
@@ -177,11 +197,15 @@ class _Customer
|
||||
{
|
||||
if( $callback == 'parseImageProxy' )
|
||||
{
|
||||
$rebuilt = \IPS\Text\Parser::parseImageProxy( $member[ $fieldId ], $this->_imageProxyStatus );
|
||||
$rebuilt = \IPS\Text\Parser::removeImageProxy( $member[ $fieldId ], $this->proxyUrl );
|
||||
}
|
||||
elseif( $callback == 'parseLazyLoad' )
|
||||
{
|
||||
$rebuilt = \IPS\Text\Parser::parseLazyLoad( $member[ $fieldId ], $this->_lazyLoadStatus );
|
||||
}
|
||||
else
|
||||
{
|
||||
$rebuilt = call_user_func( $callback, $member[ $fieldId ], \IPS\Member::load( $member['member_id'] ) );
|
||||
$rebuilt = $callback( $member[ $fieldId ], \IPS\Member::load( $member['member_id'] ) );
|
||||
}
|
||||
}
|
||||
catch( \InvalidArgumentException $e )
|
||||
@@ -202,7 +226,7 @@ class _Customer
|
||||
}
|
||||
}
|
||||
|
||||
if( count( $toUpdate ) )
|
||||
if( \count( $toUpdate ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_customers', $toUpdate, array( 'member_id=?', $member['member_id'] ) );
|
||||
}
|
||||
@@ -226,7 +250,7 @@ class _Customer
|
||||
$editorFields[] = 'field_' . $field['f_id'];
|
||||
}
|
||||
|
||||
if( !count( $editorFields ) )
|
||||
if( !\count( $editorFields ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\EditorLocations;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -72,7 +72,7 @@ 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 \IPS\nexus\Invoice::load( \intval( mb_substr( $id3, 7 ) ) )->canView( $member );
|
||||
}
|
||||
|
||||
/* If it's in an purchase, we can link to that */
|
||||
@@ -110,7 +110,7 @@ class _Purchases
|
||||
/* 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 ) ) );
|
||||
$invoice = \IPS\nexus\Invoice::load( \intval( mb_substr( $id3, 8 ) ) );
|
||||
return \IPS\Dispatcher::i()->controllerLocation == 'admin' ? $invoice->acpUrl() : $invoice->url();
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\EditorLocations;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\EditorLocations;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -34,16 +34,6 @@ class _Support
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only allow local embeds?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function embedLocalOnly()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can we use attachments in this editor?
|
||||
*
|
||||
@@ -102,18 +92,4 @@ class _Support
|
||||
{
|
||||
return \IPS\nexus\Support\Reply::load( $id2 );
|
||||
}
|
||||
|
||||
/**
|
||||
* HTMLPurifier Configuration
|
||||
*
|
||||
* @param \HTMLPurifier_Config $config Configuration
|
||||
* @return void
|
||||
*/
|
||||
public function htmlPurifierConfig( \HTMLPurifier_Config $config )
|
||||
{
|
||||
$config->set( 'URI.Munge', \IPS\Settings::i()->base_url . 'index.php?app=core&module=system&controller=redirect&url=%s&key=%t&resource=%r' );
|
||||
$config->set( 'URI.MungeResources', TRUE );
|
||||
$config->set( 'URI.MungeSecretKey', \IPS\Settings::i()->site_secret_key );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\FileStorage;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -96,7 +96,7 @@ class _Ads
|
||||
{
|
||||
foreach ( \IPS\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;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\FileStorage;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -35,7 +35,7 @@ class _Customer
|
||||
{
|
||||
$where[] = "field_{$field->id}<>''";
|
||||
}
|
||||
if ( !count( $where ) )
|
||||
if ( !\count( $where ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -61,7 +61,7 @@ class _Customer
|
||||
$ids[] = $field->id;
|
||||
$where[] = "field_{$field->id}<>''";
|
||||
}
|
||||
if ( !count( $where ) )
|
||||
if ( !\count( $where ) )
|
||||
{
|
||||
throw new \Underflowexception;
|
||||
}
|
||||
@@ -80,7 +80,7 @@ class _Customer
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $update ) )
|
||||
if ( \count( $update ) )
|
||||
{
|
||||
foreach( $update as $k => $v )
|
||||
{
|
||||
@@ -90,7 +90,7 @@ class _Customer
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $update ) )
|
||||
if ( \count( $update ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_customers', $update, array( 'member_id=?', $customer['member_id'] ) );
|
||||
}
|
||||
@@ -112,7 +112,7 @@ class _Customer
|
||||
$ids[] = $field->id;
|
||||
$where[] = "field_{$field->id}<>''";
|
||||
}
|
||||
if ( !count( $where ) )
|
||||
if ( !\count( $where ) )
|
||||
{
|
||||
throw new \Underflowexception;
|
||||
}
|
||||
@@ -127,9 +127,9 @@ class _Customer
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $update ) )
|
||||
if ( \count( $update ) )
|
||||
{
|
||||
if ( count( $update ) )
|
||||
if ( \count( $update ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_customers', $update, array( 'member_id=?', $customer['member_id'] ) );
|
||||
}
|
||||
@@ -149,12 +149,12 @@ class _Customer
|
||||
{
|
||||
$_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();
|
||||
@@ -174,7 +174,7 @@ class _Customer
|
||||
$ids[] = $field->id;
|
||||
$where[] = "field_{$field->id}<>''";
|
||||
}
|
||||
if ( !count( $where ) )
|
||||
if ( !\count( $where ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\FileStorage;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\FileStorage;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\FileStorage;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -45,7 +45,7 @@ class _PurchaseFields
|
||||
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
|
||||
{
|
||||
$customFields = \IPS\nexus\Package\CustomField::roots( NULL, NULL, array( 'cf_type=?', 'upload' ) );
|
||||
if ( count( $customFields ) )
|
||||
if ( \count( $customFields ) )
|
||||
{
|
||||
$packages = array();
|
||||
foreach ( $customFields as $field )
|
||||
@@ -93,7 +93,7 @@ class _PurchaseFields
|
||||
public function fixUrls( $offset )
|
||||
{
|
||||
$customFields = \IPS\nexus\Package\CustomField::roots( NULL, NULL, array( 'cf_type=?', 'upload' ) );
|
||||
if ( count( $customFields ) )
|
||||
if ( \count( $customFields ) )
|
||||
{
|
||||
$packages = array();
|
||||
foreach ( $customFields as $field )
|
||||
@@ -137,9 +137,9 @@ class _PurchaseFields
|
||||
public function isValidFile( $file )
|
||||
{
|
||||
$customFields = \IPS\nexus\Package\CustomField::roots( NULL, NULL, array( 'cf_type=?', 'upload' ) );
|
||||
if ( count( $customFields ) )
|
||||
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 ( \IPS\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 )
|
||||
@@ -162,7 +162,7 @@ class _PurchaseFields
|
||||
public function delete()
|
||||
{
|
||||
$customFields = \IPS\nexus\Package\CustomField::roots( NULL, NULL, array( 'cf_type=?', 'upload' ) );
|
||||
if ( count( $customFields ) )
|
||||
if ( \count( $customFields ) )
|
||||
{
|
||||
$packages = array();
|
||||
foreach ( $customFields as $field )
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief File Storage Extension: Referral Banners
|
||||
* @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 Aug 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: Referral Banners
|
||||
*/
|
||||
class _ReferralBanners
|
||||
{
|
||||
/**
|
||||
* Count stored files
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_referral_banners', 'rb_upload=1' )->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 )
|
||||
{
|
||||
$record = \IPS\Db::i()->select( '*', 'nexus_referral_banners', 'rb_upload=1', 'rb_id', array( $offset, 1 ) )->first();
|
||||
|
||||
try
|
||||
{
|
||||
$file = \IPS\File::get( $oldConfiguration ?: 'nexus_ReferralBanners', $record['rb_url'] )->move( $storageConfiguration );
|
||||
|
||||
if ( (string) $file != $record['rb_url'] )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_referral_banners', array( 'rb_url' => (string) $file ), array( 'rb_id=?', $record['rb_id'] ) );
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
/* 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_referral_banners', 'rb_upload=1', 'rb_id', array( $offset, 1 ) )->first();
|
||||
|
||||
if ( $new = \IPS\File::repairUrl( $record['rb_url'] ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_referral_banners', array( 'rb_url' => $new ), array( 'rb_id=?', $record['rb_id'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file is valid
|
||||
*
|
||||
* @param string $file The file path to check
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidFile( $file )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->select( '*', 'nexus_referral_banners', array( 'rb_url=? and rb_upload=1', (string) $file ) )->first();
|
||||
return TRUE;
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all stored files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_referral_banners', 'rb_upload=1' ) as $banner )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'nexus_ReferralBanners', $banner['rb_url'] )->delete();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\FileStorage;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -45,7 +45,7 @@ class _Support
|
||||
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
|
||||
{
|
||||
$customFields = \IPS\nexus\Support\CustomField::roots( NULL, NULL, array( 'sf_type=?', 'upload' ) );
|
||||
if ( count( $customFields ) )
|
||||
if ( \count( $customFields ) )
|
||||
{
|
||||
$where = array();
|
||||
$departments = array();
|
||||
@@ -99,7 +99,7 @@ class _Support
|
||||
public function fixUrls( $offset )
|
||||
{
|
||||
$customFields = \IPS\nexus\Support\CustomField::roots( NULL, NULL, array( 'sf_type=?', 'upload' ) );
|
||||
if ( count( $customFields ) )
|
||||
if ( \count( $customFields ) )
|
||||
{
|
||||
$where = array();
|
||||
$departments = array();
|
||||
@@ -149,9 +149,9 @@ class _Support
|
||||
public function isValidFile( $file )
|
||||
{
|
||||
$customFields = \IPS\nexus\Support\CustomField::roots( NULL, NULL, array( 'sf_type=?', 'upload' ) );
|
||||
if ( count( $customFields ) )
|
||||
if ( \count( $customFields ) )
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'nexus_support_requests', array( "r_cfields LIKE ?", "%" . str_replace( '\\', '\\\\', trim( json_encode( (string) $file ), '"' ) . "%" ) ) ) as $request )
|
||||
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 )
|
||||
@@ -175,7 +175,7 @@ class _Support
|
||||
public function delete()
|
||||
{
|
||||
$customFields = \IPS\nexus\Support\CustomField::roots( NULL, NULL, array( 'sf_type=?', 'upload' ) );
|
||||
if ( count( $customFields ) )
|
||||
if ( \count( $customFields ) )
|
||||
{
|
||||
$where = array();
|
||||
$departments = array();
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\FrontNavigation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\FrontNavigation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\FrontNavigation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\FrontNavigation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\FrontNavigation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -43,7 +43,7 @@ class _Credit extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
*/
|
||||
public static function isEnabled()
|
||||
{
|
||||
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 ( \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 ) ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\FrontNavigation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
|
||||
+12
-22
@@ -1,28 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Front Navigation Extension: Referrals
|
||||
* @brief Front Navigation Extension: Gift Cards
|
||||
* @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 29 Apr 2014
|
||||
* @since 28 Aug 2018
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\FrontNavigation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Front Navigation Extension: Referrals
|
||||
* Front Navigation Extension: Gift Cards
|
||||
*/
|
||||
class _Referrals extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
{
|
||||
class _Gifts extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
{
|
||||
/**
|
||||
* Get Type Title which will display in the AdminCP Menu Manager
|
||||
*
|
||||
@@ -30,7 +30,7 @@ class _Referrals extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
*/
|
||||
public static function typeTitle()
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('client_referrals');
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('gift_vouchers');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,19 +42,9 @@ class _Referrals extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
*/
|
||||
public static function isEnabled()
|
||||
{
|
||||
return \IPS\Settings::i()->cm_ref_on;
|
||||
return ( ( \IPS\Settings::i()->nexus_gift_vouchers and \count( json_decode( \IPS\Settings::i()->nexus_gift_vouchers, TRUE ) ) ) or \IPS\Settings::i()->nexus_gift_vouchers_free );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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', 'clients' ) ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
@@ -62,7 +52,7 @@ class _Referrals extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
*/
|
||||
public function title()
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('client_referrals');
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('gift_vouchers');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,7 +62,7 @@ class _Referrals extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
*/
|
||||
public function link()
|
||||
{
|
||||
return \IPS\Http\Url::internal( "app=nexus&module=clients&controller=referrals", 'front', 'clientsreferrals' );
|
||||
return \IPS\Http\Url::internal( "app=nexus&module=store&controller=gifts", 'front', 'store_giftvouchers' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,6 +72,6 @@ class _Referrals extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
*/
|
||||
public function active()
|
||||
{
|
||||
return \IPS\Dispatcher::i()->application->directory === 'nexus' and \IPS\Dispatcher::i()->module and \IPS\Dispatcher::i()->module->key === 'clients' and \IPS\Dispatcher::i()->controller == 'referrals';
|
||||
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';
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\FrontNavigation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\FrontNavigation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\FrontNavigation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\FrontNavigation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\FrontNavigation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -70,6 +70,6 @@ class _Store extends \IPS\core\FrontNavigation\FrontNavigationAbstract
|
||||
*/
|
||||
public function active()
|
||||
{
|
||||
return \IPS\Dispatcher::i()->application->directory === 'nexus' and \IPS\Dispatcher::i()->module and ( \IPS\Dispatcher::i()->module->key === 'store' or \IPS\Dispatcher::i()->module->key === 'subscriptions' );
|
||||
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' ) );
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\FrontNavigation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\FrontNavigation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\IncomingEmail;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -37,7 +37,7 @@ class _Support
|
||||
/* Replying? */
|
||||
$request = $this->_emailIsReplyForRequest( $email );
|
||||
$department = $this->_getDepartment( $email );
|
||||
|
||||
|
||||
if ( $request )
|
||||
{
|
||||
/* IS this request locked? */
|
||||
@@ -73,6 +73,11 @@ class _Support
|
||||
$this->_processNewRequest( $email, $member, $department );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Track a property in the reply-to header for reference later
|
||||
*/
|
||||
protected $_lastMessageId = NULL;
|
||||
|
||||
/**
|
||||
* Is reply?
|
||||
@@ -98,6 +103,12 @@ class _Support
|
||||
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] );
|
||||
@@ -109,12 +120,21 @@ class _Support
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
|
||||
/* If the same email generated a new support request within the last 10 minutes, add this as a reply to that */
|
||||
/* 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
|
||||
{
|
||||
$recentRequest = \IPS\Db::i()->select( '*', 'nexus_support_requests', array( 'r_email=? AND r_started>?', $email->from, ( time() - 600 ) ) )->first();
|
||||
return \IPS\nexus\Support\Request::constructFromData( $recentRequest );
|
||||
$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 ) { }
|
||||
|
||||
@@ -149,15 +169,15 @@ class _Support
|
||||
|
||||
$pending = FALSE;
|
||||
$newMessage = NULL;
|
||||
if ( $staff and isset( $matches[4] ) )
|
||||
if ( $staff and $this->_lastMessageId )
|
||||
{
|
||||
$newMessage = $request->comments( 1, 0, 'date', 'desc' );
|
||||
if ( $matches[4] != $newMessage->id )
|
||||
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;
|
||||
@@ -175,6 +195,7 @@ class _Support
|
||||
$reply->raw = $email->raw;
|
||||
$reply->save();
|
||||
static::makeAndClaimAttachments( $email->attachments, $reply, $member );
|
||||
static::storeAttachmentMappings( $email->mappedAttachments, $reply, $member );
|
||||
|
||||
if ( $pending )
|
||||
{
|
||||
@@ -233,7 +254,7 @@ class _Support
|
||||
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 ) )
|
||||
if ( !\is_null( $previousRequest ) )
|
||||
{
|
||||
/* Use the existing requests department instead. */
|
||||
$department = $previousRequest->department;
|
||||
@@ -259,8 +280,8 @@ class _Support
|
||||
|
||||
if ( $previousRequest )
|
||||
{
|
||||
$request->log( 'previous_request', $previousRequest, NULL, $member );
|
||||
$previousRequest->log( 'previous_request', NULL, $request, $member );
|
||||
$request->log( 'previous_request', $previousRequest, NULL, ( $member->member_id ) ? $member : FALSE );
|
||||
$previousRequest->log( 'previous_request', NULL, $request, ( $member->member_id ) ? $member : FALSE );
|
||||
}
|
||||
|
||||
$request->sendNotifications();
|
||||
@@ -313,7 +334,7 @@ class _Support
|
||||
$reply = $this->_createReply( $email, $request, $member, $quoted, $originallyFromEmail );
|
||||
|
||||
/* Create a hidden note */
|
||||
if ( trim( $email->message ) or count( $email->attachments ) )
|
||||
if ( trim( $email->message ) or \count( $email->attachments ) )
|
||||
{
|
||||
$note = new \IPS\nexus\Support\Reply;
|
||||
$note->request = $request->id;
|
||||
@@ -325,6 +346,7 @@ class _Support
|
||||
$note->save();
|
||||
|
||||
static::makeAndClaimAttachments( $email->attachments, $note, $member );
|
||||
static::storeAttachmentMappings( $email->mappedAttachments, $note, $member );
|
||||
}
|
||||
|
||||
/* Return */
|
||||
@@ -363,13 +385,6 @@ class _Support
|
||||
$notify[] = array( 'type' => 'e', 'value' => $cc );
|
||||
}
|
||||
}
|
||||
foreach( ( $email->bcc ?: array() ) as $cc )
|
||||
{
|
||||
if ( $cc !== $department->email )
|
||||
{
|
||||
$notify[] = array( 'type' => 'e', 'value' => $cc, 'bcc' => 1 );
|
||||
}
|
||||
}
|
||||
|
||||
$request->notify = $notify;
|
||||
$request->save();
|
||||
@@ -377,6 +392,7 @@ class _Support
|
||||
/* 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 )
|
||||
@@ -498,7 +514,7 @@ class _Support
|
||||
) );
|
||||
}
|
||||
|
||||
if ( count( $replacements ) )
|
||||
if ( \count( $replacements ) )
|
||||
{
|
||||
foreach ( $replacements as $find => $replace )
|
||||
{
|
||||
@@ -507,4 +523,25 @@ class _Support
|
||||
$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,
|
||||
) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief IP Address Lookup extension
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage
|
||||
* @since 18 Sep 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
* @deprecated 4.3
|
||||
*/
|
||||
|
||||
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 _CustomerHistory
|
||||
{
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
*@return bool
|
||||
*/
|
||||
final public function deprecated()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\IpAddresses;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -85,6 +85,6 @@ class _Payouts
|
||||
*/
|
||||
public function findByMember( $member )
|
||||
{
|
||||
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 \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' );
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\IpAddresses;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -42,7 +42,7 @@ class _Support
|
||||
*/
|
||||
public function supportedInModCp()
|
||||
{
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\IpAddresses;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -85,6 +85,6 @@ class _Transactions
|
||||
*/
|
||||
public function findByMember( $member )
|
||||
{
|
||||
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 \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' );
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\LiveSearch;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -26,7 +26,7 @@ class _Nexus
|
||||
/**
|
||||
* Check we have access
|
||||
*
|
||||
* @return void
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAccess()
|
||||
{
|
||||
@@ -41,7 +41,7 @@ class _Nexus
|
||||
/**
|
||||
* Get the search results
|
||||
*
|
||||
* @param string Search Term
|
||||
* @param string $searchTerm Search Term
|
||||
* @return array Array of results
|
||||
*/
|
||||
public function getResults( $searchTerm )
|
||||
@@ -49,7 +49,7 @@ class _Nexus
|
||||
$results = array();
|
||||
|
||||
/* Numeric */
|
||||
if ( is_numeric( $searchTerm ) )
|
||||
if ( \is_numeric( $searchTerm ) )
|
||||
{
|
||||
/* Invoice */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'invoices_manage' ) )
|
||||
@@ -144,7 +144,16 @@ class _Nexus
|
||||
/* Customers */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customers_view' ) )
|
||||
{
|
||||
foreach ( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_customers', array( "LOWER( core_members.name ) LIKE CONCAT( '%', ?, '%' ) OR LOWER( core_members.email ) LIKE CONCAT( '%', ?, '%' ) OR CONCAT( LOWER( nexus_customers.cm_first_name ), ' ', LOWER( nexus_customers.cm_last_name ) ) LIKE CONCAT( '%', ?, '%' )", mb_strtolower( $searchTerm ), mb_strtolower( $searchTerm ), mb_strtolower( $searchTerm ) ), NULL, 50 )->join( 'core_members', 'core_members.member_id=nexus_customers.member_id' ), 'IPS\nexus\Customer' ) as $customer )
|
||||
if( \IPS\core\extensions\core\LiveSearch\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' );
|
||||
}
|
||||
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' );
|
||||
}
|
||||
|
||||
foreach ( new \IPS\Patterns\ActiveRecordIterator( $query, 'IPS\nexus\Customer' ) as $customer )
|
||||
{
|
||||
$results[] = \IPS\Theme::i()->getTemplate('livesearch', 'nexus')->customer( $customer );
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\MFAArea;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -30,6 +30,6 @@ class _AccountCredit
|
||||
*/
|
||||
public function isEnabled()
|
||||
{
|
||||
return ( \IPS\Settings::i()->nexus_min_topup or count( json_decode( \IPS\Settings::i()->nexus_payout, TRUE ) ) );
|
||||
return ( \IPS\Settings::i()->nexus_min_topup or \count( json_decode( \IPS\Settings::i()->nexus_payout, TRUE ) ) );
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\MFAArea;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\MFAArea;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\MFAArea;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\MFAArea;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\MFAArea;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
|
||||
Whitespace-only changes.
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\MemberACPProfileBlocks;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -36,14 +36,14 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
'count' => 0
|
||||
)
|
||||
);
|
||||
if ( count( \IPS\nexus\Gateway::cardStorageGateways() ) )
|
||||
if ( \count( \IPS\nexus\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( \IPS\nexus\Gateway::billingAgreementGateways() ) )
|
||||
{
|
||||
$tabs['paypal'] = array(
|
||||
'icon' => 'paypal',
|
||||
@@ -54,10 +54,7 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
'icon' => 'user',
|
||||
'count' => \IPS\Db::i()->select( 'COUNT(*)', 'nexus_alternate_contacts', array( 'main_id=?', $this->member->member_id ) )->first()
|
||||
);
|
||||
$tabs['referrers'] = array(
|
||||
'icon' => 'retweet',
|
||||
'count' => \IPS\Db::i()->select( 'COUNT(*)', 'nexus_referrals', array( 'referred_by=?', $this->member->member_id ) )->first()
|
||||
);
|
||||
|
||||
return $tabs;
|
||||
}
|
||||
|
||||
@@ -71,7 +68,7 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
/* Sparkline */
|
||||
$sparkline = NULL;
|
||||
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customer', 'customers_view_statistics' ) )
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customers_view_statistics' ) )
|
||||
{
|
||||
$rows = array();
|
||||
$oneYearAgo = \IPS\DateTime::create()->sub( new \DateInterval( 'P1Y' ) );
|
||||
@@ -142,32 +139,17 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
),
|
||||
) );
|
||||
}
|
||||
|
||||
/* Referrals */
|
||||
try
|
||||
{
|
||||
$referredBy = \IPS\nexus\Customer::load( \IPS\Db::i()->select( 'referred_by', 'nexus_referrals', array( 'member_id=?', $this->member->member_id ) )->first() );
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
$referredBy = NULL;
|
||||
}
|
||||
|
||||
/* Primary Billing Address */
|
||||
$primaryBillingAddress = NULL;
|
||||
try
|
||||
{
|
||||
$primaryBillingAddress = \IPS\nexus\Customer\Address::constructFromData( \IPS\Db::i()->select( '*', 'nexus_customer_addresses', array( 'member=? AND primary_billing=1', $this->member->member_id ) )->first() )->address;
|
||||
}
|
||||
catch ( \UnderflowException $e ) { }
|
||||
$addressCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_customer_addresses', array( 'member=?', $this->member->member_id ) )->first();
|
||||
$primaryBillingAddress = $this->member->primaryBillingAddress();
|
||||
$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, $referredBy, $primaryBillingAddress, $addressCount );
|
||||
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->accountInformationOverview( $this->member, $sparkline, $primaryBillingAddress, $addressCount );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get output: CARDS
|
||||
* Get output: STORED PAYMENT METHODS
|
||||
*
|
||||
* @param bool $edit Edit view?
|
||||
* @return string
|
||||
@@ -184,21 +166,25 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
'id' => $card->id,
|
||||
'card_type' => $cardData->type,
|
||||
'card_member' => $card->member->member_id,
|
||||
'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_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
|
||||
);
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
}
|
||||
$cards = new \IPS\Helpers\Table\Custom( $cards, $this->member->acpUrl()->setQueryString( 'view', 'cards' ) );
|
||||
$cards->rootButtons = array(
|
||||
'add' => array(
|
||||
'link' => \IPS\Http\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') )
|
||||
)
|
||||
);
|
||||
|
||||
if ( \IPS\nexus\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' ),
|
||||
'title' => 'add',
|
||||
'icon' => 'plus',
|
||||
'data' => array( 'ipsDialog' => true, 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('add_card') )
|
||||
)
|
||||
);
|
||||
}
|
||||
$cards->rowButtons = function( $row )
|
||||
{
|
||||
return array(
|
||||
@@ -368,76 +354,7 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
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' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get output: REFERRERS
|
||||
*
|
||||
* @param bool $edit Edit view?
|
||||
* @return string
|
||||
*/
|
||||
protected function _referrers( $edit = FALSE )
|
||||
{
|
||||
$referCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_referrals', array( 'referred_by=?', $this->member->member_id ) )->first();
|
||||
$referrals = new \IPS\Helpers\Table\Db( 'nexus_referrals', $this->member->acpUrl()->setQueryString( 'view', 'referrals' ), array( 'referred_by=?', $this->member->member_id ) );
|
||||
$referrals->langPrefix = 'ref_';
|
||||
$referrals->include = array( 'member_id', 'amount' );
|
||||
$referrals->sortBy = $referrals->sortBy ?: 'member_id';
|
||||
$referrals->parsers = array(
|
||||
'member_id' => function( $v )
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'nexus' )->userLink( \IPS\nexus\Customer::load( $v ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('deleted_member');
|
||||
}
|
||||
},
|
||||
'email' => function( $v, $row )
|
||||
{
|
||||
try
|
||||
{
|
||||
return htmlspecialchars( \IPS\nexus\Customer::load( $row['member_id'] )->email, ENT_DISALLOWED, 'UTF-8', FALSE );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('deleted_member');
|
||||
}
|
||||
},
|
||||
'amount' => function( $v )
|
||||
{
|
||||
$return = array();
|
||||
if ( $v )
|
||||
{
|
||||
foreach ( json_decode( $v, TRUE ) as $currency => $amount )
|
||||
{
|
||||
$return[] = new \IPS\nexus\Money( $amount, $currency );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$return[] = new \IPS\nexus\Money( 0, \IPS\nexus\Customer::load( $this->member )->defaultCurrency() );
|
||||
}
|
||||
return implode( '<br>', $return );
|
||||
}
|
||||
);
|
||||
|
||||
if ( $edit )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->customerPopup( $referrals );
|
||||
}
|
||||
else
|
||||
{
|
||||
$referrals->include[] = 'email';
|
||||
$referrals->limit = 2;
|
||||
$referrals->tableTemplate = array( \IPS\Theme::i()->getTemplate( 'customers', 'nexus' ), 'referralsOverview' );
|
||||
$referrals->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'customers', 'nexus' ), 'referralsOverviewRows' );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->accountInformationTablePreview( $this->member, $referrals, \IPS\Member::loggedIn()->language()->addToStack( 'num_refer_count', FALSE, array( 'pluralize' => array( $referCount ) ) ), 'referrers' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get output
|
||||
*
|
||||
@@ -472,7 +389,7 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
public function output()
|
||||
{
|
||||
$tabs = $this->tabs();
|
||||
if ( !count( $tabs ) )
|
||||
if ( !\count( $tabs ) )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
namespace IPS\nexus\extensions\core\MemberACPProfileBlocks;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
namespace IPS\nexus\extensions\core\MemberACPProfileBlocks;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -92,7 +92,7 @@ class _Notes extends \IPS\core\MemberACPProfile\Block
|
||||
'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 ) ),
|
||||
'title' => 'delete',
|
||||
'icon' => 'times-circle',
|
||||
'data' => array( 'delete' => '' )
|
||||
'data' => array( 'confirm' => '' )
|
||||
);
|
||||
}
|
||||
return $return;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
namespace IPS\nexus\extensions\core\MemberACPProfileBlocks;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -35,7 +35,7 @@ class _ParentAccounts extends \IPS\core\MemberACPProfile\Block
|
||||
$parents[] = \IPS\nexus\Customer::load( $row );
|
||||
}
|
||||
|
||||
if ( count( $parents ) )
|
||||
if ( \count( $parents ) )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->parentAccounts( $parents );
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
namespace IPS\nexus\extensions\core\MemberACPProfileBlocks;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -20,7 +20,7 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
/**
|
||||
* @brief ACP Member Profile: Purchases
|
||||
*/
|
||||
class _Purchases extends \IPS\core\MemberACPProfile\Block
|
||||
class _Purchases extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
{
|
||||
/**
|
||||
* Purchase tree
|
||||
@@ -28,22 +28,33 @@ class _Purchases extends \IPS\core\MemberACPProfile\Block
|
||||
protected $_purchases = NULL;
|
||||
|
||||
/**
|
||||
* Get purchase table
|
||||
* Get Tab Names
|
||||
*
|
||||
* @return \IPS\Helpers\Tree\Tree
|
||||
* @return string
|
||||
*/
|
||||
protected function purchases()
|
||||
public function tabs()
|
||||
{
|
||||
if ( $this->_purchases === NULL )
|
||||
{
|
||||
$this->_purchases = \IPS\nexus\Purchase::tree( $this->member->acpUrl()->setQueryString( 'blockKey', 'nexus_Purchases' ), array( array( 'ps_member=?', $this->member->member_id ) ) );
|
||||
$this->_purchases->rootsPerPage = 15;
|
||||
$this->_purchases->getTotalRoots = function()
|
||||
{
|
||||
return NULL;
|
||||
};
|
||||
}
|
||||
return $this->_purchases;
|
||||
$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();
|
||||
$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();
|
||||
$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();
|
||||
$tabs['canceled'] = array(
|
||||
'icon' => 'credit-card',
|
||||
'count' => $canceledCount,
|
||||
);
|
||||
|
||||
return $tabs;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,19 +64,48 @@ class _Purchases extends \IPS\core\MemberACPProfile\Block
|
||||
*/
|
||||
public function output()
|
||||
{
|
||||
$purchaseCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_member=? AND ps_show=1', $this->member->member_id ) )->first();
|
||||
$purchaseRootCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_member=? AND ps_show=1 AND ps_parent=0', $this->member->member_id ) )->first();
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->purchases( $this->member, $this->purchases(), $purchaseCount, $purchaseRootCount );
|
||||
$tabs = $this->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 );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->purchases( $this->member, $tabs, $activeTabKey, $this->tabOutput( $activeTabKey ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get output
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function tabOutput()
|
||||
public function tabOutput( $activeTabKey )
|
||||
{
|
||||
return (string) $this->purchases();
|
||||
if ( $this->_purchases === NULL )
|
||||
{
|
||||
$where = array();
|
||||
$where[] = array( 'ps_member=?', $this->member->member_id );
|
||||
|
||||
switch ( $activeTabKey )
|
||||
{
|
||||
case 'active':
|
||||
$where[] = array( 'ps_active=1' );
|
||||
break;
|
||||
case 'canceled':
|
||||
$where[] = array( 'ps_cancelled=1' );
|
||||
break;
|
||||
case 'expired':
|
||||
$where[] = array( 'ps_active = 0 and ps_cancelled = 0 and ps_expire <?', \IPS\DateTime::create()->getTimestamp() );
|
||||
break;
|
||||
}
|
||||
|
||||
$this->_purchases = \IPS\nexus\Purchase::tree( $this->member->acpUrl()->setQueryString( 'blockKey', 'nexus_Purchases' ), $where );
|
||||
$this->_purchases->getTotalRoots = function()
|
||||
{
|
||||
return NULL;
|
||||
};
|
||||
}
|
||||
return $this->_purchases;
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
namespace IPS\nexus\extensions\core\MemberACPProfileBlocks;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -90,12 +90,12 @@ class _Statistics extends \IPS\core\MemberACPProfile\LazyLoadingBlock
|
||||
'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(*) )";
|
||||
$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();
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
namespace IPS\nexus\extensions\core\MemberACPProfileBlocks;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
|
||||
Whitespace-only changes.
@@ -11,7 +11,7 @@
|
||||
namespace IPS\nexus\extensions\core\MemberACPProfileTabs;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -64,7 +64,7 @@ class _Main extends \IPS\core\MemberACPProfile\MainTab
|
||||
{
|
||||
$return = array();
|
||||
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customers_view_credit' ) )
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customers_view_statistics' ) )
|
||||
{
|
||||
$return[] = 'IPS\nexus\extensions\core\MemberACPProfileBlocks\Statistics';
|
||||
}
|
||||
|
||||
Whitespace-only changes.
@@ -11,7 +11,7 @@
|
||||
namespace IPS\nexus\extensions\core\MemberExportPersonalInformation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -42,7 +42,7 @@ class _Customer
|
||||
'last_name' => $customer->cm_last_name
|
||||
);
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_customer_addresses', array( 'member=?', $member->member_id ) ) as $address )
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_customer_addresses', array( '`member`=?', $member->member_id ) ) as $address )
|
||||
{
|
||||
$return['addresses'][] = \IPS\GeoLocation::buildFromJson( $address['address'] )->toString( "," );
|
||||
}
|
||||
@@ -66,7 +66,7 @@ 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 ) {}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\MemberFilter;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -31,7 +31,7 @@ class _Purchases
|
||||
*/
|
||||
public function availableIn( $area )
|
||||
{
|
||||
return in_array( $area, array( 'bulkmail' ) );
|
||||
return \in_array( $area, array( 'bulkmail' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,7 +78,7 @@ class _Purchases
|
||||
*/
|
||||
public function save( $post )
|
||||
{
|
||||
if ( is_array( $post['nexus_bm_filters_packages'] ) )
|
||||
if ( \is_array( $post['nexus_bm_filters_packages'] ) )
|
||||
{
|
||||
$ids = array();
|
||||
foreach ( $post['nexus_bm_filters_packages'] as $package )
|
||||
@@ -88,14 +88,14 @@ class _Purchases
|
||||
|
||||
$return = array(
|
||||
'nexus_bm_filters_packages' => implode( ',', $ids ),
|
||||
'nexus_bm_filters_pkg_active' => (bool) ( in_array( "active", $post['nexus_bm_filters_type'] ) ),
|
||||
'nexus_bm_filters_pkg_canceled' => (bool) ( in_array( "canceled", $post['nexus_bm_filters_type'] ) ),
|
||||
'nexus_bm_filters_pkg_active' => (bool) ( \in_array( "active", $post['nexus_bm_filters_type'] ) ),
|
||||
'nexus_bm_filters_pkg_canceled' => (bool) ( \in_array( "canceled", $post['nexus_bm_filters_type'] ) ),
|
||||
'nexus_bm_filters_pkg_expired' => NULL
|
||||
);
|
||||
|
||||
if( isset( $post['nexus_bm_filters_pkg_expired'][2] ) AND $post['nexus_bm_filters_pkg_expired'][2] == 'days' )
|
||||
{
|
||||
$return['nexus_bm_filters_pkg_expired'] = $post['nexus_bm_filters_pkg_expired'][1] ? array( 'days' => intval( $post['nexus_bm_filters_pkg_expired'][1] ) ) : FALSE;
|
||||
$return['nexus_bm_filters_pkg_expired'] = $post['nexus_bm_filters_pkg_expired'][1] ? array( 'days' => \intval( $post['nexus_bm_filters_pkg_expired'][1] ) ) : FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -114,7 +114,7 @@ class _Purchases
|
||||
* Get where clause to add to the member retrieval database query
|
||||
*
|
||||
* @param mixed $data The array returned from the save() method
|
||||
* @return array|NULL Where clause - must be a single array( "clause", ...binds )
|
||||
* @return array|NULL Where clause - must be a single array( "clause" )
|
||||
*/
|
||||
public function getQueryWhereClause( $data )
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\MemberFilter;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -31,7 +31,7 @@ class _Subscriptions
|
||||
*/
|
||||
public function availableIn( $area )
|
||||
{
|
||||
return in_array( $area, array( 'bulkmail' ) );
|
||||
return \in_array( $area, array( 'bulkmail' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,7 +77,7 @@ class _Subscriptions
|
||||
*/
|
||||
public function save( $post )
|
||||
{
|
||||
if ( is_array( $post['nexus_bm_filters_subscription_pkgs'] ) )
|
||||
if ( \is_array( $post['nexus_bm_filters_subscription_pkgs'] ) )
|
||||
{
|
||||
$ids = array();
|
||||
foreach ( $post['nexus_bm_filters_subscription_pkgs'] as $package )
|
||||
@@ -87,13 +87,13 @@ class _Subscriptions
|
||||
|
||||
$return = array(
|
||||
'nexus_bm_filters_subscription_pkgs' => implode( ',', $ids ),
|
||||
'nexus_bm_filters_subscription_active' => (bool) ( in_array( "active", $post['nexus_bm_filters_subscription_type'] ) ),
|
||||
'nexus_bm_filters_subscription_canceled' => (bool) ( in_array( "canceled", $post['nexus_bm_filters_subscription_type'] ) ),
|
||||
'nexus_bm_filters_subscription_active' => (bool) ( \in_array( "active", $post['nexus_bm_filters_subscription_type'] ) ),
|
||||
'nexus_bm_filters_subscription_canceled' => (bool) ( \in_array( "canceled", $post['nexus_bm_filters_subscription_type'] ) ),
|
||||
);
|
||||
|
||||
if( isset( $post['nexus_bm_filters_type_expired_date'][2] ) AND $post['nexus_bm_filters_type_expired_date'][2] == 'days' )
|
||||
{
|
||||
$return['nexus_bm_filters_type_expired_date'] = $post['nexus_bm_filters_type_expired_date'][1] ? array( 'days' => intval( $post['nexus_bm_filters_type_expired_date'][1] ) ) : FALSE;
|
||||
$return['nexus_bm_filters_type_expired_date'] = $post['nexus_bm_filters_type_expired_date'][1] ? array( 'days' => \intval( $post['nexus_bm_filters_type_expired_date'][1] ) ) : FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -112,7 +112,7 @@ class _Subscriptions
|
||||
* Get where clause to add to the member retrieval database query
|
||||
*
|
||||
* @param mixed $data The array returned from the save() method
|
||||
* @return array|NULL Where clause - must be a single array( "clause", ...binds )
|
||||
* @return array|NULL Where clause - must be a single array( "clause" )
|
||||
*/
|
||||
public function getQueryWhereClause( $data )
|
||||
{
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
<?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 Nexus
|
||||
* @since 8 Aug 2018
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\MemberFilter;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Member filter extension
|
||||
*/
|
||||
class _TotalSpend
|
||||
{
|
||||
/**
|
||||
* Determine if the filter is available in a given area
|
||||
*
|
||||
* @param string $area Area to check
|
||||
* @return bool
|
||||
*/
|
||||
public function availableIn( $area )
|
||||
{
|
||||
return \in_array( $area, array( 'bulkmail' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Setting Field
|
||||
*
|
||||
* @param mixed $criteria Value returned from the save() method
|
||||
* @return array Array of form elements
|
||||
*/
|
||||
public function getSettingField( $criteria )
|
||||
{
|
||||
return array( $this->_combine( 'nexus_bm_filters_total_spend', 'IPS\nexus\Form\Money', $criteria ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the filter data
|
||||
*
|
||||
* @param array $post Form values
|
||||
* @return mixed False, or an array of data to use later when filtering the members
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function save( $post )
|
||||
{
|
||||
$amounts = array();
|
||||
|
||||
foreach( $post['nexus_bm_filters_total_spend'][1] as $amount )
|
||||
{
|
||||
$amounts[$amount->currency] = $amount->amount;
|
||||
}
|
||||
|
||||
return array( 'total_spend_operator' => $post['nexus_bm_filters_total_spend'][0], 'total_spend_amounts' => json_encode( $amounts ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get where clause to add to the member retrieval database query
|
||||
*
|
||||
* @param mixed $data The array returned from the save() method
|
||||
* @return string|array|NULL Where clause
|
||||
*/
|
||||
public function getQueryWhereClause( $data )
|
||||
{
|
||||
if ( ( isset( $data['total_spend_operator'] ) and $data['total_spend_operator'] !== 'any' ) and isset( $data['total_spend_amounts'] ) )
|
||||
{
|
||||
$where = array();
|
||||
|
||||
foreach( json_decode( $data['total_spend_amounts'], true ) as $currency => $amount )
|
||||
{
|
||||
switch ( $data['total_spend_operator'] )
|
||||
{
|
||||
case 'gt':
|
||||
$operator = ">";
|
||||
break;
|
||||
case 'lt':
|
||||
$operator = "<";
|
||||
break;
|
||||
}
|
||||
|
||||
$where[] = "(nexus_customer_spend.spend_amount{$operator}'{$amount}' and nexus_customer_spend.spend_currency='{$currency}')";
|
||||
}
|
||||
|
||||
return array( implode( ' OR ', $where ) );
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for member retrieval database query
|
||||
* Can be used to set joins
|
||||
*
|
||||
* @param mixed $data The array returned from the save() method
|
||||
* @param \IPS\Db\Query $query The query
|
||||
* @return void
|
||||
*/
|
||||
public function queryCallback( $data, &$query )
|
||||
{
|
||||
$currencies = \IPS\nexus\Money::currencies();
|
||||
$defaultCurrency = array_shift( $currencies );
|
||||
|
||||
if ( ( isset( $data['total_spend_operator'] ) and $data['total_spend_operator'] !== 'any' ) and isset( $data['total_spend_amounts'] ) )
|
||||
{
|
||||
$query->join( 'nexus_customer_spend', "core_members.member_id=nexus_customer_spend.spend_member_id AND nexus_customer_spend.spend_currency='{$defaultCurrency}'" );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Combine two fields
|
||||
*
|
||||
* @param string $name Field name
|
||||
* @param bool $field2Class Classname for second field
|
||||
* @param mixed $criteria Value returned from the save() method
|
||||
* @return \IPS\Helpers\Form\Custom
|
||||
*/
|
||||
public function _combine( $name, $field2Class, $criteria )
|
||||
{
|
||||
$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 \IPS\Helpers\Form\Select( $name . '_type', isset($criteria['total_spend_operator']) ? $criteria['total_spend_operator'] : '', FALSE, $options, NULL, NULL, NULL );
|
||||
$field2 = new $field2Class( $name . '_unit', isset( $criteria['total_spend_amounts'] ) ? $criteria['total_spend_amounts'] : NULL, FALSE, array() );
|
||||
|
||||
return new \IPS\Helpers\Form\Custom( $name, array( "gt", NULL ), FALSE, array(
|
||||
'getHtml' => function() use ( $name, $field1, $field2 )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'forms', 'nexus', 'global' )->combined( $name, $field1, $field2 );
|
||||
},
|
||||
'formatValue' => function() use ( $field1, $field2 )
|
||||
{
|
||||
return array( $field1->value, $field2->value );
|
||||
}
|
||||
) );
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Admin CP Member Form
|
||||
* @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\MemberForm;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin CP Member Form
|
||||
*/
|
||||
class _Nexus
|
||||
{
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
final public function deprecated()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\MemberHistory;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -47,7 +47,8 @@ class _Nexus
|
||||
'support',
|
||||
'custom',
|
||||
'billingagreement',
|
||||
'note'
|
||||
'note',
|
||||
'subscription'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -328,7 +329,14 @@ class _Nexus
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'history_purchase_transfer_to', FALSE, array( 'htmlsprintf' => array( $purchase, $from, $byStaff ) ) );
|
||||
|
||||
case 'cancel':
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'history_purchase_canceled', FALSE, array( 'htmlsprintf' => array( $purchase, $byStaff ) ) );
|
||||
if( isset( $val['by'] ) AND $val['by'] == 'api' )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'history_purchase_canceled_api', FALSE, array( 'htmlsprintf' => array( $purchase, $byStaff ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'history_purchase_canceled', FALSE, array( 'htmlsprintf' => array( $purchase, $byStaff ) ) );
|
||||
}
|
||||
case 'uncancel':
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'history_purchase_reactivated', FALSE, array( 'htmlsprintf' => array( $purchase, $byStaff ) ) );
|
||||
|
||||
@@ -447,7 +455,7 @@ class _Nexus
|
||||
|
||||
if ( isset( $val['name'] ) )
|
||||
{
|
||||
$name = is_array( $val['name'] ) ? implode( ' ', array_values( $val['name'] ) ) : $val['name'];
|
||||
$name = \is_array( $val['name'] ) ? implode( ' ', array_values( $val['name'] ) ) : $val['name'];
|
||||
$changes[] = \IPS\Member::loggedIn()->language()->addToStack('history_name_changed_from', FALSE, array( 'sprintf' => array( $name ) ) );
|
||||
}
|
||||
|
||||
@@ -456,7 +464,7 @@ class _Nexus
|
||||
foreach ( $val['other'] as $change )
|
||||
{
|
||||
/* Older versions may not have stored the display value, so we need to account for that */
|
||||
if( mb_strpos( $change['name'], 'nexus_ccfield_' ) !== FALSE AND is_array( $change['value'] ) )
|
||||
if( mb_strpos( $change['name'], 'nexus_ccfield_' ) !== FALSE AND \is_array( $change['value'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -479,7 +487,7 @@ class _Nexus
|
||||
/* We will just loop and implode so we have a string */
|
||||
foreach( $change['value'] as $k => $v )
|
||||
{
|
||||
if( is_array( $v ) )
|
||||
if( \is_array( $v ) )
|
||||
{
|
||||
foreach( $v as $_k => $_v )
|
||||
{
|
||||
|
||||
Whitespace-only changes.
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\MemberSync;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -31,19 +31,6 @@ class _Nexus
|
||||
*/
|
||||
public function onCreateAccount( $member )
|
||||
{
|
||||
if ( \IPS\Dispatcher::hasInstance() and \IPS\Dispatcher::i()->controllerLocation === 'front' and isset( \IPS\Request::i()->cookie['referred_by'] ) )
|
||||
{
|
||||
$referredBy = \IPS\Member::load( \IPS\Request::i()->cookie['referred_by'] );
|
||||
if ( $referredBy->member_id )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'nexus_referrals', array(
|
||||
'member_id' => $member->member_id,
|
||||
'referred_by' => \IPS\Request::i()->cookie['referred_by'],
|
||||
'amount' => '',
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $member->email )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_support_requests', array( 'r_member' => $member->member_id ), array( 'r_email=? AND r_member=0', $member->email ) );
|
||||
@@ -94,13 +81,11 @@ class _Nexus
|
||||
*/
|
||||
public function onMerge( $member, $member2 )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_customer_addresses', array( 'member' => $member->member_id ), array( 'member=?', $member2->member_id ) );
|
||||
\IPS\Db::i()->update( 'nexus_customer_addresses', array( 'member' => $member->member_id ), array( '`member`=?', $member2->member_id ) );
|
||||
\IPS\Db::i()->update( 'nexus_customer_cards', array( 'card_member' => $member->member_id ), array( 'card_member=?', $member2->member_id ) );
|
||||
\IPS\Db::i()->update( 'nexus_invoices', array( 'i_member' => $member->member_id ), array( 'i_member=?', $member2->member_id ) );
|
||||
\IPS\Db::i()->update( 'nexus_purchases', array( 'ps_member' => $member->member_id ), array( 'ps_member=?', $member2->member_id ) );
|
||||
\IPS\Db::i()->update( 'nexus_purchases', array( 'ps_pay_to' => $member->member_id ), array( 'ps_pay_to=?', $member2->member_id ) );
|
||||
\IPS\Db::i()->update( 'nexus_referrals', array( 'member_id' => $member->member_id ), array( 'member_id=?', $member2->member_id ) );
|
||||
\IPS\Db::i()->update( 'nexus_referrals', array( 'referred_by' => $member->member_id ), array( 'referred_by=?', $member2->member_id ) );
|
||||
\IPS\Db::i()->update( 'nexus_transactions', array( 't_member' => $member->member_id ), array( 't_member=?', $member2->member_id ) );
|
||||
\IPS\Db::i()->update( 'nexus_alternate_contacts', array( 'main_id' => $member->member_id ), array( 'main_id=?', $member2->member_id ) );
|
||||
\IPS\Db::i()->update( 'nexus_alternate_contacts', array( 'alt_id' => $member->member_id ), array( 'alt_id=?', $member2->member_id ) );
|
||||
@@ -112,6 +97,8 @@ class _Nexus
|
||||
\IPS\Db::i()->update( 'nexus_support_ratings', array( 'rating_from' => $member->member_id ), array( 'rating_from=?', $member2->member_id ) );
|
||||
\IPS\Db::i()->update( 'nexus_support_ratings', array( 'rating_staff' => $member->member_id ), array( 'rating_staff=?', $member2->member_id ) );
|
||||
|
||||
\IPS\Db::i()->delete( 'nexus_customer_spend', array( 'spend_member_id=?', $member2->member_id ) );
|
||||
|
||||
/* Account Credit */
|
||||
$customerToKeep = \IPS\nexus\Customer::load( $member->member_id );
|
||||
$creditToKeep = $customerToKeep->cm_credits;
|
||||
@@ -137,11 +124,14 @@ class _Nexus
|
||||
/* Subscription packages */
|
||||
if ( $keepSub = \IPS\nexus\Subscription::loadActiveByMember( $member ) )
|
||||
{
|
||||
if ( $dropSub = \IPS\nexus\Subscription::loadActiveByMember( $member2 ) )
|
||||
if ( $dropSub = \IPS\nexus\Subscription::loadActiveByMember( $member2 ) AND $package = \IPS\nexus\Subscription\Package::load( $dropSub->package_id ) )
|
||||
{
|
||||
$dropSub->removeMember( \IPS\nexus\Customer::load( $member2->member_id ) );
|
||||
$package->removeMember( \IPS\nexus\Customer::load( $member2->member_id ) );
|
||||
}
|
||||
}
|
||||
|
||||
/* Recount total spend */
|
||||
$customerToKeep->recountTotalSpend();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,11 +142,11 @@ class _Nexus
|
||||
*/
|
||||
public function onDelete( $member )
|
||||
{
|
||||
\IPS\Db::i()->delete( 'nexus_customer_addresses', array( 'member=?', $member->member_id ) );
|
||||
\IPS\Db::i()->delete( 'nexus_customer_addresses', array( '`member`=?', $member->member_id ) );
|
||||
\IPS\Db::i()->delete( 'nexus_customer_cards', array( 'card_member=?', $member->member_id ) );
|
||||
\IPS\Db::i()->delete( 'nexus_customers', array( 'member_id=?', $member->member_id ) );
|
||||
\IPS\Db::i()->delete( 'nexus_referrals', array( 'referred_by=?', $member->member_id ) ); // Don't delete the record for the referrer if this is the referree as that's still relevant for the referree's account
|
||||
\IPS\Db::i()->delete( 'nexus_alternate_contacts', array( 'main_id=? OR alt_id =?', $member->member_id, $member->member_id ) );
|
||||
\IPS\Db::i()->delete( 'nexus_alternate_contacts', array( 'main_id=?', $member->member_id ) );
|
||||
\IPS\Db::i()->delete( 'nexus_alternate_contacts', array( 'alt_id =?', $member->member_id ) );
|
||||
\IPS\Db::i()->delete( 'nexus_support_request_log', array( "rlog_member=?", $member->member_id ) );
|
||||
\IPS\Db::i()->update( 'nexus_support_requests', array( 'r_staff' => 0 ), array( "r_staff=?", $member->member_id ) );
|
||||
|
||||
@@ -179,6 +169,8 @@ class _Nexus
|
||||
|
||||
/* Subscriptions (mop up orphaned members) */
|
||||
\IPS\Db::i()->delete( 'nexus_member_subscriptions', array( "sub_member_id=?", $member->member_id ) );
|
||||
|
||||
\IPS\Db::i()->delete( 'nexus_customer_spend', array( 'spend_member_id=?', $member->member_id ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -201,7 +193,7 @@ class _Nexus
|
||||
/* Moving out of an admin group? */
|
||||
if ( $refresh === FALSE AND ( isset( $changes['member_group_id'] ) OR isset( $changes['mgroup_others'] ) ) )
|
||||
{
|
||||
if ( isset( $changes['member_group_id'] ) AND in_array( $changes['member_group_id'], $adminGroups ) )
|
||||
if ( isset( $changes['member_group_id'] ) AND \in_array( $changes['member_group_id'], $adminGroups ) )
|
||||
{
|
||||
$refresh = TRUE;
|
||||
}
|
||||
@@ -210,7 +202,7 @@ class _Nexus
|
||||
{
|
||||
foreach( explode( ',', $changes['mgroup_others'] ) AS $group )
|
||||
{
|
||||
if ( in_array( $group, $adminGroups ) )
|
||||
if ( \in_array( $group, $adminGroups ) )
|
||||
{
|
||||
$refresh = TRUE;
|
||||
break;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\OutputPlugins;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\OutputPlugins;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -46,7 +46,7 @@ class _Money
|
||||
}
|
||||
else
|
||||
{
|
||||
$options['currency'] = "( ( isset( \$_SESSION['currency'] ) and in_array( \$_SESSION['currency'], \\IPS\\nexus\\Money::currencies() ) ) ? \$_SESSION['currency'] : \\IPS\\nexus\\Customer::loggedIn()->defaultCurrency() )";
|
||||
$options['currency'] = "( ( isset( \\IPS\\Request::i()->cookie['currency'] ) and \in_array( \\IPS\\Request::i()->cookie['currency'], \\IPS\\nexus\\Money::currencies() ) ) ? \\IPS\\Request::i()->cookie['currency'] : \\IPS\\nexus\\Customer::loggedIn()->defaultCurrency() )";
|
||||
}
|
||||
|
||||
return 'new \IPS\nexus\Money( ' . $data . ", {$options['currency']} )";
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\OutputPlugins;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Overview statistics extension: Products
|
||||
* @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 15 Jan 2020
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\OverviewStatistics;
|
||||
|
||||
/* 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 Overview statistics extension: Products
|
||||
*/
|
||||
class _Products
|
||||
{
|
||||
/**
|
||||
* @brief Which statistics page (activity or user)
|
||||
*/
|
||||
public $page = 'user';
|
||||
|
||||
/**
|
||||
* Return the sub-block keys
|
||||
*
|
||||
* @note This is designed to allow one class to support multiple blocks, for instance using the ContentRouter to generate blocks.
|
||||
* @return array
|
||||
*/
|
||||
public function getBlocks()
|
||||
{
|
||||
return array( 'products' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return block details (title and description)
|
||||
*
|
||||
* @param string|NULL $subBlock The subblock we are loading as returned by getBlocks()
|
||||
* @return array
|
||||
*/
|
||||
public function getBlockDetails( $subBlock = NULL )
|
||||
{
|
||||
/* Description can be null and will not be shown if so */
|
||||
return array( 'app' => 'nexus', 'title' => 'stats_overview_products', 'description' => null, 'refresh' => 60 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the block HTML to show
|
||||
*
|
||||
* @param array|NULL $dateRange NULL for all time, or an array with 'start' and 'end' \IPS\DateTime objects to restrict to
|
||||
* @param string|NULL $subBlock The subblock we are loading as returned by getBlocks()
|
||||
* @return string
|
||||
*/
|
||||
public function getBlock( $dateRange = NULL, $subBlock = NULL )
|
||||
{
|
||||
/* Init Chart */
|
||||
$pieBarData = array();
|
||||
|
||||
/* Add Rows */
|
||||
$where = array( array( 'ps_app=?', 'nexus' ), array( 'ps_type=?', 'package' ) );
|
||||
$previousCount = NULL;
|
||||
|
||||
if( \is_array( $dateRange ) )
|
||||
{
|
||||
$where[] = array( 'ps_start > ?', $dateRange['start']->getTimestamp() );
|
||||
$where[] = array( 'ps_start < ?', $dateRange['end']->getTimestamp() );
|
||||
}
|
||||
elseif( $dateRange !== NULL )
|
||||
{
|
||||
$currentDate = new \IPS\DateTime;
|
||||
$interval = NULL;
|
||||
|
||||
switch( $dateRange )
|
||||
{
|
||||
case '7':
|
||||
$interval = new \DateInterval( 'P7D' );
|
||||
break;
|
||||
|
||||
case '30':
|
||||
$interval = new \DateInterval( 'P1M' );
|
||||
break;
|
||||
|
||||
case '90':
|
||||
$interval = new \DateInterval( 'P3M' );
|
||||
break;
|
||||
|
||||
case '180':
|
||||
$interval = new \DateInterval( 'P6M' );
|
||||
break;
|
||||
|
||||
case '365':
|
||||
$interval = new \DateInterval( 'P1Y' );
|
||||
break;
|
||||
}
|
||||
|
||||
$initialTimestamp = $currentDate->sub( $interval )->getTimestamp();
|
||||
$where[] = array( 'ps_start > ?', $initialTimestamp );
|
||||
|
||||
$previousCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( array( 'ps_app=?', 'nexus' ), array( 'ps_type=?', 'package' ), array( 'ps_start BETWEEN ? AND ?', $currentDate->sub( $interval )->getTimestamp(), $initialTimestamp ) ) )->first();
|
||||
}
|
||||
|
||||
$total = 0;
|
||||
$chart = NULL;
|
||||
|
||||
foreach( \IPS\nexus\Package::roots() as $package )
|
||||
{
|
||||
$filter = $where;
|
||||
$filter[] = array( 'ps_item_id=?', $package->id );
|
||||
|
||||
$value = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', $filter )->first();
|
||||
|
||||
if( $value > 0 )
|
||||
{
|
||||
$total += $value;
|
||||
|
||||
$pieBarData[] = array(
|
||||
'name' => \IPS\Member::loggedIn()->language()->addToStack('nexus_package_' . $package->id ),
|
||||
'value' => $value,
|
||||
'percentage' => 0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
foreach( $pieBarData as &$package )
|
||||
{
|
||||
$package['percentage'] = round( ( $package['value'] / $total ) * 100, 2 );
|
||||
}
|
||||
|
||||
if( \count( $pieBarData ) )
|
||||
{
|
||||
$chart = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->applePieChart( $pieBarData );
|
||||
}
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'stats' )->overviewComparisonCount( $total, $previousCount, $chart );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Overview statistics extension: Subscriptions
|
||||
* @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 15 Jan 2020
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\OverviewStatistics;
|
||||
|
||||
/* 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 Overview statistics extension: Subscriptions
|
||||
*/
|
||||
class _Subscriptions
|
||||
{
|
||||
/**
|
||||
* @brief Which statistics page (activity or user)
|
||||
*/
|
||||
public $page = 'user';
|
||||
|
||||
/**
|
||||
* Return the sub-block keys
|
||||
*
|
||||
* @note This is designed to allow one class to support multiple blocks, for instance using the ContentRouter to generate blocks.
|
||||
* @return array
|
||||
*/
|
||||
public function getBlocks()
|
||||
{
|
||||
return array( 'subscriptions' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return block details (title and description)
|
||||
*
|
||||
* @param string|NULL $subBlock The subblock we are loading as returned by getBlocks()
|
||||
* @return array
|
||||
*/
|
||||
public function getBlockDetails( $subBlock = NULL )
|
||||
{
|
||||
/* Description can be null and will not be shown if so */
|
||||
return \IPS\Settings::i()->nexus_subs_enabled ? array( 'app' => 'nexus', 'title' => 'stats_overview_subscriptions', 'description' => null, 'refresh' => 60 ) : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the block HTML to show
|
||||
*
|
||||
* @param array|NULL $dateRange NULL for all time, or an array with 'start' and 'end' \IPS\DateTime objects to restrict to
|
||||
* @param string|NULL $subBlock The subblock we are loading as returned by getBlocks()
|
||||
* @return string
|
||||
*/
|
||||
public function getBlock( $dateRange = NULL, $subBlock = NULL )
|
||||
{
|
||||
/* Init Chart */
|
||||
$pieBarData = array();
|
||||
|
||||
/* Add Rows */
|
||||
$where = array( array( 'ps_app=?', 'nexus' ), array( 'ps_type=?', 'subscription' ) );
|
||||
$previousCount = NULL;
|
||||
|
||||
if( \is_array( $dateRange ) )
|
||||
{
|
||||
$where[] = array( 'ps_start > ?', $dateRange['start']->getTimestamp() );
|
||||
$where[] = array( 'ps_start < ?', $dateRange['end']->getTimestamp() );
|
||||
}
|
||||
elseif( $dateRange !== NULL )
|
||||
{
|
||||
$currentDate = new \IPS\DateTime;
|
||||
$interval = NULL;
|
||||
|
||||
switch( $dateRange )
|
||||
{
|
||||
case '7':
|
||||
$interval = new \DateInterval( 'P7D' );
|
||||
break;
|
||||
|
||||
case '30':
|
||||
$interval = new \DateInterval( 'P1M' );
|
||||
break;
|
||||
|
||||
case '90':
|
||||
$interval = new \DateInterval( 'P3M' );
|
||||
break;
|
||||
|
||||
case '180':
|
||||
$interval = new \DateInterval( 'P6M' );
|
||||
break;
|
||||
|
||||
case '365':
|
||||
$interval = new \DateInterval( 'P1Y' );
|
||||
break;
|
||||
}
|
||||
|
||||
$initialTimestamp = $currentDate->sub( $interval )->getTimestamp();
|
||||
$where = array( array( 'ps_start > ?', $initialTimestamp ) );
|
||||
|
||||
$previousCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( array( 'ps_app=?', 'nexus' ), array( 'ps_type=?', 'subscription' ), array( 'ps_start BETWEEN ? AND ?', $currentDate->sub( $interval )->getTimestamp(), $initialTimestamp ) ) )->first();
|
||||
}
|
||||
|
||||
$total = 0;
|
||||
$chart = NULL;
|
||||
|
||||
foreach( \IPS\nexus\Subscription\Package::roots() as $package )
|
||||
{
|
||||
$filter = $where;
|
||||
$filter[] = array( 'ps_item_id=?', $package->id );
|
||||
|
||||
$value = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', $filter )->first();
|
||||
|
||||
if( $value > 0 )
|
||||
{
|
||||
$total += $value;
|
||||
|
||||
$pieBarData[] = array(
|
||||
'name' => \IPS\Member::loggedIn()->language()->addToStack('nexus_subs_' . $package->id ),
|
||||
'value' => $value,
|
||||
'percentage' => 0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
foreach( $pieBarData as &$package )
|
||||
{
|
||||
$package['percentage'] = round( ( $package['value'] / $total ) * 100, 2 );
|
||||
}
|
||||
|
||||
if( \count( $pieBarData ) )
|
||||
{
|
||||
$chart = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->applePieChart( $pieBarData );
|
||||
}
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'stats' )->overviewComparisonCount( $total, $previousCount, $chart );
|
||||
}
|
||||
}
|
||||
@@ -5,14 +5,13 @@
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
|
||||
* @since 10 May 2017
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\ProfileSteps;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -83,8 +82,8 @@ class _CustomerFields
|
||||
/**
|
||||
* Has a specific step been completed?
|
||||
*
|
||||
* @param \IPS\Member\ProfileStep The step to check
|
||||
* @param \IPS\Member|NULL The member to check, or NULL for currently logged in
|
||||
* @param \IPS\Member\ProfileStep $step The step to check
|
||||
* @param \IPS\Member|NULL $member The member to check, or NULL for currently logged in
|
||||
* @return bool
|
||||
*/
|
||||
public function completed( \IPS\Member\ProfileStep $step, \IPS\Member $member = NULL )
|
||||
@@ -104,7 +103,7 @@ class _CustomerFields
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( ! count( $profileFields ) )
|
||||
if ( ! \count( $profileFields ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -126,14 +125,14 @@ class _CustomerFields
|
||||
}
|
||||
}
|
||||
|
||||
return ( $done === count( $step->subcompletion_act ) );
|
||||
return ( $done === \count( $step->subcompletion_act ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Action URL
|
||||
*
|
||||
* @param string The action
|
||||
* @param \IPS\Member|NULL The member, or NULL for currently logged in
|
||||
* @param string $action The action
|
||||
* @param \IPS\Member|NULL $member The member, or NULL for currently logged in
|
||||
* @return \IPS\Http\Url
|
||||
*/
|
||||
public function url( $action, \IPS\Member $member = NULL )
|
||||
@@ -144,8 +143,8 @@ class _CustomerFields
|
||||
/**
|
||||
* Post ACP Save
|
||||
*
|
||||
* @param \IPS\Member\ProfileStep The step
|
||||
* @param array Form Values
|
||||
* @param \IPS\Member\ProfileStep $step The step
|
||||
* @param array $values Form Values
|
||||
* @return void
|
||||
*/
|
||||
public function postAcpSave( \IPS\Member\ProfileStep $step, array $values )
|
||||
@@ -155,7 +154,7 @@ class _CustomerFields
|
||||
/* If we are going to add a profile field to a step, or even require it, we need to make sure the actual field is updated */
|
||||
foreach( $subActions AS $key )
|
||||
{
|
||||
if ( in_array( $key, $values['step_subcompletion_act'] ) )
|
||||
if ( \in_array( $key, $values['step_subcompletion_act'] ) )
|
||||
{
|
||||
$fieldId = \substr( $key, 14 );
|
||||
$update = array();
|
||||
@@ -173,9 +172,9 @@ class _CustomerFields
|
||||
/**
|
||||
* Format Form Values
|
||||
*
|
||||
* @param array
|
||||
* @param \IPS\Member
|
||||
* @param \IPS\Helpers\Form
|
||||
* @param array $values The form values
|
||||
* @param \IPS\Member $member The member
|
||||
* @param \IPS\Helpers\Form $form The form object
|
||||
* @return void
|
||||
*/
|
||||
public static function formatFormValues( $values, &$member, &$form )
|
||||
@@ -202,7 +201,7 @@ class _CustomerFields
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $profileFields ) )
|
||||
if ( \count( $profileFields ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -219,8 +218,7 @@ class _CustomerFields
|
||||
/**
|
||||
* Wizard Steps
|
||||
*
|
||||
* @param \IPS\Member\ProfileStep
|
||||
* @param \IPS\Member
|
||||
* @param \IPS\Member|NULL $member The member completing the wizard, or NULL for currently logged in member
|
||||
* @return array
|
||||
*/
|
||||
public static function wizard( \IPS\Member $member = NULL )
|
||||
@@ -251,12 +249,12 @@ class _CustomerFields
|
||||
return $values;
|
||||
}
|
||||
|
||||
return $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'forms', 'core' ) ), 'profileCompleteTemplate' ), $step );
|
||||
return $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'profileCompleteTemplate' ), $step );
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $wizards ) )
|
||||
if ( \count( $wizards ) )
|
||||
{
|
||||
return $wizards;
|
||||
}
|
||||
@@ -264,8 +262,8 @@ class _CustomerFields
|
||||
|
||||
/**
|
||||
* Resyncs when something external happens
|
||||
* @param \IPS\Member\ProfileStep The step
|
||||
*
|
||||
* @param \IPS\Member\ProfileStep $step The step
|
||||
* @return void
|
||||
*/
|
||||
public function resync( \IPS\Member\ProfileStep $step )
|
||||
@@ -286,12 +284,12 @@ class _CustomerFields
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $subActions ) and count( $subActions ) != $step->subcompletion_act )
|
||||
if ( \count( $subActions ) and \count( $subActions ) != $step->subcompletion_act )
|
||||
{
|
||||
$step->subcompletion_act = $subActions;
|
||||
$step->save();
|
||||
}
|
||||
else if ( ! count( $subActions ) )
|
||||
else if ( ! \count( $subActions ) )
|
||||
{
|
||||
/* No fields left, so delete this */
|
||||
$step->delete();
|
||||
|
||||
Whitespace-only changes.
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Cancel billing agreements before removing the payment method
|
||||
* @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 14 Jan 2020
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\Queue;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel billing agreements before removing the payment method
|
||||
*/
|
||||
class _DeletePaymentMethod
|
||||
{
|
||||
/**
|
||||
* @brief Number of records to process per cycle
|
||||
*/
|
||||
public $perCycle = \IPS\REBUILD_SLOW;
|
||||
|
||||
/**
|
||||
* Parse data before queuing
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function preQueueData( $data )
|
||||
{
|
||||
$data['count'] = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_billing_agreements', array( 'ba_method=? AND ba_canceled=?', $data['id'], 0 ) )->first();
|
||||
|
||||
if( $data['count'] == 0 )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
$data['done'] = 0;
|
||||
$data['failures'] = array();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run Background Task
|
||||
*
|
||||
* @param mixed $data Data as it was passed to \IPS\Task::queue()
|
||||
* @param int $offset Offset
|
||||
* @return int New offset
|
||||
* @throws \IPS\Task\Queue\OutOfRangeException Indicates offset doesn't exist and thus task is complete
|
||||
*/
|
||||
public function run( &$data, $offset )
|
||||
{
|
||||
$agreements = \IPS\Db::i()->select( '*', 'nexus_billing_agreements', array( 'ba_method=? AND ba_id>?', $data['id'], (int) $offset ), 'ba_id ASC', $this->perCycle );
|
||||
$lastId = 0;
|
||||
|
||||
foreach( $agreements as $billingAgreement )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\nexus\Customer\BillingAgreement::constructFromData( $billingAgreement )->cancel();
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
/* Store the billing agreement ID so we can notify the admin once we're done */
|
||||
$data['failures'][] = $billingAgreement['ba_id'];
|
||||
|
||||
\IPS\Log::log( $e, 'delete-nexus-ba' );
|
||||
}
|
||||
|
||||
$lastId = $billingAgreement['ba_id'];
|
||||
}
|
||||
|
||||
if( $lastId == 0 )
|
||||
{
|
||||
throw new \IPS\Task\Queue\OutOfRangeException;
|
||||
}
|
||||
|
||||
$data['done'] += $this->perCycle;
|
||||
|
||||
return $lastId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Progress
|
||||
*
|
||||
* @param mixed $data Data as it was passed to \IPS\Task::queue()
|
||||
* @param int $offset Offset
|
||||
* @return array( 'text' => 'Doing something...', 'complete' => 50 ) Text explaining task and percentage complete
|
||||
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
|
||||
*/
|
||||
public function getProgress( $data, $offset )
|
||||
{
|
||||
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('delete_gateway_with_bas'), 'complete' => $data['done'] ? ( round( 100 / $data['done'] * $data['count'], 2 ) ) : 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform post-completion processing
|
||||
*
|
||||
* @param array $data
|
||||
* @return void
|
||||
*/
|
||||
public function postComplete( $data )
|
||||
{
|
||||
$_data = json_decode( $data['data'], true );
|
||||
|
||||
/* Send notification about any failures */
|
||||
if( \count( $_data['failures'] ) )
|
||||
{
|
||||
\IPS\core\AdminNotification::send( 'nexus', 'ConfigurationError', json_encode( $_data['failures'] ), FALSE );
|
||||
}
|
||||
|
||||
/* And delete the gateway itself */
|
||||
\IPS\nexus\Gateway::load( $_data['id'] )->delete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Background task to fix refunded transactions following the 4.3.5 change to treat refunds and credits separately
|
||||
* @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 10 Apr 2019
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\Queue;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Background task to fix refunded transactions following the 4.3.5 change to treat refunds and credits separately
|
||||
*/
|
||||
class _FixMissingAddresses
|
||||
{
|
||||
/**
|
||||
* @brief Number of records to process per cycle
|
||||
*/
|
||||
public $perCycle = \IPS\REBUILD_QUICK;
|
||||
|
||||
/**
|
||||
* Parse data before queuing
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function preQueueData( $data )
|
||||
{
|
||||
$data['count'] = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_invoices', array( 'i_status=? AND i_billaddress IS NULL', \IPS\nexus\Invoice::STATUS_PAID ) )->first();
|
||||
|
||||
if( $data['count'] == 0 )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
$data['done'] = 0;
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run Background Task
|
||||
*
|
||||
* @param mixed $data Data as it was passed to \IPS\Task::queue()
|
||||
* @param int $offset Offset
|
||||
* @return int New offset
|
||||
* @throws \IPS\Task\Queue\OutOfRangeException Indicates offset doesn't exist and thus task is complete
|
||||
*/
|
||||
public function run( $data, $offset )
|
||||
{
|
||||
$invoices = \IPS\Db::i()->select( '*', 'nexus_invoices', array( array( 'i_id>?', $offset ), array( 'i_status=? AND i_billaddress IS NULL', \IPS\nexus\Invoice::STATUS_PAID ) ), 'i_id ASC', $this->perCycle );
|
||||
$lastId = 0;
|
||||
|
||||
foreach( $invoices as $invoiceData )
|
||||
{
|
||||
$invoice = \IPS\nexus\Invoice::constructFromData( $invoiceData );
|
||||
|
||||
try
|
||||
{
|
||||
$invoice->billaddress = \IPS\nexus\Customer\Address::constructFromData( \IPS\Db::i()->select( '*', 'nexus_customer_addresses', array( '`member`=? AND primary_billing=1', $invoiceData['i_member'] ) )->first() )->address;
|
||||
$invoice->save();
|
||||
}
|
||||
catch ( \UnderflowException $e ) { }
|
||||
|
||||
$lastId = $invoiceData['i_id'];
|
||||
}
|
||||
|
||||
if( $lastId == 0 )
|
||||
{
|
||||
throw new \IPS\Task\Queue\OutOfRangeException;
|
||||
}
|
||||
|
||||
$data['done'] += $this->perCycle;
|
||||
|
||||
return $lastId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Progress
|
||||
*
|
||||
* @param mixed $data Data as it was passed to \IPS\Task::queue()
|
||||
* @param int $offset Offset
|
||||
* @return array( 'text' => 'Doing something...', 'complete' => 50 ) Text explaining task and percentage complete
|
||||
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
|
||||
*/
|
||||
public function getProgress( $data, $offset )
|
||||
{
|
||||
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('upgrade_fix_missing_addresses'), 'complete' => $data['done'] ? ( round( 100 / $data['done'] * $data['count'], 2 ) ) : 0 );
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\Queue;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -23,8 +23,10 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
*/
|
||||
class _FixRefundTransactions
|
||||
{
|
||||
|
||||
public $perCycle = 500;
|
||||
/**
|
||||
* @brief Number of records to process per cycle
|
||||
*/
|
||||
public $perCycle = \IPS\REBUILD_QUICK;
|
||||
|
||||
/**
|
||||
* Parse data before queuing
|
||||
@@ -82,22 +84,22 @@ class _FixRefundTransactions
|
||||
|
||||
if ( isset( $history['amount'] ) )
|
||||
{
|
||||
$credit = $credit->add( new \IPS\Math\Number( $history['amount'] ) );
|
||||
$credit = $credit->add( new \IPS\Math\Number( (string) $history['amount'] ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$credit = $credit->add( new \IPS\Math\Number( $transaction['t_amount'] ) );
|
||||
$credit = $credit->add( new \IPS\Math\Number( (string) $transaction['t_amount'] ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isset( $history['amount'] ) )
|
||||
{
|
||||
$totalRefunded = $totalRefunded->add( new \IPS\Math\Number( $history['amount'] ) );
|
||||
$totalRefunded = $totalRefunded->add( new \IPS\Math\Number( (string) $history['amount'] ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$totalRefunded = $totalRefunded->add( new \IPS\Math\Number( $transaction['t_amount'] ) );
|
||||
$totalRefunded = $totalRefunded->add( new \IPS\Math\Number( (string) $transaction['t_amount'] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,11 +113,11 @@ class _FixRefundTransactions
|
||||
{
|
||||
$update['t_credit'] = (string) $credit;
|
||||
}
|
||||
if ( $transaction['t_status'] === \IPS\nexus\Transaction::STATUS_PART_REFUNDED and $totalRefunded->compare( new \IPS\Math\Number( $transaction['t_partial_refund'] ) ) !== 0 )
|
||||
if ( $transaction['t_status'] === \IPS\nexus\Transaction::STATUS_PART_REFUNDED and $totalRefunded->compare( new \IPS\Math\Number( (string) $transaction['t_partial_refund'] ) ) !== 0 )
|
||||
{
|
||||
$update['t_partial_refund'] = (string) $totalRefunded;
|
||||
}
|
||||
if ( $transaction['t_status'] === \IPS\nexus\Transaction::STATUS_REFUNDED and $totalRefunded->compare( new \IPS\Math\Number( $transaction['t_amount'] ) ) !== 0 )
|
||||
if ( $transaction['t_status'] === \IPS\nexus\Transaction::STATUS_REFUNDED and $totalRefunded->compare( new \IPS\Math\Number( (string) $transaction['t_amount'] ) ) !== 0 )
|
||||
{
|
||||
$update['t_status'] = \IPS\nexus\Transaction::STATUS_PART_REFUNDED;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Background Task
|
||||
* @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 20 Dec 2019
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\Queue;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Background Task
|
||||
*/
|
||||
class _MassChangePurchases
|
||||
{
|
||||
/**
|
||||
* Parse data before queuing
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function preQueueData( $data )
|
||||
{
|
||||
$data['count'] = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_app=? AND ps_type=? AND ps_item_id=?', 'nexus', 'package', $data['id'] ) )->first();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run Background Task
|
||||
*
|
||||
* @param mixed $data Data as it was passed to \IPS\Task::queue()
|
||||
* @param int $offset Offset
|
||||
* @return int New offset
|
||||
* @throws \IPS\Task\Queue\OutOfRangeException Indicates offset doesn't exist and thus task is complete
|
||||
*/
|
||||
public function run( $data, $offset )
|
||||
{
|
||||
$package = \IPS\nexus\Package::load( $data['id'] );
|
||||
$admin = \IPS\Member::load( $data['admin'] );
|
||||
if ( $data['cancel_type'] == 'change' )
|
||||
{
|
||||
$newPackage = \IPS\nexus\Package::load( $data['mass_change_purchases_to'] );
|
||||
}
|
||||
|
||||
$query = \IPS\Db::i()->select( '*', 'nexus_purchases', array( 'ps_app=? AND ps_type=? AND ps_item_id=?', 'nexus', 'package', $data['id'] ), 'ps_id ASC', ( $data['cancel_type'] == 'change' ) ? NULL : array( $offset, \IPS\REBUILD_SLOW ) );
|
||||
if ( !\count( $query ) )
|
||||
{
|
||||
throw new \IPS\Task\Queue\OutOfRangeException;
|
||||
}
|
||||
|
||||
foreach ( new \IPS\Patterns\ActiveRecordIterator( $query, 'IPS\nexus\Purchase' ) as $purchase )
|
||||
{
|
||||
if ( $data['cancel_type'] == 'change' )
|
||||
{
|
||||
$package->upgradeDowngrade( $purchase, $newPackage, isset( $data[ 'renew_option_' . $newPackage->_id ] ) ? $data[ 'renew_option_' . $newPackage->_id ] : NULL, (bool) $data['mass_change_purchases_override'] );
|
||||
$purchase->member->log( 'purchase', array( 'type' => 'change', 'id' => $purchase->id, 'old' => $purchase->name, 'name' => $newPackage->titleForLog(), 'system' => FALSE ), $admin );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If grouped, ungroup */
|
||||
$grouped = $purchase->grouped_renewals;
|
||||
if ( $grouped )
|
||||
{
|
||||
$purchase->ungroupFromParent();
|
||||
$purchase->save();
|
||||
}
|
||||
|
||||
/* Update purchase and log */
|
||||
if ( $data['cancel_type'] == 'expire' )
|
||||
{
|
||||
$purchase->renewals = NULL;
|
||||
$purchase->member->log( 'purchase', array( 'type' => 'info', 'id' => $purchase->id, 'name' => $purchase->name, 'info' => 'remove_renewals' ), $admin );
|
||||
}
|
||||
else
|
||||
{
|
||||
$purchase->cancelled = TRUE;
|
||||
$purchase->member->log( 'purchase', array( 'type' => 'cancel', 'id' => $purchase->id, 'name' => $purchase->name ), $admin );
|
||||
}
|
||||
$purchase->can_reactivate = $data['ps_can_reactivate'];
|
||||
$purchase->save();
|
||||
|
||||
/* If grouped, regroup */
|
||||
if ( $grouped )
|
||||
{
|
||||
$purchase->groupWithParent();
|
||||
$purchase->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $offset + \IPS\REBUILD_SLOW;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Progress
|
||||
*
|
||||
* @param mixed $data Data as it was passed to \IPS\Task::queue()
|
||||
* @param int $offset Offset
|
||||
* @return array( 'text' => 'Doing something...', 'complete' => 50 ) Text explaining task and percentage complete
|
||||
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
|
||||
*/
|
||||
public function getProgress( $data, $offset )
|
||||
{
|
||||
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack( 'mass_change_purchases_in_progress_text', FALSE, array( 'sprintf' => \IPS\nexus\Package::load( $data['id'] )->_title ) ), 'complete' => floor( 100 / $data['count'] * $offset ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform post-completion processing
|
||||
*
|
||||
* @param array $data Data returned from preQueueData
|
||||
* @param bool $processed Was anything processed or not? If preQueueData returns NULL, this will be FALSE.
|
||||
* @return void
|
||||
*/
|
||||
public function postComplete( $data, $processed = TRUE )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\extensions\core\Queue;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -23,8 +23,10 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
*/
|
||||
class _MoveCustomerHistory
|
||||
{
|
||||
|
||||
public $perCycle = 500;
|
||||
/**
|
||||
* @brief Number of records to process per cycle
|
||||
*/
|
||||
public $perCycle = \IPS\REBUILD_QUICK;
|
||||
|
||||
/**
|
||||
* Parse data before queuing
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Background Task
|
||||
* @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 08 Aug 2018
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\Queue;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Background Task
|
||||
*/
|
||||
class _RecountTotalSpend
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief Number of records to process per cycle
|
||||
*/
|
||||
public $perCycle = \IPS\REBUILD_QUICK;
|
||||
|
||||
/**
|
||||
* Parse data before queuing
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function preQueueData( $data )
|
||||
{
|
||||
$data['count'] = (int) \IPS\Db::i()->select( 'count(*)', 'nexus_customers' )->first();
|
||||
|
||||
if( $data['count'] == 0 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$data['completed'] = 0;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run Background Task
|
||||
*
|
||||
* @param mixed $data Data as it was passed to \IPS\Task::queue()
|
||||
* @param int $offset Offset
|
||||
* @return int New offset
|
||||
* @throws \IPS\Task\Queue\OutOfRangeException Indicates offset doesn't exist and thus task is complete
|
||||
*/
|
||||
public function run( &$data, $offset )
|
||||
{
|
||||
$last = null;
|
||||
|
||||
/* Loop over members to fix them */
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_customers', array( 'member_id > ?', $offset ), 'member_id ASC', array( 0, $this->perCycle ) ) as $customer )
|
||||
{
|
||||
$last = $customer['member_id'];
|
||||
$data['completed']++;
|
||||
|
||||
try
|
||||
{
|
||||
$customer = \IPS\nexus\Customer::load( $customer['member_id'] );
|
||||
$customer->recountTotalSpend();
|
||||
}
|
||||
catch( \Exception $ex ) { }
|
||||
}
|
||||
|
||||
if( $last === NULL )
|
||||
{
|
||||
throw new \IPS\Task\Queue\OutOfRangeException;
|
||||
}
|
||||
|
||||
return $last;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Progress
|
||||
*
|
||||
* @param mixed $data Data as it was passed to \IPS\Task::queue()
|
||||
* @param int $offset Offset
|
||||
* @return array( 'text' => 'Doing something...', 'complete' => 50 ) Text explaining task and percentage complete
|
||||
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
|
||||
*/
|
||||
public function getProgress( $data, $offset )
|
||||
{
|
||||
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack( 'recounting_total_spend' ), 'complete' => $data['count'] ? ( round( 100 / $data['count'] * $data['completed'], 2 ) ) : 100 );
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Uninstall callback
|
||||
* @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 02 Nov 2018
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\Uninstall;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstall callback
|
||||
*/
|
||||
class _DisablePOP
|
||||
{
|
||||
/**
|
||||
* Code to execute before the application has been uninstalled
|
||||
*
|
||||
* @param string $application Application directory
|
||||
* @return array
|
||||
*/
|
||||
public function preUninstall( $application )
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Code to execute after the application has been uninstalled
|
||||
*
|
||||
* @param string $application Application directory
|
||||
* @return array
|
||||
*/
|
||||
public function postUninstall( $application )
|
||||
{
|
||||
/* Disable pop3 tasks */
|
||||
if ( \IPS\Settings::i()->pop3_server )
|
||||
{
|
||||
\IPS\Settings::i()->changeValues( array( 'pop3_server' => '' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Code to execute when other applications are uninstalled
|
||||
*
|
||||
* @param string $application Application directory
|
||||
* @return void
|
||||
* @deprecated This is here for backwards-compatibility - all new code should go in onOtherUninstall
|
||||
*/
|
||||
public function onOtherAppUninstall( $application )
|
||||
{
|
||||
return $this->onOtherUninstall( $application );
|
||||
}
|
||||
|
||||
/**
|
||||
* Code to execute when other applications or plugins are uninstalled
|
||||
*
|
||||
* @param string $application Application directory
|
||||
* @param int $plugin Plugin ID
|
||||
* @return void
|
||||
*/
|
||||
public function onOtherUninstall( $application=NULL, $plugin=NULL )
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user