Index

Access

MMO\edms\helpers · 1 symbol · generated 5 Oct 2026

class

Access

Access.php:33

Who can do what with a file or a label: the one place edms answers it, for its routes and for its listings.

class MMO\edms\helpers\Access
Namespace
MMO\edms\helpers
See
SHARE (put it in labels), and on a label CREATE (put files in it, make labels under it). A scope without an action is every action.
The rights are mmo.oauth scopes, held by the client (or its roles), keyed by id so a rename changes nothing: - `edms.files.{id}-{ctime}` a file ([`File::scopeID`](https://mcp.mmoframework.fr/documentation/mmo.edms/php/entities/File.md#file-scopeid): its creation time too, as a repository can give the id of a file deleted to a new one), `edms.labels.{id}` a label and every label under it, `edms.files`/`edms.labels` all of them, `edms` everything; - an action narrows it: `edms.labels.12#show`. The actions are [`SHOW`](https://mcp.mmoframework.fr/documentation/mmo.edms/php/helpers/Access.md#access-show), [`EDIT`](https://mcp.mmoframework.fr/documentation/mmo.edms/php/helpers/Access.md#access-edit), [`DELETE`](https://mcp.mmoframework.fr/documentation/mmo.edms/php/helpers/Access.md#access-delete), on a file A client can do anything with the files it owns and the labels of its own space ([`Label::$owner`](https://mcp.mmoframework.fr/documentation/mmo.edms/php/entities/Label.md#label-owner)). With another's file, the most precise scope set decides, that is, in order: 1. the file's own (`edms.files.{id}-{ctime}`): it can refuse what a label gives; 2. its labels': any label granting the action is enough -- a label, or the closest of its parents holding a scope. A folder shared is every file in it. A label refusing it, and none granting it, refuses it. The owner of a label sees the files put in it, and nothing more; 3. the global ones: `edms.files` for any file, `edms.labels` for any file carrying a label. Putting a file in labels is sharing it: the owner does, or a client granted [`SHARE`](https://mcp.mmoframework.fr/documentation/mmo.edms/php/helpers/Access.md#access-share) on it ([`canShare`](https://mcp.mmoframework.fr/documentation/mmo.edms/php/helpers/Access.md#access-canshare)) -- never one who can only edit it, who would give it to the labels of its own space.
$user->allow($label->scopeID('show')); // $user sees every file carrying $label, or one of its children $access->can($user, Access::SHOW, $file); // true

Index

CREATE
DELETE
EDIT
SHARE
SHOW
can($client, $action, $file)
canLabel($client, $action, $label)
canShare($client, $file)
decide($client, $scopes, $action, $label, $forFile)What decides $action on $label for $client: its owner, or the closest scope set, on it or on one of its parents
explicit($scopes, $uid, $action)
filter($client, $labels, $action)A filter of the files $client can see, for a query to paginate itself: it can hold some $client cannot (a file refusing it, while one of its labels grants it) -- can decides for each.
granted($scopes, $prefix, $action)The ids $scopes grant under $prefix: {prefix}.{id} or {prefix}.{id}#{action} set to true
loopTree($labels, $roots)$roots and every label under them, each once
visibleLabels($client, $labels, $action)The labels $client can see: its own, those granted to it, and their children

Constants5

CREATE

const CREATE = 'create'

DELETE

const DELETE = 'delete'

EDIT

const EDIT = 'edit'

SHARE

const SHARE = 'share'

SHOW

const SHOW = 'show'

Methods9

can($client, $action, $file)

Access.php:41
function can( ?MMO\oauth\interfaces\iClient $client, string $action, MMO\edms\entities\File $file ): bool
$clientnull | iClient
$actionstring
$fileFile
returnsbooltrue if $client can do $action with $file

canLabel($client, $action, $label)

Access.php:70
function canLabel( ?MMO\oauth\interfaces\iClient $client, string $action, MMO\edms\entities\Label $label ): bool
$clientnull | iClient
$actionstring
$labelLabel
returnsbooltrue if $client can do $action with $label

canShare($client, $file)

Access.php:64
function canShare(?MMO\oauth\interfaces\iClient $client, MMO\edms\entities\File $file): bool
$clientnull | iClient
$fileFile
returnsbooltrue if $client can put $file in labels: its owner, or a client granted it (edms.files.{id}-{ctime}#share, edms.files#share...) -- a label's scope never gives it

decide($client, $scopes, $action, $label, $forFile)

Access.php:138

What decides $action on $label for $client: its owner, or the closest scope set, on it or on one of its parents

protected function decide( MMO\oauth\interfaces\iClient $client, array $scopes, string $action, MMO\edms\entities\Label $label, bool $forFile = false ): ?bool
$clientiClient
$scopesarray
$actionstring
$labelLabel
$forFile = falsebooltrue when it is for a file carrying $label: the owner of a label only sees the files in it
returnsnull | boolnull if nothing does

explicit($scopes, $uid, $action)

Access.php:153
protected function explicit(array $scopes, string $uid, string $action): ?bool
$scopesarray
$uidstring
$actionstring
returnsnull | boolthe scope set for $uid itself, with the action or without: null if neither is

filter($client, $labels, $action)

Access.php:82

A filter of the files $client can see, for a query to paginate itself: it can hold some $client cannot (a file refusing it, while one of its labels grants it) -- can decides for each.

function filter( MMO\oauth\interfaces\iClient $client, MMO\core\interfaces\iCollection $labels, string $action = self::SHOW ): ?array
$clientiClient
$labelsiCollectionthe labels' collection
$action = self::SHOWstring
returnsnull | arraymixed> null when $client can see every file

granted($scopes, $prefix, $action)

Access.php:162

The ids $scopes grant under $prefix: {prefix}.{id} or {prefix}.{id}#{action} set to true

protected function granted(array $scopes, string $prefix, string $action): Generator
$scopesarray
$prefixstring
$actionstring
returnsGenerator

loopTree($labels, $roots)

Access.php:174

$roots and every label under them, each once

protected function loopTree(MMO\core\interfaces\iCollection $labels, iterable $roots): Generator
$labelsiCollection
$rootsiterable
returnsGenerator

visibleLabels($client, $labels, $action)

Access.php:112

The labels $client can see: its own, those granted to it, and their children

function visibleLabels( MMO\oauth\interfaces\iClient $client, MMO\core\interfaces\iCollection $labels, string $action = self::SHOW ): array
$clientiClient
$labelsiCollection
$action = self::SHOWstring
returnsarray