* 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:20:33 +00:00
parent 7a3b2e7180
commit d7b0414a49
2 changed files with 29 additions and 25 deletions

View File

@ -1336,9 +1336,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)
{
if (!($event = $this->read($cal_id,$recur_date)) ||
!$ignore_acl && !$this->check_perms(EGW_ACL_DELETE,$event))
@ -1379,6 +1383,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

@ -621,34 +621,13 @@ class calendar_uiforms extends calendar_ui
break;
case 'delete':
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 ($content['reference'] == 0 && !$content['edit_single'])
{
$msg = lang('Series deleted');
$delete_exceptions = false;
$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);
$exceptions_kept = true;
}
}
if ($exceptions_kept)
{
$msg .= lang(', exceptions preserved');
}
if ($exceptions_kept) $msg .= lang(', exceptions preserved');
}
else
{