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
@@ -12,43 +12,50 @@
|
||||
namespace IPS\nexus\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Db;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Number;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
use IPS\Theme;
|
||||
use IPS\Widget\Customizable;
|
||||
use IPS\Widget\PermissionCache;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* bestSellers Widget
|
||||
*/
|
||||
class _bestSellers extends \IPS\Widget\PermissionCache
|
||||
class bestSellers extends PermissionCache implements Customizable
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'bestSellers';
|
||||
public string $key = 'bestSellers';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'nexus';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
public string $app = 'nexus';
|
||||
|
||||
/**
|
||||
* Init widget
|
||||
*
|
||||
* @return null
|
||||
* @return void
|
||||
*/
|
||||
public function init()
|
||||
public function init(): void
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge(
|
||||
\IPS\Output::i()->cssFiles,
|
||||
\IPS\Theme::i()->css( 'widgets.css', 'nexus' ),
|
||||
\IPS\Theme::i()->css( 'store.css', 'nexus' )
|
||||
Output::i()->cssFiles = array_merge(
|
||||
Output::i()->cssFiles,
|
||||
Theme::i()->css( 'widgets.css', 'nexus' ),
|
||||
Theme::i()->css( 'store.css', 'nexus' )
|
||||
);
|
||||
|
||||
parent::init();
|
||||
@@ -57,14 +64,14 @@ class _bestSellers extends \IPS\Widget\PermissionCache
|
||||
/**
|
||||
* Specify widget configuration
|
||||
*
|
||||
* @param null|\IPS\Helpers\Form $form Form object
|
||||
* @return null|\IPS\Helpers\Form
|
||||
* @param null|Form $form Form object
|
||||
* @return Form
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
public function configuration( ?Form &$form=null ): Form
|
||||
{
|
||||
$form = parent::configuration( $form );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'number_to_show', isset( $this->configuration['number_to_show'] ) ? $this->configuration['number_to_show'] : 5, TRUE ) );
|
||||
$form->add( new Number( 'number_to_show', $this->configuration['number_to_show'] ?? 5, TRUE ) );
|
||||
|
||||
return $form;
|
||||
}
|
||||
@@ -75,7 +82,7 @@ class _bestSellers extends \IPS\Widget\PermissionCache
|
||||
* @param array $values Values from form
|
||||
* @return array
|
||||
*/
|
||||
public function preConfig( $values )
|
||||
public function preConfig( array $values ): array
|
||||
{
|
||||
return $values;
|
||||
}
|
||||
@@ -85,12 +92,12 @@ class _bestSellers extends \IPS\Widget\PermissionCache
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
public function render(): string
|
||||
{
|
||||
$packages = array();
|
||||
$purchases = \IPS\Db::i()->select( 'count(*) as purchased, ps_item_id', 'nexus_purchases', array(
|
||||
$purchases = Db::i()->select( 'count(*) as purchased, ps_item_id', 'nexus_purchases', array(
|
||||
array( 'p_store=1' ),
|
||||
array( "( p_member_groups='*' OR " . \IPS\Db::i()->findInSet( 'p_member_groups', \IPS\Member::loggedIn()->groups ) . ' )' )
|
||||
array( "( p_member_groups='*' OR " . Db::i()->findInSet( 'p_member_groups', Member::loggedIn()->groups ) . ' )' )
|
||||
), 'purchased DESC', array( 0, ( isset( $this->configuration['number_to_show'] ) AND $this->configuration['number_to_show'] > 0 ) ? $this->configuration['number_to_show'] : 5 ), 'ps_item_id' )
|
||||
->join( 'nexus_packages', array( "ps_item_id=p_id") );
|
||||
|
||||
@@ -104,7 +111,7 @@ class _bestSellers extends \IPS\Widget\PermissionCache
|
||||
return "";
|
||||
}
|
||||
|
||||
$packages = new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_packages', array( \IPS\Db::i()->in( 'p_id', $packages ) ) ), 'IPS\nexus\Package' );
|
||||
$packages = new ActiveRecordIterator( Db::i()->select( '*', 'nexus_packages', array( Db::i()->in( 'p_id', $packages ) ) ), 'IPS\nexus\Package' );
|
||||
|
||||
return $this->output( $packages );
|
||||
}
|
||||
|
||||
@@ -12,39 +12,52 @@
|
||||
namespace IPS\nexus\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Member;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use IPS\Widget\Customizable;
|
||||
use IPS\Widget\StaticCache;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* donations Widget
|
||||
*/
|
||||
class _donations extends \IPS\Widget\StaticCache
|
||||
class donations extends StaticCache implements Customizable
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'donations';
|
||||
public string $key = 'donations';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'nexus';
|
||||
|
||||
public string $app = 'nexus';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
* Constructor
|
||||
*
|
||||
* @param String $uniqueKey Unique key for this specific instance
|
||||
* @param array $configuration Widget custom configuration
|
||||
* @param array|string|null $access Array/JSON string of executable apps (core=sidebar only, content=IP.Content only, etc)
|
||||
* @param string|null $orientation Orientation (top, bottom, right, left)
|
||||
* @param string $layout
|
||||
* @return void
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
public function __construct( $uniqueKey, array $configuration, $access=null, $orientation=null )
|
||||
public function __construct(string $uniqueKey, array $configuration, array|string $access=null, string $orientation=null, string $layout='table' )
|
||||
{
|
||||
parent::__construct( $uniqueKey, $configuration, $access, $orientation );
|
||||
parent::__construct( $uniqueKey, $configuration, $access, $orientation, $layout );
|
||||
|
||||
$member = \IPS\Member::loggedIn();
|
||||
$member = Member::loggedIn();
|
||||
|
||||
$theme = $member->skin ?: \IPS\Theme::defaultTheme();
|
||||
$theme = $member->skin ?: Theme::defaultTheme();
|
||||
$this->cacheKey = "widget_{$this->key}_" . $this->uniqueKey . '_' . md5( json_encode( $configuration ) . "_" . $member->language()->id . "_" . $member->member_id ? 1 : 0 . "_" . $theme . "_" . $orientation );
|
||||
}
|
||||
|
||||
@@ -53,10 +66,9 @@ class _donations extends \IPS\Widget\StaticCache
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init()
|
||||
public function init(): void
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'donations.css', 'nexus' ) );
|
||||
return parent::init();
|
||||
parent::init();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,8 +76,14 @@ class _donations extends \IPS\Widget\StaticCache
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
public function render(): string
|
||||
{
|
||||
/* Do we have any donation goals to show? */
|
||||
if( !Settings::i()->donation_goals )
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
return $this->output();
|
||||
}
|
||||
}
|
||||
@@ -12,57 +12,66 @@
|
||||
namespace IPS\nexus\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Db;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Node;
|
||||
use IPS\nexus\Package;
|
||||
use IPS\Output;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
use IPS\Theme;
|
||||
use IPS\Widget\PermissionCache;
|
||||
use OutOfRangeException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function is_array;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* featuredProduct Widget
|
||||
*/
|
||||
class _featuredProduct extends \IPS\Widget\PermissionCache
|
||||
class featuredProduct extends PermissionCache
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'featuredProduct';
|
||||
public string $key = 'featuredProduct';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'nexus';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
public string $app = 'nexus';
|
||||
|
||||
/**
|
||||
* Initialise this widget
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init()
|
||||
public function init(): void
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'widgets.css', 'nexus' ) );
|
||||
Output::i()->cssFiles = array_merge( Output::i()->cssFiles, Theme::i()->css( 'widgets.css', 'nexus' ) );
|
||||
parent::init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify widget configuration
|
||||
*
|
||||
* @param null|\IPS\Helpers\Form $form Form object
|
||||
* @return null|\IPS\Helpers\Form
|
||||
* @param null|Form $form Form object
|
||||
* @return Form
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
public function configuration( Form &$form=null ): Form
|
||||
{
|
||||
$form = parent::configuration( $form );
|
||||
|
||||
$value = 0;
|
||||
if ( isset( $this->configuration['package'] ) )
|
||||
{
|
||||
if ( \is_array( $this->configuration['package'] ) )
|
||||
if ( is_array( $this->configuration['package'] ) )
|
||||
{
|
||||
$value = $this->configuration['package'];
|
||||
}
|
||||
@@ -72,7 +81,7 @@ class _featuredProduct extends \IPS\Widget\PermissionCache
|
||||
}
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'package', $value, FALSE, array(
|
||||
$form->add( new Node( 'package', $value, FALSE, array(
|
||||
'class' => '\IPS\nexus\Package',
|
||||
'permissionCheck' => function( $node )
|
||||
{
|
||||
@@ -95,9 +104,9 @@ class _featuredProduct extends \IPS\Widget\PermissionCache
|
||||
* @param array $values Values from form
|
||||
* @return array
|
||||
*/
|
||||
public function preConfig( $values )
|
||||
public function preConfig( array $values ): array
|
||||
{
|
||||
if ( \is_array( $values['package'] ) )
|
||||
if ( is_array( $values['package'] ) )
|
||||
{
|
||||
$save = array();
|
||||
foreach( $values['package'] AS $pkg )
|
||||
@@ -119,27 +128,27 @@ class _featuredProduct extends \IPS\Widget\PermissionCache
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
public function render(): string
|
||||
{
|
||||
//Load the product
|
||||
$packages = array();
|
||||
if( isset( $this->configuration['package'] ) )
|
||||
{
|
||||
if ( \is_array( $this->configuration['package'] ) )
|
||||
if ( is_array( $this->configuration['package'] ) )
|
||||
{
|
||||
$packages = new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_packages', array( array( 'p_store=1' ), array( \IPS\Db::i()->in( 'p_id', $this->configuration['package'] ) ) ) ), 'IPS\nexus\Package' );
|
||||
$packages = new ActiveRecordIterator( Db::i()->select( '*', 'nexus_packages', array( array( 'p_store=1' ), array( Db::i()->in( 'p_id', $this->configuration['package'] ) ) ) ), 'IPS\nexus\Package' );
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
$packages = array( \IPS\nexus\Package::load( $this->configuration['package'] ) );
|
||||
$packages = array( Package::load( $this->configuration['package'] ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ){}
|
||||
catch ( OutOfRangeException ){}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !\count( $packages ) )
|
||||
if ( !count( $packages ) )
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -12,43 +12,51 @@
|
||||
namespace IPS\nexus\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Db;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Number;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
use IPS\Theme;
|
||||
use IPS\Widget\Customizable;
|
||||
use IPS\Widget\PermissionCache;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* latestProducts Widget
|
||||
*/
|
||||
class _latestProducts extends \IPS\Widget\PermissionCache
|
||||
class latestProducts extends PermissionCache implements Customizable
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'latestProducts';
|
||||
public string $key = 'latestProducts';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'nexus';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
public string $app = 'nexus';
|
||||
|
||||
/**
|
||||
* Initialise this widget
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init()
|
||||
public function init(): void
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge(
|
||||
\IPS\Output::i()->cssFiles,
|
||||
\IPS\Theme::i()->css( 'widgets.css', 'nexus' ),
|
||||
\IPS\Theme::i()->css( 'store.css', 'nexus' )
|
||||
Output::i()->cssFiles = array_merge(
|
||||
Output::i()->cssFiles,
|
||||
Theme::i()->css( 'widgets.css', 'nexus' ),
|
||||
Theme::i()->css( 'store.css', 'nexus' )
|
||||
);
|
||||
parent::init();
|
||||
}
|
||||
@@ -56,14 +64,14 @@ class _latestProducts extends \IPS\Widget\PermissionCache
|
||||
/**
|
||||
* Specify widget configuration
|
||||
*
|
||||
* @param null|\IPS\Helpers\Form $form Form object
|
||||
* @return null|\IPS\Helpers\Form
|
||||
* @param null|Form $form Form object
|
||||
* @return Form
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
public function configuration( Form &$form=null ): Form
|
||||
{
|
||||
$form = parent::configuration( $form );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'number_to_show', isset( $this->configuration['number_to_show'] ) ? $this->configuration['number_to_show'] : 5, TRUE ) );
|
||||
$form->add( new Number( 'number_to_show', $this->configuration['number_to_show'] ?? 5, TRUE ) );
|
||||
|
||||
return $form;
|
||||
}
|
||||
@@ -74,7 +82,7 @@ class _latestProducts extends \IPS\Widget\PermissionCache
|
||||
* @param array $values Values from form
|
||||
* @return array
|
||||
*/
|
||||
public function preConfig( $values )
|
||||
public function preConfig( array $values ): array
|
||||
{
|
||||
return $values;
|
||||
}
|
||||
@@ -84,20 +92,20 @@ class _latestProducts extends \IPS\Widget\PermissionCache
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
public function render(): string
|
||||
{
|
||||
//Load the products
|
||||
$select = \IPS\Db::i()->select( '*', 'nexus_packages', array(
|
||||
$select = Db::i()->select( '*', 'nexus_packages', array(
|
||||
array( 'p_store=1' ),
|
||||
array( "( p_member_groups='*' OR " . \IPS\Db::i()->findInSet( 'p_member_groups', \IPS\Member::loggedIn()->groups ) . ' )' )
|
||||
array( "( p_member_groups='*' OR " . Db::i()->findInSet( 'p_member_groups', Member::loggedIn()->groups ) . ' )' )
|
||||
), "p_date_added DESC", array( 0, ( isset( $this->configuration['number_to_show'] ) AND $this->configuration['number_to_show'] > 0 ) ? $this->configuration['number_to_show'] : 5 ) );
|
||||
|
||||
if ( !\count( $select ) )
|
||||
if ( !count( $select ) )
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
$packages = new \IPS\Patterns\ActiveRecordIterator( $select, 'IPS\nexus\Package' );
|
||||
$packages = new ActiveRecordIterator( $select, 'IPS\nexus\Package' );
|
||||
|
||||
return $this->output( $packages );
|
||||
}
|
||||
|
||||
@@ -12,70 +12,77 @@
|
||||
namespace IPS\nexus\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Db;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\CheckboxSet;
|
||||
use IPS\Member;
|
||||
use IPS\nexus\Payout;
|
||||
use IPS\nexus\Transaction;
|
||||
use IPS\Output;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use IPS\Widget;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pending Actions Widget
|
||||
*/
|
||||
class _pendingActions extends \IPS\Widget
|
||||
class pendingActions extends Widget
|
||||
{
|
||||
/**
|
||||
* @brief Options
|
||||
*/
|
||||
protected static $options = array(
|
||||
protected static array $options = array(
|
||||
'transactions' => 'pending_transactions',
|
||||
'shipments' => 'pending_shipments',
|
||||
'withdrawals' => 'pending_widthdrawals',
|
||||
'support' => 'open_support_requests',
|
||||
'ads' => 'pending_advertisements',
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'pendingActions';
|
||||
public string $key = 'pendingActions';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'nexus';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
public string $app = 'nexus';
|
||||
|
||||
/**
|
||||
* Initialise this widget
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init()
|
||||
public function init(): void
|
||||
{
|
||||
if ( !isset( $this->configuration['pendingActions_stuff'] ) )
|
||||
{
|
||||
$this->configuration['pendingActions_stuff'] = array_keys( static::$options );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'widgets.css', 'nexus', 'front' ) );
|
||||
Output::i()->cssFiles = array_merge( Output::i()->cssFiles, Theme::i()->css( 'widgets.css', 'nexus', 'front' ) );
|
||||
parent::init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify widget configuration
|
||||
*
|
||||
* @param null|\IPS\Helpers\Form $form Form object
|
||||
* @return null|\IPS\Helpers\Form
|
||||
* @param null|Form $form Form object
|
||||
* @return Form
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
public function configuration( Form &$form=null ): Form
|
||||
{
|
||||
$form = parent::configuration( $form );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'pendingActions_stuff', $this->configuration['pendingActions_stuff'], TRUE, array( 'options' => static::$options ) ) );
|
||||
$form->add( new CheckboxSet( 'pendingActions_stuff', $this->configuration['pendingActions_stuff'], TRUE, array( 'options' => static::$options ) ) );
|
||||
|
||||
return $form;
|
||||
}
|
||||
@@ -85,41 +92,30 @@ class _pendingActions extends \IPS\Widget
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
public function render(): string
|
||||
{
|
||||
if ( !\IPS\Member::loggedIn()->isAdmin() )
|
||||
if ( !Member::loggedIn()->isAdmin() )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/* Pending transactions *might* happen some weird way, so always get the count... but only show the count if we have fraud rules set up */
|
||||
$pendingTransactions = NULL;
|
||||
if ( \in_array( 'transactions', $this->configuration['pendingActions_stuff'] ) and \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'transactions_manage' ) )
|
||||
if ( in_array( 'transactions', $this->configuration['pendingActions_stuff'] ) and Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'transactions_manage' ) )
|
||||
{
|
||||
$pendingTransactions = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_transactions', array( 't_status=?', \IPS\nexus\Transaction::STATUS_HELD ) )->first();
|
||||
if ( !$pendingTransactions and !\IPS\Db::i()->select( 'COUNT(*)', 'nexus_fraud_rules' )->first() )
|
||||
$pendingTransactions = Db::i()->select( 'COUNT(*)', 'nexus_transactions', array( 't_status=?', Transaction::STATUS_HELD ) )->first();
|
||||
if ( !$pendingTransactions and !Db::i()->select( 'COUNT(*)', 'nexus_fraud_rules' )->first() )
|
||||
{
|
||||
$pendingTransactions = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Same with shipments */
|
||||
$pendingShipments = NULL;
|
||||
if ( \in_array( 'shipments', $this->configuration['pendingActions_stuff'] ) and \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'shiporders_manage' ) )
|
||||
{
|
||||
$pendingShipments = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_ship_orders', array( 'o_status=?', \IPS\nexus\Shipping\Order::STATUS_PENDING ) )->first();
|
||||
if ( !$pendingShipments and !\IPS\Db::i()->select( 'COUNT(*)', 'nexus_packages_products', 'p_physical=1' )->first() )
|
||||
{
|
||||
$pendingShipments = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* And advertisements */
|
||||
$pendingAdvertisements = NULL;
|
||||
if ( \in_array( 'ads', $this->configuration['pendingActions_stuff'] ) and \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'promotion', 'advertisements_manage' ) )
|
||||
if ( in_array( 'ads', $this->configuration['pendingActions_stuff'] ) and Member::loggedIn()->hasAcpRestriction( 'core', 'promotion', 'advertisements_manage' ) )
|
||||
{
|
||||
$pendingAdvertisements = \IPS\Db::i()->select( 'COUNT(*)', 'core_advertisements', array( 'ad_active=-1' ) )->first();
|
||||
if ( !$pendingAdvertisements and !\IPS\Db::i()->select( 'COUNT(*)', 'nexus_packages_ads' )->first() )
|
||||
$pendingAdvertisements = Db::i()->select( 'COUNT(*)', 'core_advertisements', array( 'ad_active=-1' ) )->first();
|
||||
if ( !$pendingAdvertisements and !Db::i()->select( 'COUNT(*)', 'nexus_packages_ads' )->first() )
|
||||
{
|
||||
$pendingAdvertisements = NULL;
|
||||
}
|
||||
@@ -127,19 +123,11 @@ class _pendingActions extends \IPS\Widget
|
||||
|
||||
/* Withdrawals will only be if enabled */
|
||||
$pendingWithdrawals = NULL;
|
||||
if ( \in_array( 'withdrawals', $this->configuration['pendingActions_stuff'] ) and \IPS\Settings::i()->nexus_payout and \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'payouts_manage' ) )
|
||||
if ( in_array( 'withdrawals', $this->configuration['pendingActions_stuff'] ) and Settings::i()->nexus_payout and Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'payouts_manage' ) )
|
||||
{
|
||||
$pendingWithdrawals = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_payouts', array( 'po_status=?', \IPS\nexus\Payout::STATUS_PENDING ) )->first();
|
||||
}
|
||||
|
||||
/* Show support if there are departments we can see */
|
||||
$openSupportRequests = NULL;
|
||||
if ( \in_array( 'support', $this->configuration['pendingActions_stuff'] ) and \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'support', 'requests_manage' ) and \IPS\Db::i()->select( '*', 'nexus_support_departments', array( "( dpt_staff='*' OR " . \IPS\Db::i()->findInSet( 'dpt_staff', \IPS\nexus\Support\Department::staffDepartmentPerms() ) . ')' ) ) )
|
||||
{
|
||||
$myStream = \IPS\nexus\Support\Stream::myStream();
|
||||
$openSupportRequests = $myStream->count( \IPS\Member::loggedIn() );
|
||||
$pendingWithdrawals = Db::i()->select( 'COUNT(*)', 'nexus_payouts', array( 'po_status=?', Payout::STATUS_PENDING ) )->first();
|
||||
}
|
||||
|
||||
return $this->output( $pendingTransactions, $pendingShipments, $pendingWithdrawals, $openSupportRequests, $pendingAdvertisements );
|
||||
return $this->output( $pendingTransactions, $pendingWithdrawals, $pendingAdvertisements );
|
||||
}
|
||||
}
|
||||
@@ -12,55 +12,65 @@
|
||||
namespace IPS\nexus\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Content\Filter;
|
||||
use IPS\Db;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Node;
|
||||
use IPS\Helpers\Form\Number;
|
||||
use IPS\nexus\Package\Review;
|
||||
use IPS\Output;
|
||||
use IPS\Theme;
|
||||
use IPS\Widget\Customizable;
|
||||
use IPS\Widget\PermissionCache;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function is_array;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* recentCommerceReviews Widget
|
||||
*/
|
||||
class _recentCommerceReviews extends \IPS\Widget\PermissionCache
|
||||
class recentCommerceReviews extends PermissionCache implements Customizable
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'recentCommerceReviews';
|
||||
public string $key = 'recentCommerceReviews';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'nexus';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
public string $app = 'nexus';
|
||||
|
||||
/**
|
||||
* Init widget
|
||||
*
|
||||
* @return null
|
||||
* @return void
|
||||
*/
|
||||
public function init()
|
||||
public function init(): void
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'widgets.css', 'nexus', 'front' ) );
|
||||
Output::i()->cssFiles = array_merge( Output::i()->cssFiles, Theme::i()->css( 'widgets.css', 'nexus', 'front' ) );
|
||||
parent::init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify widget configuration
|
||||
*
|
||||
* @param null|\IPS\Helpers\Form $form Form object
|
||||
* @return null|\IPS\Helpers\Form
|
||||
* @param null|Form $form Form object
|
||||
* @return Form
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
public function configuration( Form &$form=null ): Form
|
||||
{
|
||||
$form = parent::configuration( $form );
|
||||
|
||||
/* Container */
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'widget_group', isset( $this->configuration['widget_group'] ) ? $this->configuration['widget_group'] : 0, FALSE, array(
|
||||
$form->add( new Node( 'widget_group', $this->configuration['widget_group'] ?? 0, FALSE, array(
|
||||
'class' => '\IPS\nexus\Package\Group',
|
||||
'zeroVal' => 'all',
|
||||
'permissionCheck' => 'view',
|
||||
@@ -68,7 +78,7 @@ class _recentCommerceReviews extends \IPS\Widget\PermissionCache
|
||||
'subnodes' => false,
|
||||
) ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'review_count', isset( $this->configuration['review_count'] ) ? $this->configuration['review_count'] : 5, TRUE ) );
|
||||
$form->add( new Number( 'review_count', $this->configuration['review_count'] ?? 5, TRUE ) );
|
||||
|
||||
return $form;
|
||||
}
|
||||
@@ -79,9 +89,9 @@ class _recentCommerceReviews extends \IPS\Widget\PermissionCache
|
||||
* @param array $values Values from form
|
||||
* @return array
|
||||
*/
|
||||
public function preConfig( $values )
|
||||
public function preConfig( array $values ): array
|
||||
{
|
||||
if ( \is_array( $values['widget_group'] ) )
|
||||
if ( is_array( $values['widget_group'] ) )
|
||||
{
|
||||
$values['widget_group'] = array_keys( $values['widget_group'] );
|
||||
}
|
||||
@@ -94,18 +104,18 @@ class _recentCommerceReviews extends \IPS\Widget\PermissionCache
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
public function render(): string
|
||||
{
|
||||
$where = array();
|
||||
|
||||
if ( ! empty( $this->configuration['widget_group'] ) )
|
||||
{
|
||||
$where['item'][] = array( \IPS\Db::i()->in( 'p_group', $this->configuration['widget_group'] ) );
|
||||
$where['item'][] = array( Db::i()->in( 'p_group', $this->configuration['widget_group'] ) );
|
||||
}
|
||||
|
||||
$reviews = \IPS\nexus\Package\Review::getItemsWithPermission( $where, NULL, ( isset( $this->configuration['review_count'] ) AND $this->configuration['review_count'] > 0 ) ? $this->configuration['review_count'] : 5, 'read', \IPS\Content\Hideable::FILTER_PUBLIC_ONLY );
|
||||
$reviews = Review::getItemsWithPermission( $where, null, ( isset( $this->configuration['review_count'] ) and $this->configuration['review_count'] > 0 ) ? $this->configuration['review_count'] : 5, 'read', Filter::FILTER_PUBLIC_ONLY );
|
||||
|
||||
if ( !\count( $reviews ) )
|
||||
if ( !count( $reviews ) )
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -12,40 +12,41 @@
|
||||
namespace IPS\nexus\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Member;
|
||||
use IPS\nexus\Subscription;
|
||||
use IPS\Widget;
|
||||
use IPS\Widget\Customizable;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* subscriptions Widget
|
||||
*/
|
||||
class _subscriptions extends \IPS\Widget
|
||||
class subscriptions extends Widget implements Customizable
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'subscriptions';
|
||||
public string $key = 'subscriptions';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'nexus';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
public string $app = 'nexus';
|
||||
|
||||
/**
|
||||
* Initialise this widget
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init()
|
||||
public function init(): void
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'subscriptions.css', 'nexus' ) );
|
||||
parent::init();
|
||||
}
|
||||
|
||||
@@ -54,10 +55,10 @@ class _subscriptions extends \IPS\Widget
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
public function render(): string
|
||||
{
|
||||
/* If we already have one, don't show it */
|
||||
if ( \IPS\nexus\Subscription::loadActiveByMember( \IPS\Member::loggedIn() ) )
|
||||
if ( Subscription::loadByMember( Member::loggedIn(), true ) )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user