hryvinskyi / magento2-privacy-consent-admin-ui
Admin screens of the privacy consent suite: consents, the consent journal with CSV export, the customer's Consents tab, configuration.
Package info
github.com/hryvinskyi/magento2-privacy-consent-admin-ui
Type:magento2-module
pkg:composer/hryvinskyi/magento2-privacy-consent-admin-ui
Requires
- php: ~8.1.0||~8.2.0||~8.3.0||~8.4.0||~8.5.0
- hryvinskyi/magento2-document-export: ^1.0
- hryvinskyi/magento2-privacy-consent: ^1.0
- hryvinskyi/magento2-privacy-consent-api: ^1.0
- magento/framework: *
- magento/module-backend: *
- magento/module-cms: *
- magento/module-config: *
- magento/module-customer: *
- magento/module-store: *
- magento/module-ui: *
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
The admin half of the privacy consent suite: the screens where staff create the consents a store shows, read the consent journal, export it, and see one customer's records on the customer page. It implements no rule of its own. It calls the services of hryvinskyi/magento2-privacy-consent and reads its tables.
What it does for a store
- Consents (Customers > Privacy Consents > Consents). A listing of every consent with its code, title, required and active flags, store views, forms, sort order and current version. It filters by store view and by form. A Disable mass action deactivates the selected consents without changing anything else and writes no version, unless the linked CMS page was deleted since the last version; then the next save, a deactivation included, writes a version without a page. The form creates and edits a consent: code, title, checkbox text, linked CMS page, required, active, sort order, store views, forms and withdrawal actions. A Versions block on the form lists every version of the consent (number, the first 12 characters of the hash, date, required flag, page identifier). A consent the journal names cannot be deleted: the refusal is shown and the form stays open.
- Consent Journal (Customers > Privacy Consents > Consent Journal). A listing of the journal that filters by action, form, consent, store view, date, e-mail address and the unverified flag. Each row shows the consent and the version number, a link to the customer, the reference, the client address, whether the row was imported, and whether it is unverified. A row has a Delete action. The listing exports to CSV and Excel.
- The CSV export is safe for a spreadsheet. Text a visitor typed (the e-mail address, the reference, the consent code and title, the form code, the client address) is written with a leading
'when it starts with=,+,-,@, a tab or a carriage return, or holds one of those four signs after a;, a tab, a carriage return or a line break. Dates are written as the admin reads them. A value with a comma is quoted once. The Excel export keeps the values as they are: its cells are typed text, so a leading'would become part of the e-mail address or reference. - A Consents tab on the customer page. It lists the records of that customer only, and nothing for a customer who is not saved yet.
- Settings (Stores > Settings > Configuration > Hryvinskyi Extensions > Privacy Consents): whether the store view shows consent checkboxes, and how the journal keeps the client address.
- Permissions are the core's. A role that may only view consents is offered no Add New Consent button, no Save or Delete Consent button, no row Delete action and no mass action, and the routes refuse its requests. Exporting the journal needs its own permission, and a role without it is sent to the dashboard with "Sorry, you need permissions to view this content."
Requirements
- Magento Open Source or Adobe Commerce 2.4.x. The suite is built and tested on 2.4.9.
- PHP 8.1 to 8.5.
hryvinskyi/magento2-privacy-consent-api^1.0,hryvinskyi/magento2-privacy-consent^1.0 andhryvinskyi/magento2-document-export^1.0.- The platform's Backend, Config, UI, Customer, CMS and Store modules.
Installation
Run from the Magento root. hryvinskyi/magento2-privacy-consent-pack installs this package with the rest of the suite.
composer require hryvinskyi/magento2-privacy-consent-admin-ui bin/magento module:enable Hryvinskyi_PrivacyConsentApi Hryvinskyi_Clock Hryvinskyi_ClientAddress Hryvinskyi_PrivacyConsent Hryvinskyi_DocumentExport Hryvinskyi_PrivacyConsentAdminUi bin/magento setup:upgrade bin/magento setup:di:compile # production mode only bin/magento setup:static-content:deploy -f # production mode only bin/magento cache:flush
Verify in the admin, as a user whose role holds the resources listed below: Customers lists Privacy Consents with Consents and Consent Journal, and Consents opens an empty listing with an Add New Consent button.
Give each role the resources it needs under System > Permissions > User Roles > Role Resources. Saving a role asks for the admin's own password.
| Role resource | Allows |
|---|---|
Privacy Consents (Hryvinskyi_PrivacyConsent::privacy_consent) |
The menu group. |
View consents (Hryvinskyi_PrivacyConsent::consents) |
The consents listing and form, read only. |
Manage consents (Hryvinskyi_PrivacyConsent::consents_manage) |
New consent, save, delete, the Disable mass action. |
View the consent journal (Hryvinskyi_PrivacyConsent::journal) |
The journal listing, and the Consents tab on the customer page. |
Export the consent journal (Hryvinskyi_PrivacyConsent::journal_export) |
The CSV and Excel export. It also needs View the consent journal. |
Delete journal records (Hryvinskyi_PrivacyConsent::journal_delete) |
The Delete action of a journal row. |
Privacy Consents (Hryvinskyi_PrivacyConsent::config) |
The configuration section. |
Configuration
The section is hryvinskyi_privacy_consent, under the tab Hryvinskyi Extensions. Both fields can be set for a store view. The defaults, the stored values and what each address mode keeps are described in the core package's README.
| Label | Path | Options |
|---|---|---|
| Show Consent Checkboxes | hryvinskyi_privacy_consent/general/enabled |
Yes, No |
| Client Address | hryvinskyi_privacy_consent/journal/ip_mode |
Anonymised (recommended), Full address, Do not store |
Limits
- A consent's code cannot be changed after the first save. The form shows it read-only, and the save ignores a posted code.
- A consent the journal names cannot be deleted; deactivate it with Disable or the Active switch. Deactivating writes no version (unless the linked CMS page was deleted since the last version, see Consents above) and keeps the journal.
- The form and withdrawal action codes of a saved consent are not checked against the registered forms and actions. The form offers only registered ones. A code a hand-made request adds is stored and never shown; an action code that is not registered is skipped when the consent is withdrawn.
- The store views field is a plain multi-select. The platform's own store view field disables itself in a single-store shop, which would leave no way to assign a consent there.
- The delete confirmations name no consent title. No text an admin typed goes into a confirm dialog.
- The Consents tab on the customer page has no export button. Export is on the journal listing.
- A refused save keeps what was posted for the form's next display, once. The reason is the one the engine gives: an invalid code, a text with more than one link span, or a code that is already used.
Registrations
| Where | What |
|---|---|
| Admin route | frontName privacyconsent: consent/index, consent/new, consent/edit, consent/save, consent/delete, consent/massDisable, record/index, record/delete. |
| Menu | Hryvinskyi_PrivacyConsentAdminUi::menu (Privacy Consents, under Customers), ::consents and ::journal. |
| UI components | hryvinskyi_privacy_consent_listing, hryvinskyi_privacy_consent_form, hryvinskyi_privacy_consent_record_listing, hryvinskyi_privacy_consent_customer_record_listing, and a fieldset Consents merged into customer_form. |
| Layout handles | privacyconsent_consent_index, privacyconsent_consent_new, privacyconsent_consent_edit, privacyconsent_record_index. |
| Template | consent/versions.phtml (the Versions block). |
| Grid data | CollectionFactory::collections items hryvinskyi_privacy_consent_listing_data_source, hryvinskyi_privacy_consent_record_listing_data_source and hryvinskyi_privacy_consent_customer_record_listing_data_source. |
| Plugins (admin area) | Magento\Ui\Model\Export\MetadataProvider (guards the exported text of a CSV export, writes the date columns); Magento\Ui\Controller\Adminhtml\Export\GridToCsv and GridToXml (ask for the export permission). |
| Configuration | system.xml: section hryvinskyi_privacy_consent and tab hryvinskyi. |
The package registers no table, command, cron job, event or storefront file. The permissions and the defaults are the core's.
Extension points
None of its own. A form or a withdrawal action registered through the core's pools appears in the consent form without a change here.
Tests
Run from the Magento root.
- Unit:
vendor/bin/phpunit -c app/code/Hryvinskyi/PrivacyConsentAdminUi/phpunit.xml.dist. - Integration: the platform's harness in
dev/tests/integration, against its own database, one run at a time.cd dev/tests/integration && php -d memory_limit=4G ../../../vendor/bin/phpunit -c phpunit.xml ../../../app/code/Hryvinskyi/PrivacyConsentAdminUi/Test/Integration. - Browser flows: the journal and the customer's Consents tab are opened by the suite's browser specs, which sign in to the admin.
- Static analysis: PHPStan 2.x at level 10 with the package's
phpstan.neon.dist(phpstan analyse -c app/code/Hryvinskyi/PrivacyConsentAdminUi/phpstan.neon.dist --level=10), andvendor/bin/phpcs --standard=app/code/Hryvinskyi/PrivacyConsentAdminUi/phpcs.xml.dist app/code/Hryvinskyi/PrivacyConsentAdminUi.
Translations
The admin wording ships in en_US and 25 more locales: the official languages of the European Union, Norwegian Bokmål and Ukrainian. The translations are machine-made; have them read by a native speaker before a store relies on them, and override a phrase in a theme or a language pack.