|
|
|
@ -1429,37 +1429,40 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription |
|
|
|
/** |
|
|
|
* Moves a calendar object from calendar to calendar. |
|
|
|
* |
|
|
|
* @param int $sourceCalendarId |
|
|
|
* @param string $sourcePrincipalUri |
|
|
|
* @param int $sourceObjectId |
|
|
|
* @param string $targetPrincipalUri |
|
|
|
* @param int $targetCalendarId |
|
|
|
* @param int $objectId |
|
|
|
* @param string $oldPrincipalUri |
|
|
|
* @param string $newPrincipalUri |
|
|
|
* @param string $tragetObjectUri |
|
|
|
* @param int $calendarType |
|
|
|
* @return bool |
|
|
|
* @throws Exception |
|
|
|
*/ |
|
|
|
public function moveCalendarObject(int $sourceCalendarId, int $targetCalendarId, int $objectId, string $oldPrincipalUri, string $newPrincipalUri, int $calendarType = self::CALENDAR_TYPE_CALENDAR): bool { |
|
|
|
public function moveCalendarObject(string $sourcePrincipalUri, int $sourceObjectId, string $targetPrincipalUri, int $targetCalendarId, string $tragetObjectUri, int $calendarType = self::CALENDAR_TYPE_CALENDAR): bool { |
|
|
|
$this->cachedObjects = []; |
|
|
|
return $this->atomic(function () use ($sourceCalendarId, $targetCalendarId, $objectId, $oldPrincipalUri, $newPrincipalUri, $calendarType) { |
|
|
|
$object = $this->getCalendarObjectById($oldPrincipalUri, $objectId); |
|
|
|
return $this->atomic(function () use ($sourcePrincipalUri, $sourceObjectId, $targetPrincipalUri, $targetCalendarId, $tragetObjectUri, $calendarType) { |
|
|
|
$object = $this->getCalendarObjectById($sourcePrincipalUri, $sourceObjectId); |
|
|
|
if (empty($object)) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
$sourceCalendarId = $object['calendarid']; |
|
|
|
$sourceObjectUri = $object['uri']; |
|
|
|
|
|
|
|
$query = $this->db->getQueryBuilder(); |
|
|
|
$query->update('calendarobjects') |
|
|
|
->set('calendarid', $query->createNamedParameter($targetCalendarId, IQueryBuilder::PARAM_INT)) |
|
|
|
->where($query->expr()->eq('id', $query->createNamedParameter($objectId, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT)) |
|
|
|
->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter($calendarType, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT)) |
|
|
|
->set('uri', $query->createNamedParameter($tragetObjectUri, IQueryBuilder::PARAM_STR)) |
|
|
|
->where($query->expr()->eq('id', $query->createNamedParameter($sourceObjectId, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT)) |
|
|
|
->executeStatement(); |
|
|
|
|
|
|
|
$this->purgeProperties($sourceCalendarId, $objectId); |
|
|
|
$this->updateProperties($targetCalendarId, $object['uri'], $object['calendardata'], $calendarType); |
|
|
|
$this->purgeProperties($sourceCalendarId, $sourceObjectId); |
|
|
|
$this->updateProperties($targetCalendarId, $tragetObjectUri, $object['calendardata'], $calendarType); |
|
|
|
|
|
|
|
$this->addChanges($sourceCalendarId, [$object['uri']], 3, $calendarType); |
|
|
|
$this->addChanges($targetCalendarId, [$object['uri']], 1, $calendarType); |
|
|
|
$this->addChanges($sourceCalendarId, [$sourceObjectUri], 3, $calendarType); |
|
|
|
$this->addChanges($targetCalendarId, [$tragetObjectUri], 1, $calendarType); |
|
|
|
|
|
|
|
$object = $this->getCalendarObjectById($newPrincipalUri, $objectId); |
|
|
|
$object = $this->getCalendarObjectById($targetPrincipalUri, $sourceObjectId); |
|
|
|
// Calendar Object wasn't found - possibly because it was deleted in the meantime by a different client
|
|
|
|
if (empty($object)) { |
|
|
|
return false; |
|
|
|
|