ZoneOwnershipLimit
class ZoneOwnershipLimit (View source)
How many zones a user or group may own, and whether a change would exceed it.
A user counts the zones they own directly, a group the zones granted to it; group grants never count toward the members. The limit binds the owner, whoever acts, and a superuser owner is never limited. Lowering a limit keeps existing zones. Grants decide and write under a lock on the limited owners' rows.
Constants
| MAX_LIMIT |
Largest value the INT columns hold on every supported database |
| ERR_FORBIDDEN |
|
| ERR_INVALID |
|
| ERR_NOT_FOUND |
|
Methods
No description
Makes the user an owner through $write unless that takes them past their limit.
Grants the group a zone through $write unless that takes it past its limit. With $zoneId, a group that already holds the zone gains nothing and is never refused for it.
Moves every zone of one user to another through $write unless that takes the receiver past their limit. The receiver is counted again after the move and the move rolled back if it went over, since a zone granted to the sender meanwhile moves too.
Gives each user the listed zones through $write, all or nothing: every limited user's row is locked, each one's total re-checked, and $write returning false rolls back.
The breach a new zone would cause, decided under a lock on the owners' rows.
Locks these users' rows in the open transaction, in the order every grant takes them.
The user's limit: their own, else dns.default_max_zones_per_user. Null means unlimited.
The group's limit: its own, else dns.default_max_zones_per_group. Null means unlimited.
Owned count and limit for a page of users, in two queries; for the users list.
No description
No description
Zones the user can still take on, or null when unlimited.
Whether giving the user $adding more zones would exceed their limit.
Whether granting the group $adding more zones would exceed its limit.
The first owner a new zone would take past its limit: the user owner, then each group.
Whether moving every zone of one user to another would exceed the receiver's limit.
Whether making the user an owner of these zones would exceed their limit.
Set or clear (null) a user's own limit. Only a superuser may, so a delegated administrator cannot lift the limits of the users they manage.
Set or clear (null) a group's own limit; superusers only, as for users.
Whether the acting user may change limits at all.
Details
__construct(UserRepositoryInterface $users, UserGroupRepositoryInterface $groups, ZoneGroupRepositoryInterface $zoneGroups, PermissionService $permissions, ConfigurationInterface $config, TransactionInterface|null $transaction = null, mixed $retry = null)
No description
mixed
addUserOwner(int $userId, callable $write, int|null $zoneId = null)
Makes the user an owner through $write unless that takes them past their limit.
With $zoneId, a user who already owns that zone (say, through a concurrent request) gains nothing, so the grant is never refused for it; $write should skip the insert then.
mixed
addGroupOwner(int $groupId, callable $write, int|null $zoneId = null)
Grants the group a zone through $write unless that takes it past its limit. With $zoneId, a group that already holds the zone gains nothing and is never refused for it.
ZoneLimitBreach|bool
transferZones(int $fromUserId, int $toUserId, callable $write)
Moves every zone of one user to another through $write unless that takes the receiver past their limit. The receiver is counted again after the move and the move rolled back if it went over, since a zone granted to the sender meanwhile moves too.
ZoneLimitBreach|bool
reassignZones(array $zonesByUser, callable $write)
Gives each user the listed zones through $write, all or nothing: every limited user's row is locked, each one's total re-checked, and $write returning false rolls back.
ZoneLimitBreach|null
lockedNewZoneBreach(int|null $ownerUserId, array $groupIds)
The breach a new zone would cause, decided under a lock on the owners' rows.
For a caller that has just opened the transaction its write runs in: the lock comes first, so the count that follows sees every grant committed before it.
void
lockUsers(array $userIds)
Locks these users' rows in the open transaction, in the order every grant takes them.
For a writer that decides itself, such as the zone sync adopting zones.
int|null
userLimit(int $userId)
The user's limit: their own, else dns.default_max_zones_per_user. Null means unlimited.
int|null
groupLimit(int $groupId)
The group's limit: its own, else dns.default_max_zones_per_group. Null means unlimited.
array
userUsage(array $userIds)
Owned count and limit for a page of users, in two queries; for the users list.
int
userZoneCount(int $userId)
No description
int
groupZoneCount(int $groupId)
No description
int|null
userRemaining(int $userId)
Zones the user can still take on, or null when unlimited.
ZoneLimitBreach|null
userBreach(int $userId, int $adding = 1)
Whether giving the user $adding more zones would exceed their limit.
ZoneLimitBreach|null
groupBreach(int $groupId, int $adding = 1)
Whether granting the group $adding more zones would exceed its limit.
ZoneLimitBreach|null
newZoneBreach(int|null $ownerUserId, array $groupIds)
The first owner a new zone would take past its limit: the user owner, then each group.
ZoneLimitBreach|null
transferBreach(int $fromUserId, int $toUserId)
Whether moving every zone of one user to another would exceed the receiver's limit.
Zones the receiver already owns do not count twice.
ZoneLimitBreach|null
zonesBreach(int $userId, array $zoneIds)
Whether making the user an owner of these zones would exceed their limit.
Zones the user already owns do not count twice.
array
setUserLimit(int $actingUserId, int $userId, int|null $limit)
Set or clear (null) a user's own limit. Only a superuser may, so a delegated administrator cannot lift the limits of the users they manage.
array
setGroupLimit(int $actingUserId, int $groupId, int|null $limit)
Set or clear (null) a group's own limit; superusers only, as for users.
bool
maySetLimits(int $actingUserId)
Whether the acting user may change limits at all.