Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -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();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user