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,26 +12,37 @@
namespace IPS\nexus\extensions\core\Queue;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Db;
use IPS\Extensions\QueueAbstract;
use IPS\Member;
use IPS\nexus\Package;
use IPS\Patterns\ActiveRecordIterator;
use OutOfRangeException;
use function count;
use function defined;
use const IPS\REBUILD_SLOW;
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;
}
/**
* Background Task
*/
class _MassChangePurchases
class MassChangePurchases extends QueueAbstract
{
/**
* Parse data before queuing
*
* @param array $data
* @return array
* @return array|null
*/
public function preQueueData( $data )
public function preQueueData( array $data ): ?array
{
$data['count'] = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_app=? AND ps_type=? AND ps_item_id=?', 'nexus', 'package', $data['id'] ) )->first();
$data['count'] = Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_app=? AND ps_type=? AND ps_item_id=?', 'nexus', 'package', $data['id'] ) )->first();
return $data;
}
@@ -44,30 +55,30 @@ class _MassChangePurchases
* @return int New offset
* @throws \IPS\Task\Queue\OutOfRangeException Indicates offset doesn't exist and thus task is complete
*/
public function run( $data, $offset )
public function run( array &$data, int $offset ): int
{
try
{
$package = \IPS\nexus\Package::load( $data['id'] );
$package = Package::load( $data['id'] );
}
catch( \OutOfRangeException $e )
catch( OutOfRangeException )
{
throw new \IPS\Task\Queue\OutOfRangeException;
}
$admin = \IPS\Member::load( $data['admin'] );
$admin = Member::load( $data['admin'] );
if ( $data['cancel_type'] == 'change' )
{
$newPackage = \IPS\nexus\Package::load( $data['mass_change_purchases_to'] );
$newPackage = Package::load( $data['mass_change_purchases_to'] );
}
$query = \IPS\Db::i()->select( '*', 'nexus_purchases', array( 'ps_app=? AND ps_type=? AND ps_item_id=?', 'nexus', 'package', $data['id'] ), 'ps_id ASC', ( $data['cancel_type'] == 'change' ) ? NULL : array( $offset, \IPS\REBUILD_SLOW ) );
if ( !\count( $query ) )
$query = Db::i()->select( '*', 'nexus_purchases', array( 'ps_app=? AND ps_type=? AND ps_item_id=?', 'nexus', 'package', $data['id'] ), 'ps_id ASC', ( $data['cancel_type'] == 'change' ) ? NULL : array( $offset, REBUILD_SLOW ) );
if ( !count( $query ) )
{
throw new \IPS\Task\Queue\OutOfRangeException;
}
foreach ( new \IPS\Patterns\ActiveRecordIterator( $query, 'IPS\nexus\Purchase' ) as $purchase )
foreach ( new ActiveRecordIterator( $query, 'IPS\nexus\Purchase' ) as $purchase )
{
if ( $data['cancel_type'] == 'change' )
{
@@ -107,7 +118,7 @@ class _MassChangePurchases
}
}
return $offset + \IPS\REBUILD_SLOW;
return $offset + REBUILD_SLOW;
}
/**
@@ -116,11 +127,11 @@ class _MassChangePurchases
* @param mixed $data Data as it was passed to \IPS\Task::queue()
* @param int $offset Offset
* @return array( 'text' => 'Doing something...', 'complete' => 50 ) Text explaining task and percentage complete
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
* @throws OutOfRangeException Indicates offset doesn't exist and thus task is complete
*/
public function getProgress( $data, $offset )
public function getProgress( mixed $data, int $offset ): array
{
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack( 'mass_change_purchases_in_progress_text', FALSE, array( 'sprintf' => \IPS\nexus\Package::load( $data['id'] )->_title ) ), 'complete' => floor( 100 / $data['count'] * $offset ) );
return array( 'text' => Member::loggedIn()->language()->addToStack( 'mass_change_purchases_in_progress_text', FALSE, array( 'sprintf' => Package::load( $data['id'] )->_title ) ), 'complete' => floor( 100 / $data['count'] * $offset ) );
}
/**
@@ -130,7 +141,7 @@ class _MassChangePurchases
* @param bool $processed Was anything processed or not? If preQueueData returns NULL, this will be FALSE.
* @return void
*/
public function postComplete( $data, $processed = TRUE )
public function postComplete( array $data, bool $processed = TRUE ) : void
{
}