Version 5.0.0 beta 1

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

No files matched your search

@@ -11,38 +11,48 @@
namespace IPS\nexus\extensions\core\AdminNotifications;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\core\AdminNotification;
use IPS\core\modules\admin\promotion\advertisements;
use IPS\DateTime;
use IPS\Db;
use IPS\Http\Url;
use IPS\Member;
use UnderflowException;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* ACP Notification: Advertisements Requiring Approval
*/
class _Advertisement extends \IPS\core\AdminNotification
class Advertisement extends AdminNotification
{
/**
* @brief Identifier for what to group this notification type with on the settings form
*/
public static $group = 'commerce';
public static string $group = 'commerce';
/**
* @brief Priority 1-5 (1 being highest) for this group compared to others
*/
public static $groupPriority = 4;
public static int $groupPriority = 4;
/**
* @brief Priority 1-5 (1 being highest) for this notification type compared to others in the same group
*/
public static $itemPriority = 4;
public static int $itemPriority = 4;
/**
* Title for settings
*
* @return string
*/
public static function settingsTitle()
public static function settingsTitle(): string
{
return 'acp_notification_Advertisement';
}
@@ -50,9 +60,9 @@ class _Advertisement extends \IPS\core\AdminNotification
/**
* Is this type of notification ever optional (controls if it will be selectable as "viewable" in settings)
*
* @return string
* @return bool
*/
public static function mayBeOptional()
public static function mayBeOptional(): bool
{
return TRUE;
}
@@ -62,7 +72,7 @@ class _Advertisement extends \IPS\core\AdminNotification
*
* @return bool
*/
public static function mayRecur()
public static function mayRecur(): bool
{
return TRUE;
}
@@ -70,18 +80,18 @@ class _Advertisement extends \IPS\core\AdminNotification
/**
* @brief Current count
*/
protected $count = NULL;
protected ?int $count = NULL;
/**
* Get count
*
* @return bool
* @return int
*/
public function count()
public function count(): int
{
if ( $this->count === NULL )
{
$this->count = \IPS\Db::i()->select( 'COUNT(*)', 'core_advertisements', array( 'ad_active=-1' ) )->first();
$this->count = Db::i()->select( 'COUNT(*)', 'core_advertisements', array( 'ad_active=-1' ) )->first();
}
return $this->count;
}
@@ -89,12 +99,12 @@ class _Advertisement extends \IPS\core\AdminNotification
/**
* Can a member access this type of notification?
*
* @param \IPS\Member $member The member
* @param Member $member The member
* @return bool
*/
public static function permissionCheck( \IPS\Member $member )
public static function permissionCheck( Member $member ): bool
{
return $member->hasAcpRestriction( 'core', 'promotion', 'advertisements_manage' ) and \IPS\Db::i()->select( 'COUNT(*)', 'nexus_packages_ads' )->first();
return $member->hasAcpRestriction( 'core', 'promotion', 'advertisements_manage' ) and Db::i()->select( 'COUNT(*)', 'nexus_packages_ads' )->first();
}
/**
@@ -102,23 +112,23 @@ class _Advertisement extends \IPS\core\AdminNotification
*
* @return string
*/
public function title()
public function title(): string
{
return \IPS\Member::loggedIn()->language()->addToStack( 'acpNotification_nexusAdvertisements', FALSE, array( 'pluralize' => array( $this->count() ) ) );
return Member::loggedIn()->language()->addToStack( 'acpNotification_nexusAdvertisements', FALSE, array( 'pluralize' => array( $this->count() ) ) );
}
/**
* Notification Subtitle (no HTML)
*
* @return string
* @return string|null
*/
public function subtitle()
public function subtitle(): ?string
{
try
{
return \IPS\DateTime::ts( \IPS\Db::i()->select( 'ad_start', 'core_advertisements', array( 'ad_active=-1' ), 'ad_start asc', 1 )->first() )->relative();
return DateTime::ts( Db::i()->select( 'ad_start', 'core_advertisements', array( 'ad_active=-1' ), 'ad_start asc', 1 )->first() )->relative();
}
catch ( \UnderflowException $e )
catch ( UnderflowException )
{
return NULL;
}
@@ -127,15 +137,15 @@ class _Advertisement extends \IPS\core\AdminNotification
/**
* Notification Body (full HTML, must be escaped where necessary)
*
* @return string
* @return string|null
*/
public function body()
public function body(): ?string
{
$table = \IPS\core\modules\admin\promotion\advertisements::table( \IPS\Http\Url::internal('app=core&module=overview&controller=notifications&_table=nexus_Advertisement') );
$table = advertisements::table( Url::internal('app=core&module=overview&controller=notifications&_table=nexus_Advertisement') );
$table->limit = 10;
$table->filters = array();
$table->quickSearch = NULL;
$table->advancedSearch = NULL;
$table->advancedSearch = [];
$table->where[] = array( 'ad_active=-1' );
return (string) $table;
@@ -146,7 +156,7 @@ class _Advertisement extends \IPS\core\AdminNotification
*
* @return string
*/
public function severity()
public function severity(): string
{
return static::SEVERITY_OPTIONAL;
}
@@ -156,7 +166,7 @@ class _Advertisement extends \IPS\core\AdminNotification
*
* @return string
*/
public function dismissible()
public function dismissible(): string
{
return static::DISMISSIBLE_NO;
}
@@ -164,9 +174,9 @@ class _Advertisement extends \IPS\core\AdminNotification
/**
* Style
*
* @return bool
* @return string
*/
public function style()
public function style(): string
{
return static::STYLE_INFORMATION;
}
@@ -174,11 +184,11 @@ class _Advertisement extends \IPS\core\AdminNotification
/**
* Quick link from popup menu
*
* @return bool
* @return Url
*/
public function link()
public function link(): Url
{
return \IPS\Http\Url::internal('app=core&module=promotion&controller=advertisements&filter=ad_filters_pending');
return Url::internal('app=core&module=promotion&controller=advertisements&filter=ad_filters_pending');
}
/**
@@ -187,7 +197,7 @@ class _Advertisement extends \IPS\core\AdminNotification
* @note This is checked every time the notification shows. Should be lightweight.
* @return bool
*/
public function selfDismiss()
public function selfDismiss(): bool
{
return !$this->count();
}
@@ -11,38 +11,49 @@
namespace IPS\nexus\extensions\core\AdminNotifications;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\core\AdminNotification;
use IPS\Http\Url;
use IPS\Member;
use IPS\nexus\Gateway;
use IPS\Theme;
use OutOfRangeException;
use function count;
use function defined;
use function substr;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* ACP Notification Extension
*/
class _ConfigurationError extends \IPS\core\AdminNotification
class ConfigurationError extends AdminNotification
{
/**
* @brief Identifier for what to group this notification type with on the settings form
*/
public static $group = 'commerce';
public static string $group = 'commerce';
/**
* @brief Priority 1-5 (1 being highest) for this group compared to others
*/
public static $groupPriority = 4;
public static int $groupPriority = 4;
/**
* @brief Priority 1-5 (1 being highest) for this notification type compared to others in the same group
*/
public static $itemPriority = 5;
public static int $itemPriority = 5;
/**
* Title for settings
*
* @return string
*/
public static function settingsTitle()
public static function settingsTitle(): string
{
return 'acp_notification_ConfigurationError';
}
@@ -50,10 +61,10 @@ class _ConfigurationError extends \IPS\core\AdminNotification
/**
* Can a member access this type of notification?
*
* @param \IPS\Member $member The member
* @param Member $member The member
* @return bool
*/
public static function permissionCheck( \IPS\Member $member )
public static function permissionCheck( Member $member ): bool
{
return $member->hasAcpRestriction( 'nexus', 'payments', 'gateways_manage' );
}
@@ -61,9 +72,9 @@ class _ConfigurationError extends \IPS\core\AdminNotification
/**
* Is this type of notification ever optional (controls if it will be selectable as "viewable" in settings)
*
* @return string
* @return bool
*/
public static function mayBeOptional()
public static function mayBeOptional(): bool
{
return TRUE;
}
@@ -73,7 +84,7 @@ class _ConfigurationError extends \IPS\core\AdminNotification
*
* @return bool
*/
public static function mayRecur()
public static function mayRecur(): bool
{
return TRUE;
}
@@ -83,64 +94,62 @@ class _ConfigurationError extends \IPS\core\AdminNotification
*
* @return string
*/
public function title()
public function title(): string
{
if( mb_substr( $this->extra, 0, 2 ) === 'pm' )
{
return \IPS\Member::loggedIn()->language()->addToStack('acp_notification_nexus_config_error_paymethod');
return Member::loggedIn()->language()->addToStack('acp_notification_nexus_config_error_paymethod');
}
elseif( mb_substr( $this->extra, 0, 2 ) === 'po' )
{
return \IPS\Member::loggedIn()->language()->addToStack( 'acp_notification_nexus_config_error_payoutmethod' );
return Member::loggedIn()->language()->addToStack( 'acp_notification_nexus_config_error_payoutmethod' );
}
else
{
return \IPS\Member::loggedIn()->language()->addToStack( 'acpNotification_nexusBACancelErrors', FALSE, array( 'pluralize' => array( \count( json_decode( $this->extra, TRUE ) ) ) ) );
return Member::loggedIn()->language()->addToStack( 'acpNotification_nexusBACancelErrors', FALSE, array( 'pluralize' => array( count( json_decode( $this->extra, TRUE ) ) ) ) );
}
}
/**
* Notification Subtitle (no HTML)
*
* @return string
* @return string|null
*/
public function subtitle()
public function subtitle(): ?string
{
if( mb_substr( $this->extra, 0, 2 ) === 'pm' )
{
try
{
$method = \IPS\nexus\Gateway::load( \substr( $this->extra, 2 ) );
return \IPS\Member::loggedIn()->language()->addToStack( 'acp_notification_nexus_config_error_paymethod_desc', FALSE, array( 'sprintf' => array( $method->_title ) ) );
$method = Gateway::load( substr( $this->extra, 2 ) );
return Member::loggedIn()->language()->addToStack( 'acp_notification_nexus_config_error_paymethod_desc', FALSE, array( 'sprintf' => array( $method->_title ) ) );
}
catch ( \OutOfRangeException $e ) { }
catch ( OutOfRangeException ) { }
}
elseif( mb_substr( $this->extra, 0, 2 ) === 'po' )
{
$gateway = mb_substr( $this->extra, 2 );
return \IPS\Member::loggedIn()->language()->addToStack( 'acp_notification_nexus_config_error_payoutmethod_desc', FALSE, array( 'sprintf' => array( $gateway ) ) );
}
else
{
return '';
return Member::loggedIn()->language()->addToStack( 'acp_notification_nexus_config_error_payoutmethod_desc', FALSE, array( 'sprintf' => array( $gateway ) ) );
}
return '';
}
/**
* Notification Body (full HTML, must be escaped where necessary)
*
* @return string
* @return string|null
*/
public function body()
public function body(): ?string
{
if( mb_substr( $this->extra, 0, 2 ) === 'pm' )
{
try
{
$method = \IPS\nexus\Gateway::load( \substr( $this->extra, 2 ) );
return \IPS\Theme::i()->getTemplate( 'notifications', 'nexus', 'admin' )->paymentMethodError( $method );
$method = Gateway::load( substr( $this->extra, 2 ) );
return Theme::i()->getTemplate( 'notifications', 'nexus', 'admin' )->paymentMethodError( $method );
}
catch ( \OutOfRangeException $e )
catch ( OutOfRangeException )
{
return '';
}
@@ -148,11 +157,11 @@ class _ConfigurationError extends \IPS\core\AdminNotification
elseif( mb_substr( $this->extra, 0, 2 ) === 'po' )
{
$gateway = mb_substr( $this->extra, 2 );
return \IPS\Theme::i()->getTemplate( 'notifications', 'nexus', 'admin' )->payoutSettingsError( $gateway );
return Theme::i()->getTemplate( 'notifications', 'nexus', 'admin' )->payoutSettingsError( $gateway );
}
else
{
return \IPS\Theme::i()->getTemplate( 'notifications', 'nexus', 'admin' )->baCancellationError( json_decode( $this->extra, TRUE ) );
return Theme::i()->getTemplate( 'notifications', 'nexus', 'admin' )->baCancellationError( json_decode( $this->extra, TRUE ) );
}
}
@@ -161,7 +170,7 @@ class _ConfigurationError extends \IPS\core\AdminNotification
*
* @return string
*/
public function severity()
public function severity(): string
{
return ( mb_substr( $this->extra, 0, 2 ) === 'pm' OR mb_substr( $this->extra, 0, 2 ) === 'po' ) ? static::SEVERITY_CRITICAL : static::SEVERITY_OPTIONAL;
}
@@ -171,7 +180,7 @@ class _ConfigurationError extends \IPS\core\AdminNotification
*
* @return string
*/
public function dismissible()
public function dismissible(): string
{
return ( mb_substr( $this->extra, 0, 2 ) === 'pm' OR mb_substr( $this->extra, 0, 2 ) === 'po' ) ? static::DISMISSIBLE_NO : static::DISMISSIBLE_PERMANENT;
}
@@ -182,16 +191,16 @@ class _ConfigurationError extends \IPS\core\AdminNotification
* @note This is checked every time the notification shows. Should be lightweight.
* @return bool
*/
public function selfDismiss()
public function selfDismiss(): bool
{
if( mb_substr( $this->extra, 0, 2 ) === 'pm' )
{
try
{
\IPS\nexus\Gateway::load( \substr( $this->extra, 2 ) );
Gateway::load( substr( $this->extra, 2 ) );
return FALSE;
}
catch( \OutOfRangeException $e )
catch( OutOfRangeException )
{
return TRUE;
}
@@ -205,9 +214,9 @@ class _ConfigurationError extends \IPS\core\AdminNotification
/**
* Style
*
* @return bool
* @return string
*/
public function style()
public function style(): string
{
return ( mb_substr( $this->extra, 0, 2 ) === 'pm' OR mb_substr( $this->extra, 0, 2 ) === 'po' ) ? static::STYLE_ERROR : static::STYLE_WARNING;
}
@@ -215,19 +224,19 @@ class _ConfigurationError extends \IPS\core\AdminNotification
/**
* Quick link from popup menu
*
* @return \IPS\Http\Url
* @return Url|null
*/
public function link()
public function link(): Url|null
{
if( mb_substr( $this->extra, 0, 2 ) === 'pm' )
{
return \IPS\Http\Url::internal( 'app=nexus&module=payments&controller=paymentsettings&tab=gateways&do=form&id=' . \substr( $this->extra, 2 ) );
return Url::internal( 'app=nexus&module=payments&controller=paymentsettings&tab=gateways&do=form&id=' . substr( $this->extra, 2 ) );
}
elseif( mb_substr( $this->extra, 0, 2 ) === 'po' )
{
return \IPS\Http\Url::internal( 'app=nexus&module=payments&controller=payouts&do=settings' );
return Url::internal( 'app=nexus&module=payments&controller=payouts&do=settings' );
}
parent::link();
return parent::link();
}
}
@@ -11,38 +11,45 @@
namespace IPS\nexus\extensions\core\AdminNotifications;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\core\AdminNotification;
use IPS\Http\Url;
use IPS\Member;
use IPS\Theme;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* ACP Notification Extension
*/
class _Maxmind extends \IPS\core\AdminNotification
class Maxmind extends AdminNotification
{
/**
* @brief Identifier for what to group this notification type with on the settings form
*/
public static $group = 'commerce';
public static string $group = 'commerce';
/**
* @brief Priority 1-5 (1 being highest) for this group compared to others
*/
public static $groupPriority = 3;
public static int $groupPriority = 3;
/**
* @brief Priority 1-5 (1 being highest) for this notification type compared to others in the same group
*/
public static $itemPriority = 1;
public static int $itemPriority = 1;
/**
* Title for settings
*
* @return string
*/
public static function settingsTitle()
public static function settingsTitle(): string
{
return 'acp_notification_Maxmind';
}
@@ -50,10 +57,10 @@ class _Maxmind extends \IPS\core\AdminNotification
/**
* Can a member access this type of notification?
*
* @param \IPS\Member $member The member
* @param Member $member The member
* @return bool
*/
public static function permissionCheck( \IPS\Member $member )
public static function permissionCheck( Member $member ): bool
{
return true;// $member->hasAcpRestriction( ... );
}
@@ -61,9 +68,9 @@ class _Maxmind extends \IPS\core\AdminNotification
/**
* Is this type of notification ever optional (controls if it will be selectable as "viewable" in settings)
*
* @return string
* @return bool
*/
public static function mayBeOptional()
public static function mayBeOptional(): bool
{
return FALSE;
}
@@ -73,7 +80,7 @@ class _Maxmind extends \IPS\core\AdminNotification
*
* @return bool
*/
public static function mayRecur()
public static function mayRecur(): bool
{
return FALSE;
}
@@ -83,29 +90,29 @@ class _Maxmind extends \IPS\core\AdminNotification
*
* @return string
*/
public function title()
public function title(): string
{
return \IPS\Member::loggedIn()->language()->addToStack('acp_notification_nexus_maxmind');
return Member::loggedIn()->language()->addToStack('acp_notification_nexus_maxmind');
}
/**
* Notification Subtitle (no HTML)
*
* @return string
* @return string|null
*/
public function subtitle()
public function subtitle(): ?string
{
return \IPS\Member::loggedIn()->language()->addToStack( 'acp_notification_nexus_maxmind_sub', FALSE );
return Member::loggedIn()->language()->addToStack( 'acp_notification_nexus_maxmind_sub', FALSE );
}
/**
* Notification Body (full HTML, must be escaped where necessary)
*
* @return string
* @return string|null
*/
public function body()
public function body(): ?string
{
return \IPS\Theme::i()->getTemplate( 'notifications', 'nexus', 'admin' )->maxmind();
return Theme::i()->getTemplate( 'notifications', 'nexus', 'admin' )->maxmind();
}
/**
@@ -113,7 +120,7 @@ class _Maxmind extends \IPS\core\AdminNotification
*
* @return string
*/
public function severity()
public function severity(): string
{
return static::SEVERITY_HIGH;
}
@@ -123,7 +130,7 @@ class _Maxmind extends \IPS\core\AdminNotification
*
* @return string
*/
public function dismissible()
public function dismissible(): string
{
return static::DISMISSIBLE_TEMPORARY;
}
@@ -131,9 +138,9 @@ class _Maxmind extends \IPS\core\AdminNotification
/**
* Style
*
* @return bool
* @return string
*/
public function style()
public function style(): string
{
return static::STYLE_ERROR;
}
@@ -141,9 +148,9 @@ class _Maxmind extends \IPS\core\AdminNotification
/**
* Quick link from popup menu
*
* @return \IPS\Http\Url
* @return Url|null
*/
public function link()
public function link(): Url|null
{
return parent::link(); // \IPS\Http\Url::internal( '...' );
}
@@ -1,194 +0,0 @@
<?php
/**
* @brief ACP Notification: Pending Shipping Orders
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 26 Jul 2018
*/
namespace IPS\nexus\extensions\core\AdminNotifications;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* ACP Notification: Pending Shipping Orders
*/
class _Shipment extends \IPS\core\AdminNotification
{
/**
* @brief Identifier for what to group this notification type with on the settings form
*/
public static $group = 'commerce';
/**
* @brief Priority 1-5 (1 being highest) for this group compared to others
*/
public static $groupPriority = 4;
/**
* @brief Priority 1-5 (1 being highest) for this notification type compared to others in the same group
*/
public static $itemPriority = 3;
/**
* Title for settings
*
* @return string
*/
public static function settingsTitle()
{
return 'acp_notification_Shipments';
}
/**
* Is this type of notification ever optional (controls if it will be selectable as "viewable" in settings)
*
* @return string
*/
public static function mayBeOptional()
{
return TRUE;
}
/**
* Is this type of notification might recur (controls what options will be available for the email setting)
*
* @return bool
*/
public static function mayRecur()
{
return TRUE;
}
/**
* @brief Current count
*/
protected $count = NULL;
/**
* Get count
*
* @return bool
*/
public function count()
{
if ( $this->count === NULL )
{
$this->count = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_ship_orders', array( 'o_status=?', 'pend' ) )->first();
}
return $this->count;
}
/**
* Can a member access this type of notification?
*
* @param \IPS\Member $member The member
* @return bool
*/
public static function permissionCheck( \IPS\Member $member )
{
return $member->hasAcpRestriction( 'nexus', 'payments', 'shiporders_manage' ) and \IPS\Db::i()->select( 'COUNT(*)', 'nexus_shipping' )->first();
}
/**
* Notification Title (full HTML, must be escaped where necessary)
*
* @return string
*/
public function title()
{
return \IPS\Member::loggedIn()->language()->addToStack( 'acpNotification_nexusShipments', FALSE, array( 'pluralize' => array( $this->count() ) ) );
}
/**
* Notification Subtitle (no HTML)
*
* @return string
*/
public function subtitle()
{
try
{
return \IPS\DateTime::ts( \IPS\Db::i()->select( 'o_date', 'nexus_ship_orders', array( 'o_status=?', 'pend' ), 'o_date asc', 1 )->first() )->relative();
}
catch ( \UnderflowException $e )
{
return NULL;
}
}
/**
* Notification Body (full HTML, must be escaped where necessary)
*
* @return string
*/
public function body()
{
$table = \IPS\nexus\Shipping\Order::table( \IPS\Http\Url::internal('app=core&module=overview&controller=notifications&_table=nexus_Shipment') );
$table->limit = 10;
$table->filters = array();
$table->quickSearch = NULL;
$table->advancedSearch = NULL;
$table->where[] = array( 'o_status=?', 'pend' );
return $table;
}
/**
* Severity
*
* @return string
*/
public function severity()
{
return static::SEVERITY_OPTIONAL;
}
/**
* Dismissible?
*
* @return string
*/
public function dismissible()
{
return static::DISMISSIBLE_NO;
}
/**
* Style
*
* @return bool
*/
public function style()
{
return static::STYLE_INFORMATION;
}
/**
* Quick link from popup menu
*
* @return bool
*/
public function link()
{
return \IPS\Http\Url::internal('app=nexus&module=payments&controller=shipping');
}
/**
* Should this notification dismiss itself?
*
* @note This is checked every time the notification shows. Should be lightweight.
* @return bool
*/
public function selfDismiss()
{
return !$this->count();
}
}
@@ -1,268 +0,0 @@
<?php
/**
* @brief ACP Notification: Open Support Requests
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 26 Jul 2018
*/
namespace IPS\nexus\extensions\core\AdminNotifications;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* ACP Notification: Open Support Requests
*/
class _Support extends \IPS\core\AdminNotification
{
/**
* @brief Identifier for what to group this notification type with on the settings form
*/
public static $group = 'commerce';
/**
* @brief Priority 1-5 (1 being highest) for this group compared to others
*/
public static $groupPriority = 4;
/**
* @brief Priority 1-5 (1 being highest) for this notification type compared to others in the same group
*/
public static $itemPriority = 1;
/**
* Title for settings
*
* @return string
*/
public static function settingsTitle()
{
return 'acp_notification_Support';
}
/**
* Is this type of notification ever optional (controls if it will be selectable as "viewable" in settings)
*
* @return string
*/
public static function mayBeOptional()
{
return TRUE;
}
/**
* Is this type of notification might recur (controls what options will be available for the email setting)
*
* @return bool
*/
public static function mayRecur()
{
return TRUE;
}
/**
* @brief Current count (that this admin can see)
*/
protected $count = NULL;
/**
* Get count
*
* @param \IPS\Member $member The member
* @return bool
*/
public function count( \IPS\Member $member = NULL )
{
if ( $this->count === NULL )
{
$member = $member ?: \IPS\Member::loggedIn();
$where = array();
$openStatuses = array();
foreach ( \IPS\nexus\Support\Status::roots() as $status )
{
if ( $status->open )
{
$openStatuses[] = $status->_id;
}
}
$where[] = array( \IPS\Db::i()->in( 'r_status', $openStatuses ) );
$departments = array_keys( iterator_to_array( \IPS\nexus\Support\Department::departmentsWithPermission( $member ) ) );
if ( $departments )
{
$where[] = array( \IPS\Db::i()->in( 'r_department', $departments ) );
}
$this->count = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_support_requests', $where )->first();
}
return $this->count;
}
/**
* Can a member access this type of notification?
*
* @param \IPS\Member $member The member
* @return bool
*/
public static function permissionCheck( \IPS\Member $member )
{
return $member->hasAcpRestriction( 'nexus', 'support', 'requests_manage' ) and \count( \IPS\nexus\Support\Department::departmentsWithPermission( $member ) );
}
/**
* Notification Title (full HTML, must be escaped where necessary)
*
* @return string
*/
public function title()
{
return \IPS\Member::loggedIn()->language()->addToStack( 'acpNotification_nexusSupport', FALSE, array( 'pluralize' => array( $this->count() ) ) );
}
/**
* Notification Subtitle (no HTML)
*
* @return string
*/
public function subtitle()
{
try
{
$where = array();
$openStatuses = array();
foreach ( \IPS\nexus\Support\Status::roots() as $status )
{
if ( $status->open )
{
$openStatuses[] = $status->_id;
}
}
$where[] = array( \IPS\Db::i()->in( 'r_status', $openStatuses ) );
$departments = array_keys( iterator_to_array( \IPS\nexus\Support\Department::departmentsWithPermission( \IPS\Member::loggedIn() ) ) );
if ( $departments )
{
$where[] = array( \IPS\Db::i()->in( 'r_department', $departments ) );
}
return \IPS\DateTime::ts( \IPS\Db::i()->select( 'r_started', 'nexus_support_requests', $where, 'r_started asc', 1 )->first() )->relative();
}
catch ( \UnderflowException $e )
{
return NULL;
}
}
/**
* Notification Body (full HTML, must be escaped where necessary)
*
* @return string
*/
public function body()
{
$sortBy = ( isset( \IPS\Request::i()->cookie['support_sort'] ) and \in_array( \IPS\Request::i()->cookie['support_sort'], array( 'r_started', 'r_last_new_reply', 'r_last_reply', 'r_last_staff_reply' ) ) ) ? \IPS\Request::i()->cookie['support_sort'] : 'r_last_new_reply';
$sortDir = ( isset( \IPS\Request::i()->cookie['support_order'] ) and \in_array( \IPS\Request::i()->cookie['support_order'], array( 'ASC', 'DESC' ) ) ) ? \IPS\Request::i()->cookie['support_order'] : 'ASC';
$i = 0;
$results = array();
$allIds = array();
foreach ( \IPS\nexus\Support\Stream::myStreams( \IPS\Member::loggedIn() ) as $stream )
{
$results[ $stream->id ] = $stream->results( \IPS\Member::loggedIn(), "{$sortBy} {$sortDir}", 1, 3 );
$allIds += array_keys( iterator_to_array( $results[ $stream->id ] ) );
$i++;
if ( $i >= 3 )
{
break;
}
}
$tracked = iterator_to_array( \IPS\Db::i()->select( array( 'request_id', 'notify' ), 'nexus_support_tracker', array( array( 'member_id=?', \IPS\Member::loggedIn()->member_id ), array( \IPS\Db::i()->in( 'request_id', $allIds ) ) ) )->setKeyField( 'request_id' )->setValueField( 'notify' ) );
$participatedIn = iterator_to_array( \IPS\Db::i()->select( 'DISTINCT reply_request', 'nexus_support_replies', array( array( 'reply_member=?', \IPS\Member::loggedIn()->member_id ), array( \IPS\Db::i()->in( 'reply_request', $allIds ) ) ) ) );
$resultsHtml = array();
foreach ( $results as $streamId => $resultSet )
{
$resultsHtml[ $streamId ] = \IPS\Theme::i()->getTemplate( 'support', 'nexus' )->requestsTableResults( $resultSet, NULL, FALSE, $tracked, $participatedIn, FALSE );
}
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'support.css', 'nexus', 'admin' ) );
return \IPS\Theme::i()->getTemplate( 'notifications', 'nexus' )->support( $resultsHtml );
}
/**
* Severity
*
* @return string
*/
public function severity()
{
return static::SEVERITY_DYNAMIC;
}
/**
* Dismissible?
*
* @return string
*/
public function dismissible()
{
return static::DISMISSIBLE_NO;
}
/**
* Style
*
* @return bool
*/
public function style()
{
return static::STYLE_INFORMATION;
}
/**
* Quick link from popup menu
*
* @return bool
*/
public function link()
{
return \IPS\Http\Url::internal('app=nexus&module=support&controller=requests');
}
/**
* For dynamic notifications: should this show for this member?
*
* @note This is checked every time the notification shows. Should be lightweight.
* @param \IPS\Member $member The member
* @return bool
*/
public function dynamicShow( \IPS\Member $member )
{
return (bool) $this->count( $member );
}
/**
* Custom per-admin setting for if email shoild be sent for this notification
*
* @param string $key Setting field key
* @param mixed $value Current value
* @return \IPS\Helpers\Form\FormAbstract|NULL
*/
public static function customEmailConfigurationSetting( $key, $value )
{
return new \IPS\Helpers\Form\Custom( $key, NULL, FALSE, array( 'getHtml' => function() {
return \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( \IPS\Http\Url::internal('app=nexus&module=support&controller=requests&do=preferences'), TRUE, \IPS\Member::loggedIn()->language()->addToStack('acp_notifications_email_configure') );
} ) );
}
}
@@ -11,31 +11,45 @@
namespace IPS\nexus\extensions\core\AdminNotifications;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\core\AdminNotification;
use IPS\DateTime;
use IPS\Db;
use IPS\Http\Url;
use IPS\Member;
use IPS\nexus\Transaction as NexusTransaction;
use IPS\Output;
use IPS\Patterns\ActiveRecordIterator;
use IPS\Theme;
use UnderflowException;
use function count;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* ACP Notification: Transactions Requiring Attention
*/
class _Transaction extends \IPS\core\AdminNotification
class Transaction extends AdminNotification
{
/**
* @brief Identifier for what to group this notification type with on the settings form
*/
public static $group = 'commerce';
public static string $group = 'commerce';
/**
* @brief Priority 1-5 (1 being highest) for this group compared to others
*/
public static $groupPriority = 4;
public static int $groupPriority = 4;
/**
* @brief Priority 1-5 (1 being highest) for this notification type compared to others in the same group
*/
public static $itemPriority = 2;
public static int $itemPriority = 2;
/**
* Get queue HTML
@@ -43,13 +57,13 @@ class _Transaction extends \IPS\core\AdminNotification
* @param string $status Status to show
* @return string
*/
public static function queueHtml( $status )
public static function queueHtml( string $status ) : string
{
$select = \IPS\Db::i()->select( '*', 'nexus_transactions', array( 't_status=?', $status ), 't_date ASC', array( 0, 12 ) );
$select = Db::i()->select( '*', 'nexus_transactions', array( 't_status=?', $status ), 't_date ASC', array( 0, 12 ) );
if ( \count( $select ) )
if ( count( $select ) )
{
return \IPS\Theme::i()->getTemplate( 'notifications', 'nexus' )->transactions( new \IPS\Patterns\ActiveRecordIterator( $select, 'IPS\nexus\Transaction' ) );
return Theme::i()->getTemplate( 'notifications', 'nexus' )->transactions( new ActiveRecordIterator( $select, 'IPS\nexus\Transaction' ) );
}
else
{
@@ -62,7 +76,7 @@ class _Transaction extends \IPS\core\AdminNotification
*
* @return string
*/
public static function settingsTitle()
public static function settingsTitle(): string
{
return 'acp_notification_Transaction';
}
@@ -70,9 +84,9 @@ class _Transaction extends \IPS\core\AdminNotification
/**
* Is this type of notification ever optional (controls if it will be selectable as "viewable" in settings)
*
* @return string
* @return bool
*/
public static function mayBeOptional()
public static function mayBeOptional(): bool
{
return TRUE;
}
@@ -82,7 +96,7 @@ class _Transaction extends \IPS\core\AdminNotification
*
* @return bool
*/
public static function mayRecur()
public static function mayRecur(): bool
{
return TRUE;
}
@@ -90,18 +104,18 @@ class _Transaction extends \IPS\core\AdminNotification
/**
* @brief Current count
*/
protected $count = NULL;
protected ?int $count = NULL;
/**
* Get count
*
* @return bool
* @return int
*/
public function count()
public function count(): int
{
if ( $this->count === NULL )
{
$this->count = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_transactions', array( 't_status=?', $this->extra ) )->first();
$this->count = Db::i()->select( 'COUNT(*)', 'nexus_transactions', array( 't_status=?', $this->extra ) )->first();
}
return $this->count;
}
@@ -109,10 +123,10 @@ class _Transaction extends \IPS\core\AdminNotification
/**
* Can a member access this type of notification?
*
* @param \IPS\Member $member The member
* @param Member $member The member
* @return bool
*/
public static function permissionCheck( \IPS\Member $member )
public static function permissionCheck( Member $member ): bool
{
return $member->hasAcpRestriction( 'nexus', 'payments', 'transactions_manage' );
}
@@ -122,23 +136,23 @@ class _Transaction extends \IPS\core\AdminNotification
*
* @return string
*/
public function title()
public function title(): string
{
return \IPS\Member::loggedIn()->language()->addToStack( 'acpNotification_nexusTransaction_' . $this->extra, FALSE, array( 'pluralize' => array( $this->count() ) ) );
return Member::loggedIn()->language()->addToStack( 'acpNotification_nexusTransaction_' . $this->extra, FALSE, array( 'pluralize' => array( $this->count() ) ) );
}
/**
* Notification Subtitle (no HTML)
*
* @return string
* @return string|null
*/
public function subtitle()
public function subtitle(): ?string
{
try
{
return \IPS\DateTime::ts( \IPS\Db::i()->select( 't_date', 'nexus_transactions', array( 't_status=?', $this->extra ), 't_date asc', 1 )->first() )->relative();
return DateTime::ts( Db::i()->select( 't_date', 'nexus_transactions', array( 't_status=?', $this->extra ), 't_date asc', 1 )->first() )->relative();
}
catch ( \UnderflowException $e )
catch ( UnderflowException )
{
return NULL;
}
@@ -147,11 +161,11 @@ class _Transaction extends \IPS\core\AdminNotification
/**
* Notification Body (full HTML, must be escaped where necessary)
*
* @return string
* @return string|null
*/
public function body()
public function body(): ?string
{
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js('admin_notifications.js', 'nexus') );
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js('admin_notifications.js', 'nexus') );
return static::queueHtml( $this->extra );
}
@@ -161,7 +175,7 @@ class _Transaction extends \IPS\core\AdminNotification
*
* @return string
*/
public function severity()
public function severity(): string
{
return static::SEVERITY_OPTIONAL;
}
@@ -171,7 +185,7 @@ class _Transaction extends \IPS\core\AdminNotification
*
* @return string
*/
public function dismissible()
public function dismissible(): string
{
return static::DISMISSIBLE_NO;
}
@@ -179,11 +193,11 @@ class _Transaction extends \IPS\core\AdminNotification
/**
* Style
*
* @return bool
* @return string
*/
public function style()
public function style(): string
{
if ( $this->extra === \IPS\nexus\Transaction::STATUS_DISPUTED )
if ( $this->extra === NexusTransaction::STATUS_DISPUTED )
{
return static::STYLE_WARNING;
}
@@ -196,11 +210,11 @@ class _Transaction extends \IPS\core\AdminNotification
/**
* Quick link from popup menu
*
* @return bool
* @return Url
*/
public function link()
public function link(): Url
{
return \IPS\Http\Url::internal('app=nexus&module=payments&controller=transactions&attn=1');
return Url::internal('app=nexus&module=payments&controller=transactions&attn=1');
}
/**
@@ -209,7 +223,7 @@ class _Transaction extends \IPS\core\AdminNotification
* @note This is checked every time the notification shows. Should be lightweight.
* @return bool
*/
public function selfDismiss()
public function selfDismiss(): bool
{
return !$this->count();
}
@@ -11,38 +11,49 @@
namespace IPS\nexus\extensions\core\AdminNotifications;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\core\AdminNotification;
use IPS\DateTime;
use IPS\Db;
use IPS\Http\Url;
use IPS\Member;
use IPS\nexus\Payout;
use IPS\Settings;
use UnderflowException;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* ACP Notification: Pending Credit Withdrawals
*/
class _Withdrawal extends \IPS\core\AdminNotification
class Withdrawal extends AdminNotification
{
/**
* @brief Identifier for what to group this notification type with on the settings form
*/
public static $group = 'commerce';
public static string $group = 'commerce';
/**
* @brief Priority 1-5 (1 being highest) for this group compared to others
*/
public static $groupPriority = 4;
public static int $groupPriority = 4;
/**
* @brief Priority 1-5 (1 being highest) for this notification type compared to others in the same group
*/
public static $itemPriority = 4;
public static int $itemPriority = 4;
/**
* Title for settings
*
* @return string
*/
public static function settingsTitle()
public static function settingsTitle(): string
{
return 'acp_notification_Withdrawals';
}
@@ -50,9 +61,9 @@ class _Withdrawal extends \IPS\core\AdminNotification
/**
* Is this type of notification ever optional (controls if it will be selectable as "viewable" in settings)
*
* @return string
* @return bool
*/
public static function mayBeOptional()
public static function mayBeOptional(): bool
{
return TRUE;
}
@@ -62,7 +73,7 @@ class _Withdrawal extends \IPS\core\AdminNotification
*
* @return bool
*/
public static function mayRecur()
public static function mayRecur(): bool
{
return TRUE;
}
@@ -70,18 +81,18 @@ class _Withdrawal extends \IPS\core\AdminNotification
/**
* @brief Current count
*/
protected $count = NULL;
protected ?int $count = NULL;
/**
* Get count
*
* @return bool
* @return int
*/
public function count()
public function count(): int
{
if ( $this->count === NULL )
{
$this->count = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_payouts', array( 'po_status=?', \IPS\nexus\Payout::STATUS_PENDING ) )->first();
$this->count = Db::i()->select( 'COUNT(*)', 'nexus_payouts', array( 'po_status=?', Payout::STATUS_PENDING ) )->first();
}
return $this->count;
}
@@ -89,12 +100,12 @@ class _Withdrawal extends \IPS\core\AdminNotification
/**
* Can a member access this type of notification?
*
* @param \IPS\Member $member The member
* @param Member $member The member
* @return bool
*/
public static function permissionCheck( \IPS\Member $member )
public static function permissionCheck( Member $member ): bool
{
return \IPS\Settings::i()->nexus_payout and $member->hasAcpRestriction( 'nexus', 'payments', 'payouts_manage' );
return Settings::i()->nexus_payout and $member->hasAcpRestriction( 'nexus', 'payments', 'payouts_manage' );
}
/**
@@ -102,23 +113,23 @@ class _Withdrawal extends \IPS\core\AdminNotification
*
* @return string
*/
public function title()
public function title(): string
{
return \IPS\Member::loggedIn()->language()->addToStack( 'acpNotification_nexusWithdrawals', FALSE, array( 'pluralize' => array( $this->count() ) ) );
return Member::loggedIn()->language()->addToStack( 'acpNotification_nexusWithdrawals', FALSE, array( 'pluralize' => array( $this->count() ) ) );
}
/**
* Notification Subtitle (no HTML)
*
* @return string
* @return string|null
*/
public function subtitle()
public function subtitle(): ?string
{
try
{
return \IPS\DateTime::ts( \IPS\Db::i()->select( 'po_date', 'nexus_payouts', array( 'po_status=?', \IPS\nexus\Payout::STATUS_PENDING ), 'po_date asc', 1 )->first() )->relative();
return DateTime::ts( Db::i()->select( 'po_date', 'nexus_payouts', array( 'po_status=?', Payout::STATUS_PENDING ), 'po_date asc', 1 )->first() )->relative();
}
catch ( \UnderflowException $e )
catch ( UnderflowException )
{
return NULL;
}
@@ -127,15 +138,15 @@ class _Withdrawal extends \IPS\core\AdminNotification
/**
* Notification Body (full HTML, must be escaped where necessary)
*
* @return string
* @return string|null
*/
public function body()
public function body(): ?string
{
$table = \IPS\nexus\Payout::table( array( 'po_status=?', 'pend' ), \IPS\Http\Url::internal('app=nexus&module=payments&controller=payouts&filter=postatus_pend') );
$table = Payout::table( array( 'po_status=?', 'pend' ), Url::internal('app=nexus&module=payments&controller=payouts&filter=postatus_pend') );
$table->limit = 10;
$table->filters = array();
$table->quickSearch = NULL;
$table->advancedSearch = NULL;
$table->advancedSearch = [];
return $table;
}
@@ -145,7 +156,7 @@ class _Withdrawal extends \IPS\core\AdminNotification
*
* @return string
*/
public function severity()
public function severity(): string
{
return static::SEVERITY_OPTIONAL;
}
@@ -155,7 +166,7 @@ class _Withdrawal extends \IPS\core\AdminNotification
*
* @return string
*/
public function dismissible()
public function dismissible(): string
{
return static::DISMISSIBLE_NO;
}
@@ -163,9 +174,9 @@ class _Withdrawal extends \IPS\core\AdminNotification
/**
* Style
*
* @return bool
* @return string
*/
public function style()
public function style(): string
{
return static::STYLE_INFORMATION;
}
@@ -173,11 +184,11 @@ class _Withdrawal extends \IPS\core\AdminNotification
/**
* Quick link from popup menu
*
* @return bool
* @return Url
*/
public function link()
public function link(): Url
{
return \IPS\Http\Url::internal('app=nexus&module=payments&controller=payouts&filter=postatus_pend');
return Url::internal('app=nexus&module=payments&controller=payouts&filter=postatus_pend');
}
/**
@@ -186,7 +197,7 @@ class _Withdrawal extends \IPS\core\AdminNotification
* @note This is checked every time the notification shows. Should be lightweight.
* @return bool
*/
public function selfDismiss()
public function selfDismiss(): bool
{
return !$this->count();
}