Nextcloud PHP API (master)

ShareReviewAccessCheckEvent extends Event
in package

Authorization gate for deleting an app-managed share through a share-review app.

Background: Apps such as Deck or Tables manage their own shares outside of the regular sharing backend (IManager). They can expose those shares to a share-review app — a compliance tool that lets designated operators audit and revoke shares across all apps — by implementing IShareReviewSource. When a share-review operator requests the deletion of such a share, the deletion is executed by the app that owns the share, not by the share-review app. The owning app has no way of knowing whether the acting user is actually authorized to perform share reviews — only the share-review app knows that. This event closes that gap: it lets the owning app ask "may the current user delete this share on behalf of a share review?" before deleting anything.

Dispatched by: the app that owns the share, i.e. the IShareReviewSource implementation, at the beginning of its deleteShare() method:

public function deleteShare(string $shareId): bool { $event = new ShareReviewAccessCheckEvent('MyApp', $shareId); $this->dispatcher->dispatchTyped($event); if (!$event->isHandled() || !$event->isGranted()) { return false; // default-deny: no listener means no access } // ... actually delete the share ... }

Listened to by: the share-review app. Its listener decides whether the current user is an authorized share-review operator (e.g. the app is enabled for the user) and answers with grantAccess() or denyAccess():

public function handle(Event $event): void { if (!$event instanceof ShareReviewAccessCheckEvent) { return; } if ($this->isShareReviewOperator()) { $event->grantAccess(); } else { $event->denyAccess('User is not a share-review operator.'); } }

Apps that merely expose shares must not listen to this event; answering it is the responsibility of the share-review app that triggered the deletion.

Semantics:

  • Default-deny: if no listener responds (isHandled() is false, e.g. no share-review app is installed), the dispatcher must not delete the share.
  • Deny wins: once denyAccess() is called, further grantAccess() calls are ignored and propagation is stopped immediately.
  • Multiple grants are harmless; the last listener to deny is authoritative.
Tags
since
34.0.2
Attributes
#[Consumable]
$since: '34.0.2'

Table of Contents

Properties

$granted  : bool
$handled  : bool
$reason  : string|null
$shareId  : string
$sourceName  : string

Methods

__construct()  : mixed
Compatibility constructor
denyAccess()  : void
Deny access and provide a human-readable reason.
getReason()  : string|null
Human-readable denial reason, or null if access was granted or the event has not been handled yet.
getShareId()  : string
App-internal identifier of the share being deleted.
getSourceName()  : string
Stable, non-translated identifier of the app that owns this share source.
grantAccess()  : void
Grant access to delete the share.
isGranted()  : bool
Whether access was granted.
isHandled()  : bool
Whether any listener has responded to this event.
isPropagationStopped()  : bool
{@inheritDoc}
stopPropagation()  : void
Stops the propagation of the event to further event listeners

Properties

Methods

__construct()

Compatibility constructor

public __construct(string $sourceName, string $shareId) : mixed
Parameters
$sourceName : string

Stable, non-translated identifier for the app registering the share source (e.g. 'Deck', 'Tables').

$shareId : string

App-internal identifier of the share being deleted.

Tags
since
34.0.2

denyAccess()

Deny access and provide a human-readable reason.

public denyAccess(string $reason) : void

Stops event propagation immediately — no further listeners will run.

Parameters
$reason : string
Tags
since
34.0.2

getReason()

Human-readable denial reason, or null if access was granted or the event has not been handled yet.

public getReason() : string|null
Tags
since
34.0.2
Return values
string|null

getShareId()

App-internal identifier of the share being deleted.

public getShareId() : string
Tags
since
34.0.2
Return values
string

getSourceName()

Stable, non-translated identifier of the app that owns this share source.

public getSourceName() : string
Tags
since
34.0.2
Return values
string

grantAccess()

Grant access to delete the share.

public grantAccess() : void

Has no effect if denyAccess() was already called on this event — deny wins.

Tags
since
34.0.2

isHandled()

Whether any listener has responded to this event.

public isHandled() : bool
Tags
since
34.0.2
Return values
bool

isPropagationStopped()

{@inheritDoc}

public isPropagationStopped() : bool
Tags
since
22.0.0
see
StoppableEventInterface
Attributes
#[Override]
Return values
bool

stopPropagation()

Stops the propagation of the event to further event listeners

public stopPropagation() : void
Tags
since
22.0.0
On this page

Search results