Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,221 of 9,224 pages
About the help in other languages
All help pages

User notifications: the administrator's guide

The kernel stores notifications per user (tables expusernotif and expusernotif_delivery), shows them in the admin4 bell and on a list page, and can deliver the same event through further channels. This page is for…

Download as PDF

Address: https://doc.exponential.earth/learninminutes/exphelp/viewer/features/6.0/user-notifications-administrator.md

On this page

User notifications: the administrator's guide

The kernel stores notifications per user (tables expusernotif and expusernotif_delivery), shows them in the admin4 bell and on a list page, and can deliver the same event through further channels. This page is for administrators: subscriptions, channels, the outward switch and its guards, transports, the cron part, the console command, retention and the policy. Extension authors find the API in Notifications for your extension; users find the bell and the list page in Notifications: the user's guide. This is a separate feature from the older e-mail notifications of content you follow.

All settings are in usernotification.ini. Do not edit the shipped file: use settings/override/ or settings/siteaccess/<name>/. After a change clear the INI cache and all caches:

rm -f var/cache/ini/*.php
php bin/php/ezcache.php --clear-all

Subscriptions: which channel a type uses

Each notification type (an identifier like workflow.stage_entered, registered by the kernel or an extension in [Types] List[]) goes to the channels listed in [Subscriptions], separated by semicolons:

[Subscriptions]
Channels[]
Channels[*]=system
Channels[acme.order_shipped]=system;email

Channels[<type>] wins; a type without a line uses Channels[*] (shipped as system). The subscriptions belong to the siteaccess in which the event happens, so a site can differ per siteaccess. A channel name that is unknown or not available is skipped and logged; the other channels still run.

ChannelWhat it doesWhen
systemstores the notification (bell, list page)at once
browsershows a one-time notice (at most [Bell] NoticeLimit, shipped 3)at once
logwrites a log lineat once
emailone mail per recipient through the kernel's mail transport and its preferencesat once; a transport failure leaves a pending row for the cron part
chat, sms, pushoutward channels, see belownever inline: queued, sent by the cron part

The e-mail channel does not send to a disabled account, a user without a valid address, a reserved address, or a recipient whose mail preferences block it; each of these is recorded as a skipped row with the reason disabled, no_address, reserved_domain or preference. Reserved addresses are those ending in a [Channel_email] SkipDomains[] value (.suffix matches a domain ending in it, @host that host exactly); without the key the five values .invalid, .test, .example, .localhost and @localhost apply.

Outward channels and the switch

chat, sms and push post once per event to destinations the site configures, never once per recipient and never to a user's address. The text is the type's reduced outward text: type label, counts, ids and absolute admin links, never names, logins, addresses, phone numbers or content text.

Three gates must all be open, in this order:

  1. The switch. [Outward] Delivery=disabled is the shipped default. Only enabled turns outward delivery on. With the switch off a queued row is recorded as skipped with the reason outward_off.
  2. The source. The code that emits the event must pass the option outward => true. Missing or false means no, and the row is skipped with source_refused.
  3. The guard of the source. A source may register [Outward] Guards[<source>]=<Class>::<staticMethod>, a callable that returns true when an outward message may leave. A guard that is registered but not callable, throws, or returns anything other than true refuses: guard_refused. The scripts whose events are never sent outward are listed by expworkflow in its own expworkflow.ini, [Outward] BulkScripts[].

The switch and the guard are checked twice: when the message is queued and again when the cron part sends it. A row queued before you turned the switch off therefore does not leave the site.

Other skip reasons you can meet in the delivery rows: unavailable (no transport could be built), no_destination (SMS without a number), no_text (the type produced no outward text).

Transports and secrets

An outward channel needs a transport, one DSN per name:

[Transports]
Chat[<name>]=
Sms[<name>]=
Push[<name>]=

[Channel_sms]
To=

[Channel_sms] To is the number the SMS channel posts to (the team number). The lists ship empty on purpose. Put DSNs and the team number only in the secrets override of the installation (an INI override that is not in version control), never in settings/ or an extension's versioned INI; a guard test fails on a non-empty DSN or To in a versioned file. A channel is available when at least one DSN can be built into a transport. The transports come from the Symfony Notifier package; a DSN whose bridge is not installed makes the channel unavailable (for SMS also without To). Install the bridge a DSN needs with Composer.

The cron part

usernotification.php is listed in cronjob.ini [CronjobPart-frequent], so it runs with the frequent cron part. In each run it:

  • sends up to [Delivery] BatchSize (100) pending rows, oldest first: e-mail rows are sent again, outward rows are posted;
  • gives up on a row after [Delivery] MaxAttempts (5) attempts; the row becomes failed;
  • handles only rows queued by its own siteaccess (the links and settings of the message come from it) and counts the pending rows of other siteaccesses it left alone. Run the cron part for each siteaccess that queues outward messages (-s <siteaccess>);
  • prints one line, for example User notifications (siteaccess "site_admin"): 3 sent, 0 pending again, 0 failed, 1 skipped; 0 pending rows of other siteaccesses left alone;
  • once a day runs the retention cleanup (below). The day is kept in a stamp file <vardir>/usernotification/cleanup.stamp; a failed cleanup is tried again at the next run.

Without the database tables (an installation not upgraded yet) the part prints a notice and does nothing.

The command

./console exp:usernotification:subscriptions -s <siteaccess>
./console exp:usernotification:subscriptions -s <siteaccess> --json

Use this command instead of reading INI files: INI precedence between override, siteaccess and extensions is easy to get wrong. For the siteaccess given with -s it prints each notification type with its channels as that siteaccess resolves them, the channels that were skipped and why (unknown, no transport, no destination, outward_off, or the error of a transport), the same for the default (a type without a line), whether each channel is available, the outward switch and the registered guards. It changes nothing and shows no DSN or secret. The last line is Siteaccess <name>; other siteaccesses were not looked at; run the command once per siteaccess. --json prints the same as one JSON object (siteaccess, note, types, default, channels, outward).

Retention

The daily cleanup of the cron part deletes, by age:

[Retention]
ReadDays=90
AllDays=365
DeliveryDays=30

ReadDays for read notifications, AllDays for any notification (also unread), DeliveryDays for finished delivery rows (sent, skipped, failed). The shipped values are in the example. 0 keeps that kind for good. The delivery rows of a deleted notification go with it.

The policy and the bell

Every view of the module usernotification (the list page, opening a notification, the actions on the list page) needs the policy usernotification/use. A role without it sees no bell, no list page and fetches nothing. Give the policy to the roles whose users should receive notifications in the admin; it is not part of the shipped roles.

The bell is a header item of the admin4 design. It needs two things:

  • usernotification/use, and
  • ezjscore/call, because the bell loads its list from the feed ezjscore/call/usernotification::notices. The policy ezjscore/call must be unlimited or limited to the function list usernotification (registered in ezjscore.ini [ezjscServer] FunctionList[]). A user with a limited ezjscore/call that lacks usernotification sees an empty bell.

The bell is registered in the kernel's design.ini [AdminHeaderSettings] HeaderItems[] as usernotification/header_bell.tpl. A siteaccess that resets HeaderItems[] in its own design.ini.append.php loses the bell (and the items of every extension); if it needs its own list, keep the usernotification/header_bell.tpl line. The header is cached per user and role, so after changing roles clear the caches as above.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x