This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * |
||
4 | * @package Quickedit |
||
5 | * @copyright (c) 2015 - 2021 Marc Alexander ( www.m-a-styles.de ) |
||
6 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 |
||
7 | * |
||
8 | */ |
||
9 | |||
10 | namespace marc1706\quickedit\event; |
||
11 | |||
12 | use phpbb\config\config; |
||
13 | use phpbb\json_response; |
||
14 | use phpbb\language\language; |
||
15 | use phpbb\request\request; |
||
16 | use phpbb\request\request_interface; |
||
17 | use phpbb\template\template; |
||
18 | use phpbb\template\twig\twig; |
||
19 | use phpbb\user; |
||
20 | use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
||
21 | |||
22 | class listener implements EventSubscriberInterface |
||
23 | { |
||
24 | /** @var config */ |
||
25 | protected $config; |
||
26 | |||
27 | /** @var listener_helper */ |
||
28 | protected $helper; |
||
29 | |||
30 | /** @var request */ |
||
31 | protected $request; |
||
32 | |||
33 | /** @var twig */ |
||
34 | protected $template; |
||
35 | |||
36 | /** @var user */ |
||
37 | protected $user; |
||
38 | |||
39 | /* @var language */ |
||
40 | protected $language; |
||
41 | 29 | ||
42 | /** |
||
43 | 29 | * Constructor for listener |
|
44 | 29 | * |
|
45 | 29 | * @param config $config phpBB config |
|
46 | 29 | * @param listener_helper $helper Listener helper |
|
47 | 29 | * @param request_interface $request $request phpBB request |
|
48 | 29 | * @param template $template phpBB template |
|
49 | * @param user $user phpBB user |
||
50 | * @param language $language |
||
51 | */ |
||
52 | public function __construct(config $config, listener_helper $helper, request_interface $request, template $template, user $user, language $language) |
||
53 | { |
||
54 | $this->config = $config; |
||
55 | $this->helper = $helper; |
||
56 | $this->request = $request; |
||
0 ignored issues
–
show
|
|||
57 | 11 | $this->template = $template; |
|
0 ignored issues
–
show
It seems like
$template of type object<phpbb\template\template> is incompatible with the declared type object<phpbb\template\twig\twig> of property $template .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..
Loading history...
|
|||
58 | $this->user = $user; |
||
59 | $this->language = $language; |
||
60 | 9 | } |
|
61 | 9 | ||
62 | 9 | /** |
|
63 | 11 | * Assign functions defined in this class to event listeners in the core |
|
64 | 11 | * |
|
65 | 9 | * @return array |
|
66 | 11 | * @static |
|
67 | 9 | */ |
|
68 | static public function getSubscribedEvents() : array |
||
69 | { |
||
70 | return array( |
||
71 | 'core.posting_modify_template_vars' => 'catch_ajax_requests', |
||
72 | 'core.acp_board_config_edit_add' => 'acp_board_settings', |
||
73 | 'core.acp_manage_forums_request_data' => 'add_forums_request_data', |
||
74 | 'core.acp_manage_forums_initialise_data' => 'initialise_forums_flag_data', |
||
75 | 'core.acp_manage_forums_display_form' => 'acp_forums_settings', |
||
76 | 'core.acp_manage_forums_update_data_before' => 'acp_forums_update_data', |
||
77 | 3 | 'core.viewtopic_modify_page_title' => 'check_quickedit_enabled', |
|
78 | ); |
||
79 | } |
||
80 | 3 | ||
81 | 3 | /** |
|
82 | * Check if request is ajax and output quickedit if it is |
||
83 | 2 | * |
|
84 | * @param object $event The event object |
||
85 | * @return void |
||
86 | 2 | */ |
|
87 | 2 | public function catch_ajax_requests($event) : void |
|
88 | { |
||
89 | 2 | // Parse page for quickedit window |
|
90 | if ($this->helper->is_catchable_request($event)) |
||
91 | 2 | { |
|
92 | 2 | // Add hidden fields |
|
93 | 2 | $this->helper->add_hidden_fields($event); |
|
94 | 2 | ||
95 | 2 | // Update S_HIDDEN_FIELDS in page_data |
|
96 | $this->template->assign_vars(array_merge($event['page_data'], array('S_HIDDEN_FIELDS' => $event['s_hidden_fields']))); |
||
97 | 1 | $this->template->set_filenames(array( |
|
98 | 'body' => '@marc1706_quickedit/quickedit_body.html' |
||
99 | )); |
||
100 | |||
101 | $json = new json_response(); |
||
102 | $json->send(array( |
||
103 | 'POST_ID' => $event['post_id'], |
||
104 | 'MESSAGE' => $this->template->assign_display('body'), |
||
105 | )); |
||
106 | 1 | } |
|
107 | } |
||
108 | 1 | ||
109 | 1 | /** |
|
110 | 1 | * Set ACP board settings |
|
111 | * |
||
112 | 1 | * @param object $event The event object |
|
113 | * @return void |
||
114 | 1 | */ |
|
115 | 1 | public function acp_board_settings($event) : void |
|
116 | 1 | { |
|
117 | 1 | if ($event['mode'] == 'features') |
|
118 | 1 | { |
|
119 | 1 | $this->helper->modify_acp_display_vars($event); |
|
120 | |||
121 | $this->language->add_lang('quickedit_acp', 'marc1706/quickedit'); |
||
122 | |||
123 | if ($this->request->is_set_post('allow_quick_edit_enable')) |
||
124 | { |
||
125 | $this->helper->enable_quick_edit($event); |
||
126 | } |
||
127 | } |
||
128 | } |
||
129 | 1 | ||
130 | /** |
||
131 | * Global quick edit enable/disable setting and button to enable in all forums |
||
132 | 1 | * |
|
133 | * @param int $value Value of quickedit settings. 1 if enabled, 0 if disabled |
||
134 | 1 | * @param string $key The key of the setting |
|
135 | * @return string HTML for quickedit settings |
||
136 | 1 | */ |
|
137 | static public function quickedit_settings(int $value, string $key) : string |
||
138 | 1 | { |
|
139 | 1 | // Called statically so can't use $this->language |
|
140 | 1 | global $language; |
|
141 | |||
142 | $language->add_lang('quickedit_acp', 'marc1706/quickedit'); |
||
143 | |||
144 | $radio_ary = array(1 => 'YES', 0 => 'NO'); |
||
145 | |||
146 | return h_radio('config[allow_quick_edit]', $radio_ary, $value) . |
||
147 | '<br /><br /><input class="button2" type="submit" id="' . $key . '_enable" name="' . $key . '_enable" value="' . $language->lang('ALLOW_QUICK_EDIT_BUTTON') . '" />'; |
||
148 | } |
||
149 | 1 | ||
150 | /** |
||
151 | 1 | * Add quickedit settings to forums request data |
|
152 | 1 | * |
|
153 | 1 | * @param object $event The event object |
|
154 | 1 | * @return void |
|
155 | */ |
||
156 | public function add_forums_request_data($event) : void |
||
157 | { |
||
158 | $forum_data = $event['forum_data']; |
||
159 | $forum_data += array('enable_quick_edit' => $this->request->variable('enable_quick_edit', false)); |
||
160 | $event->offsetSet('forum_data', $forum_data); |
||
161 | } |
||
162 | |||
163 | 1 | /** |
|
164 | * Add quickedit flag to forums_flag |
||
165 | 1 | * |
|
166 | 1 | * @param object $event The event object |
|
167 | 1 | * @return void |
|
168 | 1 | */ |
|
169 | public function initialise_forums_flag_data($event) : void |
||
170 | { |
||
171 | $forum_data = $event['forum_data']; |
||
172 | $forum_data['forum_flags'] += ($this->request->variable('enable_quick_edit', false)) ? listener_helper::QUICKEDIT_FLAG : 0; |
||
173 | $event->offsetSet('forum_data', $forum_data); |
||
174 | } |
||
175 | |||
176 | /** |
||
177 | 1 | * Add quickedit setting to acp_forums settings |
|
178 | * |
||
179 | 1 | * @param object $event The event object |
|
180 | * @return void |
||
181 | 1 | */ |
|
182 | 1 | public function acp_forums_settings($event) : void |
|
183 | 1 | { |
|
184 | 1 | $this->language->add_lang('quickedit_acp', 'marc1706/quickedit'); |
|
185 | |||
186 | $template_data = $event['template_data']; |
||
187 | $template_data['S_ENABLE_QUICK_EDIT'] = ($event['forum_data']['forum_flags'] & listener_helper::QUICKEDIT_FLAG) ? true : false; |
||
188 | $event->offsetSet('template_data', $template_data); |
||
189 | } |
||
190 | |||
191 | /** |
||
192 | * Update the forum_data_sql with the correct flag before submitting |
||
193 | 1 | * |
|
194 | * @param object $event The event object |
||
195 | 1 | * @return void |
|
196 | 1 | */ |
|
197 | 1 | public function acp_forums_update_data($event) : void |
|
198 | 1 | { |
|
199 | 1 | $forum_data_sql = $event['forum_data_sql']; |
|
200 | $forum_data_sql['forum_flags'] += ($forum_data_sql['enable_quick_edit']) ? listener_helper::QUICKEDIT_FLAG : 0; |
||
201 | unset($forum_data_sql['enable_quick_edit']); |
||
202 | $event->offsetSet('forum_data_sql', $forum_data_sql); |
||
203 | } |
||
204 | |||
205 | /** |
||
206 | * Check if quickedit is enabled and assign S_QUICK_EDIT accordingly |
||
207 | * |
||
208 | 1 | * @param object $event The event object |
|
209 | * @return void |
||
210 | */ |
||
211 | 1 | public function check_quickedit_enabled($event) : void |
|
212 | 1 | { |
|
213 | 1 | // Check if quick edit is available |
|
214 | $s_quick_edit = false; |
||
215 | 1 | if ($this->user->data['is_registered'] && $this->config['allow_quick_edit'] && $this->helper->check_forum_permissions($event)) |
|
216 | 1 | { |
|
217 | 1 | // Quick edit enabled forum |
|
218 | 1 | $s_quick_edit = $this->helper->check_topic_edit($event); |
|
219 | } |
||
220 | $this->template->assign_var('S_QUICK_EDIT', $s_quick_edit); |
||
221 | } |
||
222 | } |
||
223 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..