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,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();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user