* 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
This commit is contained in:
Ralf Becker 2012-10-22 13:15:58 +00:00
parent 61966de428
commit 122230b88e
2 changed files with 29 additions and 25 deletions

View File

@ -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
{

View File

@ -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
{