Admin
Reference for the Admin module: the routed admin system, its per-site theming and navigation, and the users, groups and permissions behind it. A site mounts the admin at a URL, registers its sections, and the module handles login, menus, routing and access control.
This page is a pure reference. Every public class and function is listed with its exact signature, parameters and return type.
Admin- render the admin page shell, mount admin routing, and build admin links.AdminAction- the login and logout form actions.AdminConfig- register admin sections, navigation, home panels and hero content.AdminGroupData- one admin group row.AdminGroupDatabase- read and write admin groups.AdminGroupPermissionData- one permission row for a group.AdminGroupPermissionDatabase- storage and combined lookup for group permissions.AdminGroupPermissionUrl- build permission admin URLs.AdminGroupUrl- build group admin URLs.AdminGroupUserDatabase- read and write group membership.AdminGroupUserUrl- build group-user admin URLs.AdminNavigation- unified routing and menu generation for admin sections.AdminNavigationButtonUi- permission-aware buttons and links for admin pages.AdminNavigationConfig- a registered top-level navigation entry.AdminNavigationUi- the logged-in and not-logged-in admin route trees.AdminPageUi- reusable admin page layouts.AdminPermission- permission checks for admin navigation.AdminPermissionTargetData- a permission target: a module and a path within it.AdminSecurity- guard admin code behind a logged-in check.AdminSession- the logged-in admin user session.AdminThemeConfig- recolour the admin system to match a site's brand.AdminUi- built-in admin pages and self-highlighting menu links.AdminUrl- build the login and logout action URLs.AdminUserData- one admin user row.AdminUserDatabase- read and write admin users.AdminUserUrl- build user admin URLs.
Admin
Render the admin page shell, mount admin routing at a URL path, and build links within the admin. Link building tracks a per-section base path so pages can use short relative paths.
GetBasePath
Admin::GetBasePath(): string
The current section base path set by LinkBase, or '' at the admin root.
Returns string The current base path.
Html
Admin::Html(Callable $content): void
Emit the admin page HTML shell, including the admin stylesheet and any theme overrides, and run the content callback inside the body.
| Name | Type | Description |
|---|---|---|
$content | Callable | The callback that renders the page body. |
Returns void
Link
Admin::Link(string $path): string
An absolute admin URL for a path, prefixed with the site URL, the admin mount path and the current section base path.
| Name | Type | Description |
|---|---|---|
$path | string | The admin-relative path. |
Returns string The full URL.
LinkBase
Admin::LinkBase(string $basePath, Callable $callback): void
Run a callback with the current section base path extended by a segment, so Link calls inside it resolve relative to that section. The previous base is restored afterwards.
| Name | Type | Description |
|---|---|---|
$basePath | string | The path segment to append to the base. |
$callback | Callable | The work to run within the extended base. |
Returns void
RootLink
Admin::RootLink(string $path): string
An admin link resolved from the admin root, ignoring the current section base path. Use it to link across top-level admin sections; the path must be the full admin-relative path.
| Name | Type | Description |
|---|---|---|
$path | string | The full admin-relative path. |
Returns string The full URL.
Route
Admin::Route(string $path): void
Mount the admin system at a URL path: serve the admin stylesheet, and render the logged-in or not-logged-in navigation tree depending on the session.
| Name | Type | Description |
|---|---|---|
$path | string | The URL path to mount the admin at. |
Returns void
AdminAction
The login and logout form actions, wired to admin routes. Each validates input, updates the session and redirects with a status message.
Login
AdminAction::Login(): void
Validate the posted login and password, log the admin user in on success, and redirect back to the admin with a status message.
Returns void
Logout
AdminAction::Logout(): void
Log the current admin user out and redirect back to the admin with a status message.
Returns void
AdminConfig
Register what appears in the admin system: top-level sections, navigation entries, home page panels and workflows, and optional hero content for the home page.
eachNavigation
AdminConfig::eachNavigation(string $urlPath, callable $callback): void
Call the callback for each registered navigation entry immediately inside the given URL path. Requires a logged-in admin.
| Name | Type | Description |
|---|---|---|
$urlPath | string | The parent URL path to match entries under. |
$callback | callable | Called with each matching AdminNavigationConfig. |
Returns void
getNavigation
AdminConfig::getNavigation(string $urlPath): AdminNavigationConfig|null
The navigation entry registered at an exact URL path, or null when none is registered there.
| Name | Type | Description |
|---|---|---|
$urlPath | string | The exact URL path to look up. |
Returns AdminNavigationConfig|null The entry, or null.
HeroContent
AdminConfig::HeroContent(Callable $contentCallback): void
Set the hero content for the admin home page, replacing the default title and intro. Only one hero content is allowed; throws when one is already registered.
| Name | Type | Description |
|---|---|---|
$contentCallback | Callable | The callback that renders the hero content. |
Returns void
Navigation
AdminConfig::Navigation(string $urlPath, string $buttonLabel, string $pageTitle, callable|null $optionalAdminAsideCallback, callable|null $optionalAdminNavigationCallback): void
Define a top-level admin navigation entry. The navigation callback uses the admin routing to define the routes for this section.
| Name | Type | Description |
|---|---|---|
$urlPath | string | The URL path of the entry. |
$buttonLabel | string | The menu button label. |
$pageTitle | string | The page title. |
$optionalAdminAsideCallback | callable|null | An optional callback rendering the aside, or null. |
$optionalAdminNavigationCallback | callable|null | An optional callback defining the section routes, or null. |
Returns void
Panel
AdminConfig::Panel(string $title, Callable $contentCallback): void
Add a module panel to the admin home page.
| Name | Type | Description |
|---|---|---|
$title | string | The panel title. |
$contentCallback | Callable | The callback that renders the panel content. |
Returns void
Section
AdminConfig::Section(string $buttonLabel, string $urlName, callable|null $routeCallback): void
Register a top-level admin section. The route callback defines the routing for this section.
| Name | Type | Description |
|---|---|---|
$buttonLabel | string | The menu button label. |
$urlName | string | The URL name segment of the section. |
$routeCallback | callable|null | The callback defining the section routes, or null. |
Returns void
Workflow
AdminConfig::Workflow(string $title, Callable $contentCallback): void
Add a workflow panel to the admin home page.
| Name | Type | Description |
|---|---|---|
$title | string | The panel title. |
$contentCallback | Callable | The callback that renders the workflow content. |
Returns void
AdminGroupData
One admin group row. A group can be marked as a superuser group, whose members bypass all permission checks.
Properties
| Name | Type | Description |
|---|---|---|
$id | int | The group id. |
$name | string | The group name. |
$isSuperuser | bool | Whether members bypass all permission checks. |
$added | CalendarDateTimeData | When the group was added. |
__construct
AdminGroupData::__construct(int $id = 0, string $name = "", bool $isSuperuser = false, CalendarDateTimeData $added = new CalendarDateTimeData())
Construct an admin group data object.
| Name | Type | Description |
|---|---|---|
$id | int | The group id. |
$name | string | The group name. |
$isSuperuser | bool | Whether members bypass all permission checks. |
$added | CalendarDateTimeData | When the group was added. |
AdminGroupDatabase
Read and write admin groups, and count and list the users in a group.
Add
AdminGroupDatabase::Add(string $name, bool $isSuperuser): int
Insert a new group and return its new id.
| Name | Type | Description |
|---|---|---|
$name | string | The group name. |
$isSuperuser | bool | Whether this is a superuser group. |
Returns int The new group id.
Count
AdminGroupDatabase::Count(): int
The total number of admin groups.
Returns int The group count.
CountMembers
AdminGroupDatabase::CountMembers(int $adminGroupId): int
How many users are in a group.
| Name | Type | Description |
|---|---|---|
$adminGroupId | int | The group id. |
Returns int The member count.
GetById
AdminGroupDatabase::GetById(int $adminGroupId): AdminGroupData
Read a group by id.
| Name | Type | Description |
|---|---|---|
$adminGroupId | int | The group id. |
Returns AdminGroupData The group.
GetMaxId
AdminGroupDatabase::GetMaxId(): int
The maximum group id, for prev/next navigation.
Returns int The maximum id, or 0 when there are no groups.
GetOptionalById
AdminGroupDatabase::GetOptionalById(int $adminGroupId): AdminGroupData|null
Read a group by id, or null when there is no match.
| Name | Type | Description |
|---|---|---|
$adminGroupId | int | The group id. |
Returns AdminGroupData|null The group, or null.
GetUsersInGroup
AdminGroupDatabase::GetUsersInGroup(int $adminGroupId): array
All users in a group, ordered by login.
| Name | Type | Description |
|---|---|---|
$adminGroupId | int | The group id. |
Returns array A list of AdminUserData.
List
AdminGroupDatabase::List(int $pagenum = 1, int $perpage = 50): array
A page of groups, ordered by id.
| Name | Type | Description |
|---|---|---|
$pagenum | int | The 1-based page number. |
$perpage | int | The number of groups per page. |
Returns array A list of AdminGroupData.
ListAll
AdminGroupDatabase::ListAll(): array
Every group, ordered by id.
Returns array A list of AdminGroupData.
AdminGroupPermissionData
One permission row for a group: a module and a path within it, with a level (0 none, 1 read, 2 write).
Properties
| Name | Type | Description |
|---|---|---|
$id | int | The permission row id. |
$groupId | int | The group the permission belongs to. |
$moduleName | string | The module (tab) the permission targets. |
$path | string | '' for the whole tab, otherwise a path starting with '/' and no trailing slash. |
$level | int | 0 none, 1 read, 2 write. |
__construct
AdminGroupPermissionData::__construct(int $id = 0, int $groupId = 0, string $moduleName = "", string $path = "", int $level = 0)
Construct an admin group permission data object.
| Name | Type | Description |
|---|---|---|
$id | int | The permission row id. |
$groupId | int | The group the permission belongs to. |
$moduleName | string | The module (tab) the permission targets. |
$path | string | '' for the whole tab, otherwise a path starting with '/'. |
$level | int | 0 none, 1 read, 2 write. |
AdminGroupPermissionDatabase
Storage and combined lookup for group permissions. It folds every permission from every group a user is in into a single per-request cached lookup table keyed by full path, recording the highest level granted.
ClearCache
AdminGroupPermissionDatabase::ClearCache(): void
Clear the static lookup cache; call after changing permissions in the same request.
Returns void
CountAll
AdminGroupPermissionDatabase::CountAll(int $filteredGroupId, string $filteredModuleName, int $filteredLevel): int
Count permission rows with the same optional filters as ListAll.
| Name | Type | Description |
|---|---|---|
$filteredGroupId | int | 0 for any group. |
$filteredModuleName | string | '' for any module. |
$filteredLevel | int | -1 for any level, or 0/1/2 for an exact level. |
Returns int The matching row count.
CountForGroup
AdminGroupPermissionDatabase::CountForGroup(int $groupId): int
Count the permission rows for a single group.
| Name | Type | Description |
|---|---|---|
$groupId | int | The group id. |
Returns int The row count.
GetForGroup
AdminGroupPermissionDatabase::GetForGroup(int $groupId): array
All permission rows for a single group, ordered by module then path.
| Name | Type | Description |
|---|---|---|
$groupId | int | The group id. |
Returns array A list of AdminGroupPermissionData.
GetOptionalById
AdminGroupPermissionDatabase::GetOptionalById(int $id): AdminGroupPermissionData|null
A single permission row by its primary key, or null when there is no match.
| Name | Type | Description |
|---|---|---|
$id | int | The permission row id. |
Returns AdminGroupPermissionData|null The row, or null.
GetRowsForGroups
AdminGroupPermissionDatabase::GetRowsForGroups(array $groupIds): array
Every permission row for the given groups, in a single query.
| Name | Type | Description |
|---|---|---|
$groupIds | array | A list of group ids. |
Returns array A list of AdminGroupPermissionData.
ListAll
AdminGroupPermissionDatabase::ListAll(int $filteredGroupId, string $filteredModuleName, int $filteredLevel, int $page, int $perPage): array
A page of permission rows with optional filters, joined to the group name.
| Name | Type | Description |
|---|---|---|
$filteredGroupId | int | 0 for any group. |
$filteredModuleName | string | '' for any module. |
$filteredLevel | int | -1 for any level, or 0/1/2 for an exact level. |
$page | int | The 1-based page number. |
$perPage | int | The number of rows per page. |
Returns array Raw rows including the group name.
LookupForCurrentUser
AdminGroupPermissionDatabase::LookupForCurrentUser(): array
Load once, cache, and fold all the current user's group permissions into a single lookup table keyed by full path (module plus path), holding the highest level granted.
Returns array A map of full path to highest level.
Remove
AdminGroupPermissionDatabase::Remove(int $groupId, string $moduleName, string $path): void
Remove the permission row for an exact group, module and path.
| Name | Type | Description |
|---|---|---|
$groupId | int | The group id. |
$moduleName | string | The module name. |
$path | string | The path within the module. |
Returns void
SetLevel
AdminGroupPermissionDatabase::SetLevel(int $groupId, string $moduleName, string $path, int $level): void
Insert or update the permission level for a group's module and path.
| Name | Type | Description |
|---|---|---|
$groupId | int | The group id. |
$moduleName | string | The module name. |
$path | string | '' or a path starting with '/' and not ending with '/'. |
$level | int | 0 none, 1 read, 2 write. |
Returns void
ValidatePath
AdminGroupPermissionDatabase::ValidatePath(string $path): void
Validate a module-relative path: blank, or starting with '/' and not ending with '/'. Throws when invalid.
| Name | Type | Description |
|---|---|---|
$path | string | The path to validate. |
Returns void
AdminGroupPermissionUrl
Build the URLs of the permission admin pages.
Add
AdminGroupPermissionUrl::Add(): string
The URL of the add-permission page.
Returns string The URL.
List
AdminGroupPermissionUrl::List(): string
The URL of the permission list page.
Returns string The URL.
Reference
AdminGroupPermissionUrl::Reference(): string
The URL of the permission reference page.
Returns string The URL.
Remove
AdminGroupPermissionUrl::Remove(int $adminGroupPermissionId): string
The URL of the remove-permission page for a permission row.
| Name | Type | Description |
|---|---|---|
$adminGroupPermissionId | int | The permission row id. |
Returns string The URL.
View
AdminGroupPermissionUrl::View(int $adminGroupPermissionId): string
The URL of the view-permission page for a permission row.
| Name | Type | Description |
|---|---|---|
$adminGroupPermissionId | int | The permission row id. |
Returns string The URL.
AdminGroupUrl
Build the URLs of the group admin pages.
Add
AdminGroupUrl::Add()
The URL of the add-group page.
Returns The URL.
List
AdminGroupUrl::List()
The URL of the group list page.
Returns The URL.
View
AdminGroupUrl::View($adminGroupId)
The URL of the view-group page for a group.
| Name | Type | Description |
|---|---|---|
$adminGroupId | mixed | The group id. |
Returns The URL.
AdminGroupUserDatabase
Read and write which users belong to which groups, and check superuser membership.
AddUserToGroup
AdminGroupUserDatabase::AddUserToGroup(int $adminGroupId, int $adminUserId): void
Add a user to a group, doing nothing when the user is already a member.
| Name | Type | Description |
|---|---|---|
$adminGroupId | int | The group id. |
$adminUserId | int | The user id. |
Returns void
CountAll
AdminGroupUserDatabase::CountAll(int $filteredGroupId, int $filteredUserId): int
Count group-user associations with optional group and user filters.
| Name | Type | Description |
|---|---|---|
$filteredGroupId | int | 0 for any group. |
$filteredUserId | int | 0 for any user. |
Returns int The matching count.
CountGroupsForUser
AdminGroupUserDatabase::CountGroupsForUser(int $adminUserId): int
How many groups a user belongs to.
| Name | Type | Description |
|---|---|---|
$adminUserId | int | The user id. |
Returns int The group count.
CountUsersInGroup
AdminGroupUserDatabase::CountUsersInGroup(int $adminGroupId): int
How many users are in a group.
| Name | Type | Description |
|---|---|---|
$adminGroupId | int | The group id. |
Returns int The user count.
GetGroupIdsForUser
AdminGroupUserDatabase::GetGroupIdsForUser(int $adminUserId): array
The ids of the groups a user belongs to.
| Name | Type | Description |
|---|---|---|
$adminUserId | int | The user id. |
Returns array A list of group ids.
GetGroupsForUser
AdminGroupUserDatabase::GetGroupsForUser(int $adminUserId): array
The groups a user belongs to, ordered by name.
| Name | Type | Description |
|---|---|---|
$adminUserId | int | The user id. |
Returns array A list of AdminGroupData.
GetOptional
AdminGroupUserDatabase::GetOptional(int $adminGroupId, int $adminUserId): ?object
A single group-user record joined to the group and user, or null when there is no match.
| Name | Type | Description |
|---|---|---|
$adminGroupId | int | The group id. |
$adminUserId | int | The user id. |
Returns ?object The record, or null.
GetUsersForGroup
AdminGroupUserDatabase::GetUsersForGroup(int $adminGroupId): array
The users in a group, ordered by login.
| Name | Type | Description |
|---|---|---|
$adminGroupId | int | The group id. |
Returns array A list of AdminUserData.
IsUserSuperuser
AdminGroupUserDatabase::IsUserSuperuser(int $adminUserId): bool
Whether a user is in any superuser group.
| Name | Type | Description |
|---|---|---|
$adminUserId | int | The user id. |
Returns bool True when the user is a superuser.
ListAll
AdminGroupUserDatabase::ListAll(int $filteredGroupId, int $filteredUserId, int $page, int $perPage): array
A page of group-user associations with optional filters, joined to the group name, user login and email.
| Name | Type | Description |
|---|---|---|
$filteredGroupId | int | 0 for any group. |
$filteredUserId | int | 0 for any user. |
$page | int | The 1-based page number. |
$perPage | int | The number of rows per page. |
Returns array Raw rows including the group name, user login and email.
RemoveUserFromGroup
AdminGroupUserDatabase::RemoveUserFromGroup(int $adminGroupId, int $adminUserId): void
Remove a user from a group.
| Name | Type | Description |
|---|---|---|
$adminGroupId | int | The group id. |
$adminUserId | int | The user id. |
Returns void
SetGroupUsers
AdminGroupUserDatabase::SetGroupUsers(int $adminGroupId, array $userIds): void
Replace a group's user memberships with the given user ids.
| Name | Type | Description |
|---|---|---|
$adminGroupId | int | The group id. |
$userIds | array | The user ids to set as members. |
Returns void
SetUserGroups
AdminGroupUserDatabase::SetUserGroups(int $adminUserId, array $groupIds): void
Replace a user's group memberships with the given group ids.
| Name | Type | Description |
|---|---|---|
$adminUserId | int | The user id. |
$groupIds | array | The group ids to set the user in. |
Returns void
AdminGroupUserUrl
Build the URLs of the group-user admin pages.
Add
AdminGroupUserUrl::Add(): string
The URL of the add-group-user page.
Returns string The URL.
List
AdminGroupUserUrl::List(): string
The URL of the group-user list page.
Returns string The URL.
Remove
AdminGroupUserUrl::Remove(int $adminGroupId, int $adminUserId): string
The URL of the remove-group-user page for a membership.
| Name | Type | Description |
|---|---|---|
$adminGroupId | int | The group id. |
$adminUserId | int | The user id. |
Returns string The URL.
View
AdminGroupUserUrl::View(int $adminGroupId, int $adminUserId): string
The URL of the view-group-user page for a membership.
| Name | Type | Description |
|---|---|---|
$adminGroupId | int | The group id. |
$adminUserId | int | The user id. |
Returns string The URL.
AdminNavigation
Unified routing and menu generation for admin sections. A single declaration builds both the menu and the routes: routes with labels appear in the menu, routes without labels are hidden but reachable, and every node is gated by the current user's permissions.
CurrentPathPrefix
AdminNavigation::CurrentPathPrefix(): string
The current admin path prefix (e.g. '/messaging'), or '' at the admin root.
Returns string The current path prefix.
Dir
AdminNavigation::Dir(string $name, ?string $label, callable $callback): void
Define a directory route that can contain sub-routes. A null label hides it from the menu while keeping it reachable.
| Name | Type | Description |
|---|---|---|
$name | string | The URL segment name. |
$label | ?string | The menu label, or null to hide from the menu. |
$callback | callable | The route callback. |
Returns void
Enumerate
AdminNavigation::Enumerate(string $sectionName, callable $sectionCallback): array
Enumerate all routes a section declares, without rendering it: runs the section callback in enumerate mode so Dir and File record their path and label instead of rendering UI or registering routes.
| Name | Type | Description |
|---|---|---|
$sectionName | string | The section URL segment. |
$sectionCallback | callable | The section callback. |
Returns array A list of routes, each with path, label, hidden and type.
File
AdminNavigation::File(string $name, ?string $label, callable $callback, ...$args): void
Define a terminal file route with no sub-routes. A null label hides it from the menu while keeping it reachable.
| Name | Type | Description |
|---|---|---|
$name | string | The URL segment name. |
$label | ?string | The menu label, or null to hide from the menu. |
$callback | callable | The page callback. |
...$args | mixed | Additional arguments passed to the callback. |
Returns void
Integer
AdminNavigation::Integer(callable $callback, ...$args): void
Define an integer parameter route. Integer routes do not appear in menus.
| Name | Type | Description |
|---|---|---|
$callback | callable | The callback that receives the integer value. |
...$args | mixed | Additional arguments passed to the callback. |
Returns void
Section
AdminNavigation::Section(string $title, callable $routesCallback): void
Create a navigation section with a header, menu and routes. The routes callback defines the routes using Dir, File and the other route methods.
| Name | Type | Description |
|---|---|---|
$title | string | The section title shown in the header. |
$routesCallback | callable | The callback that defines the routes. |
Returns void
ViewSection
AdminNavigation::ViewSection(string $title, int $maxId, string $baseUrl, string $asideLabel, callable $contentCallback): void
A view section with prev/next navigation: a header with prev/next controls over an id range, and an integer route that renders the content for the selected id.
| Name | Type | Description |
|---|---|---|
$title | string | The section title. |
$maxId | int | The maximum id for navigation. |
$baseUrl | string | The full base URL for navigation links. |
$asideLabel | string | The label for the aside. |
$contentCallback | callable | The callback that receives the id and renders content. |
Returns void
WithPathPrefix
AdminNavigation::WithPathPrefix(string $segment, callable $callback): void
Run a callback with the navigation path prefix extended by a segment. Used to build menu paths and permission targets without touching the admin link base.
| Name | Type | Description |
|---|---|---|
$segment | string | The path segment to append. |
$callback | callable | The work to run within the extended prefix. |
Returns void
AdminNavigationButtonUi
Permission-aware buttons and links for admin pages. Use these instead of the plain UI button when linking to another admin page: the control is hidden when the current user cannot see the destination.
Button
AdminNavigationButtonUi::Button(string $url, string $label): void
Render a button, only when the current user can see the destination URL.
| Name | Type | Description |
|---|---|---|
$url | string | The destination URL. |
$label | string | The button label. |
Returns void
Link
AdminNavigationButtonUi::Link(string $url, string $label): void
Render a link, only when the current user can see the destination URL.
| Name | Type | Description |
|---|---|---|
$url | string | The destination URL. |
$label | string | The link label. |
Returns void
PathFromUrl
AdminNavigationButtonUi::PathFromUrl(string $url): string
Extract the URL path (including any query string) from a full URL or path string.
| Name | Type | Description |
|---|---|---|
$url | string | A full URL or a path. |
Returns string The URL path, with an optional query string.
AdminNavigationConfig
A registered top-level navigation entry: a URL path, button label and page title, with optional aside and navigation callbacks.
Properties
| Name | Type | Description |
|---|---|---|
$urlPath | string | The URL path of the entry. |
$buttonLabel | string | The menu button label. |
$pageTitle | string | The page title. |
$optionalAdminAsideCallback | mixed | An optional aside callback, or null. |
$optionalAdminNavigationCallback | mixed | An optional navigation callback, or null. |
__construct
AdminNavigationConfig::__construct(string $urlPath, string $buttonLabel, string $pageTitle, mixed $optionalAdminAsideCallback, mixed $optionalAdminNavigationCallback)
Construct a navigation entry; the callbacks may be null.
| Name | Type | Description |
|---|---|---|
$urlPath | string | The URL path of the entry. |
$buttonLabel | string | The menu button label. |
$pageTitle | string | The page title. |
$optionalAdminAsideCallback | mixed | An optional aside callback, or null. |
$optionalAdminNavigationCallback | mixed | An optional navigation callback, or null. |
AdminNavigationUi
The admin route trees for logged-in and not-logged-in visitors, and the permission checks that decide which top-level tabs are visible.
CanSeeSection
AdminNavigationUi::CanSeeSection(stdClass $section): bool
Whether the current user can see a top-level admin section (tab). The System section is a menu grouping and is shown when any module inside it is visible.
| Name | Type | Description |
|---|---|---|
$section | stdClass | A registered section with a urlName and buttonLabel. |
Returns bool True when the section is visible.
CanSeeSystemGroup
AdminNavigationUi::CanSeeSystemGroup(): bool
Whether the System tab is visible: true for superusers, or when at least one module registered inside the System menu is visible to the current user.
Returns bool True when the System tab is visible.
LoggedIn
AdminNavigationUi::LoggedIn(): void
Render the routing and pages for a logged-in admin: the home page, the registered sections and navigations (filtered by permission), logout, and a 404 handler.
Returns void
NotLoggedIn
AdminNavigationUi::NotLoggedIn(): void
Render the routing and pages for a visitor who is not logged in: the login page and login action, with everything else redirecting to the login.
Returns void
AdminPageUi
Reusable admin page layouts built on the UI library.
SimpleList
AdminPageUi::SimpleList(string $title, int $page, int $per_page_limit, string $baseUrl, array $columnNames, callable $countCallback, callable $listCallback, callable $rowCellsCallback): void
Render a titled, paged list page: a status message, a paging bar, and a table whose rows are produced by the callbacks.
| Name | Type | Description |
|---|---|---|
$title | string | The page title. |
$page | int | The 1-based page number. |
$per_page_limit | int | The number of rows per page. |
$baseUrl | string | The admin-relative base URL for paging links. |
$columnNames | array | The table column headers. |
$countCallback | callable | Returns the total row count. |
$listCallback | callable | Returns the items for a page. |
$rowCellsCallback | callable | Renders the cells for one item. |
Returns void
AdminPermission
Permission checks for admin navigation. A target is a (module, path) pair, exactly as rows are stored. Levels are NONE (0) hidden, READ (1) view only, WRITE (2) full; superusers bypass all checks.
Constants
| Constant | Value | Description |
|---|---|---|
AdminPermission::PERMISSION_NONE | 0 | No access; hidden. |
AdminPermission::PERMISSION_READ | 1 | View only. |
AdminPermission::PERMISSION_WRITE | 2 | Full access. |
CanSeeTab
AdminPermission::CanSeeTab(string $module, string $tabPath): bool
Whether the current user can see a tab path. Superusers see everything; otherwise the tab is visible when the user has an inherited permission at the path, or any permission anywhere inside it.
| Name | Type | Description |
|---|---|---|
$module | string | The module (tab) url name. |
$tabPath | string | '' for the whole tab, otherwise '/section/page'. |
Returns bool True when the tab is visible.
CurrentModuleName
AdminPermission::CurrentModuleName(): string
The module currently being rendered, or '' when none has been entered.
Returns string The current module name.
EnterModule
AdminPermission::EnterModule(string $moduleName, string $moduleBasePath, callable $callback): void
Run a callback with the current permission module set, so every deeper check knows which module it is in. The module and its base path are restored afterwards.
| Name | Type | Description |
|---|---|---|
$moduleName | string | The module (tab) url name. |
$moduleBasePath | string | The admin URL base path of the module. |
$callback | callable | The work to run within this module scope. |
Returns void
HasModule
AdminPermission::HasModule(): bool
Whether a module has been entered, so checks can use the injected module instead of parsing the URL.
Returns bool True when a module has been entered.
IsSuperuser
AdminPermission::IsSuperuser(): bool
Whether the current user is in any superuser group; false when nobody is logged in.
Returns bool True when the user is a superuser.
PathWithinModule
AdminPermission::PathWithinModule(string $fullPath): string
Turn a full admin URL path into the path within the current module: '' for the module root, otherwise '/section/page'. Numeric id segments are dropped; returns '' when the path is not inside the current module.
| Name | Type | Description |
|---|---|---|
$fullPath | string | The full admin URL path. |
Returns string The path within the module.
TargetForUrl
AdminPermission::TargetForUrl(string $urlPath): AdminPermissionTargetData
Split a full admin URL path into its (module, path) permission target, dropping numeric id segments and treating a leading 'system' as a menu grouping.
| Name | Type | Description |
|---|---|---|
$urlPath | string | The full admin URL path. |
Returns AdminPermissionTargetData The permission target.
AdminPermissionTargetData
A permission target: a module and a path within it, mirroring how rows are stored so the module is always kept separate from the path.
Properties
| Name | Type | Description |
|---|---|---|
$moduleName | string | The module (tab) url name; '' for the admin root. |
$path | string | '' for the whole module, otherwise '/section/page'. |
__construct
AdminPermissionTargetData::__construct(string $moduleName = "", string $path = "")
Construct a permission target data object.
| Name | Type | Description |
|---|---|---|
$moduleName | string | The module (tab) url name. |
$path | string | The path within the module. |
AdminSecurity
Guard admin code behind a logged-in check.
LoggedIn
AdminSecurity::LoggedIn(): void
Fail unless an admin user is logged in.
Returns void
AdminSession
The logged-in admin user session, stored in the session under a fixed key.
GetLoggedInId
AdminSession::GetLoggedInId(): int
The logged-in admin user id, or 0 when nobody is logged in.
Returns int The admin user id, or 0.
IsLoggedIn
AdminSession::IsLoggedIn(): bool
Whether an admin user is logged in.
Returns bool True when logged in.
Login
AdminSession::Login(int $adminUserId): void
Record an admin user as logged in.
| Name | Type | Description |
|---|---|---|
$adminUserId | int | The admin user id to log in. |
Returns void
Logout
AdminSession::Logout(): void
Clear the logged-in admin user from the session.
Returns void
AdminThemeConfig
Recolour the admin system to match a site's brand. A site supplies only the base colour tokens through the grouped methods below; the module recomputes every derived shade and emits an inline style block with only the tokens that differ from the default silver palette. Colours must be hex.
Aside
AdminThemeConfig::Aside(?string $background = null, ?string $text = null): void
Set the colours of the aside info block in the navigation.
| Name | Type | Description |
|---|---|---|
$background | ?string | The aside background, or null to leave the default. |
$text | ?string | The aside text colour, or null to leave the default. |
Returns void
Content
AdminThemeConfig::Content(?string $main = null, ?string $secondary = null, ?string $button = null, ?string $buttonText = null, ?string $text = null, ?string $background = null): void
Set the colours of the main content area: tables, menus, forms, cards and inputs. main is the primary accent and secondary the quieter one.
| Name | Type | Description |
|---|---|---|
$main | ?string | The primary content accent, or null. |
$secondary | ?string | The secondary content accent, or null. |
$button | ?string | The content button colour, or null. |
$buttonText | ?string | The content button text colour, or null. |
$text | ?string | The content text colour, or null. |
$background | ?string | The content background, or null. |
Returns void
derive
AdminThemeConfig::derive(array $base): array
Given a full set of resolved base tokens, return them plus every derived shade, all as hex. This is the single source of truth for the derivations.
| Name | Type | Description |
|---|---|---|
$base | array | The resolved base tokens, keyed by CSS variable name. |
Returns array The base tokens plus every derived shade.
Navigation
AdminThemeConfig::Navigation(?string $gradientStart = null, ?string $gradientEnd = null, ?string $text = null, ?string $buttonStart = null, ?string $buttonEnd = null, ?string $buttonText = null, ?string $titleStart = null, ?string $titleEnd = null): void
Set the colours of the navigation chrome: the header and footer bars and their buttons. titleStart and titleEnd colour the section-header titles as their own gradient across nesting depth.
| Name | Type | Description |
|---|---|---|
$gradientStart | ?string | The bar gradient start, or null. |
$gradientEnd | ?string | The bar gradient end, or null. |
$text | ?string | The bar text colour, or null. |
$buttonStart | ?string | The button gradient start, or null. |
$buttonEnd | ?string | The button gradient end, or null. |
$buttonText | ?string | The button text colour, or null. |
$titleStart | ?string | The shallowest section-title colour, or null. |
$titleEnd | ?string | The deepest section-title colour, or null. |
Returns void
RenderStyle
AdminThemeConfig::RenderStyle(): void
Emit the site's overrides as an inline :root style block, to be called in the page head after the linked stylesheet. Emits nothing when the site set no overrides.
Returns void
Status
AdminThemeConfig::Status(?string $success = null, ?string $error = null, ?string $info = null): void
Set the semantic status colours. These have sensible fixed defaults and normally do not need overriding.
| Name | Type | Description |
|---|---|---|
$success | ?string | The success colour, or null. |
$error | ?string | The error colour, or null. |
$info | ?string | The info colour, or null. |
Returns void
AdminUi
The built-in admin pages (home, login, 404 and the user-info aside) and a self-highlighting menu link that detects whether it points at the current route.
ErrorPage
AdminUi::ErrorPage(): void
Render the 404 page for admin routes that do not exist.
Returns void
HomePage
AdminUi::HomePage(): void
Render the admin home page: the hero or default intro, plus the registered workflow and module panels.
Returns void
Link
AdminUi::Link(string $buttonLabel, string $urlPath): void
Render an admin menu link with automatic selection detection: the link is highlighted when its path matches the current route path or an ancestor of it.
| Name | Type | Description |
|---|---|---|
$buttonLabel | string | The link label. |
$urlPath | string | The full admin URL path. |
Returns void
LoginPage
AdminUi::LoginPage()
Render the admin login page with the login form.
Returns The page is rendered directly.
UserInfo
AdminUi::UserInfo(): void
Render the user-info aside shown in the top-level admin menu: the logged-in user's login and site and log-out buttons.
Returns void
AdminUrl
Build the login and logout action URLs.
LoginAction
AdminUrl::LoginAction()
The URL of the login action.
Returns The URL.
LogoutAction
AdminUrl::LogoutAction()
The URL of the logout action.
Returns The URL.
AdminUserData
One admin user row, including the bcrypt password hash.
Properties
| Name | Type | Description |
|---|---|---|
$id | int | The user id. |
$login | string | The login name. |
$email | string | The email address. |
$passwordHashed | string | The bcrypt password hash. |
$added | CalendarDateTimeData | When the user was added. |
__construct
AdminUserData::__construct(int $id = 0, string $login = "", string $email = "", string $passwordHashed = "", CalendarDateTimeData $added = new CalendarDateTimeData())
Construct an admin user data object.
| Name | Type | Description |
|---|---|---|
$id | int | The user id. |
$login | string | The login name. |
$email | string | The email address. |
$passwordHashed | string | The bcrypt password hash. |
$added | CalendarDateTimeData | When the user was added. |
AdminUserDatabase
Read and write admin users, verify a login, and look up users in bulk.
Add
AdminUserDatabase::Add(string $login, string $email, string $password): int
Insert a new admin user with a bcrypt-hashed password and return the new id.
| Name | Type | Description |
|---|---|---|
$login | string | The login name. |
$email | string | The email address. |
$password | string | The plaintext password to hash and store. |
Returns int The new user id.
Count
AdminUserDatabase::Count(int $adminId, string $adminLogin, string $adminEmail): int
Count admin users, optionally filtered by id, login or email.
| Name | Type | Description |
|---|---|---|
$adminId | int | 0 for any id. |
$adminLogin | string | '' for any login. |
$adminEmail | string | '' for any email. |
Returns int The matching count.
Delete
AdminUserDatabase::Delete(int $adminUserId): void
Delete an admin user.
| Name | Type | Description |
|---|---|---|
$adminUserId | int | The user id. |
Returns void
GetById
AdminUserDatabase::GetById(int $adminUserId): AdminUserData
Read an admin user by id.
| Name | Type | Description |
|---|---|---|
$adminUserId | int | The user id. |
Returns AdminUserData The user.
GetMaxId
AdminUserDatabase::GetMaxId(): int
The maximum user id, for prev/next view navigation.
Returns int The maximum id, or 0 when there are no users.
GetOptionalById
AdminUserDatabase::GetOptionalById(int $adminUserId): AdminUserData|null
Read an admin user by id, or null when there is no match.
| Name | Type | Description |
|---|---|---|
$adminUserId | int | The user id. |
Returns AdminUserData|null The user, or null.
List
AdminUserDatabase::List(int $adminId, string $adminLogin, string $adminEmail, int $pagenum, int $perpage): array
A page of admin users, optionally filtered by id, login or email, ordered by id descending.
| Name | Type | Description |
|---|---|---|
$adminId | int | 0 for any id. |
$adminLogin | string | '' for any login. |
$adminEmail | string | '' for any email. |
$pagenum | int | The 1-based page number. |
$perpage | int | The number of users per page. |
Returns array A list of AdminUserData.
ListAll
AdminUserDatabase::ListAll(): array
Every admin user, ordered by login.
Returns array A list of AdminUserData.
Login
AdminUserDatabase::Login(string $login, string $password): AdminUserData
Verify a login and password, returning the user on success and throwing when they do not match.
| Name | Type | Description |
|---|---|---|
$login | string | The login name. |
$password | string | The plaintext password to verify. |
Returns AdminUserData The verified user.
SetPassword
AdminUserDatabase::SetPassword(int $adminUserId, string $password): void
Set a new bcrypt-hashed password for an admin user.
| Name | Type | Description |
|---|---|---|
$adminUserId | int | The user id. |
$password | string | The new plaintext password to hash and store. |
Returns void
Update
AdminUserDatabase::Update(int $adminUserId, string $login, string $email): void
Update an admin user's login and email.
| Name | Type | Description |
|---|---|---|
$adminUserId | int | The user id. |
$login | string | The new login name. |
$email | string | The new email address. |
Returns void
UserNamesByIDs
AdminUserDatabase::UserNamesByIDs(array $adminUserIds): array
Look up user emails in bulk by their ids.
| Name | Type | Description |
|---|---|---|
$adminUserIds | array | A list of admin user ids. |
Returns array A map of admin user id to email.
AdminUserUrl
Build the URLs of the user admin pages.
Add
AdminUserUrl::Add()
The URL of the add-user page.
Returns The URL.
Delete
AdminUserUrl::Delete($adminUserId)
The URL of the delete-user page for a user.
| Name | Type | Description |
|---|---|---|
$adminUserId | mixed | The user id. |
Returns The URL.
Edit
AdminUserUrl::Edit($adminUserId)
The URL of the edit-user page for a user.
| Name | Type | Description |
|---|---|---|
$adminUserId | mixed | The user id. |
Returns The URL.
List
AdminUserUrl::List()
The URL of the user list page.
Returns The URL.
Password
AdminUserUrl::Password($adminUserId)
The URL of the change-password page for a user.
| Name | Type | Description |
|---|---|---|
$adminUserId | mixed | The user id. |
Returns The URL.
Switch
AdminUserUrl::Switch($adminUserId)
The URL of the switch-user page for a user.
| Name | Type | Description |
|---|---|---|
$adminUserId | mixed | The user id. |
Returns The URL.
View
AdminUserUrl::View($adminUserId = null)
The URL of the view-user page, for a specific user or the default view.
| Name | Type | Description |
|---|---|---|
$adminUserId | mixed | The user id, or null for the default view. |
Returns The URL.