diff options
author | Anna Larch <anna@nextcloud.com> | 2021-12-06 20:01:22 +0100 |
---|---|---|
committer | Anna Larch <anna@nextcloud.com> | 2022-03-16 12:48:50 +0100 |
commit | 0745fc50126e92406ec95265ef1ff5d4b5575d3e (patch) | |
tree | 452e44b917c0d242669ee93d58fc84d5210802e5 /apps/dav/lib/Command | |
parent | a626307da8e9a4e5124da1c35429892f745b2de9 (diff) | |
download | nextcloud-server-0745fc50126e92406ec95265ef1ff5d4b5575d3e.tar.gz nextcloud-server-0745fc50126e92406ec95265ef1ff5d4b5575d3e.zip |
Move calendar objects between calendars instead of deleting and recreating them
Signed-off-by: Anna Larch <anna@nextcloud.com>
Diffstat (limited to 'apps/dav/lib/Command')
-rw-r--r-- | apps/dav/lib/Command/DeleteCalendar.php | 12 | ||||
-rw-r--r-- | apps/dav/lib/Command/MoveCalendar.php | 12 |
2 files changed, 19 insertions, 5 deletions
diff --git a/apps/dav/lib/Command/DeleteCalendar.php b/apps/dav/lib/Command/DeleteCalendar.php index 42aa0e3278f..dd5f11c740f 100644 --- a/apps/dav/lib/Command/DeleteCalendar.php +++ b/apps/dav/lib/Command/DeleteCalendar.php @@ -30,6 +30,7 @@ use OCA\DAV\CalDAV\Calendar; use OCP\IConfig; use OCP\IL10N; use OCP\IUserManager; +use Psr\Log\LoggerInterface; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -49,6 +50,9 @@ class DeleteCalendar extends Command { /** @var IUserManager */ private $userManager; + /** @var LoggerInterface */ + private $logger; + /** * @param CalDavBackend $calDav * @param IConfig $config @@ -59,13 +63,15 @@ class DeleteCalendar extends Command { CalDavBackend $calDav, IConfig $config, IL10N $l10n, - IUserManager $userManager + IUserManager $userManager, + LoggerInterface $logger ) { parent::__construct(); $this->calDav = $calDav; $this->config = $config; $this->l10n = $l10n; $this->userManager = $userManager; + $this->logger = $logger; } protected function configure(): void { @@ -123,7 +129,9 @@ class DeleteCalendar extends Command { $this->calDav, $calendarInfo, $this->l10n, - $this->config); + $this->config, + $this->logger + ); $force = $input->getOption('force'); if ($force) { diff --git a/apps/dav/lib/Command/MoveCalendar.php b/apps/dav/lib/Command/MoveCalendar.php index e6cba3b3330..320fe8aeac6 100644 --- a/apps/dav/lib/Command/MoveCalendar.php +++ b/apps/dav/lib/Command/MoveCalendar.php @@ -33,6 +33,7 @@ use OCP\IGroupManager; use OCP\IL10N; use OCP\IUserManager; use OCP\Share\IManager as IShareManager; +use Psr\Log\LoggerInterface; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -63,6 +64,9 @@ class MoveCalendar extends Command { /** @var CalDavBackend */ private $calDav; + /** @var LoggerInterface */ + private $logger; + public const URI_USERS = 'principals/users/'; /** @@ -79,7 +83,8 @@ class MoveCalendar extends Command { IShareManager $shareManager, IConfig $config, IL10N $l10n, - CalDavBackend $calDav + CalDavBackend $calDav, + LoggerInterface $logger ) { parent::__construct(); $this->userManager = $userManager; @@ -88,6 +93,7 @@ class MoveCalendar extends Command { $this->config = $config; $this->l10n = $l10n; $this->calDav = $calDav; + $this->logger = $logger; } protected function configure() { @@ -218,7 +224,7 @@ class MoveCalendar extends Command { */ if ($this->shareManager->shareWithGroupMembersOnly() === true && 'groups' === $prefix && !$this->groupManager->isInGroup($userDestination, $userOrGroup)) { if ($force) { - $this->calDav->updateShares(new Calendar($this->calDav, $calendar, $this->l10n, $this->config), [], ['href' => 'principal:principals/groups/' . $userOrGroup]); + $this->calDav->updateShares(new Calendar($this->calDav, $calendar, $this->l10n, $this->config, $this->logger), [], ['href' => 'principal:principals/groups/' . $userOrGroup]); } else { throw new \InvalidArgumentException("User <$userDestination> is not part of the group <$userOrGroup> with whom the calendar <" . $calendar['uri'] . "> was shared. You may use -f to move the calendar while deleting this share."); } @@ -229,7 +235,7 @@ class MoveCalendar extends Command { */ if ($userOrGroup === $userDestination) { if ($force) { - $this->calDav->updateShares(new Calendar($this->calDav, $calendar, $this->l10n, $this->config), [], ['href' => 'principal:principals/users/' . $userOrGroup]); + $this->calDav->updateShares(new Calendar($this->calDav, $calendar, $this->l10n, $this->config, $this->logger), [], ['href' => 'principal:principals/users/' . $userOrGroup]); } else { throw new \InvalidArgumentException("The calendar <" . $calendar['uri'] . "> is already shared to user <$userDestination>.You may use -f to move the calendar while deleting this share."); } |