diff options
Diffstat (limited to 'apps/dav/lib/CalDAV/Calendar.php')
-rw-r--r-- | apps/dav/lib/CalDAV/Calendar.php | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/apps/dav/lib/CalDAV/Calendar.php b/apps/dav/lib/CalDAV/Calendar.php index fa29fc8d588..75c815c3b0a 100644 --- a/apps/dav/lib/CalDAV/Calendar.php +++ b/apps/dav/lib/CalDAV/Calendar.php @@ -33,11 +33,15 @@ use DateTimeInterface; use OCA\DAV\CalDAV\Trashbin\Plugin as TrashbinPlugin; use OCA\DAV\DAV\Sharing\IShareable; use OCA\DAV\Exception\UnsupportedLimitOnInitialSyncException; +use OCP\DB\Exception; use OCP\IConfig; use OCP\IL10N; +use Psr\Log\LoggerInterface; use Sabre\CalDAV\Backend\BackendInterface; use Sabre\DAV\Exception\Forbidden; use Sabre\DAV\Exception\NotFound; +use Sabre\DAV\IMoveTarget; +use Sabre\DAV\INode; use Sabre\DAV\PropPatch; /** @@ -46,7 +50,7 @@ use Sabre\DAV\PropPatch; * @package OCA\DAV\CalDAV * @property CalDavBackend $caldavBackend */ -class Calendar extends \Sabre\CalDAV\Calendar implements IRestorable, IShareable { +class Calendar extends \Sabre\CalDAV\Calendar implements IRestorable, IShareable, IMoveTarget { /** @var IConfig */ private $config; @@ -57,6 +61,9 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IRestorable, IShareable /** @var bool */ private $useTrashbin = true; + /** @var LoggerInterface */ + private $logger; + /** * Calendar constructor. * @@ -65,7 +72,7 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IRestorable, IShareable * @param IL10N $l10n * @param IConfig $config */ - public function __construct(BackendInterface $caldavBackend, $calendarInfo, IL10N $l10n, IConfig $config) { + public function __construct(BackendInterface $caldavBackend, $calendarInfo, IL10N $l10n, IConfig $config, LoggerInterface $logger) { // Convert deletion date to ISO8601 string if (isset($calendarInfo[TrashbinPlugin::PROPERTY_DELETED_AT])) { $calendarInfo[TrashbinPlugin::PROPERTY_DELETED_AT] = (new DateTimeImmutable()) @@ -85,6 +92,7 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IRestorable, IShareable $this->config = $config; $this->l10n = $l10n; + $this->logger = $logger; } /** @@ -415,6 +423,9 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IRestorable, IShareable return parent::getChanges($syncToken, $syncLevel, $limit); } + /** + * @inheritDoc + */ public function restore(): void { $this->caldavBackend->restoreCalendar((int) $this->calendarInfo['id']); } @@ -422,4 +433,20 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IRestorable, IShareable public function disableTrashbin(): void { $this->useTrashbin = false; } + + /** + * @inheritDoc + */ + public function moveInto($targetName, $sourcePath, INode $sourceNode) { + if (!($sourceNode instanceof CalendarObject)) { + return false; + } + + try { + return $this->caldavBackend->moveCalendarObject($sourceNode->getCalendarId(), (int)$this->calendarInfo['id'], $sourceNode->getId(), $sourceNode->getPrincipalUri()); + } catch (Exception $e) { + $this->logger->error('Could not move calendar object: ' . $e->getMessage(), ['exception' => $e]); + return false; + } + } } |