From 24b869d61a422344b4503253bdc5953147935b69 Mon Sep 17 00:00:00 2001 From: nathangray Date: Mon, 22 Oct 2018 09:25:28 -0600 Subject: [PATCH] * Calendar - Add checkbox to turn on or off emptying calendar before iCal import --- .../inc/class.calendar_import_ical.inc.php | 23 +++++++++++-------- .../class.calendar_wizard_import_ical.inc.php | 2 +- .../default/import.ical_conditions.xet | 10 +++++--- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/calendar/inc/class.calendar_import_ical.inc.php b/calendar/inc/class.calendar_import_ical.inc.php index 610cf730c7..43ce8bd359 100644 --- a/calendar/inc/class.calendar_import_ical.inc.php +++ b/calendar/inc/class.calendar_import_ical.inc.php @@ -144,18 +144,21 @@ class calendar_import_ical implements importexport_iface_import_plugin { $owner = $plugin_options['cal_owner']; // Purge - $remove_past = new Api\DateTime(); - $remove_future = new Api\DateTime(); - $plugin_options = array_merge(array('remove_past' => 100, 'remove_future' => 365), $plugin_options); - foreach(array('remove_past','remove_future') as $date) + if($plugin_options['empty_before_import']) { - ${$date}->add( (($date == 'remove_past' ? -1 : 1) * (int)$plugin_options[$date]) . ' days'); + $remove_past = new Api\DateTime(); + $remove_future = new Api\DateTime(); + $plugin_options = array_merge(array('remove_past' => 100, 'remove_future' => 365), $plugin_options); + foreach(array('remove_past','remove_future') as $date) + { + ${$date}->add( (($date == 'remove_past' ? -1 : 1) * (int)$plugin_options[$date]) . ' days'); + } + $this->purge_calendar( + $owner, + array('from' => $remove_past, 'to' => $remove_future), + $plugin_options['no_notification'] + ); } - $this->purge_calendar( - $owner, - array('from' => $remove_past, 'to' => $remove_future), - $plugin_options['no_notification'] - ); // User wants conflicting events to not be imported if($_definition->plugin_options['skip_conflicts']) diff --git a/calendar/inc/class.calendar_wizard_import_ical.inc.php b/calendar/inc/class.calendar_wizard_import_ical.inc.php index 2dfc3cdaff..3e2ad89c56 100644 --- a/calendar/inc/class.calendar_wizard_import_ical.inc.php +++ b/calendar/inc/class.calendar_wizard_import_ical.inc.php @@ -70,7 +70,7 @@ class calendar_wizard_import_ical { $content['text'] = $this->steps['wizard_step55']; $content['step'] = 'wizard_step55'; - foreach(array('skip_conflicts','remove_past','remove_future') as $field) + foreach(array('skip_conflicts','empty_before_import','remove_past','remove_future') as $field) { if(!$content[$field] && array_key_exists($field, $content['plugin_options'])) { diff --git a/calendar/templates/default/import.ical_conditions.xet b/calendar/templates/default/import.ical_conditions.xet index 79b27d9d61..8b9ca63a29 100644 --- a/calendar/templates/default/import.ical_conditions.xet +++ b/calendar/templates/default/import.ical_conditions.xet @@ -9,9 +9,13 @@ - - - + + + + + + + #importexport-wizardbox_delete_title {