Access conditions (ACS)
An ACS string decides whether a caller may see or use something: SL20, GM[sysops], (SL50 | SY) & !NN1. The syntax follows ENiGMA½. This page is a reference for the syntax as AcsParser.php implements it, the built-in codes in Acs.php, and adding your own.
Where ACS strings are used
| Where | Field |
|---|---|
| menus | $menu->acs('SY', fallback: 'main') (menus) |
| menu options and global commands | $option->acs('SL20') |
| doors | acs on #[Door] or DoorDefinition (doors) |
| message conferences and areas | acsRead, acsWrite columns (data) |
| module code | $session->can('SL50') |
null or an empty string always allows.
Syntax
A string is one or more terms joined by operators.
A term is a two-letter code (case-insensitive) followed by at most one argument:
| Form | Example | The check receives |
|---|---|---|
| code alone | SY |
$number = null, $list = [] |
| code + digits | SL20 |
$number = 20 |
code + [list] |
GM[sysops,cosysops] |
$list = ['sysops', 'cosysops'] (trimmed, empties dropped) |
Operators, tightest first:
| Operator | Meaning |
|---|---|
! |
not |
&, or two terms side by side |
and |
| |
or |
( … ) |
grouping |
Whitespace between terms is ignored. Examples:
| String | Allows |
|---|---|
SL20 |
security level 20 or higher |
GM[users] NC5 |
members of users with at least 5 calls (adjacent terms are ANDed) |
SY | GM[cosysops] |
sysops and members of cosysops |
(SL50 | SY) & !NN1 |
level 50+ or a sysop, but not on node 1 |
!PR[web] |
everyone except web-terminal callers |
TW132 EC1 |
terminals at least 132 columns wide, using UTF-8 |
Unknown codes deny. A typo such as SX evaluates to false instead of opening the gate. Syntax errors (an unclosed ( or [, a stray character) throw Carrier\Acs\AcsSyntaxError when the string is first checked. Parsed strings are cached.
Built-in codes
| Code | True when | Argument |
|---|---|---|
SL |
security level ≥ n; callers not logged in count as 0 | number |
SY |
the caller is a sysop (level ≥ BbsConfig::$sysopLevel) |
— |
LI |
the caller is logged in | — |
ID |
the user id is n, or is in the list | number or list |
FL |
the user has any of the listed flags (letters in the user's flags string, case-insensitive) |
list |
GM |
the user is in any of the listed groups (case-insensitive) | list |
NC |
the user has ≥ n calls | number |
NP |
the user has ≥ n posts | number |
AA |
the account is ≥ n days old | number |
ML |
≥ n minutes left today; unlimited allowances always pass | number |
SC |
the connection is encrypted (SSH, or the web terminal over wss) | — |
NN |
the caller is on node n, or on a listed node | number or list |
PR |
the transport is in the list: telnet, ssh, rlogin, web |
list |
WD |
today is weekday n, or a listed weekday (0 = Sunday … 6 = Saturday) | number or list |
MM |
the time of day is ≥ n minutes after midnight | number |
TW |
the terminal is ≥ n columns wide | number |
TH |
the terminal is ≥ n rows tall | number |
EC |
EC1: the terminal uses UTF-8; EC0: CP437 |
number |
AN |
the terminal answered the ANSI probe | — |
TT |
the terminal type is in the list as the transport reported it, lower-cased (e.g. xterm-256color; xterm.js for the web terminal; telnet when telnet sent no TTYPE) |
list |
The board adds one code in BoardCodes.php:
| Code | True when | Argument |
|---|---|---|
NM |
the caller has ≥ n unread e-mails (n defaults to 1) | number |
For callers who are not logged in: ID, FL, GM and AA are false, NC and NP count 0, SL counts level 0, and ML passes.
Adding codes
Mark a public method with #[Carrier\Acs\AccessCheck('XX')] on any class in app/. Discovery registers it. The method receives $session, $number and $list by name; ask only for the ones you need. Other parameters are injected from the container. It returns a bool.
use Carrier\Acs\AccessCheck;
use Carrier\Art\DisplayCode;
use Carrier\Session\Session;
final class BoardCodes
{
#[DisplayCode('NM')]
public function newMail(Session $session): int
{
return $session->user !== null ? Mail::unreadFor($session->user->key()) : 0;
}
#[AccessCheck('NM')]
public function hasMail(Session $session, ?int $number): bool
{
return $this->newMail($session) >= max(1, (int) $number);
}
}The code is now usable everywhere ACS strings are: $option->acs('NM') shows an option only to callers with new mail. A code registered later replaces a built-in one with the same letters.
Codes can also be added at runtime: Carrier\Acs\Acs is a singleton with extend(string $code, \Closure $check). The closure has the signature fn (Session $session, ?int $number, array $list): bool.
Checking and validating in code
| Call | Returns |
|---|---|
$session->can(?string $acs): bool |
the result for this caller |
Acs::check(string $acs, Session $session): bool |
the same, on the Acs service |
Acs::validate(string $acs): ?string |
an error message for a syntax error or an unknown code, or null when the string is valid |
php carrier menu:list runs validate() on every option's ACS string. The sysop console runs it on the write ACS of a new message area. See menus.