Version 5.0.14
This commit is contained in:
1 parent
5efe744c5f
commit
dbd774b30c
364 files changed
+7048
-1377
No files matched your search
@@ -1446,6 +1446,7 @@ class Event extends Item implements Embeddable,
|
||||
'event_repeat_freq' => NULL, /* Repeat every 1 day, 2 days, 3 days, etc. */
|
||||
'repeat_end_occurrences' => NULL, /* Ends after x occurrences */
|
||||
'repeat_end_date' => NULL, /* Ends on x date (which is separate from the event end date - e.g. jan 9 2014 3pm to jan 10 2014 3pm, repeat annually until jan 9 2019) */
|
||||
'allow_recurring' => ( !$container->calendar_bitoptions['bw_disable_recurring'] )
|
||||
);
|
||||
|
||||
/* If we're copying an event, reset the date & time fields */
|
||||
@@ -1463,7 +1464,7 @@ class Event extends Item implements Embeddable,
|
||||
}
|
||||
|
||||
/* Figure out the recurrence data if we are editing */
|
||||
if ( $item AND $item->recurring )
|
||||
if ( $item AND $item->recurring AND $dateValues['allow_recurring'] )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1768,6 +1769,13 @@ class Event extends Item implements Embeddable,
|
||||
$this->start_date = Date::createFromForm( $values['event_dates']['start_date'], ( ( !isset( $values['event_dates']['all_day'] ) OR !$values['event_dates']['all_day'] ) ? $values['event_dates']['start_time'] : '' ), ( isset( $values['event_dates']['all_day'] ) AND $values['event_dates']['all_day'] ) ? 'UTC' : $values['event_dates']['event_timezone'] )->format( 'Y-m-d H:i' );
|
||||
$this->end_date = null;
|
||||
|
||||
/* If the calendar does not allow recurring events, force the settings */
|
||||
if( $this->container()->calendar_bitoptions['bw_disable_recurring'] )
|
||||
{
|
||||
$values['event_dates']['repeat_end'] = 'never';
|
||||
$values['event_dates']['event_repeat'] = 0;
|
||||
}
|
||||
|
||||
/* Clear clear fields for non-selected items */
|
||||
switch( $values['event_dates']['repeat_end'] )
|
||||
{
|
||||
@@ -2279,57 +2287,61 @@ class Event extends Item implements Embeddable,
|
||||
$formattedEvents = iterator_to_array( $events );
|
||||
}
|
||||
|
||||
/* Now get the recurring events.... */
|
||||
$recurringEvents = Event::getItemsWithPermission( array_merge( $where, array( array( "event_recurring IS NOT NULL AND (event_recurring_end_date IS NULL OR DATE(event_recurring_end_date) >= '{$startDate->mysqlDatetime( FALSE )}')" ) ) ), 'event_start_date ASC', NULL, ( $skipPermissions === TRUE ) ? NULL : 'view', ( $skipPermissions === TRUE ) ? Filter::FILTER_SHOW_HIDDEN : Filter::FILTER_AUTOMATIC, 0, $member, FALSE, FALSE, FALSE,FALSE, NULL, FALSE, TRUE, TRUE, TRUE, FALSE, $location );
|
||||
|
||||
/* Loop over any results */
|
||||
foreach( $recurringEvents as $event )
|
||||
/* Now get the recurring events....
|
||||
If we only have one calendar, and it does not allow recurring events, we can skip this extra query */
|
||||
if( !( $calendar instanceof Calendar ) or !$calendar->calendar_bitoptions['bw_disable_recurring'] )
|
||||
{
|
||||
/* @var Event $event */
|
||||
/* Find occurrences within our date range (if any) */
|
||||
$thisEndDate = ( $endDate ? $endDate->setTime( 23, 59, 59 ) : $startDate->adjust( "+2 years" ) )->setTime( 23, 59, 59 );
|
||||
$thisEndDate = ( clone $thisEndDate )->adjust( "+1 day" );
|
||||
$occurrences = $event->findOccurrences( $startDate, $thisEndDate );
|
||||
$recurringEvents = Event::getItemsWithPermission( array_merge( $where, array( array( "event_recurring IS NOT NULL AND (event_recurring_end_date IS NULL OR DATE(event_recurring_end_date) >= '{$startDate->mysqlDatetime( FALSE )}')" ) ) ), 'event_start_date ASC', NULL, ( $skipPermissions === TRUE ) ? NULL : 'view', ( $skipPermissions === TRUE ) ? Filter::FILTER_SHOW_HIDDEN : Filter::FILTER_AUTOMATIC, 0, $member, FALSE, FALSE, FALSE,FALSE, NULL, FALSE, TRUE, TRUE, TRUE, FALSE, $location );
|
||||
|
||||
/* Do we have any? */
|
||||
if ( count( $occurrences ) )
|
||||
/* Loop over any results */
|
||||
foreach( $recurringEvents as $event )
|
||||
{
|
||||
/* Are we formatting events? If so, place into the array as appropriate. */
|
||||
if ( $formatEvents )
|
||||
/* @var Event $event */
|
||||
/* Find occurrences within our date range (if any) */
|
||||
$thisEndDate = ( $endDate ? $endDate->setTime( 23, 59, 59 ) : $startDate->adjust( "+2 years" ) )->setTime( 23, 59, 59 );
|
||||
$thisEndDate = ( clone $thisEndDate )->adjust( "+1 day" );
|
||||
$occurrences = $event->findOccurrences( $startDate, $thisEndDate );
|
||||
|
||||
/* Do we have any? */
|
||||
if ( count( $occurrences ) )
|
||||
{
|
||||
foreach( $occurrences as $occurrence )
|
||||
/* Are we formatting events? If so, place into the array as appropriate. */
|
||||
if ( $formatEvents )
|
||||
{
|
||||
/* Is this a ranged repeating event? */
|
||||
if ( $occurrence['endDate'] !== NULL )
|
||||
foreach( $occurrences as $occurrence )
|
||||
{
|
||||
$date = $occurrence['startDate'];
|
||||
$eDate = ( $thisEndDate->mysqlDatetime( FALSE ) < $occurrence['endDate']->mysqlDatetime( FALSE ) ) ? $thisEndDate : $occurrence['endDate'];
|
||||
|
||||
if ( $date->mysqlDatetime( FALSE ) < $eDate->mysqlDatetime( FALSE ) )
|
||||
/* Is this a ranged repeating event? */
|
||||
if ( $occurrence['endDate'] !== NULL )
|
||||
{
|
||||
while( $date->mysqlDatetime( FALSE ) < $eDate->mysqlDatetime( FALSE ) )
|
||||
{
|
||||
$formattedEvents[ $date->mysqlDatetime( FALSE ) ]['ranged'][ $event->id ] = $event;
|
||||
$date = $date->adjust( '+1 day' );
|
||||
}
|
||||
$date = $occurrence['startDate'];
|
||||
$eDate = ( $thisEndDate->mysqlDatetime( FALSE ) < $occurrence['endDate']->mysqlDatetime( FALSE ) ) ? $thisEndDate : $occurrence['endDate'];
|
||||
|
||||
$formattedEvents[ $eDate->mysqlDatetime( FALSE ) ]['ranged'][ $event->id ] = $event;
|
||||
if ( $date->mysqlDatetime( FALSE ) < $eDate->mysqlDatetime( FALSE ) )
|
||||
{
|
||||
while( $date->mysqlDatetime( FALSE ) < $eDate->mysqlDatetime( FALSE ) )
|
||||
{
|
||||
$formattedEvents[ $date->mysqlDatetime( FALSE ) ]['ranged'][ $event->id ] = $event;
|
||||
$date = $date->adjust( '+1 day' );
|
||||
}
|
||||
|
||||
$formattedEvents[ $eDate->mysqlDatetime( FALSE ) ]['ranged'][ $event->id ] = $event;
|
||||
}
|
||||
else
|
||||
{
|
||||
$formattedEvents[ $date->mysqlDatetime( FALSE ) ]['single'][ $event->id ] = $event;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$formattedEvents[ $date->mysqlDatetime( FALSE ) ]['single'][ $event->id ] = $event;
|
||||
$formattedEvents[ $occurrence['startDate']->mysqlDatetime( FALSE ) ]['single'][ $event->id ] = $event;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$formattedEvents[ $occurrence['startDate']->mysqlDatetime( FALSE ) ]['single'][ $event->id ] = $event;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Otherwise we only want one instance of the event in our final array */
|
||||
else
|
||||
{
|
||||
$formattedEvents[] = $event;
|
||||
/* Otherwise we only want one instance of the event in our final array */
|
||||
else
|
||||
{
|
||||
$formattedEvents[] = $event;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user