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,39 +11,50 @@
|
||||
namespace IPS\core\Online;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Helpers\Table\Table as TableHelper;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Request;
|
||||
use IPS\Session\Store;
|
||||
use IPS\Settings;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
use function intval;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Promote Table Helper
|
||||
*/
|
||||
class _Table extends \IPS\Helpers\Table\Table
|
||||
class Table extends TableHelper
|
||||
{
|
||||
/**
|
||||
* @brief Rows
|
||||
*/
|
||||
protected static $rows = null;
|
||||
protected static ?array $rows = null;
|
||||
|
||||
/**
|
||||
* @brief WHERE clause
|
||||
*/
|
||||
protected $where = array();
|
||||
protected array $where = array();
|
||||
|
||||
/**
|
||||
* @brief WHERE clause
|
||||
*/
|
||||
public $count = 0;
|
||||
public int $count = 0;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \IPS\Http\Url Base URL
|
||||
* @param Url|null $url Base URL
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( \IPS\Http\Url $url=NULL )
|
||||
public function __construct( Url $url=NULL )
|
||||
{
|
||||
/* Init */
|
||||
parent::__construct( $url );
|
||||
@@ -52,10 +63,10 @@ class _Table extends \IPS\Helpers\Table\Table
|
||||
/**
|
||||
* Get rows
|
||||
*
|
||||
* @param array $advancedSearchValues Values from the advanced search form
|
||||
* @param array|null $advancedSearchValues Values from the advanced search form
|
||||
* @return array
|
||||
*/
|
||||
public function getRows( $advancedSearchValues=NULL )
|
||||
public function getRows( array $advancedSearchValues=NULL ): array
|
||||
{
|
||||
if ( static::$rows === NULL )
|
||||
{
|
||||
@@ -63,28 +74,28 @@ class _Table extends \IPS\Helpers\Table\Table
|
||||
static::$rows = array();
|
||||
|
||||
/* What are we sorting by? */
|
||||
$sortDirection = ( mb_strtolower( $this->sortDirection ) == 'asc' ? 'asc' : 'desc' );
|
||||
$flags = \IPS\Session\Store::ONLINE_MEMBERS | \IPS\Session\Store::ONLINE_GUESTS;
|
||||
$sortDirection = ( ( $this->sortDirection and mb_strtolower( $this->sortDirection ) == 'asc' ) ? 'asc' : 'desc' );
|
||||
$flags = Store::ONLINE_MEMBERS | Store::ONLINE_GUESTS;
|
||||
$memberGroup = NULL;
|
||||
|
||||
if ( $this->filter == 'filter_loggedin' )
|
||||
{
|
||||
$flags = \IPS\Session\Store::ONLINE_MEMBERS;
|
||||
$flags = Store::ONLINE_MEMBERS;
|
||||
}
|
||||
elseif ( mb_stristr( $this->filter, 'group_' ) )
|
||||
elseif ( $this->filter and mb_stristr( $this->filter, 'group_' ) )
|
||||
{
|
||||
$memberGroup = \intval( $this->filters[ $this->filter ] );
|
||||
$memberGroup = intval( $this->filters[ $this->filter ] );
|
||||
}
|
||||
|
||||
$this->count = \IPS\Session\Store::i()->getOnlineUsers( $flags | \IPS\Session\Store::ONLINE_COUNT_ONLY, $sortDirection, NULL, $memberGroup, \IPS\Member::loggedIn()->isAdmin() );
|
||||
$this->count = Store::i()->getOnlineUsers( $flags | Store::ONLINE_COUNT_ONLY, $sortDirection, NULL, $memberGroup, Member::loggedIn()->isAdmin() );
|
||||
|
||||
/* If we're not filtering - update our most online count */
|
||||
if ( $this->filter === NULL )
|
||||
{
|
||||
$mostOnline = json_decode( \IPS\Settings::i()->most_online, TRUE );
|
||||
$mostOnline = json_decode( Settings::i()->most_online, TRUE );
|
||||
if ( $this->count > $mostOnline['count'] )
|
||||
{
|
||||
\IPS\Settings::i()->changeValues( array( 'most_online' => json_encode( array(
|
||||
Settings::i()->changeValues( array( 'most_online' => json_encode( array(
|
||||
'count' => $this->count,
|
||||
'time' => time()
|
||||
) ) ) );
|
||||
@@ -94,7 +105,7 @@ class _Table extends \IPS\Helpers\Table\Table
|
||||
$this->pages = ceil( $this->count / $this->limit );
|
||||
|
||||
/* Get results */
|
||||
$rows = \IPS\Session\Store::i()->getOnlineUsers( $flags, $sortDirection, array( ( $this->limit * ( $this->page - 1 ) ), $this->limit ), $memberGroup, \IPS\Member::loggedIn()->isAdmin() );
|
||||
$rows = Store::i()->getOnlineUsers( $flags, $sortDirection, array( ( $this->limit * ( $this->page - 1 ) ), $this->limit ), $memberGroup, Member::loggedIn()->isAdmin() );
|
||||
|
||||
/* Loop the data */
|
||||
foreach ( $rows as $rowId => $row )
|
||||
@@ -106,14 +117,14 @@ class _Table extends \IPS\Helpers\Table\Table
|
||||
$row = array();
|
||||
foreach ( $this->include as $k )
|
||||
{
|
||||
$row[ $k ] = isset( $_row[ $k ] ) ? $_row[ $k ] : NULL;
|
||||
$row[ $k ] = $_row[$k] ?? NULL;
|
||||
}
|
||||
|
||||
if( !empty( $advancedSearchValues ) AND !isset( \IPS\Request::i()->noColumn ) )
|
||||
if( !empty( $advancedSearchValues ) AND !isset( Request::i()->noColumn ) )
|
||||
{
|
||||
foreach ( $advancedSearchValues as $k => $v )
|
||||
{
|
||||
$row[ $k ] = isset( $_row[ $k ] ) ? $_row[ $k ] : NULL;
|
||||
$row[ $k ] = $_row[$k] ?? NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -132,7 +143,7 @@ class _Table extends \IPS\Helpers\Table\Table
|
||||
}
|
||||
|
||||
/* Are we including this one? */
|
||||
if( ( ( $this->include !== NULL and !\in_array( $k, $this->include ) ) or ( $this->exclude !== NULL and \in_array( $k, $this->exclude ) ) ) and !array_key_exists( $k, $advancedSearchValues ) )
|
||||
if( ( ( $this->include !== NULL and !in_array( $k, $this->include ) ) or ( $this->exclude !== NULL and in_array( $k, $this->exclude ) ) ) and !array_key_exists( $k, $advancedSearchValues ) )
|
||||
{
|
||||
unset( $row[ $k ] );
|
||||
continue;
|
||||
@@ -157,7 +168,7 @@ class _Table extends \IPS\Helpers\Table\Table
|
||||
* @param array|NULL $advancedSearchValues Advanced search values
|
||||
* @return array
|
||||
*/
|
||||
public function getHeaders( $advancedSearchValues )
|
||||
public function getHeaders( array $advancedSearchValues=NULL ): array
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user