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

+26 -15
View File
@@ -11,23 +11,34 @@
namespace IPS\core\tasks;
/* 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\Login;
use IPS\Member;
use IPS\Task;
use UnderflowException;
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;
}
/**
* Profile-sync Task
*/
class _profilesync extends \IPS\Task
class profilesync extends Task
{
/**
* Execute
*
* @return void
* @return mixed
*/
public function execute()
public function execute() : mixed
{
/* Do we have any login methods that even support syncing enabled? */
if( !$this->canSync() )
@@ -38,7 +49,7 @@ class _profilesync extends \IPS\Task
$where = array( array( "temp_ban=?", 0 ), array( "profilesync_lastsync > ?", 0 ) );
/* Only check accounts that have visited in the last 6 months */
$where[] = array( "GREATEST(last_activity, last_visit) > ?", \IPS\DateTime::create()->sub( new \DateInterval('P6M') )->getTimestamp() );
$where[] = array( "GREATEST(last_activity, last_visit) > ?", DateTime::create()->sub( new DateInterval('P6M') )->getTimestamp() );
/* And only check accounts that are actually synchronizing, UNLESS the admin is also forcing synchronization for any login methods */
if( !$this->hasForcedSync() )
@@ -47,7 +58,7 @@ class _profilesync extends \IPS\Task
}
$totalToSync = \IPS\Db::i()->select( 'count(*)', 'core_members', $where )->first();
$totalToSync = Db::i()->select( 'count(*)', 'core_members', $where )->first();
if( !$totalToSync )
{
@@ -67,14 +78,14 @@ class _profilesync extends \IPS\Task
{
try
{
$member = \IPS\Db::i()->select( '*', 'core_members', $where, 'profilesync_lastsync ASC', 1 )->first();
$member = Db::i()->select( '*', 'core_members', $where, 'profilesync_lastsync ASC', 1 )->first();
}
catch ( \UnderflowException $e )
catch ( UnderflowException $e )
{
return FALSE;
}
$member = \IPS\Member::constructFromData( $member );
$member = Member::constructFromData( $member );
$member->profileSync();
return TRUE;
@@ -88,9 +99,9 @@ class _profilesync extends \IPS\Task
*
* @return bool
*/
protected function canSync()
protected function canSync() : bool
{
foreach ( \IPS\Login::methods() as $method )
foreach ( Login::methods() as $method )
{
if( $method->hasSyncOptions() )
{
@@ -106,11 +117,11 @@ class _profilesync extends \IPS\Task
*
* @return bool
*/
protected function hasForcedSync()
protected function hasForcedSync() : bool
{
foreach ( \IPS\Login::methods() as $method )
foreach ( Login::methods() as $method )
{
if( \count( $method->forceSync() ) )
if( count( $method->forceSync() ) )
{
return TRUE;
}