interface UserRepositoryInterface implements UserLookupInterface, AuthUserLookupInterface, UserNotificationRecipientInterface, UserPermissionReadInterface, UserCredentialWriterInterface, UserAdminInterface (View source)

Persistence for user accounts and the zones they own.

Union of the UserRepositoryInterface roles; consumers should depend on the narrowest role they use.

Methods

array|null
getUserById(int $userId)

Get a user by ID

array|null
getUserByUsername(string $username)

Get a user by username

User|null
findByUsername(string $username)

Find a user by username

array|null
getUserByEmail(string $email)

Get a user by email

array
findActiveUsersByEmail(string $email)

Every active account registered to an email address, ordered by username.

int
countUsersByEmail(string $email)

Count how many users share the given email address.

int|null
findActiveUserIdByEmail(string $email)

Id of the active user with exactly this email address, accent-exact so a look-alike address from an identity provider cannot resolve to another account.

int|null
findInactiveUserIdByEmail(string $email)

Id of a disabled user with exactly this email address, matched the same way as findActiveUserIdByEmail().

array
getProvisioningProfile(int $userId)

The columns external provisioning compares before writing.

string|null
getFullNameById(int $userId)

Get a user's full name by ID

string|null
getFullNameByUsername(string $username)

Full name of the user with exactly this username (accent-exact match), or null when there is none

int|null
findZoneLimit(int $userId)

The user's own zone limit: null when none is set (the configured default applies), 0 when the user may own no zones

array
findZoneLimits(array $userIds)

findZoneLimit() for many users in one query

array|null
findSqlLoginUser(string $username)

The password-login row: id, fullname, password, active, email. LDAP accounts are excluded so a directory account cannot be logged into with a local hash.

array|null
findActiveLdapUser(string $username)

The LDAP-login row: id, fullname, email, for active LDAP-enabled accounts only.

bool
hasActiveLdapUser(string $username)

Whether the account is still active and still LDAP-enabled, re-checked on every request so a disabled account loses a cached LDAP bind at once.

bool
isActiveUser(int $userId)

Whether the account still exists and is active, re-checked on every request for sessions an identity provider established.

array|null
findBasicAuthUser(string $username)

The HTTP Basic row: id, password, use_ldap, for active accounts only.

array|null
findAuthMethodRow(string $username)

The stored auth_method for a username, or null when no such account exists.

array|null
findNotificationRecipient(int $userId)

One recipient by id: id, username, fullname, email.

array
listNotifiableUsers()

Every active account with a usable email address, ordered by id. The caller filters further by permission.

array
listActiveUsers()

Every active account, with or without an email address, ordered by id.

array
getUserPermissions(int $userId)

Get all permissions for a specific user

bool
hasAdminPermission(int $userId)

Check if a user has admin permissions

bool
templateGrantsUberuser(int $permTemplId)

Check whether a permission template grants the uberuser permission

array
getTemplatePermissionNames(int $permTemplId)

Names of the permissions a permission template grants

int|null
findPermissionTemplateIdByName(string $name)

Id of the permission template with exactly this name, accent-exact so an IdP-asserted claim cannot map to a look-alike template.

array
getPermissionIdsByName(string $name)

Resolve every permission id carrying a given name

bool
isUberuser(int $userId)

Check if a specific user is an uberuser

int
countUberusers()

Count total number of uberusers (super admins) in the system

bool
isLastUberuser(int $userId)

Whether removing or demoting this user would leave no active uberuser.

bool
holdsUberuserThroughGroup(int $userId)

Whether a group the user belongs to grants the super admin permission, so changing the user's own template cannot take it away.

int
countUberusersAfter(UberuserChange $change)

How many active super admins would remain once $change is written. Inside an open transaction it locks the active super admin rows first, as isLastUberuser() does.

array
getAdminUserIds()

Ids of every user holding the ueberuser permission directly or through a group.

bool
userOwnsZone(int $userId, int $domainId)

Check if a user owns a zone directly or via group membership

array
getUserGroupIds(int $userId)

Ids of the groups the user is a member of

array
getUserOwnedZoneIds(int $userId)

Canonical ids of the zones the user owns directly or through any group

array
getDirectlyOwnedZoneIds(int $userId)

Canonical ids of the zones the user owns directly, without group grants; each zone once however many owner rows it has

array
countDirectlyOwnedZones(array $userIds)

getDirectlyOwnedZoneIds() counted for many users in one query

bool
updatePassword(int $userId, string $hashedPassword)

Update a user's password

string
getZoneOwnerFullNames(int $domainId)

Get the full names of all owners of a zone, comma-separated

array
getUsersList(int $offset, int $limit, string|null $search = null, array $sort = [])

Get a paginated list of users with zone counts

array
getUsersWithZoneCounts()

Get all users with the number of zones each one owns

array
getUserDetailList(bool $ldapUse, int|null $restrictToUserId, int|null $specific = null, int|null $limit = null, int|null $offset = null, string|null $search = null)

Get detailed user list with template, group, and MFA info

int
getTotalUserCount(int|null $restrictToUserId = null, string|null $search = null)

Get total count of users in the system

bool
deleteUser(int $userId, int|null $sharedTemplateHeir = null)

Delete a user by ID

array
getUserZones(int $userId)

Get zones owned by a user

bool
transferUserZones(int $fromUserId, int $toUserId)

Transfer zone ownership from one user to another

bool
setZoneLimit(int $userId, int|null $limit)

Set the user's own zone limit; null removes it so the configured default applies

void
lockForZoneLimit(int $userId)

Lock the user's row until the open transaction ends, so zone limit checks for this user run one at a time

int|null
createUser(CreateUserCommand $user)

Create a new user

bool
updateUser(int $userId, UpdateUserCommand $changes)

Update a user's information

int
createProvisionedUser(array $userData)

Insert a user created from an external identity (LDAP, OIDC or SAML).

void
updateProvisionedUser(int $userId, array $fields)

Update the identity and template columns that external provisioning owns.

bool
assignPermissionTemplate(int $userId, int $permTemplId)

Assign permission template to a user

bool
permissionTemplateExists(int $permTemplId, string|null $templateType = null)

Check if a permission template exists

Details

array|null getUserById(int $userId)

Get a user by ID

Parameters

int $userId

User ID to retrieve

Return Value

array|null

User data if found, null otherwise

array|null getUserByUsername(string $username)

Get a user by username

Parameters

string $username

Username to search for

Return Value

array|null

User data if found, null otherwise

User|null findByUsername(string $username)

Find a user by username

Parameters

string $username

Username to search for

Return Value

User|null

User object if found, null otherwise

array|null getUserByEmail(string $email)

Get a user by email

Parameters

string $email

Email to search for

Return Value

array|null

User data if found, null otherwise

array findActiveUsersByEmail(string $email)

Every active account registered to an email address, ordered by username.

Parameters

string $email

Return Value

array

int countUsersByEmail(string $email)

Count how many users share the given email address.

Parameters

string $email

Email to search for

Return Value

int

Number of matching users

int|null findActiveUserIdByEmail(string $email)

Id of the active user with exactly this email address, accent-exact so a look-alike address from an identity provider cannot resolve to another account.

Parameters

string $email

Return Value

int|null

int|null findInactiveUserIdByEmail(string $email)

Id of a disabled user with exactly this email address, matched the same way as findActiveUserIdByEmail().

Parameters

string $email

Return Value

int|null

array getProvisioningProfile(int $userId)

The columns external provisioning compares before writing.

Parameters

int $userId

Return Value

array

Empty when the user does not exist

string|null getFullNameById(int $userId)

Get a user's full name by ID

Parameters

int $userId

User ID to look up

Return Value

string|null

Full name, or null if the user does not exist

string|null getFullNameByUsername(string $username)

Full name of the user with exactly this username (accent-exact match), or null when there is none

Parameters

string $username

Return Value

string|null

int|null findZoneLimit(int $userId)

The user's own zone limit: null when none is set (the configured default applies), 0 when the user may own no zones

Parameters

int $userId

Return Value

int|null

array findZoneLimits(array $userIds)

findZoneLimit() for many users in one query

Parameters

array $userIds

Return Value

array

Own limit keyed by user id; every requested id is present

array|null findSqlLoginUser(string $username)

The password-login row: id, fullname, password, active, email. LDAP accounts are excluded so a directory account cannot be logged into with a local hash.

Parameters

string $username

Return Value

array|null

array|null findActiveLdapUser(string $username)

The LDAP-login row: id, fullname, email, for active LDAP-enabled accounts only.

Parameters

string $username

Return Value

array|null

bool hasActiveLdapUser(string $username)

Whether the account is still active and still LDAP-enabled, re-checked on every request so a disabled account loses a cached LDAP bind at once.

Parameters

string $username

Return Value

bool

bool isActiveUser(int $userId)

Whether the account still exists and is active, re-checked on every request for sessions an identity provider established.

Parameters

int $userId

Return Value

bool

array|null findBasicAuthUser(string $username)

The HTTP Basic row: id, password, use_ldap, for active accounts only.

Parameters

string $username

Return Value

array|null

array|null findAuthMethodRow(string $username)

The stored auth_method for a username, or null when no such account exists.

The row is returned rather than the value so a missing account stays distinguishable from an account with no auth_method set.

Parameters

string $username

Return Value

array|null

array|null findNotificationRecipient(int $userId)

One recipient by id: id, username, fullname, email.

Parameters

int $userId

Return Value

array|null

array listNotifiableUsers()

Every active account with a usable email address, ordered by id. The caller filters further by permission.

Return Value

array

array listActiveUsers()

Every active account, with or without an email address, ordered by id.

Return Value

array

array getUserPermissions(int $userId)

Get all permissions for a specific user

Parameters

int $userId

User ID to get permissions for

Return Value

array

Array of permission names

bool hasAdminPermission(int $userId)

Check if a user has admin permissions

Parameters

int $userId

User ID to check

Return Value

bool

True if the user is an admin

bool templateGrantsUberuser(int $permTemplId)

Check whether a permission template grants the uberuser permission

Parameters

int $permTemplId

Permission template ID

Return Value

bool

True if the template grants user_is_ueberuser

array getTemplatePermissionNames(int $permTemplId)

Names of the permissions a permission template grants

Parameters

int $permTemplId

Return Value

array

int|null findPermissionTemplateIdByName(string $name)

Id of the permission template with exactly this name, accent-exact so an IdP-asserted claim cannot map to a look-alike template.

Parameters

string $name

Return Value

int|null

array getPermissionIdsByName(string $name)

Resolve every permission id carrying a given name

perm_items.name has no unique constraint, so a name can map to several rows and all of them grant the permission.

Parameters

string $name

Permission name as stored in perm_items

Return Value

array

Matching permission ids, empty when the permission is absent

bool isUberuser(int $userId)

Check if a specific user is an uberuser

Parameters

int $userId

User ID to check

Return Value

bool

True if user is an uberuser

int countUberusers()

Count total number of uberusers (super admins) in the system

Return Value

int

Number of uberusers

bool isLastUberuser(int $userId)

Whether removing or demoting this user would leave no active uberuser.

Inside an open transaction it locks the active uberuser rows first, so callers that check and then write in one transaction cannot race each other.

Parameters

int $userId

Return Value

bool

bool holdsUberuserThroughGroup(int $userId)

Whether a group the user belongs to grants the super admin permission, so changing the user's own template cannot take it away.

Parameters

int $userId

Return Value

bool

int countUberusersAfter(UberuserChange $change)

How many active super admins would remain once $change is written. Inside an open transaction it locks the active super admin rows first, as isLastUberuser() does.

Parameters

UberuserChange $change

Return Value

int

array getAdminUserIds()

Ids of every user holding the ueberuser permission directly or through a group.

Return Value

array

bool userOwnsZone(int $userId, int $domainId)

Check if a user owns a zone directly or via group membership

Parameters

int $userId

User ID to check

int $domainId

Domain/zone ID

Return Value

bool

True if the user owns the zone

array getUserGroupIds(int $userId)

Ids of the groups the user is a member of

Parameters

int $userId

Return Value

array

array getUserOwnedZoneIds(int $userId)

Canonical ids of the zones the user owns directly or through any group

Parameters

int $userId

Return Value

array

array getDirectlyOwnedZoneIds(int $userId)

Canonical ids of the zones the user owns directly, without group grants; each zone once however many owner rows it has

Parameters

int $userId

Return Value

array

array countDirectlyOwnedZones(array $userIds)

getDirectlyOwnedZoneIds() counted for many users in one query

Parameters

array $userIds

Return Value

array

Zone count keyed by user id; every requested id is present

bool updatePassword(int $userId, string $hashedPassword)

Update a user's password

Parameters

int $userId

User ID to update

string $hashedPassword

Hashed password to set

Return Value

bool

True if the password was updated successfully

string getZoneOwnerFullNames(int $domainId)

Get the full names of all owners of a zone, comma-separated

Parameters

int $domainId

Domain/zone ID

Return Value

string

Comma-separated owner full names, empty string if none

array getUsersList(int $offset, int $limit, string|null $search = null, array $sort = [])

Get a paginated list of users with zone counts

Parameters

int $offset

Starting offset for pagination

int $limit

Maximum number of users to return

string|null $search

Case-insensitive substring filter on username, full name, email or description

array $sort

Sort keys (id, username, fullname or email); empty sorts by id

Return Value

array

Array of user data with zone counts

array getUsersWithZoneCounts()

Get all users with the number of zones each one owns

Return Value

array

Array of user rows [id, username, fullname, email, description, active, numdomains]

array getUserDetailList(bool $ldapUse, int|null $restrictToUserId, int|null $specific = null, int|null $limit = null, int|null $offset = null, string|null $search = null)

Get detailed user list with template, group, and MFA info

Parameters

bool $ldapUse

Whether the LDAP column should be included

int|null $restrictToUserId

Return only this user (for users without view-others permission)

int|null $specific

User ID to fetch (overrides the restriction)

int|null $limit

Number of records to return (optional)

int|null $offset

Starting offset (optional)

string|null $search

Filter on username, full name, email or description

Return Value

array

Array of user details

int getTotalUserCount(int|null $restrictToUserId = null, string|null $search = null)

Get total count of users in the system

Parameters

int|null $restrictToUserId

Count only this user (for users without view-others permission)

string|null $search

Filter on username, full name, email or description

Return Value

int

Total number of users

bool deleteUser(int $userId, int|null $sharedTemplateHeir = null)

Delete a user by ID

Parameters

int $userId

User ID to delete

int|null $sharedTemplateHeir

Gets the user's templates that are shared with groups; without one they are deleted too

Return Value

bool

True if the user was deleted successfully

array getUserZones(int $userId)

Get zones owned by a user

Parameters

int $userId

User ID

Return Value

array

Array of zone data owned by the user

bool transferUserZones(int $fromUserId, int $toUserId)

Transfer zone ownership from one user to another

Parameters

int $fromUserId

Source user ID

int $toUserId

Target user ID

Return Value

bool

True if zones were transferred successfully

bool setZoneLimit(int $userId, int|null $limit)

Set the user's own zone limit; null removes it so the configured default applies

Parameters

int $userId
int|null $limit

Return Value

bool

void lockForZoneLimit(int $userId)

Lock the user's row until the open transaction ends, so zone limit checks for this user run one at a time

Parameters

int $userId

Return Value

void

int|null createUser(CreateUserCommand $user)

Create a new user

Parameters

CreateUserCommand $user

The row to write, with the password already in its stored form

Return Value

int|null

User ID if created successfully, null otherwise

bool updateUser(int $userId, UpdateUserCommand $changes)

Update a user's information

Parameters

int $userId

User ID to update

UpdateUserCommand $changes

The fields to write (null ones stay), the password already in its stored form

Return Value

bool

True if updated successfully, false otherwise

int createProvisionedUser(array $userData)

Insert a user created from an external identity (LDAP, OIDC or SAML).

Parameters

array $userData

Return Value

int

The new user id

Exceptions

RuntimeException

void updateProvisionedUser(int $userId, array $fields)

Update the identity and template columns that external provisioning owns.

Parameters

int $userId
array $fields

Column => value, limited to fullname, email, auth_method, perm_templ and perm_templ_source

Return Value

void

bool assignPermissionTemplate(int $userId, int $permTemplId)

Assign permission template to a user

Parameters

int $userId

User ID

int $permTemplId

Permission template ID

Return Value

bool

True if assignment was successful

bool permissionTemplateExists(int $permTemplId, string|null $templateType = null)

Check if a permission template exists

Parameters

int $permTemplId

Permission template ID

string|null $templateType

Optional template_type filter ('user' or 'group')

Return Value

bool

True if the permission template exists (and matches type when set)