From f8a007bad4f4a555a5d533ea8c16a8bb4f30456a Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 22 Oct 2012 13:15:40 +0000 Subject: [PATCH] * Calendar/CalDAV/eSync: fixed exceptions get not deleted with series via CalDAV or eSync moved code from our UI to BO, to either delete exceptions (default) or keep them with a new UID --- calendar/inc/class.calendar_boupdate.inc.php | 27 +++++++++++++++++++- calendar/inc/class.calendar_uiforms.inc.php | 27 +++----------------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/calendar/inc/class.calendar_boupdate.inc.php b/calendar/inc/class.calendar_boupdate.inc.php index b10eca91f1..cff735572e 100644 --- a/calendar/inc/class.calendar_boupdate.inc.php +++ b/calendar/inc/class.calendar_boupdate.inc.php @@ -1410,9 +1410,13 @@ class calendar_boupdate extends calendar_bo * @param int $cal_id id of the event to delete * @param int $recur_date=0 if a single event from a series should be deleted, its date * @param boolean $ignore_acl=false true for no ACL check, default do ACL check + * @param boolean $skip_notification=false + * @param boolean $delete_exceptions=true true: delete, false: keep exceptions (with new UID) + * @param int &$exceptions_kept=null on return number of kept exceptions * @return boolean true on success, false on error (usually permission denied) */ - function delete($cal_id,$recur_date=0,$ignore_acl=false,$skip_notification=false) + function delete($cal_id, $recur_date=0, $ignore_acl=false, $skip_notification=false, + $delete_exceptions=true, &$exceptions_kept=null) { //error_log(__METHOD__."(cal_id=$cal_id, recur_date=$recur_date, ignore_acl=$ignore_acl, skip_notifications=$skip_notification)"); if (!($event = $this->read($cal_id,$recur_date)) || @@ -1454,6 +1458,27 @@ class calendar_boupdate extends calendar_bo } } $GLOBALS['egw']->contenthistory->updateTimeStamp('calendar', $cal_id, 'delete', $this->now); + + // delete or keep (with new uid) exceptions of a recurring event + if ($event['recur_type'] != MCAL_RECUR_NONE) + { + $exceptions_kept = 0; + foreach ($this->so->get_related($event['uid']) as $id) + { + if ($delete_exceptions) + { + $this->delete($id, 0, $ignore_acl, true); + } + else + { + if (!($exception = $this->read($id))) continue; + $exception['uid'] = common::generate_uid('calendar', $id); + $exception['reference'] = $exception['recurrence'] = 0; + $this->update($exception, true, true, false, true, $msg=null, true); + ++$exceptions_kept; + } + } + } } else // delete an exception { diff --git a/calendar/inc/class.calendar_uiforms.inc.php b/calendar/inc/class.calendar_uiforms.inc.php index e30be95294..76e35a0c49 100644 --- a/calendar/inc/class.calendar_uiforms.inc.php +++ b/calendar/inc/class.calendar_uiforms.inc.php @@ -858,34 +858,13 @@ class calendar_uiforms extends calendar_ui case 'delete': // delete of regular event case 'delete_keep_exceptions': // series and user selected to keep the exceptions case 'delete_exceptions': // series and user selected to delete the exceptions too - if ($this->bo->delete($event['id'],(int)$content['edit_single'])) + if ($this->bo->delete($event['id'], (int)$content['edit_single'], false, false, + $button == 'delete_exceptions', $exceptions_kept)) { if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single']) { $msg = lang('Series deleted'); - $delete_exceptions = $button == 'delete_exceptions'; - $exceptions_kept = false; - // Handle the exceptions - $recur_exceptions = $this->bo->so->get_related($event['uid']); - foreach ($recur_exceptions as $id) - { - if ($delete_exceptions) - { - $this->bo->delete($id); - } - else - { - if (!($exception = $this->bo->read($id))) continue; - $exception['uid'] = common::generate_uid('calendar', $id); - $exception['reference'] = $exception['recurrence'] = 0; - $this->bo->update($exception, true,true,false,true,$msg=null,$content['no_notifications']); - $exceptions_kept = true; - } - } - if ($exceptions_kept) - { - $msg .= lang(', exceptions preserved'); - } + if ($exceptions_kept) $msg .= lang(', exceptions preserved'); } else {