Skip to content

Commit 3388090

Browse files
author
tchapi
committed
chore
1 parent 0cae15d commit 3388090

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

src/Controller/Admin/CalendarController.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,17 @@ public function calendarDelete(ManagerRegistry $doctrine, int $userId, string $i
252252
$entityManager->remove($subscription);
253253
}
254254

255+
// Scheduling objects attached to the principal
255256
$schedulingObjects = $doctrine->getRepository(SchedulingObject::class)->findByPrincipalUri($instance->getPrincipalUri());
256257
foreach ($schedulingObjects ?? [] as $object) {
257258
$entityManager->remove($object);
258259
}
259-
260+
261+
// Scheduling objects attached to the calendar objects of the calendar
262+
$schedulingObjectsOfCalendarObjects = $doctrine->getRepository(CalendarInstance::class)->findAllSchedulingObjectsForCalendar($instance->getId());
263+
foreach ($schedulingObjectsOfCalendarObjects ?? [] as $object) {
264+
$entityManager->remove($object);
265+
}
260266
foreach ($instance->getCalendar()->getObjects() ?? [] as $object) {
261267
$entityManager->remove($object);
262268
}

src/Plugins/PublicAwareDAVACLPlugin.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ public function getAcl($node): array
4848
$acl = parent::getAcl($node);
4949

5050
if ($this->public_calendars_enabled) {
51+
// We have nothing to handle here, but SchedulingObject extends Calendar so we bail out early
52+
if ($node instanceof \Sabre\CalDAV\SchedulingObject) {
53+
return $acl;
54+
}
5155
// Handle both Calendar AND SharedCalendar (which extends Calendar)
5256
if ($node instanceof \Sabre\CalDAV\Calendar || $node instanceof \Sabre\CalDAV\CalendarObject) {
5357
// The property is private in \Sabre\CalDAV\CalendarObject and we don't want to create

src/Repository/CalendarInstanceRepository.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,19 @@ public function hasDifferentOwner(int $calendarId, string $principalUri): bool
7474
->getSingleScalarResult() > 0;
7575
}
7676

77+
public function findAllSchedulingObjectsForCalendar(int $calendarId): array
78+
{
79+
$objectRepository = $this->getEntityManager()->getRepository(\App\Entity\SchedulingObject::class);
80+
81+
return $objectRepository->createQueryBuilder('s')
82+
->leftJoin(CalendarObject::class, 'c', \Doctrine\ORM\Query\Expr\Join::WITH, 'c.uri = s.uri')
83+
->where('c.calendarid = :id')
84+
->andWhere('s.principaluri = :principalUri')
85+
->setParameter('id', $calendarId)
86+
->getQuery()
87+
->getResult();
88+
}
89+
7790
/**
7891
* Get counts of calendar objects by component type for a calendar instance.
7992
*

0 commit comments

Comments
 (0)