# Message unification checkpoint (local implementation complete)

Approved objective: use one PHP generator and one browser behavior for operational alerts, infoboxes, and modals, while retaining Bootstrap and existing Flash transport/confirmation contracts. Do not change core framework, commit, push, or deploy. One Sol Low worker proceeds in small sequential phases; orchestrator reviews each phase.

## Completed and current phase

Phase 1 inventory found server-rendered Flash alerts/modals, server-rendered announcements with separate browser persistence, shared confirmation modal, legacy `#infomodal` for account balance and terms, legacy `data-dismiss-cookie` alerts in calendar and account, operational alerts across account, calendar, RollPoints, management, and instructor views, plus AJAX error dialogs. Exceptions agreed with user: cookie consent, static public information, static nondismissible phone alert, and the large calendar text when nonempty.

Phase 2 foundation is implemented. `Mini\Libs\UiMessage` and shared alert/modal/action templates have been added. Flash and confirmation templates call the generator; Flash session transport and `data-confirmation-*` triggers remain. Text is escaped by default; explicit `body_html` accepts only caller-prepared HTML. Links reject unsafe schemes, control characters and backslashes. Actions support multiple links/buttons, icons, form submit/name/value and Bootstrap variants; buttons use `btn-sm`. Dismiss-and-navigate links are handled by the shared JS handler after the modal closes. Operational containers carry `data-nosnippet`. Browser storage logic in `application.js` accepts configurable `data-ui-memory-*` attributes.

Action links accept the application's scheme-relative URL base (`//host/path`)
after validating its HTTP(S) authority, including rejecting embedded credentials.
This preserves HTTP locally and HTTPS on hosted environments. A regression in
the original URL filter hid account balance list/payment links while leaving the
OK button visible; `tests/account_balance_interface_test.php` covers this modal,
the corresponding account alert, unsafe action URLs and mixed group/individual
balance rendering. No configuration change, migration or CSS build is required.

Success infoboxes use the theme's `secondary` brand green instead of `success`.
The shared renderer maps the success variant for alerts, including successful
Flash alerts, without changing their semantic type or modal variants. Alert
callers can pass `actions_class` to place actions in a separate Bootstrap row with
spacing; child-enrollment guidance uses `d-flex flex-wrap gap-2 mt-3` and secondary
buttons. Other alert action layouts retain their existing behavior.

Phases 3–4 completed: announcements, balance and terms modals, account balance warnings, the calendar hint, enrollment conflicts, course warnings, and upcoming lesson messages now use the shared renderer. The Flash → account → announcement order remains; manual confirmations use the same queue with priority over waiting automatic modals. Announcement flash/session keys and infobox/TTL keys retain their earlier storage names. A global Web Lock serializes initial session-cookie creation across tabs. The absence reminder on `moje_zajecia` was removed; the approved static paragraph now uses configured hours and absence limit. The unconfirmed-phone alert is static and nondismissible. Calendar large text is static when nonempty. Static pass restrictions and child-enrollment guidance remain plain nondismissible alerts, with no `data-nosnippet`, as clarified by the user. Existing legacy `#infomodal`, `data-dismiss-cookie`, and announcement-specific DOM branches are removed.

Phase 5 migrated 85 additional operational alert blocks in account, RollPoints, and management views. Plain text and simple dynamic errors call `UiMessage::render` directly; mixed HTML bodies use output buffering with the existing escaped values. Three native AJAX `alert()` errors now clone one PHP-rendered alert template and fill its text with `textContent`. No remaining raw Bootstrap modal shell or native `alert()` exists outside the consent library. The raw alert inventory below contains only reviewed static content. The orchestrator's isolated announcement database tests with RollPoints enabled and disabled and the admin controller test passed before this presentation-only phase; no backend retest is needed.

## Final orchestrator review

Follow-up: alert/infobox memory now uses cookies filtered by `UiMessage` on the
server before HTML is emitted. The calendar hint and announcement infoboxes share
this behavior; modal memory remains in localStorage. Earlier infobox localStorage
keys are not migrated because this feature has not reached production. The focused
PHP cookie-rendering test and three existing JavaScript tests pass.

The orchestrator reviewed shared rendering, actions, browser queue/storage, AJAX errors, and the static-content corrections. A final scan found dismissible alert and modal shells only in the shared templates; `git diff --check` passed. Calendar static/small hint and announcement preview/link navigation were already checked in-browser and passed. No Sass build is needed because no SCSS changed. Real-browser mobile and simultaneous multi-tab scenarios were not exhaustively exercised; queue and memory behavior also have focused automated coverage.

Final focused checks completed: PHP syntax of `UiMessage.php` and every view, JS syntax, all three focused JS tests (including no-message page and mixed modal/confirmation initialization), and `git diff --check` passed. Worktree status contains only source, migration, docs and test files for this feature; no secrets, dependencies or `Files` data were added. No commit, push or deployment was performed.

## Reviewed static alert inventory

The following raw Bootstrap alert boxes are intentionally page content, not operational messages; they have no close button and no `data-nosnippet`:

- All `home/*` public information and FAQ boxes, including homepage child guidance, voucher guidance, sports/event information, rental rules and contact prompts.
- `kalendarz/sezon.php` large editable calendar text; `kalendarz/pokaz.php` child-enrollment guidance; `_templates/pass_restriction_alert.php` class pass/payment rules.
- `konto/moje_zajecia.php` unconfirmed phone notice; `konto/dane_do_przelewu.php` payment instruction; `_snippets/rental_order_form_fields.php` package price.
- `zajecia_grupowe/cennik.php` discount rules; `rollpoints/informacje.php` complaint help; `rollpoints/promotion.php` public promotion terms; `rollpoints/index.php` complaint help near the bottom of the page.
- `zarzadzanie/edycja_okresu_wylaczenia_wypozyczalni.php` date-range explanation; `zarzadzanie/okresy_oplat_sekcji.php` selected-season configuration explanation; `zarzadzanie/ustawienia_systemu.php` critical-settings instruction.
- `zarzadzanie/termin_indywidualne_zaplanuj.php` price explanation; `zarzadzanie/wplata_kwota.php` and `zarzadzanie/paragon_wystaw.php` payment-category instructions; all three alert-style blocks in printable `zarzadzanie/podglad_vouchera.php`.

## Minimal commands

PHP syntax: `docker compose -f "$HOME/Docker/localdev/docker-compose.yml" exec -T --workdir /var/www/sites/rollschool.localhost web-rollschool php -l application/Libs/UiMessage.php` (repeat for touched PHP templates).

JS syntax: `docker compose -f "$HOME/Docker/localdev/docker-compose.yml" run --rm -T -w /var/www/sites/rollschool.localhost sass node --check application/Resources/js/application.js`.

Focused JS tests: `docker compose -f "$HOME/Docker/localdev/docker-compose.yml" run --rm -T -w /var/www/sites/rollschool.localhost sass node --test tests/announcement_modal_queue_test.js tests/announcements_client_test.js tests/ui_messages_full_initialization_test.js`.
