mirror of
https://github.com/nextcloud/server.git
synced 2026-11-30 20:18:46 +01:00
Published properties such as calendar availability and the default calendar URL were looked up in oc_properties by path only. Rows that another user stored under the same path, which the legacy webdav endpoint does because its paths are relative to the user's home, were returned as well, together with any other property on that path. Only rows stored by the node's owner, and only the published property names, are read now, as UserStatusAutomation and TimezoneService already do. CalendarProvider merged every property a user stored for their view of a calendar over the backend's calendar info, so stored values for computed properties such as read-only or owner-principal overrode the real ones for IManager consumers like calendar import and upcoming events. Only per-user display properties are taken from oc_properties now. Group memberships and calendar delegations of a principal are only served to the principal itself. Clients only need them for the current user; other principals answer 403 for these properties. Not included: prefixing legacy webdav property paths on write, which needs a repair step for existing rows, and rejecting computed property names in propPatch(), which the provider now ignores. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Grigory Vodyanov <scratchx@gmx.com>
67 lines
1.7 KiB
PHP
67 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
namespace OCA\DAV\Db;
|
|
|
|
use OCP\AppFramework\Db\QBMapper;
|
|
use OCP\DB\QueryBuilder\IQueryBuilder;
|
|
use OCP\IDBConnection;
|
|
|
|
/**
|
|
* @template-extends QBMapper<Property>
|
|
*/
|
|
class PropertyMapper extends QBMapper {
|
|
|
|
private const TABLE_NAME = 'properties';
|
|
|
|
public function __construct(IDBConnection $db) {
|
|
parent::__construct($db, self::TABLE_NAME, Property::class);
|
|
}
|
|
|
|
/**
|
|
* @return Property[]
|
|
*/
|
|
public function findPropertyByPathAndName(string $userId, string $path, string $name): array {
|
|
$selectQb = $this->db->getQueryBuilder();
|
|
$selectQb->select('*')
|
|
->from(self::TABLE_NAME)
|
|
->where(
|
|
$selectQb->expr()->eq('userid', $selectQb->createNamedParameter($userId)),
|
|
$selectQb->expr()->eq('propertypath', $selectQb->createNamedParameter($path)),
|
|
$selectQb->expr()->eq('propertyname', $selectQb->createNamedParameter($name)),
|
|
);
|
|
return $this->findEntities($selectQb);
|
|
}
|
|
|
|
/**
|
|
* @param array<string, string[]> $calendars
|
|
* @return Property[]
|
|
* @throws \OCP\DB\Exception
|
|
*/
|
|
public function findPropertiesByPathsAndUsers(array $calendars): array {
|
|
if (empty($calendars)) {
|
|
return [];
|
|
}
|
|
$selectQb = $this->db->getQueryBuilder();
|
|
$selectQb->select('*')
|
|
->from(self::TABLE_NAME);
|
|
|
|
foreach ($calendars as $user => $paths) {
|
|
$selectQb->orWhere(
|
|
$selectQb->expr()->andX(
|
|
$selectQb->expr()->eq('userid', $selectQb->createNamedParameter($user)),
|
|
$selectQb->expr()->in('propertypath', $selectQb->createNamedParameter($paths, IQueryBuilder::PARAM_STR_ARRAY)),
|
|
)
|
|
);
|
|
}
|
|
|
|
return $this->findEntities($selectQb);
|
|
}
|
|
}
|