Skip to content

Commit de4961a

Browse files
committed
Ammend privacy policy regarding embedded content
1 parent 6086b19 commit de4961a

3 files changed

Lines changed: 95 additions & 0 deletions

File tree

event/main_listener.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public static function getSubscribedEvents()
7070
'core.message_parser_check_message' => [['check_signature'], ['check_magic_urls'], ['check_bbcode_enabled']],
7171
'core.text_formatter_s9e_parser_setup' => [['disable_media_embed'], ['setup_cache_dir']],
7272
'core.page_header' => 'setup_media_configs',
73+
'core.page_footer_after' => 'append_agreement',
7374
];
7475
}
7576

@@ -365,4 +366,21 @@ protected function get_siteIds()
365366

366367
return $siteIds ? json_decode($siteIds, true) : [];
367368
}
369+
370+
/**
371+
* Appends additional language to the privacy policy agreement text.
372+
*
373+
* @return void
374+
*/
375+
public function append_agreement()
376+
{
377+
if (!$this->template->retrieve_var('S_AGREEMENT') || ($this->template->retrieve_var('AGREEMENT_TITLE') !== $this->language->lang('PRIVACY')))
378+
{
379+
return;
380+
}
381+
382+
$this->language->add_lang('info_ucp_mediaembed', 'phpbb/mediaembed');
383+
384+
$this->template->append_var('AGREEMENT_TEXT', $this->language->lang('MEDIA_EMBED_PRIVACY_POLICY', $this->config['sitename']));
385+
}
368386
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
*
4+
* phpBB Media Embed PlugIn extension for the phpBB Forum Software package.
5+
*
6+
* @copyright (c) 2016 phpBB Limited <https://www.phpbb.com>
7+
* @license GNU General Public License, version 2 (GPL-2.0)
8+
*
9+
*/
10+
11+
if (!defined('IN_PHPBB'))
12+
{
13+
exit;
14+
}
15+
16+
if (empty($lang) || !is_array($lang))
17+
{
18+
$lang = [];
19+
}
20+
21+
$lang = array_merge($lang, [
22+
'MEDIA_EMBED_PRIVACY_POLICY' => '
23+
<br><br>
24+
<h3>Embedded Content from Other Websites</h3>
25+
“%1$s” may include posts or content that contain embedded material from external websites, including but not limited to YouTube, Facebook, Twitter, and similar platforms. Embedded content from these external sites behaves in the same way as if you had visited the originating website directly.
26+
<br><br>These external websites may collect data about you, use cookies, embed additional third-party tracking, and monitor your interaction with the embedded content, including tracking your interaction if you have an account and are logged in to that website.
27+
<br><br>Please note that such activity is beyond the control of “%1$s” and is governed by the privacy policies and terms of service of the respective external websites. We encourage you to review the privacy and cookie policies of any third-party services you interact with through embedded content.
28+
',
29+
]);

tests/event/listener_test.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ public function test_getSubscribedEvents()
133133
'core.message_parser_check_message',
134134
'core.text_formatter_s9e_parser_setup',
135135
'core.page_header',
136+
'core.page_footer_after',
136137
], array_keys(\phpbb\mediaembed\event\main_listener::getSubscribedEvents()));
137138
}
138139

@@ -512,6 +513,53 @@ public function test_setup_cache_dir($cache)
512513
}
513514
}
514515

516+
/**
517+
* Data for test_append_agreement
518+
*
519+
* @return array
520+
*/
521+
public function append_agreement_data()
522+
{
523+
return [
524+
[false, 'PRIVACY', 0], // No agreement
525+
[true, 'TERMS', 0], // Wrong title
526+
[true, 'PRIVACY', 1], // Correct conditions
527+
];
528+
}
529+
530+
/**
531+
* Test the append_agreement method
532+
*
533+
* @dataProvider append_agreement_data
534+
* @param mixed $s_agreement S_AGREEMENT template variable value
535+
* @param mixed $agreement_title AGREEMENT_TITLE template variable value
536+
* @param int $expected_append_calls Expected append_var calls
537+
*/
538+
public function test_append_agreement($s_agreement, $agreement_title, $expected_append_calls)
539+
{
540+
$this->config['sitename'] = 'Test Forum';
541+
542+
$this->template->expects(self::atMost(2))
543+
->method('retrieve_var')
544+
->withConsecutive(['S_AGREEMENT'], ['AGREEMENT_TITLE'])
545+
->willReturnOnConsecutiveCalls($s_agreement, $this->language->lang($agreement_title));
546+
547+
if ($expected_append_calls > 0)
548+
{
549+
$this->template->expects(self::once())
550+
->method('append_var')
551+
->with('AGREEMENT_TEXT', $this->language->lang('MEDIA_EMBED_PRIVACY_POLICY', 'Test Forum'));
552+
}
553+
else
554+
{
555+
$this->template->expects(self::never())
556+
->method('append_var');
557+
}
558+
559+
$listener = $this->get_listener();
560+
$listener->append_agreement();
561+
}
562+
515563
protected function mock_s9e_parser()
516564
{
517565
return $this->getMockBuilder('s9e\\TextFormatter\\Parser')

0 commit comments

Comments
 (0)