Registry Mirror
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter
Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion apps/dav/lib/CalDAV/CalDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,9 @@ public function getCalendarsForUser($principalUri) {
->join('s', 'calendars', 'a', $select->expr()->eq('s.resourceid', 'a.id', IQueryBuilder::PARAM_INT))
->where($select->expr()->in('s.principaluri', $select->createNamedParameter($principals, IQueryBuilder::PARAM_STR_ARRAY), IQueryBuilder::PARAM_STR_ARRAY))
->andWhere($select->expr()->eq('s.type', $select->createNamedParameter('calendar', IQueryBuilder::PARAM_STR), IQueryBuilder::PARAM_STR))
->andWhere($select->expr()->notIn('a.id', $select->createFunction($subSelect->getSQL()), IQueryBuilder::PARAM_INT_ARRAY));
->andWhere($select->expr()->notIn('a.id', $select->createFunction($subSelect->getSQL()), IQueryBuilder::PARAM_INT_ARRAY))
// calendars in the owner's trash bin are not available to sharees
->andWhere($select->expr()->isNull('a.deleted_at'));

$results = $select->executeQuery();

Expand Down Expand Up @@ -531,6 +533,7 @@ public function getPublicCalendars() {
->join('s', 'calendars', 'a', $query->expr()->eq('s.resourceid', 'a.id'))
->where($query->expr()->in('s.access', $query->createNamedParameter(self::ACCESS_PUBLIC)))
->andWhere($query->expr()->eq('s.type', $query->createNamedParameter('calendar')))
->andWhere($query->expr()->isNull('a.deleted_at'))
->executeQuery();

while ($row = $result->fetchAssociative()) {
Expand Down Expand Up @@ -589,6 +592,7 @@ public function getPublicCalendar($uri) {
->where($query->expr()->in('s.access', $query->createNamedParameter(self::ACCESS_PUBLIC)))
->andWhere($query->expr()->eq('s.type', $query->createNamedParameter('calendar')))
->andWhere($query->expr()->eq('s.publicuri', $query->createNamedParameter($uri)))
->andWhere($query->expr()->isNull('a.deleted_at'))
->executeQuery();

$row = $result->fetchAssociative();
Expand Down Expand Up @@ -1562,6 +1566,10 @@ public function createCalendarObject($calendarId, $objectUri, $calendarData, $ca
// RFC 4791 no-uid-conflict (409) reporting the existing object's href.
throw UidConflict::forCalendar($existing['uri']);
}
// The URI may still belong to a trashed object, which is not served as a child of the calendar
if ($this->getCalendarObject($calendarId, $objectUri, $calendarType) !== null) {
throw new Forbidden("A calendar object with URI $objectUri already exists in calendar $calendarId");
}
// The UID may still belong to a trashed object; delete it and replace it with the new object.
$found = $this->findCalendarObjectByUid($calendarId, $extraData['uid'], $calendarType, true);
if ($found !== null) {
Expand Down Expand Up @@ -2820,6 +2828,7 @@ private function findDeletedCalendarObjectForPrincipal(int $id, string $principa
->join('co', 'calendars', 'c', $select->expr()->eq('c.id', 'co.calendarid', IQueryBuilder::PARAM_INT))
->andWhere($select->expr()->eq('co.id', $select->createNamedParameter($id, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT))
->andWhere($select->expr()->isNotNull('co.deleted_at'))
->andWhere($select->expr()->isNull('c.deleted_at'))
->orderBy('s.access', 'ASC');
$this->applySharedCalendarFilters($select, $principals, $principalUri);

Expand Down
8 changes: 6 additions & 2 deletions apps/dav/lib/CalDAV/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public function propPatch(PropPatch $propPatch) {
public function getChild($name) {
$obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name, $this->getCalendarType());

if (!$obj) {
if (!$obj || isset($obj[TrashbinPlugin::PROPERTY_DELETED_AT])) {
throw new NotFound('Calendar object not found');
}

Expand Down Expand Up @@ -330,7 +330,7 @@ public function getMultipleChildren(array $paths) {
#[\Override]
public function childExists($name) {
$obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name, $this->getCalendarType());
if (!$obj) {
if (!$obj || isset($obj[TrashbinPlugin::PROPERTY_DELETED_AT])) {
return false;
}
if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE && $this->isShared()) {
Expand Down Expand Up @@ -417,9 +417,13 @@ public function getChanges($syncToken, $syncLevel, $limit = null) {

/**
* @inheritDoc
* @throws Forbidden
*/
#[\Override]
public function restore(): void {
if ($this->isShared()) {
throw new Forbidden('Only the owner can restore a deleted calendar');
}
$this->caldavBackend->restoreCalendar((int)$this->calendarInfo['id']);
}

Expand Down
5 changes: 3 additions & 2 deletions apps/dav/lib/CalDAV/Federation/FederatedCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace OCA\DAV\CalDAV\Federation;

use OCA\DAV\CalDAV\CalDavBackend;
use OCA\DAV\CalDAV\Trashbin\Plugin as TrashbinPlugin;
use OCP\Constants;
use Sabre\CalDAV\ICalendar;
use Sabre\CalDAV\Plugin;
Expand Down Expand Up @@ -215,7 +216,7 @@ public function calendarQuery(array $filters): array {
public function getChild($name): INode {
$obj = $this->caldavBackend->getCalendarObject($this->federationInfo->getId(), $name, $this->getCalendarType());

if ($obj === null) {
if ($obj === null || isset($obj[TrashbinPlugin::PROPERTY_DELETED_AT])) {
throw new NotFound('Calendar object not found');
}

Expand Down Expand Up @@ -260,7 +261,7 @@ public function getMultipleChildren(array $paths): array {
#[\Override]
public function childExists($name): bool {
$obj = $this->caldavBackend->getCalendarObject($this->federationInfo->getId(), $name, $this->getCalendarType());
return $obj !== null;
return $obj !== null && !isset($obj[TrashbinPlugin::PROPERTY_DELETED_AT]);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion apps/dav/lib/CalDAV/PublicCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace OCA\DAV\CalDAV;

use OCA\DAV\CalDAV\Trashbin\Plugin as TrashbinPlugin;
use Sabre\DAV\Exception\NotFound;

class PublicCalendar extends Calendar {
Expand All @@ -19,7 +20,7 @@ class PublicCalendar extends Calendar {
public function getChild($name): PublicCalendarObject {
$obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name);

if (!$obj) {
if (!$obj || isset($obj[TrashbinPlugin::PROPERTY_DELETED_AT])) {
throw new NotFound('Calendar object not found');
}
if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE) {
Expand Down
6 changes: 5 additions & 1 deletion apps/dav/lib/CalDAV/Sharing/Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
use OCP\ICacheFactory;
use OCP\IGroupManager;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\Share\IManager as IShareManager;
use Psr\Log\LoggerInterface;

class Backend extends SharingBackend {
Expand All @@ -28,7 +30,9 @@ public function __construct(
private Service $service,
private FederationSharingService $federationSharingService,
private LoggerInterface $logger,
private IShareManager $shareManager,
private IUserSession $userSession,
) {
parent::__construct($this->userManager, $this->groupManager, $this->principalBackend, $this->remoteUserPrincipalBackend, $this->cacheFactory, $this->service, $this->federationSharingService, $this->logger);
parent::__construct($this->userManager, $this->groupManager, $this->principalBackend, $this->remoteUserPrincipalBackend, $this->cacheFactory, $this->service, $this->federationSharingService, $this->logger, $this->shareManager, $this->userSession);
}
}
4 changes: 4 additions & 0 deletions apps/dav/lib/CardDAV/CardDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ public function getAddressBooksForUser($principalUri) {
if ($row['principaluri'] === $principalUri) {
continue;
}
// system address books can not be shared, ignore rows stored before that was enforced
if ($row['principaluri'] === 'principals/system/system') {
continue;
}

$readOnly = (int)$row['access'] === Backend::ACCESS_READ;
if (isset($addressBooks[$row['id']])) {
Expand Down
6 changes: 5 additions & 1 deletion apps/dav/lib/CardDAV/Sharing/Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
use OCP\ICacheFactory;
use OCP\IGroupManager;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\Share\IManager as IShareManager;
use Psr\Log\LoggerInterface;

class Backend extends SharingBackend {
Expand All @@ -27,7 +29,9 @@ public function __construct(
private Service $service,
private FederationSharingService $federationSharingService,
private LoggerInterface $logger,
private IShareManager $shareManager,
private IUserSession $userSession,
) {
parent::__construct($this->userManager, $this->groupManager, $this->principalBackend, $this->remoteUserPrincipalBackend, $this->cacheFactory, $this->service, $this->federationSharingService, $this->logger);
parent::__construct($this->userManager, $this->groupManager, $this->principalBackend, $this->remoteUserPrincipalBackend, $this->cacheFactory, $this->service, $this->federationSharingService, $this->logger, $this->shareManager, $this->userSession);
}
}
Loading
Loading