Completed
Pull Request — master (#48)
by Jakub
08:27
created

ucp_controller::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 3
crap 2
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\user */
22
	protected $user;
23
24
	/** @var \phpbb\template\template */
25
	protected $template;
26
27
	/** @var string Custom form action */
28
	protected $u_action;
29
30
	/**
31
	 * Constructor
32
	 *
33
	 * @param \phpbb\ads\ad\manager		$manager 	Advertisement manager object
34
	 * @param \phpbb\user				$user		User object
35
	 * @param \phpbb\template\template	$template	Template object
36
	 */
37
	public function __construct(\phpbb\ads\ad\manager $manager, \phpbb\user $user, \phpbb\template\template $template)
38
	{
39
		$this->manager = $manager;
40
		$this->user = $user;
41
		$this->template = $template;
42
	}
43
44
	/**
45
	 * @param	string	$u_action	Action URL
46
	 */
47
	public function set_page_url($u_action)
48
	{
49
		$this->u_action = $u_action;
50
	}
51
52
	/**
53
	 * @return	string	Module language string
54
	 */
55
	public function get_page_title()
56
	{
57
		return $this->user->lang('UCP_PHPBB_ADS_STATS');
58
	}
59
60
	/**
61
	 * Display UCP ads module
62
	 */
63
	public function main()
64
	{
65
		foreach ($this->manager->get_all_ads($this->user->data['user_id']) as $ad)
66
		{
67
			$this->template->assign_block_vars('ads', array(
68
				'NAME'		=> $ad['ad_name'],
69
				'VIEWS'		=> $ad['ad_views'],
70
				'CLICKS'	=> $ad['ad_clicks'],
71
			));
72
		}
73
	}
74
}
75