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