mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
fix: do not ignore move command object target uri
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
This commit is contained in:
parent
85d2ee5262
commit
1a90998edc
2 changed files with 24 additions and 16 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -391,9 +391,14 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IRestorable, IShareable
|
|||
if (!($sourceNode instanceof CalendarObject)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
return $this->caldavBackend->moveCalendarObject($sourceNode->getCalendarId(), (int)$this->calendarInfo['id'], $sourceNode->getId(), $sourceNode->getOwner(), $this->getOwner());
|
||||
return $this->caldavBackend->moveCalendarObject(
|
||||
$sourceNode->getOwner(),
|
||||
$sourceNode->getId(),
|
||||
$this->getOwner(),
|
||||
$this->getResourceId(),
|
||||
$targetName,
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
$this->logger->error('Could not move calendar object: ' . $e->getMessage(), ['exception' => $e]);
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Reference in a new issue