Issues (97)

controller/ucp_controller.php (4 issues)

Labels
Severity
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
/**
14
 * Front controller
15
 */
16
class ucp_controller
17
{
18
	/** @var \phpbb\ads\ad\manager */
19
	protected $manager;
20
21
	/** @var \phpbb\ads\controller\helper */
22
	protected $helper;
23
24
	/** @var \phpbb\user */
0 ignored issues
show
The type phpbb\user 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...
25
	protected $user;
26
27
	/** @var \phpbb\language\language */
0 ignored issues
show
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...
28
	protected $language;
29
30
	/** @var \phpbb\template\template */
0 ignored issues
show
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...
31
	protected $template;
32
33
	/** @var \phpbb\config\config */
0 ignored issues
show
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...
34
	protected $config;
35
36
	/** @var string Custom form action */
37
	protected $u_action;
38
39
	/**
40
	 * Constructor
41
	 *
42
	 * @param \phpbb\ads\ad\manager					$manager 	Advertisement manager object
43
	 * @param \phpbb\ads\controller\helper			$helper		Helper object
44
	 * @param \phpbb\user							$user		User object
45
	 * @param \phpbb\language\language				$language	Language object
46
	 * @param \phpbb\template\template				$template	Template object
47
	 * @param \phpbb\config\config					$config		Config object
48
	 */
49 5
	public function __construct(\phpbb\ads\ad\manager $manager, \phpbb\ads\controller\helper $helper, \phpbb\user $user, \phpbb\language\language $language, \phpbb\template\template $template, \phpbb\config\config $config)
50
	{
51 5
		$this->manager = $manager;
52 5
		$this->helper = $helper;
53 5
		$this->user = $user;
54 5
		$this->language = $language;
55 5
		$this->template = $template;
56 5
		$this->config = $config;
57 5
	}
58
59
	/**
60
	 * @param	string	$u_action	Action URL
61
	 */
62 5
	public function set_page_url($u_action)
63
	{
64 5
		$this->u_action = $u_action;
65 5
	}
66
67
	/**
68
	 * Display UCP ads module
69
	 */
70 1
	public function main()
71
	{
72 1
		$this->language->add_lang('ucp', 'phpbb/ads');
73
74
		foreach ($this->manager->get_ads_by_owner($this->user->data['user_id']) as $ad)
75
		{
76
			$ad_enabled = (int) $ad['ad_enabled'];
77
			$ad_expired = $this->helper->is_expired($ad);
78 4
79
			if ($ad_expired && $ad_enabled)
80 4
			{
81
				$ad_enabled = 0;
82 4
				$this->manager->update_ad($ad['ad_id'], array('ad_enabled' => 0));
83
			}
84 1
85 1
			$this->template->assign_block_vars($ad_expired ? 'expired' : 'ads', array(
86
				'NAME'			=> $ad['ad_name'],
87 1
				'START_DATE'	=> $ad['ad_start_date'],
88 1
				'END_DATE'		=> $ad['ad_end_date'],
89
				'VIEWS'			=> $ad['ad_views'],
90
				'VIEWS_LIMIT'	=> $ad['ad_views_limit'],
91
				'CLICKS'		=> $ad['ad_clicks'],
92
				'CLICKS_LIMIT'	=> $ad['ad_clicks_limit'],
93 1
				'S_ENABLED'		=> $ad_enabled,
94 1
			));
95 1
		}
96 1
97 1
		$this->template->assign_vars(array(
98 1
			'S_VIEWS_ENABLED'	=> $this->config['phpbb_ads_enable_views'],
99 1
			'S_CLICKS_ENABLED'	=> $this->config['phpbb_ads_enable_clicks'],
100 1
		));
101 1
	}
102
}
103