UserController extends SimpleController
Controller class for user-related requests, including listing users, CRUD for users, etc.
Basic controller class, that imports the entire DI container for easy access to services. Your controller classes may extend this controller class.
Tags
Table of Contents
$ci | ContainerInterface | |
---|---|---|
create() | Processes the request to create a new user (from the admin controls). | mixed |
createPasswordReset() | Processes the request to send a user a password reset email. | mixed |
delete() | Processes the request to delete an existing user. | mixed |
getActivities() | Returns activity history for a single user. | mixed |
getInfo() | Returns info for a single user. | mixed |
getList() | Returns a list of Users. | mixed |
getModalConfirmDelete() | Renders the modal form to confirm user deletion. | mixed |
getModalCreate() | Renders the modal form for creating a new user. | mixed |
getModalEdit() | Renders the modal form for editing an existing user. | mixed |
getModalEditPassword() | Renders the modal form for editing a user's password. | mixed |
getModalEditRoles() | Renders the modal form for editing a user's roles. | mixed |
getPermissions() | Returns a list of effective Permissions for a specified User. | mixed |
getRoles() | Returns roles associated with a single user. | mixed |
pageInfo() | Renders a page displaying a user's information, in read-only mode. | mixed |
pageList() | Renders the user listing page. | mixed |
updateInfo() | Processes the request to update an existing user's basic details (first_name, last_name, email, locale, group_id). | mixed |
updateField() | Processes the request to update a specific field for an existing user. | mixed |
getUserFromParams() | Get User instance from params. | User|null |
__construct() | Constructor. | mixed |
Properties
$ci
protected
ContainerInterface
$ci
Methods
create()
Processes the request to create a new user (from the admin controls).
public
create(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
string[]
)
: mixed
Processes the request from the user creation form, checking that:
- The username and email are not already in use;
- The logged-in user has the necessary permissions to update the posted field(s);
- The submitted data is valid. This route requires authentication.
Request type: POST
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : string[]
Tags
Return values
mixedcreatePasswordReset()
Processes the request to send a user a password reset email.
public
createPasswordReset(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
string[]
)
: mixed
Processes the request from the user update form, checking that:
- The target user's new email address, if specified, is not already in use;
- The logged-in user has the necessary permissions to update the posted field(s);
- We're not trying to disable the master account;
- The submitted data is valid. This route requires authentication.
Request type: POST
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : string[]
Tags
Return values
mixeddelete()
Processes the request to delete an existing user.
public
delete(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
string[]
)
: mixed
Deletes the specified user, removing any existing associations. Before doing so, checks that:
- You are not trying to delete the master account;
- You have permission to delete the target user's account. This route requires authentication (and should generally be limited to admins or the root user).
Request type: DELETE
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : string[]
Tags
Return values
mixedgetActivities()
Returns activity history for a single user.
public
getActivities(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
string[]
)
: mixed
This page requires authentication. Request type: GET
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : string[]
Tags
Return values
mixedgetInfo()
Returns info for a single user.
public
getInfo(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
string[]
)
: mixed
This page requires authentication. Request type: GET
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : string[]
Tags
Return values
mixedgetList()
Returns a list of Users.
public
getList(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
string[]
)
: mixed
Generates a list of users, optionally paginated, sorted and/or filtered. This page requires authentication. Request type: GET
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : string[]
Tags
Return values
mixedgetModalConfirmDelete()
Renders the modal form to confirm user deletion.
public
getModalConfirmDelete(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
string[]
)
: mixed
This does NOT render a complete page. Instead, it renders the HTML for the modal, which can be embedded in other pages. This page requires authentication. Request type: GET
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : string[]
Tags
Return values
mixedgetModalCreate()
Renders the modal form for creating a new user.
public
getModalCreate(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
string[]
)
: mixed
This does NOT render a complete page. Instead, it renders the HTML for the modal, which can be embedded in other pages. If the currently logged-in user has permission to modify user group membership, then the group toggle will be displayed. Otherwise, the user will be added to the default group and receive the default roles automatically.
This page requires authentication. Request type: GET
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : string[]
Tags
Return values
mixedgetModalEdit()
Renders the modal form for editing an existing user.
public
getModalEdit(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
string[]
)
: mixed
This does NOT render a complete page. Instead, it renders the HTML for the modal, which can be embedded in other pages. This page requires authentication.
Request type: GET
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : string[]
Tags
Return values
mixedgetModalEditPassword()
Renders the modal form for editing a user's password.
public
getModalEditPassword(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
string[]
)
: mixed
This does NOT render a complete page. Instead, it renders the HTML for the form, which can be embedded in other pages. This page requires authentication.
Request type: GET
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : string[]
Tags
Return values
mixedgetModalEditRoles()
Renders the modal form for editing a user's roles.
public
getModalEditRoles(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
string[]
)
: mixed
This does NOT render a complete page. Instead, it renders the HTML for the form, which can be embedded in other pages. This page requires authentication.
Request type: GET
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : string[]
Tags
Return values
mixedgetPermissions()
Returns a list of effective Permissions for a specified User.
public
getPermissions(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
string[]
)
: mixed
Generates a list of permissions, optionally paginated, sorted and/or filtered. This page requires authentication. Request type: GET
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : string[]
Tags
Return values
mixedgetRoles()
Returns roles associated with a single user.
public
getRoles(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
string[]
)
: mixed
This page requires authentication. Request type: GET
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : string[]
Tags
Return values
mixedpageInfo()
Renders a page displaying a user's information, in read-only mode.
public
pageInfo(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
string[]
)
: mixed
This checks that the currently logged-in user has permission to view the requested user's info. It checks each field individually, showing only those that you have permission to view. This will also try to show buttons for activating, disabling/enabling, deleting, and editing the user.
This page requires authentication. Request type: GET
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : string[]
Tags
Return values
mixedpageList()
Renders the user listing page.
public
pageList(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
string[]
)
: mixed
This page renders a table of users, with dropdown menus for admin actions for each user. Actions typically include: edit user details, activate user, enable/disable user, delete user.
This page requires authentication. Request type: GET
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : string[]
Tags
Return values
mixedupdateInfo()
Processes the request to update an existing user's basic details (first_name, last_name, email, locale, group_id).
public
updateInfo(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
string[]
)
: mixed
Processes the request from the user update form, checking that:
- The target user's new email address, if specified, is not already in use;
- The logged-in user has the necessary permissions to update the putted field(s);
- The submitted data is valid.
This route requires authentication. Request type: PUT
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : string[]
Tags
Return values
mixedupdateField()
Processes the request to update a specific field for an existing user.
public
updateField(
$request :
ServerRequestInterface
, $response :
ResponseInterface
, $args :
string[]
)
: mixed
Supports editing all user fields, including password, enabled/disabled status and verification status. Processes the request from the user update form, checking that:
- The logged-in user has the necessary permissions to update the putted field(s);
- We're not trying to disable the master account;
- The submitted data is valid.
This route requires authentication. Request type: PUT
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $args : string[]
Tags
Return values
mixedgetUserFromParams()
Get User instance from params.
protected
getUserFromParams(
$params :
string[]
)
: User|null
Parameters
- $params : string[]
Tags
Return values
User|null__construct()
Constructor.
public
__construct(
$ci :
ContainerInterface
)
: mixed
Parameters
- $ci : ContainerInterface
The global container object, which holds all your services.