Passed
Branch master (d4fa65)
by Matt
15:12 queued 12:46
created

admin_controller   B

Complexity

Total Complexity 49

Size/Duplication

Total Lines 517
Duplicated Lines 0 %

Test Coverage

Coverage 94.02%

Importance

Changes 30
Bugs 0 Features 0
Metric Value
eloc 173
c 30
b 0
f 0
dl 0
loc 517
rs 8.48
ccs 220
cts 234
cp 0.9402
wmc 49

21 Methods

Rating   Name   Duplication   Size   Complexity  
A get_submitted_action() 0 12 3
A action_enable() 0 3 1
A action_add() 0 23 2
A action_delete() 0 42 5
A upload_banner() 0 3 1
A submit_add() 0 11 2
A analyse_ad_code() 0 3 1
A success() 0 3 1
A error() 0 3 1
A action_disable() 0 3 1
A preview() 0 3 1
A get_page_title() 0 3 1
A submit_edit() 0 23 4
A set_page_url() 0 3 1
A mode_manage() 0 12 2
A mode_settings() 0 23 3
B list_ads() 0 35 6
A toggle_permission() 0 7 2
A action_edit() 0 31 3
A __construct() 0 23 2
A ad_enable() 0 26 6

How to fix   Complexity   

Complex Class

Complex classes like admin_controller often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use admin_controller, and based on these observations, apply Extract Interface, too.

1
<?php
2
/**
3
 *
4
 * Advertisement management. An extension for the phpBB Forum Software package.
5
 *
6
 * @copyright (c) 2017 phpBB Limited <https://www.phpbb.com>
7
 * @license GNU General Public License, version 2 (GPL-2.0)
8
 *
9
 */
10
11
namespace phpbb\ads\controller;
12
13
use phpbb\ads\ext;
14
15
/**
16
* Admin controller
17
*/
18
class admin_controller
19
{
20
	/** @var array Form data */
21
	protected $data = array();
22
23
	/** @var \phpbb\template\template */
0 ignored issues
show
Bug introduced by
The type phpbb\template\template was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
24
	protected $template;
25
26
	/** @var \phpbb\language\language */
0 ignored issues
show
Bug introduced by
The type phpbb\language\language was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
27
	protected $language;
28
29
	/** @var \phpbb\request\request */
0 ignored issues
show
Bug introduced by
The type phpbb\request\request was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
30
	protected $request;
31
32
	/** @var \phpbb\ads\ad\manager */
33
	protected $manager;
34
35
	/** @var \phpbb\config\db_text */
0 ignored issues
show
Bug introduced by
The type phpbb\config\db_text was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
36
	protected $config_text;
37
38
	/** @var \phpbb\config\config */
0 ignored issues
show
Bug introduced by
The type phpbb\config\config was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
39
	protected $config;
40
41
	/** @var \phpbb\ads\controller\admin_input */
42
	protected $input;
43
44
	/** @var \phpbb\ads\controller\helper */
45
	protected $helper;
46
47
	/** @var \phpbb\ads\analyser\manager */
48
	protected $analyser;
49
50
	/** @var \phpbb\controller\helper */
0 ignored issues
show
Bug introduced by
The type phpbb\controller\helper was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
51
	protected $controller_helper;
52
53
	/** @var string Custom form action */
54
	protected $u_action;
55
56
	/** @var \auth_admin Auth admin */
0 ignored issues
show
Bug introduced by
The type auth_admin was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
57
	protected $auth_admin;
58
59
	/**
60
	 * Constructor
61
	 *
62
	 * @param \phpbb\template\template          $template          Template object
63
	 * @param \phpbb\language\language          $language          Language object
64
	 * @param \phpbb\request\request            $request           Request object
65
	 * @param \phpbb\ads\ad\manager             $manager           Advertisement manager object
66
	 * @param \phpbb\config\db_text             $config_text       Config text object
67
	 * @param \phpbb\config\config              $config            Config object
68
	 * @param \phpbb\ads\controller\admin_input $input             Admin input object
69
	 * @param \phpbb\ads\controller\helper      $helper            Helper object
70
	 * @param \phpbb\ads\analyser\manager       $analyser          Ad code analyser object
71
	 * @param \phpbb\controller\helper          $controller_helper Controller helper object
72
	 * @param string                            $root_path         phpBB root path
73
	 * @param string                            $php_ext           PHP extension
74
	 */
75 37
	public function __construct(\phpbb\template\template $template, \phpbb\language\language $language, \phpbb\request\request $request, \phpbb\ads\ad\manager $manager, \phpbb\config\db_text $config_text, \phpbb\config\config $config, \phpbb\ads\controller\admin_input $input, \phpbb\ads\controller\helper $helper, \phpbb\ads\analyser\manager $analyser, \phpbb\controller\helper $controller_helper, $root_path, $php_ext)
76
	{
77 37
		$this->template = $template;
78 37
		$this->language = $language;
79 37
		$this->request = $request;
80 37
		$this->manager = $manager;
81 37
		$this->config_text = $config_text;
82 37
		$this->config = $config;
83 37
		$this->input = $input;
84 37
		$this->helper = $helper;
85 37
		$this->analyser = $analyser;
86 37
		$this->controller_helper = $controller_helper;
87
88 37
		$this->language->add_lang('posting'); // Used by banner_upload() file errors
89 37
		$this->language->add_lang('acp', 'phpbb/ads');
90
91 37
		$this->template->assign_var('S_PHPBB_ADS', true);
92
93 37
		if (!class_exists('auth_admin'))
94 37
		{
95 1
			include($root_path . 'includes/acp/auth.' . $php_ext);
96 1
		}
97 37
		$this->auth_admin = new \auth_admin();
98 37
	}
99
100
	/**
101
	 * Set page url
102
	 *
103
	 * @param	string	$u_action	Custom form action
104
	 * @return	void
105
	 */
106 31
	public function set_page_url($u_action)
107
	{
108 31
		$this->u_action = $u_action;
109 31
	}
110
111
	/**
112
	 * Get ACP page title for Ads module
113
	 *
114
	 * @return	string	Language string for Ads ACP module
115
	 */
116 1
	public function get_page_title()
117
	{
118 1
		return $this->language->lang('ACP_PHPBB_ADS_TITLE');
119
	}
120
121
	/**
122
	 * Process user request for settings mode
123
	 *
124
	 * @return	void
125
	 */
126 3
	public function mode_settings()
127
	{
128 3
		if ($this->request->is_set_post('submit'))
129 3
		{
130
			// Validate form key
131 2
			if (check_form_key('phpbb_ads'))
0 ignored issues
show
Bug introduced by
The function check_form_key was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

131
			if (/** @scrutinizer ignore-call */ check_form_key('phpbb_ads'))
Loading history...
132 2
			{
133 1
				$this->config->set('phpbb_ads_adblocker_message', $this->request->variable('adblocker_message', 0));
134 1
				$this->config->set('phpbb_ads_enable_views', $this->request->variable('enable_views', 0));
135 1
				$this->config->set('phpbb_ads_enable_clicks', $this->request->variable('enable_clicks', 0));
136
137 1
				$this->success('ACP_AD_SETTINGS_SAVED');
138
			}
139
140 1
			$this->error('FORM_INVALID');
141
		}
142
143 1
		$this->template->assign_vars(array(
144 1
			'U_ACTION'          => $this->u_action,
145 1
			'AD_BLOCK_MODES'	=> ext::AD_BLOCK_MODES,
146 1
			'AD_BLOCK_CONFIG'	=> $this->config['phpbb_ads_adblocker_message'],
147 1
			'ENABLE_VIEWS'      => $this->config['phpbb_ads_enable_views'],
148 1
			'ENABLE_CLICKS'     => $this->config['phpbb_ads_enable_clicks'],
149 1
		));
150
	}
151
152
	/**
153
	 * Process user request for manage mode
154
	 *
155
	 * @return	void
156 33
	 */
157
	public function mode_manage()
158
	{
159 33
		// Trigger specific action
160 33
		$action = $this->request->variable('action', '');
161 33
		if (in_array($action, array('add', 'edit', 'enable', 'disable', 'delete')))
162 31
		{
163 16
			$this->{'action_' . $action}();
164
		}
165
		else
166
		{
167 2
			// Otherwise default to this
168
			$this->list_ads();
169 18
		}
170
	}
171
172
	/**
173
	 * Add an advertisement
174
	 *
175
	 * @return	void
176 21
	 */
177
	protected function action_add()
178 8
	{
179 8
		$action = $this->get_submitted_action();
180 8
		if ($action !== false)
181 7
		{
182 7
			$this->data = $this->input->get_form_data();
183 5
			$this->{$action}();
184 5
			$this->helper->assign_data($this->data, $this->input->get_errors());
185
		}
186
		else
187 1
		{
188 1
			$this->helper->assign_locations();
189
			$this->helper->assign_groups();
190
		}
191
192 6
		// Set output vars for display in the template
193 6
		$this->template->assign_vars(array(
194 6
			'S_ADD_AD'				=> true,
195 6
			'U_BACK'				=> $this->u_action,
196 6
			'U_ACTION'				=> "{$this->u_action}&amp;action=add",
197 21
			'PICKER_DATE_FORMAT'	=> ext::DATE_FORMAT,
198 6
			'U_FIND_USERNAME'		=> $this->helper->get_find_username_link(),
199 6
			'U_ENABLE_VISUAL_DEMO'	=> $this->controller_helper->route('phpbb_ads_visual_demo', array('action' => 'enable')),
200 6
		));
201
	}
202
203
	/**
204
	 * Edit an advertisement
205
	 *
206
	 * @return	void
207 8
	 */
208
	protected function action_edit()
209 8
	{
210 8
		$ad_id = $this->request->variable('id', 0);
211 8
		$action = $this->get_submitted_action();
212 8
		if ($action !== false)
213 6
		{
214 6
			$this->data = $this->input->get_form_data();
215 3
			$this->{$action}();
216
		}
217
		else
218 2
		{
219 2
			$this->data = $this->manager->get_ad($ad_id);
220 2
			if (empty($this->data))
221 1
			{
222
				$this->error('ACP_AD_DOES_NOT_EXIST');
223
			}
224 1
			// Load ad template locations
225
			$this->data['ad_locations'] = $this->manager->get_ad_locations($ad_id);
226
		}
227
228 4
		// Set output vars for display in the template
229 4
		$this->template->assign_vars(array(
230 4
			'S_EDIT_AD'				=> true,
231 4
			'EDIT_ID'				=> $ad_id,
232 4
			'U_BACK'				=> $this->u_action,
233 4
			'U_ACTION'				=> "{$this->u_action}&amp;action=edit&amp;id=$ad_id",
234 4
			'PICKER_DATE_FORMAT'	=> ext::DATE_FORMAT,
235 4
			'U_FIND_USERNAME'		=> $this->helper->get_find_username_link(),
236 4
			'U_ENABLE_VISUAL_DEMO'	=> $this->controller_helper->route('phpbb_ads_visual_demo', array('action' => 'enable')),
237 4
		));
238 4
		$this->helper->assign_data($this->data, $this->input->get_errors());
239
	}
240
241
	/**
242
	 * Enable an advertisement
243
	 *
244
	 * @return	void
245 4
	 */
246
	protected function action_enable()
247 4
	{
248 1
		$this->ad_enable(true);
249
	}
250
251
	/**
252
	 * Disable an advertisement
253
	 *
254
	 * @return	void
255 4
	 */
256
	protected function action_disable()
257 4
	{
258 1
		$this->ad_enable(false);
259
	}
260
261
	/**
262
	 * Delete an advertisement
263
	 *
264
	 * @return	void
265 4
	 */
266
	protected function action_delete()
267 4
	{
268
		$ad_id = $this->request->variable('id', 0);
269 4
		if ($ad_id)
270 4
		{
271 4
			if (confirm_box(true))
0 ignored issues
show
Bug introduced by
The function confirm_box was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

271
			if (/** @scrutinizer ignore-call */ confirm_box(true))
Loading history...
272
			{
273 3
				// Get ad data so that we can log ad name
274
				$ad_data = $this->manager->get_ad($ad_id);
275
276 3
				// Delete ad and it's template locations
277 3
				$this->manager->delete_ad_locations($ad_id);
278
				$success = $this->manager->delete_ad($ad_id);
279 3
280
				$this->toggle_permission($ad_data['ad_owner']);
281
282 3
				// Only notify user on error or if not ajax
283 3
				if (!$success)
284 1
				{
285
					$this->error('ACP_AD_DELETE_ERRORED');
286
				}
287
				else
288 2
				{
289
					$this->helper->log('DELETE', $ad_data['ad_name']);
290 2
291 2
					if (!$this->request->is_ajax())
292 2
					{
293
						$this->success('ACP_AD_DELETE_SUCCESS');
294
					}
295
				}
296
			}
297
			else
298 1
			{
299 1
				confirm_box(false, $this->language->lang('CONFIRM_OPERATION'), build_hidden_fields(array(
0 ignored issues
show
Bug introduced by
The function build_hidden_fields was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

299
				confirm_box(false, $this->language->lang('CONFIRM_OPERATION'), /** @scrutinizer ignore-call */ build_hidden_fields(array(
Loading history...
300 1
					'id'     => $ad_id,
301 1
					'i'      => $this->request->variable('i', ''),
302 1
					'mode'   => $this->request->variable('mode', ''),
303 1
					'action' => 'delete',
304
				)));
305
306 1
				// When you don't confirm deleting ad
307
				$this->list_ads();
308 1
			}
309 1
		}
310
	}
311
312
	/**
313
	 * Display the list of all ads
314
	 *
315
	 * @return	void
316 2
	 */
317
	protected function list_ads()
318 2
	{
319
		foreach ($this->manager->get_all_ads() as $row)
320 1
		{
321 1
			$ad_enabled = (int) $row['ad_enabled'];
322
			$ad_expired = $this->helper->is_expired($row);
323 1
324 1
			if ($ad_expired && $ad_enabled)
325 1
			{
326 1
				$ad_enabled = 0;
327 1
				$this->manager->update_ad($row['ad_id'], array('ad_enabled' => 0));
328
			}
329 1
330 1
			$this->template->assign_block_vars($ad_expired ? 'expired' : 'ads', array(
331 1
				'NAME'         => $row['ad_name'],
332 1
				'PRIORITY'     => $row['ad_priority'],
333 1
				'START_DATE'   => $row['ad_start_date'],
334 1
				'END_DATE'     => $row['ad_end_date'],
335 1
				'VIEWS'        => $row['ad_views'],
336 1
				'CLICKS'       => $row['ad_clicks'],
337 1
				'VIEWS_LIMIT'  => $row['ad_views_limit'],
338 1
				'CLICKS_LIMIT' => $row['ad_clicks_limit'],
339 1
				'S_EXPIRED'    => $ad_expired,
340 1
				'S_ENABLED'    => $ad_enabled,
341 1
				'U_ENABLE'     => $this->u_action . '&amp;action=' . ($ad_enabled ? 'disable' : 'enable') . '&amp;id=' . $row['ad_id'],
342 1
				'U_EDIT'       => $this->u_action . '&amp;action=edit&amp;id=' . $row['ad_id'],
343 1
				'U_DELETE'     => $this->u_action . '&amp;action=delete&amp;id=' . $row['ad_id'],
344 2
			));
345
		}
346
347 2
		// Set output vars for display in the template
348 2
		$this->template->assign_vars(array(
349 2
			'U_ACTION_ADD'     => $this->u_action . '&amp;action=add',
350 2
			'S_VIEWS_ENABLED'  => $this->config['phpbb_ads_enable_views'],
351 2
			'S_CLICKS_ENABLED' => $this->config['phpbb_ads_enable_clicks'],
352 2
		));
353
	}
354
355
	/**
356
	 * Get what action user wants to do with the form.
357
	 * Possible options are:
358
	 *  - preview ad code
359
	 *  - upload banner to display in an ad code
360
	 *  - analyse ad code
361
	 *  - submit form (either add or edit an ad)
362
	 *
363
	 * @return	string|false	Action name or false when no action was submitted
364 16
	 */
365
	protected function get_submitted_action()
366 16
	{
367 16
		$actions = array('preview', 'upload_banner', 'analyse_ad_code', 'submit_add', 'submit_edit');
368
		foreach ($actions as $action)
369 16
		{
370 16
			if ($this->request->is_set_post($action))
371 13
			{
372
				return $action;
373 14
			}
374
		}
375 3
376
		return false;
377
	}
378
379
	/**
380
	 * Enable/disable an advertisement
381
	 *
382
	 * @param	bool	$enable	Enable or disable the advertisement?
383
	 * @return	void
384 6
	 */
385
	protected function ad_enable($enable)
386 6
	{
387
		$ad_id = $this->request->variable('id', 0);
388 6
389 6
		$success = $this->manager->update_ad($ad_id, array(
390 6
			'ad_enabled' => (int) $enable,
391
		));
392
393 6
		// If AJAX was used, show user a result message
394 6
		if ($this->request->is_ajax())
395 2
		{
396 2
			$json_response = new \phpbb\json_response;
0 ignored issues
show
Bug introduced by
The type phpbb\json_response was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
397 2
			$json_response->send(array(
398 2
				'text'  => $this->language->lang($enable ? 'ENABLED' : 'DISABLED'),
399 2
				'title' => $this->language->lang('AD_ENABLE_TITLE', (int) $enable),
400
			));
401
		}
402
403
		// Otherwise, show traditional infobox
404 4
		if ($success)
405 2
		{
406
			$this->success($enable ? 'ACP_AD_ENABLE_SUCCESS' : 'ACP_AD_DISABLE_SUCCESS');
407
		}
408
		else
409 2
		{
410
			$this->error($enable ? 'ACP_AD_ENABLE_ERRORED' : 'ACP_AD_DISABLE_ERRORED');
411
		}
412
	}
413
414
	/**
415
	 * Submit action "preview".
416
	 * Prepare advertisement preview.
417
	 *
418
	 * @return	void
419 2
	 */
420
	protected function preview()
421 2
	{
422 2
		$this->template->assign_var('PREVIEW', htmlspecialchars_decode($this->data['ad_code'], ENT_COMPAT));
423
	}
424
425
	/**
426
	 * Submit action "upload_banner".
427
	 * Upload banner and append it to the ad code.
428
	 *
429
	 * @return	void
430 1
	 */
431
	protected function upload_banner()
432 1
	{
433 1
		$this->data['ad_code'] = $this->input->banner_upload($this->data['ad_code']);
434
	}
435
436
	/**
437
	 * Submit action "analyse_ad_code".
438
	 * Upload banner and append it to the ad code.
439
	 *
440
	 * @return	void
441 1
	 */
442
	protected function analyse_ad_code()
443 1
	{
444 1
		$this->analyser->run($this->data['ad_code']);
445
	}
446
447
	/**
448
	 * Submit action "submit_add".
449
	 * Add new ad.
450
	 *
451
	 * @return	void
452 4
	 */
453
	protected function submit_add()
454 4
	{
455 4
		if (!$this->input->has_errors())
456 2
		{
457 2
			$ad_id = $this->manager->insert_ad($this->data);
458 2
			$this->toggle_permission($this->data['ad_owner']);
459
			$this->manager->insert_ad_locations($ad_id, $this->data['ad_locations']);
460 2
461
			$this->helper->log('ADD', $this->data['ad_name']);
462 2
463
			$this->success('ACP_AD_ADD_SUCCESS');
464 2
		}
465
	}
466
467
	/**
468
	 * Submit action "submit_edit".
469
	 * Edit ad.
470
	 *
471
	 * @return	void
472 5
	 */
473
	protected function submit_edit()
474 5
	{
475 5
		$ad_id = $this->request->variable('id', 0);
476 5
		if ($ad_id && !$this->input->has_errors())
477 3
		{
478 3
			$old_data = $this->manager->get_ad($ad_id);
479
			$success = $this->manager->update_ad($ad_id, $this->data);
480 3
			if ($success)
481
			{
482 2
				// Only update permissions when update was successful
483 2
				$this->toggle_permission($old_data['ad_owner']);
484
				$this->toggle_permission($this->data['ad_owner']);
485
486 2
				// Only insert new ad locations to DB when ad exists
487 2
				$this->manager->delete_ad_locations($ad_id);
488
				$this->manager->insert_ad_locations($ad_id, $this->data['ad_locations']);
489 2
490
				$this->helper->log('EDIT', $this->data['ad_name']);
491 2
492
				$this->success('ACP_AD_EDIT_SUCCESS');
493
			}
494 1
495
			$this->error('ACP_AD_DOES_NOT_EXIST');
496 2
		}
497
	}
498
499
	/**
500
	 * Print success message.
501
	 *
502
	 * @param	string	$msg	Message lang key
503 9
	 */
504
	protected function success($msg)
505 9
	{
506
		trigger_error($this->language->lang($msg) . adm_back_link($this->u_action));
0 ignored issues
show
Bug introduced by
The function adm_back_link was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

506
		trigger_error($this->language->lang($msg) . /** @scrutinizer ignore-call */ adm_back_link($this->u_action));
Loading history...
507
	}
508
509
	/**
510
	 * Print error message.
511
	 *
512
	 * @param	string	$msg	Message lang key
513 6
	 */
514
	protected function error($msg)
515 6
	{
516
		trigger_error($this->language->lang($msg) . adm_back_link($this->u_action), E_USER_WARNING);
0 ignored issues
show
Bug introduced by
The function adm_back_link was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

516
		trigger_error($this->language->lang($msg) . /** @scrutinizer ignore-call */ adm_back_link($this->u_action), E_USER_WARNING);
Loading history...
517
	}
518
519
	/**
520
	 * Try to remove or add permission to see UCP module.
521
	 * Permission is only removed when user has no more ads.
522
	 * Permission is only added when user has at least one ad.
523
	 *
524
	 * @param	int	$user_id	User ID to try to remove permission
525
	 *
526
	 * @return	void
527 7
	 */
528
	protected function toggle_permission($user_id)
529
	{
530 7
		if ($user_id)
531 3
		{
532
			$has_ads = count($this->manager->get_ads_by_owner($user_id)) !== 0;
533 3
534 3
			$this->auth_admin->acl_set('user', 0, $user_id, array('u_phpbb_ads' => (int) $has_ads));
535 7
		}
536
	}
537
}
538