Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 76 additions & 1 deletion adm/style/consentmanager_acp.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,52 @@ <h3>{{ lang('WARNING') }}</h3>
</dl>
</fieldset>

<fieldset>
<legend>{{ lang('ACP_CONSENTMANAGER_REGISTRATIONS') }}</legend>
<dl>
<dt><span>{{ lang('ACP_CONSENTMANAGER_REGISTRATIONS_EXPLAIN') }}</span></dt>
<dd>
{% if CONSENTMANAGER_SERVICES %}
{% set services = S_CONSENTMANAGER_MEDIA ? CONSENTMANAGER_SERVICES|merge([{'category': 'media', 'label': 'iframe bbcodes', 'id': 'phpbb.consentmanager'}]) : CONSENTMANAGER_SERVICES %}
{% for category in [
{ id: 'necessary', label: lang('CONSENTMANAGER_CATEGORY_NECESSARY') },
{ id: 'analytics', label: lang('CONSENTMANAGER_CATEGORY_ANALYTICS') },
{ id: 'marketing', label: lang('CONSENTMANAGER_CATEGORY_MARKETING') },
{ id: 'media', label: lang('CONSENTMANAGER_CATEGORY_MEDIA') }
] %}
{% set category_has_services = false %}
{% for service in services if service.category == category.id %}
{% if not category_has_services %}
{% set category_has_services = true %}
<strong>{{ category.label }}</strong>
<ul>
{% endif %}
<li style="font-size: 0.7rem">{{ service.label }} » <em>{{ service.id }}</em></li>
{% endfor %}
{% if category_has_services %}
</ul>
{% endif %}
{% endfor %}
{% else %}
{{ lang('ACP_CONSENTMANAGER_REGISTRATIONS_NONE') }}
{% endif %}
</dd>
</dl>
</fieldset>

<fieldset>
<legend>{{ lang('ACP_CONSENTMANAGER_INTEGRATIONS') }}</legend>
<dl>
<dt><label for="consentmanager_integrations">{{ lang('ACP_CONSENTMANAGER_INTEGRATIONS') ~ lang('COLON') }}</label><br><span>{{ lang('ACP_CONSENTMANAGER_INTEGRATIONS_EXPLAIN') }}</span><br><br>
<span><strong>{{ lang('EXAMPLE') ~ lang('COLON') }}</strong></span><br>
<pre><samp class="error">{{ CONSENTMANAGER_INTEGRATIONS_EXAMPLE }}</samp></pre>
</dt>
<dd><textarea id="consentmanager_integrations" name="consentmanager_integrations" rows="14" cols="90">{{ CONSENTMANAGER_INTEGRATIONS|e('html') }}</textarea></dd>
<dd>
<div style="position: relative; display: inline-block;">
<textarea id="consentmanager_integrations" name="consentmanager_integrations" rows="14" cols="90" style="padding-right: 7.5em; padding-bottom: 1.8em;">{{ CONSENTMANAGER_INTEGRATIONS|e('html') }}</textarea>
<span id="consentmanager_integrations_warning" style="position: absolute; right: 0.8em; bottom: 0.8em; color: #bc2a4d; font-size: 0.85em; font-weight: bold; pointer-events: none; display: none;">{{ lang('ACP_CONSENTMANAGER_INVALID_JSON') }}</span>
</div>
</dd>
</dl>
</fieldset>

Expand All @@ -63,4 +101,41 @@ <h3>{{ lang('WARNING') }}</h3>
</fieldset>
</form>

<script>
document.addEventListener('DOMContentLoaded', function() {
var textarea = document.getElementById('consentmanager_integrations');
var warning = document.getElementById('consentmanager_integrations_warning');

if (!textarea || !warning)
{
return;
}

var updateWarning = function() {
var value = textarea.value.trim();
var isValidArray = false;

if (value === '')
{
warning.style.display = 'none';
return;
}

try
{
isValidArray = Array.isArray(JSON.parse(value));
}
catch (error)
{
isValidArray = false;
}

warning.style.display = isValidArray ? 'none' : 'block';
};

textarea.addEventListener('input', updateWarning);
updateWarning();
});
</script>

{% include 'overall_footer.html' %}
12 changes: 10 additions & 2 deletions language/en/acp_consentmanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,24 @@
'ACP_CONSENTMANAGER_MARKETING_EXPLAIN' => 'Allows advertising and marketing integrations to be presented to users and loaded after consent.',
'ACP_CONSENTMANAGER_MEDIA' => 'Enable embedded media category',
'ACP_CONSENTMANAGER_MEDIA_EXPLAIN' => 'Allows videos, players, widgets, and other iframe-based external media to be loaded after consent.',
'ACP_CONSENTMANAGER_INTEGRATIONS' => 'ACP-managed integrations',
'ACP_CONSENTMANAGER_INTEGRATIONS_EXPLAIN' => 'Use this to add simple third-party analytics, marketing, or scripts directly from the ACP instead of through an extension. These entries appear in the consent UI and are only loaded after consent.<br><br>Provide a JSON array of integrations.<br><br>Each object must include: <samp class="error">id</samp>, <samp class="error">category</samp>, <samp class="error">src</samp>. The <samp class="error">id</samp> may only use letters, numbers, dots, underscores, colons, and hyphens. The <samp class="error">category</samp> must be <samp class="error">necessary</samp>, <samp class="error">analytics</samp>, or <samp class="error">marketing</samp>. The <samp class="error">src</samp> must be a valid http, https, or relative script URL.<br><br>Optional fields: <samp class="error">label</samp>, <samp class="error">description</samp>, <samp class="error">async</samp>, <samp class="error">defer</samp>.',
'ACP_CONSENTMANAGER_INTEGRATIONS' => 'Manual integrations',
'ACP_CONSENTMANAGER_INTEGRATIONS_EXPLAIN' => 'Use this to add third-party analytics, marketing, or other scripts directly from the ACP. These integrations appear in the consent UI and are only loaded after the required consent has been granted.<br><br>Provide a JSON array of integrations.<br><br>Each object must include: <samp class="error">id</samp>, <samp class="error">category</samp>, <samp class="error">src</samp>. The <samp class="error">id</samp> may only use letters, numbers, dots, underscores, colons, and hyphens. The <samp class="error">category</samp> must be <samp class="error">necessary</samp>, <samp class="error">analytics</samp>, or <samp class="error">marketing</samp>. The <samp class="error">src</samp> must be a valid http, https, or relative script URL.<br><br>Optional fields: <samp class="error">label</samp>, <samp class="error">description</samp>, <samp class="error">async</samp>, <samp class="error">defer</samp>.',
'ACP_CONSENTMANAGER_INTEGRATIONS_EXAMPLE_LABEL' => 'Example Analytics',
'ACP_CONSENTMANAGER_INTEGRATIONS_EXAMPLE_DESC' => 'Loads a simple analytics library after consent.',
'ACP_CONSENTMANAGER_REGISTRATIONS' => 'Registered integrations',
'ACP_CONSENTMANAGER_REGISTRATIONS_EXPLAIN' => 'These services are registered with Consent Manager and automatically respect consent settings.',
'ACP_CONSENTMANAGER_REGISTRATIONS_NONE' => 'No services are currently registered with Consent Manager.',
'ACP_CONSENTMANAGER_VERSION' => 'Current consent version',
'ACP_CONSENTMANAGER_VERSION_EXPLAIN' => 'Increase the version to force a fresh prompt for every visitor when the consent text or integrations materially change.',
'ACP_CONSENTMANAGER_FORCE_REPROMPT' => 'Force re-prompt',
'ACP_CONSENTMANAGER_REPROMPT_SUCCESS' => 'Consent version increased. Visitors will be asked to review their settings again.',
'ACP_CONSENTMANAGER_INVALID_INTEGRATIONS' => 'The integrations field must contain a valid JSON array.',
'ACP_CONSENTMANAGER_INVALID_INTEGRATION_ENTRY' => 'Integration entry %1$s is invalid. Each entry must include a safe id, supported category, and valid script source URL.',
'ACP_CONSENTMANAGER_INVALID_JSON' => 'Invalid JSON',
'CONSENTMANAGER_CATEGORY_NECESSARY' => 'Necessary',
'CONSENTMANAGER_CATEGORY_ANALYTICS' => 'Analytics',
'CONSENTMANAGER_CATEGORY_MARKETING' => 'Marketing',
'CONSENTMANAGER_CATEGORY_MEDIA' => 'Media',
'EXAMPLE' => 'Example',

// Consent logs
Expand Down
1 change: 1 addition & 0 deletions service/acp_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public function get_settings_template_data()
'S_CONSENTMANAGER_MARKETING' => (bool) $this->config['consentmanager_marketing_enabled'],
'S_CONSENTMANAGER_MEDIA' => (bool) $this->config['consentmanager_media_enabled'],
'CONSENTMANAGER_VERSION' => (int) $this->config['consentmanager_consent_version'],
'CONSENTMANAGER_SERVICES' => $this->consent_manager->get_services(),
'CONSENTMANAGER_INTEGRATIONS' => $this->get_integrations_json(),
'CONSENTMANAGER_INTEGRATIONS_EXAMPLE' => $this->get_integrations_example_json(),
];
Expand Down
Loading