* Apply suggested fix to tests/Unit/FOSSBilling/Twig/EdgeCaseRenderingTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to tests/Unit/FOSSBilling/Twig/EdgeCaseRenderingTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
---------
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Attach PDF invoices to invoice emails (#1724)
Adds generic file-attachment support to the email pipeline (Mail, QueuedEmail,
Email\Service) and wires it into invoice notifications via a new
"Attach PDF Copy to Invoice Emails" setting, so clients who pay by bank
transfer can view the invoice without logging in.
Also carries the same attachment into the sent-email activity log so a
later "resend" (client or admin) reattaches the PDF instead of dropping it.
* Address PR review: avoid blob hydration in email history list, fix checkbox uncheck
- ActivityClientEmailRepository::getSearchQueryBuilder() now selects a partial
entity that excludes attachment_content, so the paginated admin/client email
history list no longer hydrates every PDF into memory just to render
has_attachment. Verified against a real Doctrine EntityManager that the DQL
parses, the generated SQL excludes the blob column, and toApiArray() still
works correctly on the partial entity.
- mod_invoice_settings.html.twig: add the hidden-input-before-checkbox pattern
already used elsewhere in this codebase (e.g. mod_client_new_form.html.twig),
so unchecking "Attach PDF Copy to Invoice Emails" actually persists as
disabled instead of being silently dropped from the form submission.
* Sort client custom fields alphabetically and raise field cap to 20
Addresses #3174: client-facing forms (profile, signup, orderbutton)
now render custom fields sorted by their configured title instead of
a fixed numeric order, and the hardcoded limit of 10 custom fields is
raised to 20 via a new client table migration (patch85).
Also ignores src/config.old.php, the backup file the config patcher
creates automatically during config version migrations.
* Show custom fields 11-20 in the admin client management form
mod_client_manage.html.twig still looped 1..10 for the per-client
custom field editor, so staff couldn't view or edit values for the
new custom_11..custom_20 fields from the admin profile UI.
* Cover all 20 custom fields in the Profile updateClient test
CodeRabbit nitpick: the test payload only exercised custom_11 and
custom_20, unlike the full custom_1..custom_10 coverage it already
had, leaving custom_12..custom_19 untested.
* Allow admins to edit ticket replies, with edit history (#2317)
Admins previously had no way to fix a typo or correct a reply without
editing the database directly. Adds an Edit action to admin-authored
messages in the admin ticket view; client-authored messages remain
uneditable so an admin can never alter a client's own words.
Every edit snapshots the message's prior content into a new
support_ticket_message_history table before overwriting it, so the
original wording sent to a client is never silently lost. Admins can
view a message's revision history via a lazy-loaded modal.
Also fixes ticket_message_update, which existed but was never wired
into any UI and skipped the markdown sanitization that ticket_reply
already applies.
* Bump fresh-install last_patch to 83
Fresh installs seed last_patch from content.sql so the patcher doesn't
try to reapply migrations already baked into structure.sql. Missed
bumping this when patch83 (support_ticket_message_history) was added.
* Fix message history modal getting stuck on Loading... after a failed fetch
dataset.loaded was set before the API call resolved, so a failed
request left the modal permanently stuck on "Loading..." with no way
to retry short of a page reload. Move the flag to the success
callback and add an error handler that shows a retryable message.
* Make support_ticket_message_history.support_ticket_message_id required
A history row is meaningless without the message it snapshots; allowing
NULL let orphaned rows exist. Tightened the column in patch84,
structure.sql, and the entity's JoinColumn to NOT NULL.
* Delete message edit history when a ticket is removed
Service::rm() explicitly removes a ticket's notes and messages rather
than relying on the entity mapping's onDelete: CASCADE, because this
schema has no real FK constraints anywhere (referential integrity is
handled at the application layer throughout this codebase). History
rows were missed by that pattern and were left orphaned after a ticket
delete. Now removed alongside their message, following the same
explicit-cleanup convention as notes/messages.
Also cache SupportTicketMessageHistoryRepository via setDi(), matching
every other repository on this service, and add direct coverage for
getMessageHistory().
* Apply suggested fix to tests/Unit/FOSSBilling/Twig/Extension/FOSSBillingExtensionTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to tests/Unit/FOSSBilling/Twig/Extension/FOSSBillingExtensionTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
---------
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
---------
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Previously an email template's "enabled" flag was the only way to control
whether a staff notification (new order, ticket, signup, etc.) went out, and
when enabled it always went to every active staff member. This adds a
per-template staff-group allow-list so notifications can be scoped to the
teams that should actually receive them.
- New email_template_group join table/entity linking templates to admin
groups, with admin API endpoints and a UI card on the template page
mirroring the existing staff-member group management UI.
- Email\Service resolves to_staff recipients from the template's assigned
groups; a template with no groups assigned sends to nobody.
- Existing and newly-created built-in staff templates are auto-linked to
every current staff group (via an UpdatePatcher migration and
createBuiltinTemplateRecord) so upgrades and fresh installs keep today's
"notify everyone" behavior by default.
- Staff\Service::deleteGroup() now blocks removing a group that's still
restricting an email template.
Closes#1247
Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to tests/Unit/FOSSBilling/i18nTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
---------
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Add per-user timezone support across app
* Bump install DB last_patch to 81
* Address timezone review findings
* Fix uninitialized variable warnings in Email
* Consolidate validation and fix PHPStan variable init
- Hoist the template parse above the recipient dispatch so
$subject/$content are always defined before use (CI PHPStan
caught them as potentially undefined in the elseif branches).
- Address timezone review feedback
* Apply suggested fix to src/modules/Invoice/tests/Unit/ServiceTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to src/modules/Invoice/tests/Unit/ServiceTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to src/modules/Massmailer/Service.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to src/modules/Staff/tests/Unit/Api/AdminTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to tests/Unit/FOSSBilling/ResponseFactoryTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Fix file/download response content disposition
---------
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Recover DirectAdmin account deletion from false-negative API errors
Some DirectAdmin servers return an error for the account-delete request
even though the deletion already succeeded server-side, leaving the
order stuck in FOSSBilling and forcing users to rely on "Force delete".
cancelAccount() now verifies whether the account still exists before
failing, and only rethrows the original error if it does.
Fixes#3725
* Verify account existence via user list, not a fallible per-user check
The delete-verification check must not confuse a genuine transport,
auth, or permission failure with a successful deletion. Switch from a
per-user API_SHOW_USER_CONFIG lookup (which can fail for reasons
unrelated to whether the account still exists) to API_SHOW_USERS, a
reseller/admin-scoped listing call, and only treat the account as
deleted when the list confirms it's actually gone. If the
verification call itself errors, assume the account still exists so
the original deletion failure is preserved.
* Backfill manage_settings permission for existing staff groups (#3873)
PR #3856 started enforcing an explicit manage_settings permission to
view or edit a module's settings (e.g. Scheduled Tasks), but existing
staff groups that already had general access to those modules never
had the new permission granted, silently locking non-super-admin
staff out of settings pages they could previously use.
Add an update patch that grants manage_settings to any existing group
that already has access to the affected modules, preserving prior
behavior for upgrading installs.
* Match json_encode style with sibling permissions patch
Drop JSON_THROW_ON_ERROR to stay consistent with patch79's plain
json_encode() calls for admin_group.permissions.
* Bump fresh-install last_patch to 80
Adding patch80 in the previous commit made a fresh install's seeded
last_patch (still 79) report as behind on patches, since
latestPatchLevel() now returns 80. Live Tests caught this via the
"system is up to date" health check.
* Scope manage_settings backfill to groups predating the enforcement change
Codex correctly flagged that patch80 couldn't tell a legacy missing
manage_settings key apart from a group where an admin deliberately left
it unchecked after #3856 shipped, since the group form only submits
checked checkboxes. Concretely, patch79 creates the Support Staff
group scoped to ticket permissions only, and patch80 was immediately
re-granting it support.manage_settings in the same run.
Restrict the backfill to admin_group rows not updated since before
#3856 (2026-06-28), so it only touches groups whose missing key
predates the manage_settings checkbox existing at all.
* Apply suggested fix to src/modules/Staff/tests/Unit/Api/AdminTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to src/modules/Staff/tests/Unit/Api/AdminTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Fix Staff admin API super-admin test mocks
---------
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to src/modules/Staff/tests/Unit/Api/AdminTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to src/modules/Staff/tests/Unit/Api/AdminTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
---------
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to src/modules/Staff/tests/Unit/Api/AdminTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to src/modules/Staff/tests/Unit/Api/AdminTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
---------
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Apply suggested fix to src/modules/Staff/tests/Unit/Api/AdminTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Address code review follow-ups from admin groups/permissions rework (#3821)
- Default staff listing to excluding the internal cron account unless
explicitly overridden, restoring the safe default while keeping the
caller-controlled toggle added in #3821.
- Remove the now-unreachable `permissions.default.all` wildcard branch
in Staff::hasPermission(); no group permission UI/API can set it
since permissions moved to groups.
- Narrow the broad `catch (\Throwable)` around the pre-migration
Super Administrator fallback check in
System\Api\Admin::checkUpdateFinalizationPermissions() to
Doctrine\DBAL\Exception, so unrelated failures aren't silently
diverted into the legacy-role compatibility path.
* Generate content.sql seed timestamps at install time instead of hardcoding a date
#3821 bumped every created_at/updated_at literal in content.sql to a fixed
date, which just goes stale again and needs another manual bump later.
Replace the hardcoded '2026-06-25 12:00:00' literals with NOW() so seed
rows get the actual install time, for both the web installer (which runs
these statements individually via PDO) and manual imports of content.sql
per the instructions in config-sample.php.
Verified structure.sql + content.sql import cleanly into a throwaway
MariaDB container and NOW() resolves to real timestamps.
* Redo and migrate the Admin Group structure
* Update permisison checks to use groups
* Migrate admin group CRUD to Doctrine
* Remove legacy permission and group membership logic
* Replace legacy role logic
* Drop the admin.permissions column
* Only allow super admins to create/edit/delete groups, better guards
* Remove the redundant `admin.protected` column
* Clean group memberships when an admin is deleted
* Make the "Exclude cron user" filter work
* Improve labels
* Addressed code review comments
* Require an initial group
* Improved logger messages
* Replace role subtitle with email
* Bypass permission checks during update finalization to make sure it's accessible
* More sensible default groups
* Update seed content timestamps
* Fixed tests
* Cron login guard
* Addressed code review comments
* Change permission column type to JSON
* Addressed code review comments
* Migrate regular staff to a temporary group and disallow groupless staff management
* Look for Super Administrator or legacy `admin` role
* Fixed tests
* Changed test name to make cspell happy
* Grant required permissions to the groups
---------
Co-authored-by: Adam Daley <admdly@users.noreply.github.com>
* Apply suggested fix to src/modules/Support/tests/Unit/Api/GuestTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to src/modules/Support/tests/Unit/Api/GuestTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to src/modules/Servicehosting/templates/admin/mod_servicehosting_manage.html.twig from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
---------
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to src/modules/Support/tests/Unit/Api/ClientTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to src/modules/Support/tests/Unit/Api/GuestTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to src/modules/Support/tests/Unit/Repository/SupportTicketRepositoryTest.php from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
---------
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to src/modules/Servicehosting/templates/admin/mod_servicehosting_manage.html.twig from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Apply suggested fix to src/modules/Servicehosting/templates/admin/mod_servicehosting_manage.html.twig from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
---------
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
* Switch to using InformationException where possible
* Email: Remove dead methods and cleanup
* Extension: Move appropriate logic to the repository
* Support: Remove dead methods and cleanup
* Addressed code review comments
---------
Co-authored-by: Adam Daley <admdly@users.noreply.github.com>
* Migrate Email, Extension, Support modules to Doctrine ORM
* Add 'initialises' to cspell.json custom words
* Add patch76 and fix extension deactivation event
* Bump database patch version to 76
* Refactor Support APIs to mapped Doctrine flows
* Handle legacy email queue and ticket filters
* Migrate Support module to Doctrine ORM
* Refactor services to use typed repositories
* Route order ticket count and ticket messages through repositories
Drops the last two thin Support\Service wrappers, calling the
SupportTicketRepository and SupportTicketMessageRepository directly
from the cross-module callers.
* Rename email queue table and add patch
* Preserve unlimited email queue processing
* Preserve unlimited email queue processing
* Refactor API request/response HTTP helpers
* Centralize exception and response handling
* Use ResponseEmitter in installer entrypoints
* Add HTTP ResponseFactory and refactor Box_App
* Extract route matching into HTTP matcher
* Fix route param parsing and remove UrlHelper
* Fix exception status code crash and clean up refactor leftovers
ApiResponseFactory::getStatusCode() required an int code, but
Throwable::getCode() can return a string (e.g. PDOException's SQLSTATE),
so any non-FOSSBilling exception with a non-integer code crashed API
error handling with a TypeError instead of returning a JSON error.
Numeric-string codes are normalized to int to preserve prior loose-
comparison behavior; non-numeric codes fall back to the default status.
Also removes now-dead ErrorPage::generatePage(), redundant manual
requires of ResponseEmitter (already covered by composer's classmap
autoload), and duplicate emitResponse() calls in exceptionHandler().