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,16 +12,28 @@
namespace IPS\calendar\setup\upg_105013;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use DateInterval;
use DatePeriod;
use InvalidArgumentException;
use IPS\calendar\Date;
use IPS\calendar\Icalendar\ICSParser;
use IPS\core\Setup\Upgrade as UpgradeClass;
use IPS\Db;
use IPS\Request;
use function defined;
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;
}
/**
* 4.5.0 Beta 1 Upgrade Code
*/
class _Upgrade
class Upgrade
{
/**
* Set the event recurring end date/time for recurring events that end
@@ -32,12 +44,12 @@ class _Upgrade
{
$perCycle = 100;
$did = 0;
$limit = \intval( \IPS\Request::i()->extra );
$limit = intval( Request::i()->extra );
/* Try to prevent timeouts to the extent possible */
$cutOff = \IPS\core\Setup\Upgrade::determineCutoff();
$cutOff = UpgradeClass::determineCutoff();
foreach( \IPS\Db::i()->select( '*', 'calendar_events', array( 'event_recurring IS NOT NULL' ), 'event_id ASC', array( $limit, $perCycle ) ) as $event )
foreach( Db::i()->select( '*', 'calendar_events', array( 'event_recurring IS NOT NULL' ), 'event_id ASC', array( $limit, $perCycle ) ) as $event )
{
if( $cutOff !== null AND time() >= $cutOff )
{
@@ -48,9 +60,9 @@ class _Upgrade
try
{
$recurrenceRule = \IPS\calendar\Icalendar\ICSParser::parseRrule( $event['event_recurring'], 'UTC' );
$recurrenceRule = ICSParser::parseRrule( $event['event_recurring'], 'UTC' );
}
catch( \InvalidArgumentException $e )
catch( InvalidArgumentException $e )
{
continue;
}
@@ -84,7 +96,7 @@ class _Upgrade
break;
}
$period = new \DatePeriod( \IPS\calendar\Date::parseTime( $event['event_start_date'], $event['event_all_day'] ? FALSE : TRUE ), new \DateInterval( 'P' . $recurrenceRule['event_repeat_freq'] . mb_strtoupper( mb_substr( $keyword, 0, 1 ) ) ), $recurrenceRule['repeat_end_occurrences'] );
$period = new DatePeriod( Date::parseTime( $event['event_start_date'], $event['event_all_day'] ? FALSE : TRUE ), new DateInterval( 'P' . $recurrenceRule['event_repeat_freq'] . mb_strtoupper( mb_substr( $keyword, 0, 1 ) ) ), $recurrenceRule['repeat_end_occurrences'] );
foreach( $period as $dateOccurrence )
{
@@ -94,7 +106,7 @@ class _Upgrade
if( $endDate !== NULL )
{
\IPS\Db::i()->update( 'calendar_events', array( 'event_recurring_end_date' => $endDate ), array( 'event_id=?', $event['event_id'] ) );
Db::i()->update( 'calendar_events', array( 'event_recurring_end_date' => $endDate ), array( 'event_id=?', $event['event_id'] ) );
}
}
@@ -116,11 +128,11 @@ class _Upgrade
*/
public function step1CustomTitle()
{
$limit = isset( \IPS\Request::i()->extra ) ? \IPS\Request::i()->extra : 0;
$limit = isset( Request::i()->extra ) ? Request::i()->extra : 0;
if( !isset( $_SESSION['_step1Count'] ) )
{
$_SESSION['_step1Count'] = \IPS\Db::i()->select( 'COUNT(*)', 'calendar_events', array( 'event_recurring IS NOT NULL' ) )->first();
$_SESSION['_step1Count'] = Db::i()->select( 'COUNT(*)', 'calendar_events', array( 'event_recurring IS NOT NULL' ) )->first();
}
return "Upgrading recurring calendar events (Upgraded so far: " . ( ( $limit > $_SESSION['_step1Count'] ) ? $_SESSION['_step1Count'] : $limit ) . ' out of ' . $_SESSION['_step1Count'] . ')';