ManageRegistrantsController
extends AdminController
in package
ManageRegistrantsController - Admin batch management of event registrants
Handles bulk registration and unregistration of users from events, including both individual and group event operations. Only accessible to administrators via POST with CSRF validation.
Supported actions (via POST 'action' field):
- 'add': Register selected users to an individual event
- 'remove' (default): Unregister selected users from an individual event
- 'group_add': Add selected users to a specific team in a group event
- 'group_remove': Remove selected users from their group
- 'group_move': Move a user to a different team
- 'group_delete': Delete an entire team and its registrations
Tags
Table of Contents
Properties
- $app : Application
- $auth : AuthManager
- $csrf : CsrfProtection
- $request : Request
- $response : Response
- $session : SessionManager
- $registrationRepo : EventRegistrationRepository
- Event registration repository instance
- $teamRepo : EventTeamRepository
- Event team repository instance
Methods
- __construct() : mixed
- Constructor - Handle batch registrant management
- getCsrfTokenForJs() : string
- Get the CSRF token for JavaScript usage
- redirect() : never
- Redirect to a URL
- redirectWithError() : never
- Redirect with an error message
- redirectWithSuccess() : never
- Redirect with a success message
- render() : void
- Render a view with automatic variable injection
- setError() : void
- Set an error flash message
- setFlash() : void
- Set a flash message
- setInfo() : void
- Set an info flash message
- setSuccess() : void
- Set a success flash message
- setWarning() : void
- Set a warning flash message
- validateCsrf() : bool
- Validate the CSRF token from the request
- addRegistrants() : void
- Add selected users as registrants to the event
- getValidatedUserIds() : array<int, int>
- Validate and return sanitized user IDs from POST data
- groupAdd() : void
- Add selected users to a specific team in a group event
- groupCreate() : void
- Create a new group and add selected users to it
- groupDelete() : void
- Delete an entire team and all its registrations
- groupMove() : void
- Move a user to a different team within the same event
- groupRemove() : void
- Remove selected users from their group in a group event
- removeRegistrants() : void
- Remove selected registrants from the event
Properties
$app
protected
Application
$app
$auth
protected
AuthManager
$auth
$csrf
protected
CsrfProtection
$csrf
$request
protected
Request
$request
$response
protected
Response
$response
$session
protected
SessionManager
$session
$registrationRepo
Event registration repository instance
private
EventRegistrationRepository
$registrationRepo
$teamRepo
Event team repository instance
private
EventTeamRepository
$teamRepo
Methods
__construct()
Constructor - Handle batch registrant management
public
__construct() : mixed
Validates HTTP method, CSRF token, and event ID before dispatching to the appropriate action handler.
Tags
getCsrfTokenForJs()
Get the CSRF token for JavaScript usage
protected
getCsrfTokenForJs() : string
This method is useful for embedding the token in JavaScript or as a meta tag for automatic AJAX injection.
Return values
string —The current CSRF token
redirect()
Redirect to a URL
protected
redirect(string $url) : never
Parameters
- $url : string
-
Destination URL
Return values
never —Terminates execution
redirectWithError()
Redirect with an error message
protected
redirectWithError(string $url, string $message) : never
Parameters
- $url : string
-
Destination URL
- $message : string
-
Error message
Return values
never —Terminates execution
redirectWithSuccess()
Redirect with a success message
protected
redirectWithSuccess(string $url, string $message) : never
Parameters
- $url : string
-
Destination URL
- $message : string
-
Success message
Return values
never —Terminates execution
render()
Render a view with automatic variable injection
protected
render(string $viewPath[, array<string, mixed> $data = [] ]) : void
This method automatically injects services and data that all views need, eliminating the need to directly access $_SESSION or global functions.
Automatically injected variables:
- $csrf: CsrfProtection service
- $auth: AuthManager service
- $request: Request object
- $flash: Flash messages array (success, error, warning, info)
- $user: Current user data (null if not logged in)
Parameters
- $viewPath : string
-
View path (e.g., 'users/loginPageView')
- $data : array<string, mixed> = []
-
View-specific data
setError()
Set an error flash message
protected
setError(string $message) : void
Parameters
- $message : string
-
Error message
setFlash()
Set a flash message
protected
setFlash(string $type, string $message) : void
Parameters
- $type : string
-
Message type (success, error, warning, info)
- $message : string
-
Message to display
setInfo()
Set an info flash message
protected
setInfo(string $message) : void
Parameters
- $message : string
-
Info message
setSuccess()
Set a success flash message
protected
setSuccess(string $message) : void
Parameters
- $message : string
-
Success message
setWarning()
Set a warning flash message
protected
setWarning(string $message) : void
Parameters
- $message : string
-
Warning message
validateCsrf()
Validate the CSRF token from the request
protected
validateCsrf([string|null $token = null ]) : bool
Supports both traditional POST body tokens and modern AJAX header tokens. Checks in order:
- Provided token parameter
- POST body 'csrf_token' field
- X-CSRF-Token HTTP header (for AJAX requests)
Parameters
- $token : string|null = null
-
Token to validate (if null, retrieves from POST or header)
Return values
bool —True if valid, false otherwise
addRegistrants()
Add selected users as registrants to the event
private
addRegistrants(int $eventId, array<int, int> $userIds) : void
Parameters
- $eventId : int
-
The event identifier
- $userIds : array<int, int>
-
Array of user identifiers to register
Return values
void —Redirects to event detail page
getValidatedUserIds()
Validate and return sanitized user IDs from POST data
private
getValidatedUserIds(int $eventId) : array<int, int>
Reads user_ids[] from POST, sanitizes to positive integers, and redirects with error if none are valid.
Parameters
- $eventId : int
-
The event identifier for redirect on error
Return values
array<int, int> —Array of validated positive user identifiers
groupAdd()
Add selected users to a specific team in a group event
private
groupAdd(int $eventId) : void
Reads team_id from POST data, validates it, then adds each selected user to that team. Enforces team size limit.
Parameters
- $eventId : int
-
The event identifier
Return values
void —Redirects to event detail page
groupCreate()
Create a new group and add selected users to it
private
groupCreate(int $eventId) : void
Creates a new team for the event, then registers all selected users into the newly created team. Enforces that the number of selected users equals the event's team size.
Parameters
- $eventId : int
-
The event identifier
Return values
void —Redirects to event detail page
groupDelete()
Delete an entire team and all its registrations
private
groupDelete(int $eventId) : void
Reads team_id from POST data. Deletes registrations first, then the team record.
Parameters
- $eventId : int
-
The event identifier
Return values
void —Redirects to event detail page
groupMove()
Move a user to a different team within the same event
private
groupMove(int $eventId) : void
Reads user_id and new_team_id from POST data.
Parameters
- $eventId : int
-
The event identifier
Return values
void —Redirects to event detail page
groupRemove()
Remove selected users from their group in a group event
private
groupRemove(int $eventId, array<int, int> $userIds) : void
Parameters
- $eventId : int
-
The event identifier
- $userIds : array<int, int>
-
Array of user identifiers to remove
Return values
void —Redirects to event detail page
removeRegistrants()
Remove selected registrants from the event
private
removeRegistrants(int $eventId, array<int, int> $userIds) : void
Parameters
- $eventId : int
-
The event identifier
- $userIds : array<int, int>
-
Array of user identifiers to remove
Return values
void —Redirects to event detail page