@@ -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