AccessLog

Core\App\AccessLog

File: /home/batoi/rad/core/app/AccessLog.cls.php
Access log reader for applications.
Provides simple, paginated log access (latest-first) with filters.

Arguments (name : type — description):

  • $config : array

Returns:

mixed

Get recent access log entries (latest first).

@param int $limit Number of lines to return
@param string|null $date Optional date folder (YYYY/MM/DD); uses latest log if null
@return array List of log lines

Arguments (name : type — description):

  • $limit : int — Number of lines to return optional default: 50
  • $date : ?string — Optional date folder (YYYY/MM/DD); uses latest log if null optional

Returns:

array — List of log lines

Activity

Core\App\Activity

File: /home/batoi/rad/core/app/Activity.cls.php
Activity log reader for applications.
Fetches recent activity (from s_activity if present) or returns empty when table missing.

Usage in a route (rad/ms/{ms}/route.{id}.php):


$activity = new \Core\App\Activity($db);
$activity->logRoute([
'route_id' => 12, // or 'route_uid' => '...'
'action' => 'invoke', // e.g., invoke/create/update
'actor_id' => $entityId, // optional
'actor_name' => $entityName, // optional
'description' => 'Called tasks list', // optional
]);

Arguments (name : type — description):

  • $db
  • $config : array optional default: array ()

Returns:

mixed

Attach access-log activity metadata for the current request.
This metadata will be picked up by the Logger when access.log is written.

Example:


$activity->setAccessContext([
'activity_label' => 'Viewed dashboard',
'activity_notify' => false,
'activity_severity' => 'info',
'space_id' => 3,
'ms_name' => 'admin',
'route_id' => 12,
]);

Arguments (name : type — description):

  • $context : array

Returns:

void

Get recent activity records.

@param int $limit Number of rows to return
@param array $filters Optional keys: user_id, space_id
@return array Activity rows (empty if table missing)

Arguments (name : type — description):

  • $limit : int — Number of rows to return optional default: 50
  • $filters : array — Optional keys: user_id, space_id optionaldefault: array ()

Returns:

array — Activity rows (empty if table missing)

Log an activity for a route, rendering the route's template when present.

$data keys:
- route_id or route_uid (required)
- action (required, e.g., invoke/create/update)
- actor_id (optional), actor_name (optional)
- ms_id (optional, will be derived from route if omitted)
- description (optional)
- space_id (optional)

@return int|null Always null; activity is written to filesystem logs for ingestion.

Arguments (name : type — description):

  • $data : array

Returns:

?int — Always null; activity is written to filesystem logs for ingestion.

Ingest access log entries into s_activity for fast user timelines.

Options:
- start (Y-m-d), end (Y-m-d)
- log_dir (override)
- max_days (int, default 31)
- skip_assets (bool, default true)

@return array counts: processed, inserted, skipped, days

Arguments (name : type — description):

  • $options : array optional default: array ()

Returns:

array — counts: processed, inserted, skipped, days

AiClient

Core\App\AiClient

File: /home/batoi/rad/core/app/AiClient.cls.php
AiClient
Convenience wrapper around Core\Sys\AiService for common AI operations

Arguments (name : type — description):

  • $config : array
  • $errorHandler : ?Core\Sys\ErrorHandler optional

Returns:

mixed

Send a chat-style message list to the AI provider.

@param array $messages Array of message objects compatible with AiService
@param array $options Provider-specific options (e.g., model, temperature)
@return string Provider response text

Arguments (name : type — description):

  • $messages: array — Array of message objects compatible with AiService
  • $options : array — Provider-specific options (e.g., model, temperature) optional default: array ()

Returns:

string — Provider response text

Send a plain completion request to the AI provider.

@param string $prompt Prompt text
@param array $options Provider-specific options (e.g., model, max_tokens)
@return string Provider response text

Arguments (name : type — description):

  • $prompt : string — Prompt text
  • $options : array — Provider-specific options (e.g., model, max_tokens) optional default: array ()

Returns:

string — Provider response text

Vision-enabled chat; accepts image paths/URLs/base64 strings.

@param array $messages
@param array $images
@param array $options
@return string Provider response text

Arguments (name : type — description):

  • $messages : array — * @param array $images
  • $images : array optionaldefault: array ()
  • $options: array — * @return string Provider response text optional default: array ()

Returns:

string — Provider response text

Generate an image from a prompt.

@param string $prompt
@param array $options
@return array Provider response payload (e.g., URLs/base64 strings)

Arguments (name : type — description):

  • $prompt : string — * @param array $options
  • $options : array optionaldefault: array ()

Returns:

array — Provider response payload (e.g., URLs/base64 strings)

Create embeddings.

@param string|array $input
@param array $options
@return array Embedding response payload

Arguments (name : type — description):

  • $input * @param array $options
  • $options : array optional default: array ()

Returns:

array — Embedding response payload

Speech-to-text.

@param string $filePath
@param array $options
@return string Transcript text

Arguments (name : type — description):

  • $filePath : string — * @param array $options
  • $options : array optional default: array ()

Returns:

string — Transcript text

Text-to-speech; returns base64-encoded audio (e.g., mp3).

@param string $text
@param array $options

Arguments (name : type — description):

  • $text : string — * @param array $options
  • $options : array optional default: array ()

Returns:

string

AuthUi

Core\App\AuthUi

File: /home/batoi/rad/core/app/AuthUi.cls.php
Auth UI helper for embedding MFA, forgot-password, and change-password screens inside custom microservice routes.

Typical usage inside a route.* file:


$authUi = new \Core\App\AuthUi($this->runData);
if ($this->runData['request']->method === 'POST') {
$result = $authUi->requestPasswordReset($_POST['s_username'] ?? '');
}
echo $authUi->renderForgotPassword([
'action' => $this->runData['route']['base_url'] . '/my/forgot',
'message' => $result['message'] ?? null,
'status' => $result['status'] ?? null,
]);

Arguments (name : type — description):

  • $runData : array
  • $ui : ?Core\App\UiTemplate optional

Returns:

mixed

Arguments (name : type — description):

  • $vars : array optional default: array ( )

Returns:

string

Arguments (name : type — description):

  • $vars : array optional default: array ( )

Returns:

string

Arguments (name : type — description):

  • $vars : array optional default: array ( )

Returns:

string

Send a reset link to the user's email.
Returns: ['status' => 'success'|'danger', 'message' => string]

Arguments (name : type — description):

  • $username : string

Returns:

array

Reset password by token (same behavior as /login/forgotpassword/{token}).
Returns: ['status' => 'success'|'danger', 'message' => string]

Arguments (name : type — description):

  • $token : string
  • $newPassword : string
  • $confirmPassword : string

Returns:

array

Change password for the current user.
Returns: ['status' => 'success'|'danger', 'message' => string]

Arguments (name : type — description):

  • $entityId : int
  • $currentPassword : string
  • $newPassword : string

Returns:

array

Get MFA state for a user and optional OTPAuth URL.

Arguments (name : type — description):

  • $entityId : int

Returns:

array

Handle MFA actions: reset, verify, disable, regen-codes.
Returns: ['status' => 'success'|'danger'|'info', 'message' => string, 'secret' => string|null, 'backup_codes' => array|null]

Arguments (name : type — description):

  • $entityId : int
  • $action : string
  • $data : array optional default: array ( )

Returns:

array

DataRecord

Core\App\DataRecord

File: /home/batoi/rad/core/app/DataRecord.cls.php

DataRecord service to read application (a_*) tables and version history.
Intended for app developers to build data viewers outside RAD Admin.

Arguments (name : type — description):

  • $db
  • $config : array optional default: array ( )

Returns:

mixed

List a_* tables available.

@return array Table names (strings)
Arguments: none
Returns
array — Table names (strings)

Get records from a table with optional filters, order, limit, offset.
$filters is an associative array of column => value (equality).

@param string $table a_* table name
@param array $filters Column => value equality filters
@param int $limit Max rows
@param int $offset Offset rows
@param array $order Column => direction map (ASC|DESC)
@return array Result rows

@throws InvalidArgumentException when table is not prefixed with a_

Arguments (name : type — description):

  • $table : string — a_* table name
  • $filters : array — Column => value equality filters optional default: array ( )
  • $limit : int — Max rows optional default: 100
  • $offset : int — Offset rows optional default: 0
  • $order : array — Column => direction map (ASC|DESC) optional default: array ( )
  • $options : array optional default: array ( )

Returns:

array — Result rows

Get a single record by primary id.

@param string $table a_* table name
@param int $id Primary id
@return array|null Record or null

@throws InvalidArgumentException when table is not prefixed with a_

Arguments (name : type — description):

  • $table : string — a_* table name
  • $id : int — Primary id
  • $options : array optional default: array ( )

Returns:

?array — Record or null

Get version history for a record from s_version_history.

@param string $table a_* table name
@param int $recordId Record id
@param int $limit Max versions to return
@return array Version rows

@throws InvalidArgumentException when table is not prefixed with a_

Arguments (name : type — description):

  • $table : string — a_* table name
  • $recordId : int — Record id
  • $limit : int — Max versions to return optional default: 20

Returns:

array - Version rows

Get the latest version snapshot for a record.

Arguments (name : type — description):

  • $table : string
  • $recordId : int

Returns:

?array

DotPhrase

Core\App\DotPhrase

File: /home/batoi/rad/core/app/DotPhrase.cls.php

App-facing Dot Phrase helper (wraps system service).

Arguments (name : type — description):

  • $db : Core\Sys\Database
  • $errorHandler : ?Core\Sys\ErrorHandler optional

Returns:

mixed

List dot phrases with optional filters.

@param array $filters Field filters passed to service
@return array Phrase rows

Arguments (name : type — description):

  • $filters : array — Field filters passed to service optional default: array ( )

Returns:

array — Phrase rows

Get a phrase by id or uid.

@param int|string $idOrUid Identifier
@return array|null Phrase row or null

Arguments (name : type — description):

  • $idOrUid — Identifier

Returns:

?array — Phrase row or null

Create a phrase.

@param array $data Required keys: s_name, s_content
@param int|null $actorId Optional actor id for audit fields
@return int Inserted id

Arguments (name : type — description):

  • $data : array — Required keys: s_name, s_content
  • $actorId : ?int — Optional actor id for audit fields optional

Returns:

int — Inserted id

Update a phrase.

@param int|string $idOrUid Identifier
@param array $data Fields to update
@param int|null $actorId Optional actor id for audit fields
@return bool True on success

Arguments (name : type — description):

  • $idOrUid - Identifier
  • $data : array — Fields to update
  • $actorId : ?int — Optional actor id for audit fields optional

Returns:

bool - True on success

Archive a phrase.

@param int|string $idOrUid Identifier
@return bool True on success

Arguments (name : type — description):

  • $idOrUid - Identifier

Returns:

bool - True on success

Resolve a phrase to content based on scope/user.

@param string $phrase Phrase text
@param int|null $entityId Optional user id
@param int|null $spaceId Optional workspace id
@param string|null $scope Optional scope
@return array|null Resolved phrase or null

Arguments (name : type — description):

  • $phrase : string — Phrase text
  • $entityId : ?int — Optional user id optional
  • $spaceId : ?int — Optional workspace id optional
  • $scope : ?string — Optional scope optional

Returns:

?array - Resolved phrase or null

Record usage of a phrase for analytics.

@param int $dotphraseId Phrase id
@param int|null $entityId Optional user id
@param int|null $spaceId Optional workspace id
@param string|null $context Optional usage context

Arguments (name : type — description):

  • $dotphraseId : int — Phrase id
  • $entityId : ?int — Optional user id optional
  • $spaceId : ?int — Optional workspace id optional
  • $context : ?string — Optional usage context optional

Returns:

void

FileStore

Core\App\FileStore

File: /home/batoi/rad/core/app/FileStore.cls.php

FileStore

Lightweight helper to persist files into RAD upload roots.
- Global files: /rad/data/uploads/global/YYYY/MM/DD/{file}
- Workspace files: /rad/data/uploads/workspaces/{hash}/{spaceUid}/YYYY/MM/DD/{file}

Usage:


$fs = new \Core\App\FileStore($config);
$path = $fs->storeGlobal('report.pdf', $binary);
$path = $fs->storeWorkspace($spaceUid, 'avatar.png', '/tmp/php123', true);

@param array $config expects ['dir']['data'] pointing to rad/data

Arguments (name : type — description):

  • $config : array — expects ['dir']['data'] pointing to rad/data

Returns:

mixed

Store a file in the global namespace.

@param string $fileName Target file name (sanitized)
@param string $contentOrPath Raw content or path to an existing temp file
@param bool $isTempPath When true, treat $contentOrPath as an existing file path
@return string Full path of the stored file

Arguments (name : type — description):

  • $fileName : string — Target file name (sanitized)
  • $contentOrPath : string — Raw content or path to an existing temp file
  • $isTempPath : bool — When true, treat $contentOrPath as an existing file path optional default: false

Returns:

string — Full path of the stored file

Store a file scoped to a workspace.

@param string $spaceUid Workspace UID
@param string $fileName Target file name (sanitized)
@param string $contentOrPath Raw content or path to an existing temp file
@param bool $isTempPath When true, treat $contentOrPath as an existing file path
@return string Full path of the stored file

Arguments (name : type — description):

  • $spaceUid : string — Workspace UID
  • $fileName : string — Target file name (sanitized)
  • $contentOrPath : string — Raw content or path to an existing temp file
  • $isTempPath : bool — When true, treat $contentOrPath as an existing file path optional default: false

Returns:

string — Full path of the stored file

Build a dated path (no write) for a global file.

Arguments (name : type — description):

  • $fileName : string
  • $date : ?DateTimeInterface optional

Returns:

string

Build a dated path (no write) for a workspace file.

Arguments (name : type — description):

  • $spaceUid : string
  • $fileName : string
  • $date : ?DateTimeInterface optional

Returns:

string

Read a stored file (within allowed roots).

@return string

Arguments (name : type — description):

  • $path : string

Returns:

string — */

Deterministic short hash for workspace sharding.

Arguments (name : type — description):

  • $spaceUid : string

Returns:

string

Check if a stored file exists (within allowed bases).

Arguments (name : type — description):

  • $path : string

Returns:

bool

Delete a stored file (within allowed bases).

@return bool true if deleted, false if not found

Arguments (name : type — description):

  • $path : string

Returns:

bool — true if deleted, false if not found

Membership

Core\App\Membership

File: /home/batoi/rad/core/app/Membership.cls.php

Membership service for workspace SaaS role assignments.
Provides read helpers and a safe assign/remove API (one SaaS role per workspace).

Arguments (name : type — description):

  • $db

Returns:

mixed

List memberships (optionally filter by space_id or user_id).

@param array $opts Optional keys: space_id, user_id
@return array Membership rows

Arguments (name : type — description):

  • $opts : array — Optional keys: space_id, user_id optional default: array ( )

Returns:

array — Membership rows

Assign a SaaS role to a membership (one SaaS role per workspace).

@param int $membershipId Membership id
@param int $roleId SaaS role id
@param string $scopeLevel workspace|ms
@param int|null $msId Required when scopeLevel=ms
@return bool True when assigned

@throws InvalidArgumentException on validation errors or duplicates

Arguments (name : type — description):

  • $membershipId : int — Membership id
  • $roleId : int — SaaS role id
  • $scopeLevel : string — workspace|ms optional default: 'workspace'
  • $msId : ?int — Required when scopeLevel=ms optional

Returns:

bool — True when assigned

Clear a role from a membership.

Arguments (name : type — description):

  • $membershipId : int

Returns:

bool

MfaSettings

Core\App\MfaSettings

File: /home/batoi/rad/core/app/MfaSettings.cls.php

MFA settings service for application developers.

Reads/writes system MFA policy stored in s_config (handle: mfa_settings).
This class does not enforce permissions; callers must implement their own access control before invoking update methods.

Arguments (name : type — description):

  • $db

Returns:

mixed

Read the normalized MFA settings payload.

@return array

Arguments : none

Returns:

array — */

Update MFA settings.

Accepts a partial payload; unknown keys are ignored.
Values are normalized to expected types.

Example:


$mfa = new \Core\App\MfaSettings($db);
$mfa->update([
'enforce_admin_mfa' => true,
'channels' => ['totp' => true, 'sms' => true],
'delivery_priority' => ['sms', 'email'],
]);

@param array $payload
@return array Normalized settings after update

Arguments (name : type — description):

  • $payload : array — * @return array Normalized settings after update

Returns:

array — Normalized settings after update

Replace the MFA settings payload with a full schema object.

@param array $payload Full settings payload
@return array Normalized settings

Arguments (name : type — description):

  • $payload : array — Full settings payload

Returns:

array — Normalized settings

Notification

Core\App\Notification

File: /home/batoi/rad/core/app/Notification.cls.php

Notification service for applications.
Supports fetching and creating simple notifications.

Usage in a route (rad/ms/{ms}/route.{id}.php):


$notif = new \Core\App\Notification($db);
$notif->logRoute([
'route_id' => 12, // or 'route_uid' => '...'
'action' => 'invoke', // e.g., invoke/create/update
'actor_id' => $entityId, // optional
'actor_name' => $entityName, // optional
'description' => 'Called tasks list', // optional
'user_id' => $entityId, // optional target user
'space_id' => $spaceId ?? 0, // optional
]);

Arguments (name : type — description):

  • $db

Returns:

mixed

Get recent notifications for a user.

@param int $userId s_entity.id of the user
@param int $limit number of records
@return array Notification rows (empty when no user)

Arguments (name : type — description):

  • $userId : int — s_entity.id of the user
  • $limit : int — number of records optional default: 20

Returns:

array — Notification rows (empty when no user)

Create a notification.

@param int $userId s_entity.id of the user
@param string $title Title text
@param string $message Body text
@return int Inserted id

@throws \InvalidArgumentException when userId/title missing

Arguments (name : type — description):

  • $userId : int — s_entity.id of the user
  • $title : string — Title text
  • $message : string — Body text

Returns:

int — Inserted id

$data keys:
- route_id or route_uid (required)
- action (required)
- actor_id (optional), actor_name (optional)
- ms_id (optional)
- description (optional)
- space_id (optional)
- user_id (optional target user)

Arguments (name : type — description):

  • $data : array

Returns:

?int

Profile

Core\App\Profile

File: /home/batoi/rad/core/app/Profile.cls.php

Profile data service for non-RAD Admin UI pages.

Usage (inside a route.* file):


$profile = new \Core\App\Profile($this->runData);
$view = $profile->overview((int)$this->runData['entity']['id']);
$ui = new \Core\App\ProfileUi($this->runData);
echo $ui->renderOverview([
'nav' => $profile->getNav('overview', $this->runData['route']['base_url'] . '/profile'),
'data' => $view['data'],
]);

Arguments (name : type — description):

  • $runData : array

Returns:

mixed

Arguments : none

Returns:

array

Arguments (name : type — description):

  • $active : string
  • $baseUrl : string

Returns:

array

Arguments (name : type — description):

  • $entityId : int

Returns:

array

Arguments (name : type — description):

  • $entityId : int
  • $filters : array optional default: array ( )

Returns:

array

Arguments (name : type — description):

  • $entityId : int
  • $input : array optional default: array ( )
  • $save : bool optional default: false

Returns:

array

Arguments (name : type — description):

  • $entityId : int
  • $input : array optional default: array ( )
  • $save : bool optional default: false

Returns:

array

Arguments (name : type — description):

  • $entityId : int
  • $current : string
  • $new : string
  • $confirm : string

Returns:

array

Arguments (name : type — description):

  • $entityId : int

Returns:

array

Arguments (name : type — description):

  • $entityId : int
  • $action : string
  • $data : array optional default: array ( )

Returns:

array

ProfileUi

Core\App\ProfileUi

File: /home/batoi/rad/core/app/ProfileUi.cls.php

UI helper for rendering non-admin profile pages from rad/data/uitpl/profile/*.

Arguments (name : type — description):

  • $runData : array
  • $ui : ?Core\App\UiTemplate optional

Returns:

mixed

Arguments (name : type — description):

  • $vars : array optional default: array ( )

Returns:

string

Arguments (name : type — description):

  • $vars : array optional default: array ( )

Returns:

string

Arguments (name : type — description):

  • $vars : array optional default: array ( )

Returns:

string

Arguments (name : type — description):

  • $vars : array optional default: array ( )

Returns:

string

Arguments (name : type — description):

  • $vars : array optional default: array ( )

Returns:

string

Arguments (name : type — description):

  • $vars : array optional default: array ( )

Returns:

string

Role

Core\App\Role

File: /home/batoi/rad/core/app/Role.cls.php

Role service for application developers.
Provides lookup and creation helpers for platform and workspace scopes.

Arguments (name : type — description):

  • $db

Returns:

mixed

Get a role by id or uid.

@param int|string $idOrUid Identifier
@return array|null Role row or null

Arguments (name : type — description):

  • $idOrUid — Identifier

Returns:

array|null — Role row or null

List roles filtered by scope.

@param array $scopes e.g. ['platform'], ['workspace'], or ['ms']
@return array Role rows

Arguments (name : type — description):

  • $scopes : array — e.g. ['platform'], ['workspace'], or ['ms'] optional default: array ( )

Returns:

array — Role rows

Create a platform, workspace, or microservice role.

@param array $data keys: s_role_name (required), s_scope (platform/workspace/ms), s_default_route_id (optional)
@return int Inserted id

@throws \InvalidArgumentException on validation errors

Arguments (name : type — description):

  • $data : array — keys: s_role_name (required), s_scope (platform/workspace/ms), s_default_route_id (optional)

Returns:

int — Inserted id

Team

Core\App\Team

File: /home/batoi/rad/core/app/Team.cls.php

Team service for application developers (non–RAD Admin).

Provides CRUD helpers for s_team and s_team_member along with member lookups.
All methods return data/booleans/ids or throw exceptions; no privilege gating.

Arguments (name : type — description):

  • $runData : array

Returns:

mixed

List teams with optional filters.

@param array $filters Optional: livestatus ('0','1','2'), name (partial match)
@return array List of team rows (with member_count/manager_count)

Arguments (name : type — description):

  • $filters : array — Optional: livestatus ('0','1','2'), name (partial match) optional default: array ( )

Returns:

array — List of team rows (with member_count/manager_count)

Fetch a team by id or uid.

@param int|string $idOrUid Numeric id or UID
@param bool $withMembers When true, attach member list
@return array|null Team row (with members when requested) or null if missing

Arguments (name : type — description):

  • $idOrUid — Numeric id or UID
  • $withMembers : bool — When true, attach member list optional default: true ( )

Returns:

?array — Team row (with members when requested) or null if missing

Create a team.

@param array $data Required: s_name. Optional: s_color, s_icon, s_description, livestatus.
@return int Inserted team id

@throws InvalidArgumentException on missing name or duplicate name.
@throws \RuntimeException when insert id is not returned.

Arguments (name : type — description):

  • $data : array — Required: s_name. Optional: s_color, s_icon, s_description, livestatus.

Returns:

int — Inserted team id

Update a team.

@param int $id Team id
@param array $data Fields to update: s_name, s_color, s_icon, s_description, livestatus
@return bool True if updated

@throws InvalidArgumentException when team not found or name duplicate.

Arguments (name : type — description):

  • $id : int — Team id
  • $data : array — Fields to update: s_name, s_color, s_icon, s_description, livestatus

Returns:

bool — True if updated

Archive (deactivate) a team by setting livestatus to 0.

@param int $id Team id
@return bool True if updated

Arguments (name : type — description):

  • $id : int — Team id

Returns:

bool — True if updated

List members of a team.

@param int $teamId Team id
@return array Member rows with entity name/identity and manager flag

Arguments (name : type — description):

  • $teamId : int — Team id

Returns:

array — Member rows with entity name/identity and manager flag

Add a member to a team.

@param int $teamId Team id
@param int $entityId User entity id
@param bool $isManager Whether the member is a manager
@return int Inserted membership id

@throws InvalidArgumentException for missing references or duplicates.
@throws \RuntimeException when insert id is not returned.

Arguments (name : type — description):

  • $teamId : int — Team id
  • $entityId : int — User entity id
  • $isManager : bool — Whether the member is a manager optional. default: false

Returns:

int — Inserted membership id

Remove a member by membership id.

@param int $membershipId Membership id
@return bool True if deleted

Arguments (name : type — description):

  • $membershipId : int — Membership id

Returns:

bool — True if deleted

Remove a member by team and entity ids.

@param int $teamId Team id
@param int $entityId User entity id
@return bool True if deleted

Arguments (name : type — description):

  • $teamId : int — Team id
  • $entityId : int — User entity id

Returns:

bool — True if deleted

Set or clear manager flag on a membership.

@param int $membershipId Membership id
@param bool $isManager Manager flag
@return bool True if updated

Arguments (name : type — description):

  • $membershipId : int — Membership id
  • $isManager : bool — Manager flag

Returns:

bool — True if deleted

Search entities for member suggestions by name or identity.

@param string $query Search term (min 2 chars recommended)
@param int $limit Max rows to return
@return array Matching entities (id, s_name, s_identity)

Arguments (name : type — description):

  • $query : string — Search term (min 2 chars recommended)
  • $limit : int — Max rows to return optional default: 20

Returns:

array — Matching entities (id, s_name, s_identity)

UiTemplate

Core\App\UiTemplate

File: /home/batoi/rad/core/app/UiTemplate.cls.php

Simple UI template renderer for embedding auth screens in custom routes.

Usage:


$ui = new \Core\App\UiTemplate($this->runData['config']);
echo $ui->render('auth/forgot-password', [
'action' => '/forgot-password',
'message' => 'Check your inbox.',
]);

Arguments (name : type — description):

  • $config : array
  • $baseDir : ?string optional

Returns:

mixed

Arguments (name : type — description):

  • $path : string
  • $vars : array optional default: array ( )

Returns:

string

User

Core\App\User

File: /home/batoi/rad/core/app/User.cls.php

User service for application developers.

Provides CRUD helpers for s_entity users plus basic membership lookups.
All methods return data/booleans or throw exceptions; no RAD Admin alerts.

Arguments (name : type — description):

  • $runData : array

Returns:

mixed

List users with optional livestatus filter.

@param array $opts Optional filters: livestatus ('0','1','2','3')
@return array List of user rows from s_entity

Arguments (name : type — description):

  • $opts : array — Optional filters: livestatus ('0','1','2','3') optional default: array ( )

Returns:

array — List of user rows from s_entity

Fetch a user by id or uid.

@param int|string $idOrUid Numeric id or UID
@return array|null User row or null when not found

Arguments (name : type — description):

  • $idOrUid — Numeric id or UID

Returns:

?array — User row or null when not found

Create a user.

Usage notes:
- Non-SaaS role: provide `nonsaas_role_id` (or legacy `role_id` when no workspace membership is requested).
- Workspace membership: provide `space_id` + `workspace_role_id` (role scope must be `workspace` or `ms`).
- Legacy shortcut: if `space_id` is set and `workspace_role_id` is omitted, `role_id` is treated as the workspace role.
- For `ms`-scoped workspace roles, `ms_id` is required. For `workspace` scope, `ms_id` must be omitted.
- If membership insert fails, the newly created user is rolled back.

Parameters summary:
- s_identity (string, required): username/login.
- s_name (string, required): display name.
- password (string, required): raw password; hashed internally.
- nonsaas_role_id (int, optional): non-SaaS role id.
- role_id (int, optional): legacy alias for nonsaas_role_id unless `space_id` is provided; then it maps to workspace_role_id.
- space_id (int, optional): workspace id for membership creation.
- workspace_role_id (int, optional): workspace role id (scope workspace/ms).
- ms_id (int, optional): required if workspace role scope is `ms`.

Example (non-SaaS only):


$userId = $user->create([
's_identity' => 'jane.doe',
's_name' => 'Jane Doe',
'password' => 'secret',
'nonsaas_role_id' => 3,
]);

Example (workspace membership):


$userId = $user->create([
's_identity' => 'jane.doe',
's_name' => 'Jane Doe',
'password' => 'secret',
'space_id' => 12,
'workspace_role_id' => 8,
]);

Example (workspace membership with ms scope):


$userId = $user->create([
's_identity' => 'jane.doe',
's_name' => 'Jane Doe',
'password' => 'secret',
'space_id' => 12,
'workspace_role_id' => 22,
'ms_id' => 5,
]);

@param array $data Required keys: s_identity (username), s_name, password.
Optional: email, mobile, enable_mfa, role_id (non-SaaS), nonsaas_role_id,
access_ips, login_mode, agreement_signed, s_definition,
space_id, workspace_role_id, ms_id.
@return int Inserted user id

@throws InvalidArgumentException on missing required fields or duplicate username.
@throws \RuntimeException if the insert fails to return an id.

Arguments (name : type — description):

  • $data : array — Required keys: s_identity (username), s_name, password.

Returns:

int — Inserted user id

Update a user (by uid).
$data may contain: s_name, s_identity, password, email, mobile, enable_mfa, role_id, access_ips, login_mode, agreement_signed

@param string $uid User UID
@param array $data Fields to update (see above)
@return bool True if updated

@throws InvalidArgumentException if user not found

Arguments (name : type — description):

  • $uid : string — User UID
  • $data : array — Fields to update (see above)

Returns:

bool — True if updated

Set or clear the non-SaaS role for a user.

Example:


$user->setNonSaasRole('user-uid', 3);

@param string $uid User UID
@param int|null $roleId Role id or null to clear
@return bool True if updated

Arguments (name : type — description):

  • $uid : string — User UID
  • $roleId : ?int — Role id or null to clear

Returns:

bool — True if updated

Update a user's workspace role for a specific workspace.

Behavior:
- Updates existing active membership when present.
- Revives the latest archived membership for the workspace if found.
- Creates a new membership if none exist.

Example (workspace scope):


$user->setWorkspaceRole('user-uid', 12, 8);

Example (ms scope):


$user->setWorkspaceRole('user-uid', 12, 22, 5);

@param string $uid User UID
@param int $spaceId Workspace id
@param int $roleId Workspace role id (scope workspace/ms)
@param int|null $msId Microservicelet id for ms-scoped roles
@return bool True if updated

Arguments (name : type — description):

  • $uid : string — User UID
  • $spaceId : int — Workspace id
  • $roleId : int — Workspace role id (scope workspace/ms)
  • $msId : ?int — Microservicelet id for ms-scoped roles optional

Returns:

bool — True if updated

Add a workspace membership for a user.

Example:


$membershipId = $user->addWorkspaceMembership('user-uid', 12, 8);

@param string $uid User UID
@param int $spaceId Workspace id
@param int $roleId Workspace role id (scope workspace/ms)
@param int|null $msId Microservicelet id for ms-scoped roles
@return int Inserted membership id

Arguments (name : type — description):

  • $uid : string — User UID
  • $spaceId : int — Workspace id
  • $roleId : int — Workspace role id (scope workspace/ms)
  • $msId : ?int — Microservicelet id for ms-scoped roles optional

Returns:

int — Inserted membership id

Remove (archive) a workspace membership for a user.

Example:


$user->removeWorkspaceMembership('user-uid', 12);

@param string $uid User UID
@param int $spaceId Workspace id
@return bool True if updated

Arguments (name : type — description):

  • $uid : string — User UID
  • $spaceId : int — Workspace id

Returns:

bool — True if updated

Archive (deactivate) a user.

@param string $uid User UID
@return bool True if updated

Arguments (name : type — description):

  • $uid : string — User UID

Returns:

bool — True if updated

Return roles assigned to the user (non-SaaS + workspace roles).

@param string $uid User UID
@return array Array of role IDs (ints)

Arguments (name : type — description):

  • $uid : string — User UID

Returns:

array — Array of role IDs (ints)

Get memberships for a user with roles (workspace SaaS roles).

@param string $uid User UID
@return array Membership rows with role info

Arguments (name : type — description):

  • $uid : string — User UID

Returns:

array — Membership rows with role info

Get workspaces for a user (unique workspaces only).

Usage examples:


$user = new \Core\App\User($runData);
$workspaces = $user->workspaces('user-uid');

// Include workspace roles for each membership
$workspaces = $user->workspaces('user-uid', ['include_roles' => true]);

// Include membership count per workspace
$workspaces = $user->workspaces('user-uid', ['include_counts' => true]);

Options:
include_roles (bool) - include role info (role_id, role_name, scope).
include_counts (bool) - include membership_count per workspace.

@param string $uid User UID
@param array $opts Optional flags
@return array Workspace list

Arguments (name : type — description):

  • $uid : string — User UID
  • $opts : array — Optional flags optional default: array ( )

Returns:

array — Workspace list

Get workspaces where the user is the owner (s_space.s_owner_entity_id).

Usage examples:


$user = new \Core\App\User($runData);
$owned = $user->ownedWorkspaces('user-uid');

// Include membership count per workspace
$owned = $user->ownedWorkspaces('user-uid', ['include_counts' => true]);

@param string $uid User UID
@param array $opts Optional flags (include_counts)
@return array Workspace list

Arguments (name : type — description):

  • $uid : string — User UID
  • $opts : array — Optional flags (include_counts) optional default: array ( )

Returns:

array — Workspace list

Workspace

Core\App\Workspace

File: /home/batoi/rad/core/app/Workspace.cls.php

Workspace service for application developers.
Provides read helpers and member listings for SaaS workspaces.

Arguments (name : type — description):

  • $db

Returns:

mixed

Get a workspace by id or uid.

@param int|string $idOrUid Identifier
@return array|null Workspace row or null

Arguments (name : type — description):

  • $idOrUid — Identifier

Returns:

?array — Workspace row or null

List workspaces, optionally filtered by livestatus.

@param array $opts Optional: livestatus
@return array Workspace rows

Arguments (name : type — description):

  • $opts : array — Optional: livestatus optional default: array ( )

Returns:

array — Workspace rows

Get members of a workspace with their SaaS roles.

@param int|string $workspaceId Id or uid
@return array Membership rows with role info

Arguments (name : type — description):

  • $workspaceId — Id or uid

Returns:

array — Membership rows with role info

Basic stats: member count and binding counts.

@param int|string $workspaceId Id or uid
@return array ['members'=>int,'bindings_ms'=>int,'bindings_route'=>int]

Arguments (name : type — description):

  • $workspaceId — Id or uid

Returns:

array — ['members'=>int,'bindings_ms'=>int,'bindings_route'=>int]