class ZoneTemplateAccessPolicy (View source)

What the acting user may do with zone templates: which template a zone may be created from, who owns a template, which record types may be stored in one, and how far the linked-zone listings reach.

Methods

__construct(ZoneTemplateRepositoryInterface $repository, PermissionService $permissionService, ActorInterface $actor)

No description

bool
currentUserHasPermission(string $permission)

Check if the logged-in user has the given permission (admins always pass)

string
currentUserEditPermissionLevel()

The logged-in user's edit level: "all", "own", "own_as_client" or "none".

bool
canStoreTemplateRecordType(string $type)

Confirm the current user may store this record type in a zone template.

int
resolveTemplateOwner(bool $requestedGlobal, int $userid)

Resolve the owner column for a template. A global template (owner 0) is reserved for ueberusers; anyone else owns the template personally.

int|null
resolveEditedTemplateOwner(int $zone_templ_id, bool $requestedGlobal, int $userid)

Owner column to write when a template is edited, or null to keep the stored one.

int|null
linkedZoneOwnerFilter(int $userid)

Owner the zone listings are narrowed to: null when the user may edit every zone, otherwise the user themselves.

bool
canUseTemplate(mixed $zone_templ_id, int $userid, bool $isAdmin)

Whether a posted template id may be applied to a zone.

bool
canViewTemplate(int $zone_templ_id, int $userid, bool $isAdmin)

Whether the user may see a template and create zones from it: a global template, their own, one shared with a group they belong to, or any template for an administrator. A missing template is never visible.

bool
canCurrentUserViewTemplate(int $zone_templ_id)

canViewTemplate() for the logged-in user.

bool
canCurrentUserUseTemplate(mixed $zone_templ_id)

canUseTemplate() for the logged-in user.

bool
isUserOwnerOfTemplate(int $zone_templ_id, int $userid)

Check if the user is the owner of the zone template

bool
canCurrentUserEditTemplate(int $owner, bool $sharedWithUser = false)

Whether the logged-in user may edit a template and its records: a ueberuser, or a holder of zone_templ_edit who owns it or shares it through a group.

bool
canCurrentUserManageTemplate(int $owner)

Whether the logged-in user may delete a template or change who it is shared with: a ueberuser, or the owner holding zone_templ_edit. Group members may not.

bool
canCurrentUserEditTemplateById(int $zone_templ_id)

canCurrentUserEditTemplate() for a stored template; false when it does not exist.

bool
canCurrentUserManageTemplateById(int $zone_templ_id)

canCurrentUserManageTemplate() for a stored template; false when it does not exist.

Details

__construct(ZoneTemplateRepositoryInterface $repository, PermissionService $permissionService, ActorInterface $actor)

No description

Parameters

ZoneTemplateRepositoryInterface $repository
PermissionService $permissionService
ActorInterface $actor

bool currentUserHasPermission(string $permission)

Check if the logged-in user has the given permission (admins always pass)

Parameters

string $permission

Return Value

bool

string currentUserEditPermissionLevel()

The logged-in user's edit level: "all", "own", "own_as_client" or "none".

Return Value

string

bool canStoreTemplateRecordType(string $type)

Confirm the current user may store this record type in a zone template.

Parameters

string $type

Return Value

bool

int resolveTemplateOwner(bool $requestedGlobal, int $userid)

Resolve the owner column for a template. A global template (owner 0) is reserved for ueberusers; anyone else owns the template personally.

Parameters

bool $requestedGlobal
int $userid

Return Value

int

0 for a permitted global template, otherwise the user id

int|null resolveEditedTemplateOwner(int $zone_templ_id, bool $requestedGlobal, int $userid)

Owner column to write when a template is edited, or null to keep the stored one.

Only a ueberuser changes it, by making the template global or by taking a global template back as their own; a group member never becomes the owner.

Parameters

int $zone_templ_id
bool $requestedGlobal
int $userid

Return Value

int|null

int|null linkedZoneOwnerFilter(int $userid)

Owner the zone listings are narrowed to: null when the user may edit every zone, otherwise the user themselves.

Parameters

int $userid

Return Value

int|null

bool canUseTemplate(mixed $zone_templ_id, int $userid, bool $isAdmin)

Whether a posted template id may be applied to a zone.

Follows the listing scope: no template, or a template canViewTemplate() allows.

Parameters

mixed $zone_templ_id

Posted template id ("none", "", 0 or an id)

int $userid
bool $isAdmin

Return Value

bool

bool canViewTemplate(int $zone_templ_id, int $userid, bool $isAdmin)

Whether the user may see a template and create zones from it: a global template, their own, one shared with a group they belong to, or any template for an administrator. A missing template is never visible.

Parameters

int $zone_templ_id
int $userid
bool $isAdmin

Return Value

bool

bool canCurrentUserViewTemplate(int $zone_templ_id)

canViewTemplate() for the logged-in user.

Parameters

int $zone_templ_id

Return Value

bool

bool canCurrentUserUseTemplate(mixed $zone_templ_id)

canUseTemplate() for the logged-in user.

Parameters

mixed $zone_templ_id

Return Value

bool

bool isUserOwnerOfTemplate(int $zone_templ_id, int $userid)

Check if the user is the owner of the zone template

Parameters

int $zone_templ_id
int $userid

Return Value

bool

bool canCurrentUserEditTemplate(int $owner, bool $sharedWithUser = false)

Whether the logged-in user may edit a template and its records: a ueberuser, or a holder of zone_templ_edit who owns it or shares it through a group.

Global templates (owner 0) are only editable by ueberusers.

Parameters

int $owner
bool $sharedWithUser

Return Value

bool

bool canCurrentUserManageTemplate(int $owner)

Whether the logged-in user may delete a template or change who it is shared with: a ueberuser, or the owner holding zone_templ_edit. Group members may not.

Parameters

int $owner

Return Value

bool

bool canCurrentUserEditTemplateById(int $zone_templ_id)

canCurrentUserEditTemplate() for a stored template; false when it does not exist.

Parameters

int $zone_templ_id

Return Value

bool

bool canCurrentUserManageTemplateById(int $zone_templ_id)

canCurrentUserManageTemplate() for a stored template; false when it does not exist.

Parameters

int $zone_templ_id

Return Value

bool