class UserManagementService (View source)

Domain service for user management operations

This service encapsulates business logic related to user operations and coordinates between repositories and other domain services.

Constants

ERR_USERNAME_REQUIRED

ERR_INVALID_LDAP

ERR_PASSWORD_REQUIRED

ERR_PASSWORD_POLICY

ERR_FIELD_LENGTH

ERR_USERNAME_EXISTS

ERR_EMAIL_EXISTS

ERR_NO_TEMPLATE

ERR_TEMPLATE_NOT_FOUND

ERR_NOT_FOUND

ERR_PASSWORD_FORBIDDEN

ERR_LAST_ADMIN

ERR_TRANSFER_TARGET

ERR_ZONE_DELETE_FORBIDDEN

ERR_ZONE_META_FORBIDDEN

ERR_ZONE_WRITE

ERR_WRITE

Methods

__construct(UserRepository $userRepository, PermissionService $permissionService, UserGroupRepositoryInterface $groupRepository, UserAuthenticationService $authService, PasswordPolicyService $passwordPolicy, bool $ldapEnabled, DomainManagerInterface $domainManager)

No description

array|null
getUserById(int $userId)

Get a user by ID with complete information including permissions

array
getUsersList(Pagination $pagination)

Get paginated list of users with their details and permissions

bool
userExists(int $userId)

Check if a user exists by ID

bool
userExistsByUsername(string $username)

Check if a user exists by username

bool
userExistsByEmail(string $email)

Check if a user exists by email

array|null
getUserByUsername(string $username)

Get user details by username (similar to list format)

array|null
getUserByEmail(string $email)

Get user details by email (similar to list format)

array|null
getUserForVerification(int $userId)

Get basic user information for verification purposes

array
createUser(array $userData)

Create a new user

array
updateUser(int $userId, array $userData)

Update an existing user

array
deleteUser(int $userId, int|null $transferToUserId = null)

Delete a user and transfer their zones to another user

array
deleteUserWithZoneDecisions(int $actingUserId, int $userId, array $zoneDecisions)

Delete a user, deciding zone by zone what happens to what they own: each decision names a zone id and a target, 'delete' or 'new_owner' (with 'newowner'); any other target leaves the zone as it is. Every decision is checked against the acting user's zone rights before any zone is touched, so a later refusal cannot leave the earlier ones half applied. That the acting user may delete this user at all is the caller's check.

array
assignPermissionTemplate(int $userId, int $permTemplId)

Assign permission template to a user

static bool
passwordGiven(array $userData)

Only the empty string means "leave unchanged"; "0" is a password.

Details

__construct(UserRepository $userRepository, PermissionService $permissionService, UserGroupRepositoryInterface $groupRepository, UserAuthenticationService $authService, PasswordPolicyService $passwordPolicy, bool $ldapEnabled, DomainManagerInterface $domainManager)

No description

Parameters

UserRepository $userRepository
PermissionService $permissionService
UserGroupRepositoryInterface $groupRepository
UserAuthenticationService $authService
PasswordPolicyService $passwordPolicy
bool $ldapEnabled
DomainManagerInterface $domainManager

array|null getUserById(int $userId)

Get a user by ID with complete information including permissions

Parameters

int $userId

User ID

Return Value

array|null

User data with permissions or null if not found

array getUsersList(Pagination $pagination)

Get paginated list of users with their details and permissions

Parameters

Pagination $pagination

Pagination parameters

Return Value

array

Array with 'data' and 'total_count' keys

bool userExists(int $userId)

Check if a user exists by ID

Parameters

int $userId

User ID

Return Value

bool

True if user exists, false otherwise

bool userExistsByUsername(string $username)

Check if a user exists by username

Parameters

string $username

Username to check

Return Value

bool

True if user exists, false otherwise

bool userExistsByEmail(string $email)

Check if a user exists by email

Parameters

string $email

Email to check

Return Value

bool

True if user exists, false otherwise

array|null getUserByUsername(string $username)

Get user details by username (similar to list format)

Parameters

string $username

Username to search for

Return Value

array|null

User data in list format or null if not found

array|null getUserByEmail(string $email)

Get user details by email (similar to list format)

Parameters

string $email

Email to search for

Return Value

array|null

User data in list format or null if not found

array|null getUserForVerification(int $userId)

Get basic user information for verification purposes

Parameters

int $userId

User ID

Return Value

array|null

Basic user data or null if not found

array createUser(array $userData)

Create a new user

Parameters

array $userData

User data containing username, fullname, email, password, etc.

Return Value

array

Result with success status, message, and user ID if successful

array updateUser(int $userId, array $userData)

Update an existing user

Parameters

int $userId

User ID to update

array $userData

Updated user data

Return Value

array

Result with success status and message

array deleteUser(int $userId, int|null $transferToUserId = null)

Delete a user and transfer their zones to another user

Parameters

int $userId

User ID to delete

int|null $transferToUserId

User ID to transfer zones to (required if user has zones)

Return Value

array

Result with success status and message

array deleteUserWithZoneDecisions(int $actingUserId, int $userId, array $zoneDecisions)

Delete a user, deciding zone by zone what happens to what they own: each decision names a zone id and a target, 'delete' or 'new_owner' (with 'newowner'); any other target leaves the zone as it is. Every decision is checked against the acting user's zone rights before any zone is touched, so a later refusal cannot leave the earlier ones half applied. That the acting user may delete this user at all is the caller's check.

Parameters

int $actingUserId
int $userId
array $zoneDecisions

Entries that are not a decision (no zid, unknown target) are ignored

Return Value

array

array assignPermissionTemplate(int $userId, int $permTemplId)

Assign permission template to a user

Parameters

int $userId

User ID

int $permTemplId

Permission template ID

Return Value

array

Result with success status and message

static bool passwordGiven(array $userData)

Only the empty string means "leave unchanged"; "0" is a password.

Parameters

array $userData

Return Value

bool