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.

Classes

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.

NameTypeDescription
$contentCallableThe callback that renders the page body.

Returns void

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.

NameTypeDescription
$pathstringThe 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.

NameTypeDescription
$basePathstringThe path segment to append to the base.
$callbackCallableThe work to run within the extended base.

Returns void

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.

NameTypeDescription
$pathstringThe 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.

NameTypeDescription
$pathstringThe 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.

Functions

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.

NameTypeDescription
$urlPathstringThe parent URL path to match entries under.
$callbackcallableCalled 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.

NameTypeDescription
$urlPathstringThe 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.

NameTypeDescription
$contentCallbackCallableThe 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.

NameTypeDescription
$urlPathstringThe URL path of the entry.
$buttonLabelstringThe menu button label.
$pageTitlestringThe page title.
$optionalAdminAsideCallbackcallable|nullAn optional callback rendering the aside, or null.
$optionalAdminNavigationCallbackcallable|nullAn 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.

NameTypeDescription
$titlestringThe panel title.
$contentCallbackCallableThe 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.

NameTypeDescription
$buttonLabelstringThe menu button label.
$urlNamestringThe URL name segment of the section.
$routeCallbackcallable|nullThe 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.

NameTypeDescription
$titlestringThe panel title.
$contentCallbackCallableThe 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

NameTypeDescription
$idintThe group id.
$namestringThe group name.
$isSuperuserboolWhether members bypass all permission checks.
$addedCalendarDateTimeDataWhen the group was added.
Functions

__construct

AdminGroupData::__construct(int $id = 0, string $name = "", bool $isSuperuser = false, CalendarDateTimeData $added = new CalendarDateTimeData())

Construct an admin group data object.

NameTypeDescription
$idintThe group id.
$namestringThe group name.
$isSuperuserboolWhether members bypass all permission checks.
$addedCalendarDateTimeDataWhen 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.

NameTypeDescription
$namestringThe group name.
$isSuperuserboolWhether 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.

NameTypeDescription
$adminGroupIdintThe group id.

Returns int The member count.

GetById

AdminGroupDatabase::GetById(int $adminGroupId): AdminGroupData

Read a group by id.

NameTypeDescription
$adminGroupIdintThe 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.

NameTypeDescription
$adminGroupIdintThe group id.

Returns AdminGroupData|null The group, or null.

GetUsersInGroup

AdminGroupDatabase::GetUsersInGroup(int $adminGroupId): array

All users in a group, ordered by login.

NameTypeDescription
$adminGroupIdintThe 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.

NameTypeDescription
$pagenumintThe 1-based page number.
$perpageintThe 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

NameTypeDescription
$idintThe permission row id.
$groupIdintThe group the permission belongs to.
$moduleNamestringThe module (tab) the permission targets.
$pathstring'' for the whole tab, otherwise a path starting with '/' and no trailing slash.
$levelint0 none, 1 read, 2 write.
Functions

__construct

AdminGroupPermissionData::__construct(int $id = 0, int $groupId = 0, string $moduleName = "", string $path = "", int $level = 0)

Construct an admin group permission data object.

NameTypeDescription
$idintThe permission row id.
$groupIdintThe group the permission belongs to.
$moduleNamestringThe module (tab) the permission targets.
$pathstring'' for the whole tab, otherwise a path starting with '/'.
$levelint0 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.

NameTypeDescription
$filteredGroupIdint0 for any group.
$filteredModuleNamestring'' for any module.
$filteredLevelint-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.

NameTypeDescription
$groupIdintThe 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.

NameTypeDescription
$groupIdintThe 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.

NameTypeDescription
$idintThe 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.

NameTypeDescription
$groupIdsarrayA 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.

NameTypeDescription
$filteredGroupIdint0 for any group.
$filteredModuleNamestring'' for any module.
$filteredLevelint-1 for any level, or 0/1/2 for an exact level.
$pageintThe 1-based page number.
$perPageintThe 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.

NameTypeDescription
$groupIdintThe group id.
$moduleNamestringThe module name.
$pathstringThe 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.

NameTypeDescription
$groupIdintThe group id.
$moduleNamestringThe module name.
$pathstring'' or a path starting with '/' and not ending with '/'.
$levelint0 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.

NameTypeDescription
$pathstringThe 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.

NameTypeDescription
$adminGroupPermissionIdintThe permission row id.

Returns string The URL.

View

AdminGroupPermissionUrl::View(int $adminGroupPermissionId): string

The URL of the view-permission page for a permission row.

NameTypeDescription
$adminGroupPermissionIdintThe permission row id.

Returns string The URL.

AdminGroupUrl

Build the URLs of the group admin pages.

Functions

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.

NameTypeDescription
$adminGroupIdmixedThe 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.

NameTypeDescription
$adminGroupIdintThe group id.
$adminUserIdintThe user id.

Returns void

CountAll

AdminGroupUserDatabase::CountAll(int $filteredGroupId, int $filteredUserId): int

Count group-user associations with optional group and user filters.

NameTypeDescription
$filteredGroupIdint0 for any group.
$filteredUserIdint0 for any user.

Returns int The matching count.

CountGroupsForUser

AdminGroupUserDatabase::CountGroupsForUser(int $adminUserId): int

How many groups a user belongs to.

NameTypeDescription
$adminUserIdintThe user id.

Returns int The group count.

CountUsersInGroup

AdminGroupUserDatabase::CountUsersInGroup(int $adminGroupId): int

How many users are in a group.

NameTypeDescription
$adminGroupIdintThe group id.

Returns int The user count.

GetGroupIdsForUser

AdminGroupUserDatabase::GetGroupIdsForUser(int $adminUserId): array

The ids of the groups a user belongs to.

NameTypeDescription
$adminUserIdintThe user id.

Returns array A list of group ids.

GetGroupsForUser

AdminGroupUserDatabase::GetGroupsForUser(int $adminUserId): array

The groups a user belongs to, ordered by name.

NameTypeDescription
$adminUserIdintThe 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.

NameTypeDescription
$adminGroupIdintThe group id.
$adminUserIdintThe user id.

Returns ?object The record, or null.

GetUsersForGroup

AdminGroupUserDatabase::GetUsersForGroup(int $adminGroupId): array

The users in a group, ordered by login.

NameTypeDescription
$adminGroupIdintThe group id.

Returns array A list of AdminUserData.

IsUserSuperuser

AdminGroupUserDatabase::IsUserSuperuser(int $adminUserId): bool

Whether a user is in any superuser group.

NameTypeDescription
$adminUserIdintThe 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.

NameTypeDescription
$filteredGroupIdint0 for any group.
$filteredUserIdint0 for any user.
$pageintThe 1-based page number.
$perPageintThe 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.

NameTypeDescription
$adminGroupIdintThe group id.
$adminUserIdintThe user id.

Returns void

SetGroupUsers

AdminGroupUserDatabase::SetGroupUsers(int $adminGroupId, array $userIds): void

Replace a group's user memberships with the given user ids.

NameTypeDescription
$adminGroupIdintThe group id.
$userIdsarrayThe 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.

NameTypeDescription
$adminUserIdintThe user id.
$groupIdsarrayThe group ids to set the user in.

Returns void

AdminGroupUserUrl

Build the URLs of the group-user admin pages.

Functions

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.

NameTypeDescription
$adminGroupIdintThe group id.
$adminUserIdintThe 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.

NameTypeDescription
$adminGroupIdintThe group id.
$adminUserIdintThe 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.

NameTypeDescription
$namestringThe URL segment name.
$label?stringThe menu label, or null to hide from the menu.
$callbackcallableThe 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.

NameTypeDescription
$sectionNamestringThe section URL segment.
$sectionCallbackcallableThe 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.

NameTypeDescription
$namestringThe URL segment name.
$label?stringThe menu label, or null to hide from the menu.
$callbackcallableThe page callback.
...$argsmixedAdditional 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.

NameTypeDescription
$callbackcallableThe callback that receives the integer value.
...$argsmixedAdditional 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.

NameTypeDescription
$titlestringThe section title shown in the header.
$routesCallbackcallableThe 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.

NameTypeDescription
$titlestringThe section title.
$maxIdintThe maximum id for navigation.
$baseUrlstringThe full base URL for navigation links.
$asideLabelstringThe label for the aside.
$contentCallbackcallableThe 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.

NameTypeDescription
$segmentstringThe path segment to append.
$callbackcallableThe 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.

Functions

Button

AdminNavigationButtonUi::Button(string $url, string $label): void

Render a button, only when the current user can see the destination URL.

NameTypeDescription
$urlstringThe destination URL.
$labelstringThe button label.

Returns void

AdminNavigationButtonUi::Link(string $url, string $label): void

Render a link, only when the current user can see the destination URL.

NameTypeDescription
$urlstringThe destination URL.
$labelstringThe 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.

NameTypeDescription
$urlstringA 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

NameTypeDescription
$urlPathstringThe URL path of the entry.
$buttonLabelstringThe menu button label.
$pageTitlestringThe page title.
$optionalAdminAsideCallbackmixedAn optional aside callback, or null.
$optionalAdminNavigationCallbackmixedAn optional navigation callback, or null.
Functions

__construct

AdminNavigationConfig::__construct(string $urlPath, string $buttonLabel, string $pageTitle, mixed $optionalAdminAsideCallback, mixed $optionalAdminNavigationCallback)

Construct a navigation entry; the callbacks may be null.

NameTypeDescription
$urlPathstringThe URL path of the entry.
$buttonLabelstringThe menu button label.
$pageTitlestringThe page title.
$optionalAdminAsideCallbackmixedAn optional aside callback, or null.
$optionalAdminNavigationCallbackmixedAn 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.

NameTypeDescription
$sectionstdClassA 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.

Functions

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.

NameTypeDescription
$titlestringThe page title.
$pageintThe 1-based page number.
$per_page_limitintThe number of rows per page.
$baseUrlstringThe admin-relative base URL for paging links.
$columnNamesarrayThe table column headers.
$countCallbackcallableReturns the total row count.
$listCallbackcallableReturns the items for a page.
$rowCellsCallbackcallableRenders 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

ConstantValueDescription
AdminPermission::PERMISSION_NONE0No access; hidden.
AdminPermission::PERMISSION_READ1View only.
AdminPermission::PERMISSION_WRITE2Full 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.

NameTypeDescription
$modulestringThe module (tab) url name.
$tabPathstring'' 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.

NameTypeDescription
$moduleNamestringThe module (tab) url name.
$moduleBasePathstringThe admin URL base path of the module.
$callbackcallableThe 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.

NameTypeDescription
$fullPathstringThe 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.

NameTypeDescription
$urlPathstringThe 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

NameTypeDescription
$moduleNamestringThe module (tab) url name; '' for the admin root.
$pathstring'' for the whole module, otherwise '/section/page'.
Functions

__construct

AdminPermissionTargetData::__construct(string $moduleName = "", string $path = "")

Construct a permission target data object.

NameTypeDescription
$moduleNamestringThe module (tab) url name.
$pathstringThe path within the module.

AdminSecurity

Guard admin code behind a logged-in check.

Functions

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.

NameTypeDescription
$adminUserIdintThe 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.

NameTypeDescription
$background?stringThe aside background, or null to leave the default.
$text?stringThe 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.

NameTypeDescription
$main?stringThe primary content accent, or null.
$secondary?stringThe secondary content accent, or null.
$button?stringThe content button colour, or null.
$buttonText?stringThe content button text colour, or null.
$text?stringThe content text colour, or null.
$background?stringThe 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.

NameTypeDescription
$basearrayThe 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.

NameTypeDescription
$gradientStart?stringThe bar gradient start, or null.
$gradientEnd?stringThe bar gradient end, or null.
$text?stringThe bar text colour, or null.
$buttonStart?stringThe button gradient start, or null.
$buttonEnd?stringThe button gradient end, or null.
$buttonText?stringThe button text colour, or null.
$titleStart?stringThe shallowest section-title colour, or null.
$titleEnd?stringThe 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.

NameTypeDescription
$success?stringThe success colour, or null.
$error?stringThe error colour, or null.
$info?stringThe 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

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.

NameTypeDescription
$buttonLabelstringThe link label.
$urlPathstringThe 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

NameTypeDescription
$idintThe user id.
$loginstringThe login name.
$emailstringThe email address.
$passwordHashedstringThe bcrypt password hash.
$addedCalendarDateTimeDataWhen the user was added.
Functions

__construct

AdminUserData::__construct(int $id = 0, string $login = "", string $email = "", string $passwordHashed = "", CalendarDateTimeData $added = new CalendarDateTimeData())

Construct an admin user data object.

NameTypeDescription
$idintThe user id.
$loginstringThe login name.
$emailstringThe email address.
$passwordHashedstringThe bcrypt password hash.
$addedCalendarDateTimeDataWhen 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.

NameTypeDescription
$loginstringThe login name.
$emailstringThe email address.
$passwordstringThe 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.

NameTypeDescription
$adminIdint0 for any id.
$adminLoginstring'' for any login.
$adminEmailstring'' for any email.

Returns int The matching count.

Delete

AdminUserDatabase::Delete(int $adminUserId): void

Delete an admin user.

NameTypeDescription
$adminUserIdintThe user id.

Returns void

GetById

AdminUserDatabase::GetById(int $adminUserId): AdminUserData

Read an admin user by id.

NameTypeDescription
$adminUserIdintThe 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.

NameTypeDescription
$adminUserIdintThe 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.

NameTypeDescription
$adminIdint0 for any id.
$adminLoginstring'' for any login.
$adminEmailstring'' for any email.
$pagenumintThe 1-based page number.
$perpageintThe 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.

NameTypeDescription
$loginstringThe login name.
$passwordstringThe 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.

NameTypeDescription
$adminUserIdintThe user id.
$passwordstringThe 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.

NameTypeDescription
$adminUserIdintThe user id.
$loginstringThe new login name.
$emailstringThe new email address.

Returns void

UserNamesByIDs

AdminUserDatabase::UserNamesByIDs(array $adminUserIds): array

Look up user emails in bulk by their ids.

NameTypeDescription
$adminUserIdsarrayA 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.

NameTypeDescription
$adminUserIdmixedThe user id.

Returns The URL.

Edit

AdminUserUrl::Edit($adminUserId)

The URL of the edit-user page for a user.

NameTypeDescription
$adminUserIdmixedThe 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.

NameTypeDescription
$adminUserIdmixedThe user id.

Returns The URL.

Switch

AdminUserUrl::Switch($adminUserId)

The URL of the switch-user page for a user.

NameTypeDescription
$adminUserIdmixedThe 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.

NameTypeDescription
$adminUserIdmixedThe user id, or null for the default view.

Returns The URL.