Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

@@ -12,25 +12,36 @@
namespace IPS\nexus\extensions\core\Dashboard;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use DateInterval;
use IPS\DateTime;
use IPS\Db;
use IPS\Extensions\DashboardAbstract;
use IPS\Helpers\Chart;
use IPS\Member;
use IPS\nexus\Money;
use IPS\nexus\Transaction;
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;
}
/**
* Dashboard extension: Income
*/
class _Income
class Income extends DashboardAbstract
{
/**
* Can the current user view this dashboard item?
*
* @return bool
*/
public function canView()
public function canView(): bool
{
return \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus' , 'transactions', 'transactions_manage' );
return Member::loggedIn()->hasAcpRestriction( 'nexus' , 'transactions', 'transactions_manage' );
}
/**
@@ -38,20 +49,20 @@ class _Income
*
* @return string
*/
public function getBlock()
public function getBlock(): string
{
$chart = new \IPS\Helpers\Chart;
$chart = new Chart;
$chart->addHeader( "Day", 'date' );
foreach ( \IPS\nexus\Money::currencies() as $currency )
foreach ( Money::currencies() as $currency )
{
$chart->addHeader( $currency, 'number' );
}
$thirtyDaysAgo = \IPS\DateTime::create()->sub( new \DateInterval('P30D') );
$thirtyDaysAgo = DateTime::create()->sub( new DateInterval('P30D') );
$results = array();
foreach( \IPS\Db::i()->select( "t_currency, DATE_FORMAT( FROM_UNIXTIME( t_date ), '%e %c %Y' ) AS date, SUM(t_amount)-SUM(t_partial_refund) AS amount", 'nexus_transactions', array( 't_date>? AND (t_status=? OR t_status=?) AND t_method>0', $thirtyDaysAgo->getTimestamp(), \IPS\nexus\Transaction::STATUS_PAID, \IPS\nexus\Transaction::STATUS_PART_REFUNDED ), NULL, NULL, array( 't_currency', 'date' ) ) as $result )
foreach( Db::i()->select( "t_currency, DATE_FORMAT( FROM_UNIXTIME( t_date ), '%e %c %Y' ) AS date, SUM(t_amount)-SUM(t_partial_refund) AS amount", 'nexus_transactions', array( 't_date>? AND (t_status=? OR t_status=?) AND t_method>0', $thirtyDaysAgo->getTimestamp(), Transaction::STATUS_PAID, Transaction::STATUS_PART_REFUNDED ), NULL, NULL, array( 't_currency', 'date' ) ) as $result )
{
$results[ $result['date'] ][ $result['t_currency'] ] = $result['amount'];
}
@@ -59,16 +70,16 @@ class _Income
$monthAndYear = date( 'n' ) . ' ' . date( 'Y' );
foreach ( range( 30, 0 ) as $daysAgo )
{
$datetime = new \IPS\DateTime;
$datetime->setTime( 0, 0, 0 );
$datetime->sub( new \DateInterval( 'P' . $daysAgo . 'D' ) );
$datetime = new DateTime;
$datetime->setTime( 0, 0 );
$datetime->sub( new DateInterval( 'P' . $daysAgo . 'D' ) );
$resultString = $datetime->format('j n Y');
if ( isset( $results[ $resultString ] ) )
{
$row = array( $datetime );
foreach ( \IPS\nexus\Money::currencies() as $currency )
foreach ( Money::currencies() as $currency )
{
if ( !isset( $results[ $resultString ][ $currency ] ) )
{
@@ -85,7 +96,7 @@ class _Income
else
{
$row = array( $datetime );
foreach ( \IPS\nexus\Money::currencies() as $currency )
foreach ( Money::currencies() as $currency )
{
$row[] = 0;
}
@@ -101,24 +112,4 @@ class _Income
'areaOpacity' => 0.4,
) );
}
/**
* Return the block information
*
* @return array array( 'name' => 'Block title', 'key' => 'unique_key', 'size' => [1,2,3], 'by' => 'Author name' )
*/
public function getInfo()
{
return array();
}
/**
* Save the block data submitted. This method is only necessary if your block accepts some sort of submitted data to save (such as the 'admin notes' block).
*
* @return void
* @throws \LogicException
*/
public function saveBlock()
{
}
}
@@ -12,31 +12,40 @@
namespace IPS\nexus\extensions\core\Dashboard;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Db;
use IPS\Extensions\DashboardAbstract;
use IPS\Member;
use IPS\nexus\Payout;
use IPS\nexus\Transaction;
use IPS\Output;
use IPS\Settings;
use IPS\Theme;
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;
}
/**
* @brief Dashboard extension: PendingActions
*/
class _PendingActions
class PendingActions extends DashboardAbstract
{
/**
* Can the current user view this dashboard item?
*
* @return bool
*/
public function canView()
public function canView(): bool
{
return ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'transactions_manage' )
return ( Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'transactions_manage' )
or
\IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'shiporders_manage' )
Member::loggedIn()->hasAcpRestriction( 'core', 'promotion', 'advertisements_manage' )
or
\IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'promotion', 'advertisements_manage' )
or
\IPS\Settings::i()->nexus_payout and \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'payouts_manage' ) );
Settings::i()->nexus_payout and Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'payouts_manage' ) );
}
/**
@@ -44,36 +53,25 @@ class _PendingActions
*
* @return string
*/
public function getBlock()
public function getBlock(): string
{
/* 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 ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'transactions_manage' ) )
if ( Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'transactions_manage' ) )
{
$pendingTransactions = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_transactions', array( \IPS\Db::i()->in( 't_status', array( \IPS\nexus\Transaction::STATUS_HELD, \IPS\nexus\Transaction::STATUS_WAITING, \IPS\nexus\Transaction::STATUS_REVIEW, \IPS\nexus\Transaction::STATUS_DISPUTED ) ) ) )->first();
if ( !$pendingTransactions and !\IPS\Db::i()->select( 'COUNT(*)', 'nexus_fraud_rules' )->first() )
$pendingTransactions = Db::i()->select( 'COUNT(*)', 'nexus_transactions', array( Db::i()->in( 't_status', array( Transaction::STATUS_HELD, Transaction::STATUS_WAITING, Transaction::STATUS_REVIEW, Transaction::STATUS_DISPUTED ) ) ) )->first();
if ( !$pendingTransactions and !Db::i()->select( 'COUNT(*)', 'nexus_fraud_rules' )->first() )
{
$pendingTransactions = NULL;
}
}
/* Same with shipments */
$pendingShipments = NULL;
if ( \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 ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'promotion', 'advertisements_manage' ) )
if ( 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;
}
@@ -81,41 +79,13 @@ class _PendingActions
/* Withdrawals will only be if enabled */
$pendingWithdrawals = NULL;
if ( \IPS\Settings::i()->nexus_payout and \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'payouts_manage' ) )
if ( 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();
$pendingWithdrawals = Db::i()->select( 'COUNT(*)', 'nexus_payouts', array( 'po_status=?', Payout::STATUS_PENDING ) )->first();
}
/* Show support if there are departments we can see */
$openSupportRequests = NULL;
if ( \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() );
}
Output::i()->cssFiles = array_merge( Output::i()->cssFiles, Theme::i()->css( 'widgets.css', 'nexus', 'front' ) );
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'widgets.css', 'nexus', 'front' ) );
return \IPS\Theme::i()->getTemplate( 'dashboard', 'nexus' )->pendingActions( $pendingTransactions, $pendingShipments, $pendingWithdrawals, $openSupportRequests, $pendingAdvertisements );
}
/**
* Return the block information
*
* @return array array( 'name' => 'Block title', 'key' => 'unique_key', 'size' => [1,2,3], 'by' => 'Author name' )
*/
public function getInfo()
{
return array();
}
/**
* Save the block data submitted. This method is only necessary if your block accepts some sort of submitted data to save (such as the 'admin notes' block).
*
* @return void
* @throws \LogicException
*/
public function saveBlock()
{
return Theme::i()->getTemplate( 'dashboard', 'nexus' )->pendingActions( $pendingTransactions, $pendingWithdrawals, $pendingAdvertisements );
}
}