Skip to content

Commit 3721f63

Browse files
authored
Merge pull request #24 from Crizz0/issue/23
Fix preview display of Privacy Policy and overwrite of default phpBBs PP and ToU
2 parents 6989621 + 9b2d712 commit 3721f63

File tree

4 files changed

+58
-2
lines changed

4 files changed

+58
-2
lines changed

adm/style/acp_tou_ppsetup.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ <h1>{{ lang('ACP_TOU_PPSETUP_TITLE') }}</h1>
3333

3434
</fieldset>
3535

36-
{% if ACP_TOU_TOU_PREVIEW %}
36+
{% if ACP_TOU_PREVIEW_PP %}
3737
<fieldset>
3838
<legend>{{ lang('ACP_TOU_INFO_PREVIEW_PP') }}</legend>
39-
<p>{{ ACP_TOU_PREVIEW_OUTPUT }}</p>
39+
<p>{{ ACP_TOU_PREVIEW_PP }}</p>
4040
</fieldset>
4141
{% endif %}
4242

config/services.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ services:
88
- '@controller.helper'
99
- '@user'
1010
- '@language'
11+
- '@request'
1112
- '@template'
1213
- '%core.root_path%'
1314
- '%core.php_ext%'

controller/main.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ class main
1919
/** @var \phpbb\db\driver\driver_interface */
2020
protected $db;
2121

22+
/** @var \phpbb\request\request */
23+
protected $request;
24+
2225
/** @var \phpbb\template\template */
2326
protected $template;
2427

event/main.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ static public function getSubscribedEvents()
2424
return array(
2525
'core.page_header' => 'page_header',
2626
'core.user_add_modify_data' => 'user_add_modify',
27+
'core.page_footer' => 'page_footer',
2728
);
2829
}
2930

@@ -36,6 +37,9 @@ static public function getSubscribedEvents()
3637
/** @var \phpbb\config\db_text */
3738
protected $config_text;
3839

40+
/** @var \phpbb\request\request */
41+
protected $request;
42+
3943
/** @var \phpbb\template\template */
4044
protected $template;
4145

@@ -63,6 +67,7 @@ static public function getSubscribedEvents()
6367
* @param \phpbb\auth\auth $auth Auth object
6468
* @param \phpbb\config\config $config
6569
* @param \phpbb\config\db_text $config_text
70+
* @param \phpbb\request\request $request
6671
* @param \phpbb\template\template $template Template object
6772
* @param \phpbb\controller\helper $helper Helper
6873
* @param \phpbb\language\language $language
@@ -77,6 +82,7 @@ public function __construct(
7782
\phpbb\controller\helper $helper,
7883
\phpbb\user $user,
7984
\phpbb\language\language $language,
85+
\phpbb\request\request $request,
8086
\phpbb\template\template $template,
8187
$phpbb_root_path,
8288
$php_ext)
@@ -90,6 +96,7 @@ public function __construct(
9096
$this->user = $user;
9197
$this->language =$language;
9298
$this->template = $template;
99+
$this->request = $request;
93100
}
94101

95102
public function page_header($event)
@@ -163,6 +170,51 @@ public function page_header($event)
163170
redirect($this->helper->route('phpbbde_tou_main_controller', [], false, false, \Symfony\Component\Routing\Generator\UrlGeneratorInterface::ABSOLUTE_URL));
164171
}
165172

173+
// Overwrite AGREEMENT_TEXT for ToU or PP
174+
public function page_footer()
175+
{
176+
$mode = $this->request->variable('mode', '');
177+
if (($mode == 'terms') && ($this->config['tou_use_custom_tou']))
178+
{
179+
$tou_data = $this->config_text->get_array(array(
180+
'tou_custom_tou_text',
181+
'tou_custom_tou_uid',
182+
'tou_custom_tou_bitfield',
183+
'tou_custom_tou_flags',
184+
));
185+
186+
$tou_custom_tou_text = generate_text_for_display(
187+
$tou_data['tou_custom_tou_text'],
188+
$tou_data['tou_custom_tou_uid'],
189+
$tou_data['tou_custom_tou_bitfield'],
190+
$tou_data['tou_custom_tou_flags']
191+
);
192+
$this->template->assign_vars(array(
193+
'AGREEMENT_TEXT' => sprintf($tou_custom_tou_text, $this->config['sitename'], generate_board_url()),
194+
));
195+
}
196+
else if (($mode == 'privacy') && ($this->config['tou_use_custom_pp']))
197+
{
198+
$pp_data = $this->config_text->get_array(array(
199+
'tou_custom_pp_text',
200+
'tou_custom_pp_uid',
201+
'tou_custom_pp_bitfield',
202+
'tou_custom_pp_flags',
203+
));
204+
205+
$tou_custom_pp_text = generate_text_for_display(
206+
$pp_data['tou_custom_pp_text'],
207+
$pp_data['tou_custom_pp_uid'],
208+
$pp_data['tou_custom_pp_bitfield'],
209+
$pp_data['tou_custom_pp_flags']
210+
);
211+
$this->template->assign_vars(array(
212+
'AGREEMENT_TEXT' => sprintf($tou_custom_pp_text, $this->config['sitename'], generate_board_url()),
213+
));
214+
}
215+
}
216+
217+
166218
public function user_add_modify($event)
167219
{
168220
$sql_ary = $event['sql_ary'];

0 commit comments

Comments
 (0)