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

@@ -11,16 +11,26 @@
namespace IPS\core\tasks;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use Exception;
use IPS\Db;
use IPS\Email;
use IPS\Lang;
use IPS\Task;
use OutOfRangeException;
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;
}
/**
* postBeforeRegisterFollowup Task
*/
class _postBeforeRegisterFollowup extends \IPS\Task
class postBeforeRegisterFollowup extends Task
{
/**
* Execute
@@ -31,21 +41,21 @@ class _postBeforeRegisterFollowup extends \IPS\Task
* Tasks should execute within the time of a normal HTTP request.
*
* @return mixed Message to log or NULL
* @throws \IPS\Task\Exception
* @throws Task\Exception
*/
public function execute()
public function execute() : mixed
{
$this->runUntilTimeout( function()
{
/* Get the email */
try
{
$userData = \IPS\Db::i()->select( array( 'email', 'language', 'secret' ), 'core_post_before_registering', array( "`member` IS NULL and followup IS NULL and timestamp<" . ( time() - ( 86400 * 2 ) ) ), 'timestamp ASC', 1 )->first();
$userData = Db::i()->select( array( 'email', 'language', 'secret' ), 'core_post_before_registering', array( "`member` IS NULL and followup IS NULL and timestamp<" . ( time() - ( 86400 * 2 ) ) ), 'timestamp ASC', 1 )->first();
}
catch ( \UnderflowException $e )
catch ( UnderflowException $e )
{
/* Disable the task if there is nothing at all left to process */
if( \IPS\Db::i()->select( 'COUNT(*)', 'core_post_before_registering', array( "`member` IS NULL") )->first() === 0 )
if( Db::i()->select( 'COUNT(*)', 'core_post_before_registering', array( "`member` IS NULL") )->first() === 0 )
{
$this->enabled = FALSE;
$this->save();
@@ -56,7 +66,7 @@ class _postBeforeRegisterFollowup extends \IPS\Task
/* Get the associated content */
$content = array();
foreach ( \IPS\Db::i()->select( array( 'class', 'id' ), 'core_post_before_registering', array( 'email=?', $userData['email'] ) ) as $contentRow )
foreach ( Db::i()->select( array( 'class', 'id' ), 'core_post_before_registering', array( 'email=?', $userData['email'] ) ) as $contentRow )
{
$class = $contentRow['class'];
try
@@ -64,14 +74,14 @@ class _postBeforeRegisterFollowup extends \IPS\Task
/* Remove any data if the content class doesn't exist any more */
if ( !class_exists( $class ) )
{
throw new \OutOfRangeException;
throw new OutOfRangeException;
}
$content[] = $class::load( $contentRow['id'] );
}
catch ( \OutOfRangeException $e )
catch ( OutOfRangeException $e )
{
\IPS\Db::i()->delete( 'core_post_before_registering', array( 'class=? AND id=?', $contentRow['class'], $contentRow['id'] ) );
Db::i()->delete( 'core_post_before_registering', array( 'class=? AND id=?', $contentRow['class'], $contentRow['id'] ) );
}
}
if ( !$content )
@@ -82,23 +92,25 @@ class _postBeforeRegisterFollowup extends \IPS\Task
/* Build the email */
try
{
$language = \IPS\Lang::load( $userData['language'] );
$language = Lang::load( $userData['language'] );
}
catch ( \Exception $e )
catch ( Exception $e )
{
$language = \IPS\Lang::load( \IPS\Lang::defaultLanguage() );
$language = Lang::load( Lang::defaultLanguage() );
}
$email = \IPS\Email::buildFromTemplate( 'core', 'postBeforeRegisterFollowup', array( $content, $userData['secret'] ), \IPS\Email::TYPE_BULK );
$email = Email::buildFromTemplate( 'core', 'postBeforeRegisterFollowup', array( $content, $userData['secret'] ), Email::TYPE_BULK );
$email->language = $language;
$email->setUnsubscribe( 'core', 'unsubscribeNotNeeded' );
$email->send( $userData['email'] );
/* Update the row */
\IPS\Db::i()->update( 'core_post_before_registering', array( 'followup' => time() ), array( 'email=?', $userData['email'] ) );
Db::i()->update( 'core_post_before_registering', array( 'followup' => time() ), array( 'email=?', $userData['email'] ) );
/* Return */
return TRUE;
} );
return null;
}
/**