Skip to content

Commit 9225678

Browse files
authored
Merge pull request #27 from iMattPro/updates
Compliance updates
2 parents ba695c3 + 8b27c5a commit 9225678

8 files changed

Lines changed: 30 additions & 16 deletions

File tree

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ Simple, GDPR-ready privacy controls with category-based consent, ACP management
1717

1818
- Consent banner and preference modal
1919
- Category-based consent options
20-
- Consent logging
20+
- Deferred script and iframe media loading
21+
- Consent logging with CSV export and deletion tools
2122
- Consent version resets
22-
- ACP-managed categories, integrations, and audit logs
23-
- Extension integration API
23+
- Google Consent Mode
24+
- ACP-managed categories, integrations, translations, and audit logs
25+
- PHP and JavaScript integration APIs
2426

2527
### Supported categories:
2628

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "phpbb/consentmanager",
33
"type": "phpbb-extension",
4-
"description": "Centralized GDPR-compliant consent and deferred script loading for phpBB forums.",
4+
"description": "GDPR-ready consent manager for phpBB forums, providing category consent, deferred script and iframe loading, consent logging, and extension integration APIs.",
55
"homepage": "https://www.phpbb.com/",
66
"version": "1.0.0-a2",
77
"keywords": ["phpbb", "extension", "gdpr", "consent", "cookies"],

language/en/common.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
'CONSENTMANAGER_DEFAULT_BANNER_TITLE' => 'We value your privacy',
3131
'CONSENTMANAGER_DEFAULT_BANNER_TEXT' => 'This forum uses cookies to keep you signed in, secure your account, and ensure the site works properly. With your consent, we may also use optional cookies and similar technologies for analytics, marketing, and embedded media.',
3232
'CONSENTMANAGER_DEFAULT_BANNER_SUBTEXT' => 'You can change your preferences at any time in the Privacy Settings.',
33+
'CONSENTMANAGER_PRIVACY_POLICY_LINK' => 'Read our %s here.',
3334
'CONSENTMANAGER_CATEGORY_NECESSARY' => 'Necessary',
3435
'CONSENTMANAGER_CATEGORY_NECESSARY_EXPLAIN' => 'Required for forum security, authentication, and essential site functionality.',
3536
'CONSENTMANAGER_CATEGORY_ANALYTICS' => 'Analytics',

service/log_manager.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,6 @@ public function __construct(config $config, driver_interface $db, user $user, $c
5454
*/
5555
public function log_consent(array $categories, $version)
5656
{
57-
if ((int) $this->user->data['user_id'] === ANONYMOUS)
58-
{
59-
return;
60-
}
61-
6257
$record = [
6358
'anonymized_id' => $this->get_anonymized_subject(),
6459
'consent_version' => (int) $version,
@@ -71,12 +66,14 @@ public function log_consent(array $categories, $version)
7166
}
7267

7368
/**
74-
* Build an anonymized identifier for the current authenticated user.
69+
* Build an anonymized identifier for the current user or session.
7570
*
7671
* @return string
7772
*/
7873
protected function get_anonymized_subject()
7974
{
80-
return hash_hmac('sha256', 'u:' . (int) $this->user->data['user_id'], $this->config['rand_seed']);
75+
$subject = (int) $this->user->data['user_id'] !== ANONYMOUS ? 'u:' . (int) $this->user->data['user_id'] : 's:' . $this->user->session_id;
76+
77+
return hash_hmac('sha256', $subject, $this->config['rand_seed']);
8178
}
8279
}

styles/all/template/event/overall_footer_body_after.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{% if S_CONSENTMANAGER_ENABLED %}
2+
{% set privacy_link %}<a class="consent-manager-policy-link" href="{{ U_PRIVACY }}">{{ lang('PRIVACY') }}</a>{% endset %}
23
<div id="consent-manager-root" class="consent-manager-root">
34
<div class="consent-manager-banner" id="consent-manager-banner" role="region" aria-labelledby="consent-manager-banner-title" aria-describedby="consent-manager-banner-copy" hidden="hidden">
45
<h2 class="consent-manager-heading" id="consent-manager-banner-title">{{ CONSENTMANAGER_BANNER_TITLE }}</h2>
5-
<p class="consent-manager-copy" id="consent-manager-banner-copy">{{ CONSENTMANAGER_BANNER_TEXT }} {{ CONSENTMANAGER_BANNER_SUBTEXT }}</p>
6+
<p class="consent-manager-copy" id="consent-manager-banner-copy">{{ CONSENTMANAGER_BANNER_TEXT }} {{ CONSENTMANAGER_BANNER_SUBTEXT }} {{ lang('CONSENTMANAGER_PRIVACY_POLICY_LINK', privacy_link) }}</p>
67
<div class="consent-manager-actions">
78
<button type="button" class="consent-manager-button" data-consent-action="accept-all">{{ lang('CONSENTMANAGER_ACCEPT_ALL') }}</button>
89
<button type="button" class="consent-manager-button" data-consent-action="reject-all">{{ lang('CONSENTMANAGER_REJECT_ALL') }}</button>
@@ -16,6 +17,7 @@ <h2 class="consent-manager-heading" id="consent-manager-modal-title" style="marg
1617
<button type="button" class="consent-manager-button" data-consent-action="close-settings">{{ lang('CLOSE_WINDOW') }}</button>
1718
</div>
1819
<p class="consent-manager-copy" id="consent-manager-modal-copy">{{ CONSENTMANAGER_BANNER_TEXT }}</p>
20+
<p class="consent-manager-copy">{{ lang('CONSENTMANAGER_PRIVACY_POLICY_LINK', privacy_link) }}</p>
1921
{% for cat in CONSENTMANAGER_CATEGORIES %}
2022
<section class="consent-manager-category">
2123
<div class="consent-manager-category-header">

styles/all/theme/consentmanager.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.consent-manager-root {
22
--consent-manager-color-text: #111827;
33
--consent-manager-color-text-muted: #475569;
4+
--consent-manager-color-link: #105289;
45
--consent-manager-color-surface: #ffffff;
56
--consent-manager-color-border: rgba(18, 41, 64, 0.16);
67
--consent-manager-color-border-subtle: #e2e8f0;
@@ -74,6 +75,10 @@
7475
margin: 0;
7576
}
7677

78+
.consent-manager-policy-link {
79+
color: var(--consent-manager-color-link);
80+
}
81+
7782
.consent-manager-actions {
7883
display: flex;
7984
flex-wrap: wrap;

tests/functional/frontend_test.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public function test_frontend_markup_is_injected_on_board_pages()
3232

3333
$this->assertStringContainsString('consent-manager-root', $content);
3434
$this->assertContainsLang('CONSENTMANAGER_SETTINGS_TITLE', $crawler->filter('#consent-manager-link')->text());
35+
$this->assertSame(2, $crawler->filter('.consent-manager-policy-link')->count());
3536
$this->assertSame(1, $payload['version']);
3637
$this->assertSame('phpbb_consent_manager', $payload['storageKey']);
3738
$this->assertSame($this->lang('CONSENTMANAGER_MEDIA_PLACEHOLDER'), $this->extract_media_placeholder_label($content));
@@ -61,7 +62,7 @@ public function test_log_endpoint_rejects_invalid_json_payload()
6162
), json_decode(self::$client->getResponse()->getContent(), true));
6263
}
6364

64-
public function test_log_endpoint_accepts_valid_anonymous_submission_without_persisting_it()
65+
public function test_log_endpoint_persists_valid_anonymous_submission()
6566
{
6667
$payload = $this->fetch_frontend_payload();
6768
$response = $this->post_log_request($payload, array('analytics', 'analytics', 'unknown'));
@@ -76,7 +77,7 @@ public function test_log_endpoint_accepts_valid_anonymous_submission_without_per
7677
$row = $this->db->sql_fetchrow($result);
7778
$this->db->sql_freeresult($result);
7879

79-
$this->assertSame(0, (int) $row['log_count']);
80+
$this->assertSame(1, (int) $row['log_count']);
8081
}
8182

8283
public function test_log_endpoint_persists_valid_authenticated_submission()

tests/service/log_manager_test.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,18 @@ public function test_log_consent_persists_authenticated_subject()
5656
FROM phpbb_consentmanager_logs');
5757
}
5858

59-
public function test_log_consent_skips_guests()
59+
public function test_log_consent_uses_session_identifier_for_guests()
6060
{
6161
$manager = $this->create_manager(ANONYMOUS, 'guest-session');
6262
$manager->log_consent(array('necessary'), 9);
6363

64-
$this->assertSqlResultEquals(array(), 'SELECT anonymized_id, consent_version, accepted_categories
64+
$this->assertSqlResultEquals(array(
65+
array(
66+
'anonymized_id' => hash_hmac('sha256', 's:guest-session', 'random-seed'),
67+
'consent_version' => '9',
68+
'accepted_categories' => '["necessary"]',
69+
),
70+
), 'SELECT anonymized_id, consent_version, accepted_categories
6571
FROM phpbb_consentmanager_logs');
6672
}
6773

0 commit comments

Comments
 (0)