Skip to content

Commit a817e75

Browse files
committed
Fix posts merging option.
1 parent f3a4efb commit a817e75

3 files changed

Lines changed: 40 additions & 6 deletions

File tree

event/listener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public function viewtopic_modify_data($event)
156156

157157
$this->helper->form_helper->prepare_qr_form($forum_id, $topic_id);
158158

159-
$this->helper->assign_template_variables_for_qr($forum_id);
159+
$this->helper->assign_template_variables_for_qr($forum_id, $topic_id);
160160

161161
$add_re = ($this->config['qr_enable_re']) ? 'Re: ' : '';
162162
$this->template->assign_var('SUBJECT', $this->request->variable('subject', $add_re . censor_text($topic_data['topic_title']), true));

functions/listener_helper.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,14 @@ public function set_form_parameters($forum_id, $topic_data, $qr_hidden_fields)
258258
* Assign template variables if quick reply is enabled
259259
*
260260
* @param int $forum_id Forum ID
261+
* @param int $topic_id Topic ID
261262
*/
262-
public function assign_template_variables_for_qr($forum_id)
263+
public function assign_template_variables_for_qr($forum_id, $topic_id)
263264
{
264265
$this->template_variables_for_qr($forum_id);
265-
$this->template_variables += $this->form_helper->form_template_variables;
266-
$this->template_variables += $this->plugins_helper->template_variables_for_plugins($forum_id);
267-
$this->template_variables += $this->plugins_helper->template_variables_for_extensions();
266+
$this->template_variables += $this->form_helper->form_template_variables
267+
+ $this->plugins_helper->template_variables_for_plugins($forum_id)
268+
+ $this->plugins_helper->template_variables_for_extensions($forum_id, $topic_id);
268269

269270
$this->template->assign_vars($this->template_variables);
270271
}

functions/plugins_helper.php

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,49 @@ public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config
3939
$this->phpbb_extension_manager = $phpbb_extension_manager;
4040
}
4141

42+
/**
43+
* Returns whether posts merging is allowed in current topic.
44+
* Used only when PostsMerging extension is enabled.
45+
*
46+
* @param int $forum_id Current forum ID
47+
* @param int $topic_id Current topic ID
48+
* @return bool
49+
*/
50+
private function posts_merging_allowed($forum_id, $topic_id)
51+
{
52+
return $this->auth->acl_get('u_postsmerging') &&
53+
$this->auth->acl_get('u_postsmerging_ignore') &&
54+
$this->auth->acl_get('f_noapprove', $forum_id) &&
55+
!$this->excluded_from_merge($forum_id, $topic_id);
56+
}
57+
58+
/**
59+
* Returns whether the current topic is excluded from posts merging.
60+
* Used only when PostsMerging extension is enabled.
61+
*
62+
* @param int $forum_id Current forum ID
63+
* @param int $topic_id Current topic ID
64+
* @return bool
65+
*/
66+
private function excluded_from_merge($forum_id, $topic_id)
67+
{
68+
return (in_array($forum_id, explode(',', $this->config['merge_no_forums']))
69+
|| in_array($topic_id, explode(',', $this->config['merge_no_topics'])));
70+
}
71+
4272
/**
4373
* Returns template variables for supported extensions for quick reply.
4474
*
75+
* @param int $forum_id Current forum ID
76+
* @param int $topic_id Current topic ID
4577
* @return array
4678
*/
47-
public function template_variables_for_extensions()
79+
public function template_variables_for_extensions($forum_id, $topic_id)
4880
{
4981
$template_variables = array();
5082
if (
5183
$this->phpbb_extension_manager->is_enabled('rxu/PostsMerging') &&
84+
$this->posts_merging_allowed($forum_id, $topic_id) &&
5285
$this->user->data['is_registered'] &&
5386
$this->config['merge_interval']
5487
)

0 commit comments

Comments
 (0)