Skip to content

Commit

Permalink
fix(calendar): Allow to get the permissions of a dedicated user
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Dec 9, 2024
1 parent 6f3ee6b commit be795ab
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion apps/dav/lib/CalDAV/CachedSubscriptionImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function search(string $pattern, array $searchProperties = [], array $opt
* @return int build up using \OCP\Constants
* @since 13.0.0
*/
public function getPermissions(): int {
public function getPermissions(?string $principal = null): int {
$permissions = $this->calendar->getACL();
$result = 0;
foreach ($permissions as $permission) {
Expand Down
8 changes: 6 additions & 2 deletions apps/dav/lib/CalDAV/CalendarImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,14 @@ public function search(string $pattern, array $searchProperties = [], array $opt
* @return int build up using \OCP\Constants
* @since 13.0.0
*/
public function getPermissions(): int {
public function getPermissions(?string $principal = null): int {
$permissions = $this->calendar->getACL();
$result = 0;
foreach ($permissions as $permission) {
if ($principal !== null && $principal !== $permission['principal']) {
continue;
}

switch ($permission['privilege']) {
case '{DAV:}read':
$result |= Constants::PERMISSION_READ;
Expand All @@ -133,7 +137,7 @@ public function getPermissions(): int {
public function isWritable(): bool {
return $this->calendar->canWrite();
}

/**
* @since 26.0.0
*/
Expand Down
6 changes: 4 additions & 2 deletions lib/public/Calendar/ICalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ public function getDisplayColor(): ?string;
public function search(string $pattern, array $searchProperties = [], array $options = [], ?int $limit = null, ?int $offset = null): array;

/**
* @return int build up using \OCP\Constants
* @param ?string $principal To only get the permissions of a dedicated principal
* @return int build up using {@see \OCP\Constants}
* @since 13.0.0
* @since 31.0.0 Parameter $principal was added to get the permissions of a dedicated principal
*/
public function getPermissions(): int;
public function getPermissions(?string $principal = null): int;

/**
* Indicates whether the calendar is in the trash bin
Expand Down

0 comments on commit be795ab

Please sign in to comment.