| @@ 16-54 (lines=39) @@ | ||
| 13 | /** |
|
| 14 | * Click controller |
|
| 15 | */ |
|
| 16 | class click_controller |
|
| 17 | { |
|
| 18 | /** @var \phpbb\ads\ad\manager */ |
|
| 19 | protected $manager; |
|
| 20 | ||
| 21 | /** @var \phpbb\request\request */ |
|
| 22 | protected $request; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * Constructor |
|
| 26 | * |
|
| 27 | * @param \phpbb\ads\ad\manager $manager Advertisement manager object |
|
| 28 | * @param \phpbb\request\request $request Request object |
|
| 29 | */ |
|
| 30 | public function __construct(\phpbb\ads\ad\manager $manager, \phpbb\request\request $request) |
|
| 31 | { |
|
| 32 | $this->manager = $manager; |
|
| 33 | $this->request = $request; |
|
| 34 | } |
|
| 35 | ||
| 36 | /** |
|
| 37 | * Increment clicks for an ad |
|
| 38 | * |
|
| 39 | * @param int $ad_id Advertisement ID |
|
| 40 | * @throws \phpbb\exception\http_exception |
|
| 41 | * @return \Symfony\Component\HttpFoundation\JsonResponse A Symfony JsonResponse object |
|
| 42 | */ |
|
| 43 | public function increment_clicks($ad_id) |
|
| 44 | { |
|
| 45 | if ($this->request->is_ajax() && !empty($ad_id)) |
|
| 46 | { |
|
| 47 | $this->manager->increment_ad_clicks($ad_id); |
|
| 48 | ||
| 49 | return new \Symfony\Component\HttpFoundation\JsonResponse(); |
|
| 50 | } |
|
| 51 | ||
| 52 | throw new \phpbb\exception\http_exception(403, 'NOT_AUTHORISED'); |
|
| 53 | } |
|
| 54 | } |
|
| 55 | ||
| @@ 16-54 (lines=39) @@ | ||
| 13 | /** |
|
| 14 | * View controller |
|
| 15 | */ |
|
| 16 | class view_controller |
|
| 17 | { |
|
| 18 | /** @var \phpbb\ads\ad\manager */ |
|
| 19 | protected $manager; |
|
| 20 | ||
| 21 | /** @var \phpbb\request\request */ |
|
| 22 | protected $request; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * Constructor |
|
| 26 | * |
|
| 27 | * @param \phpbb\ads\ad\manager $manager Advertisement manager object |
|
| 28 | * @param \phpbb\request\request $request Request object |
|
| 29 | */ |
|
| 30 | public function __construct(\phpbb\ads\ad\manager $manager, \phpbb\request\request $request) |
|
| 31 | { |
|
| 32 | $this->manager = $manager; |
|
| 33 | $this->request = $request; |
|
| 34 | } |
|
| 35 | ||
| 36 | /** |
|
| 37 | * Increment views for ads |
|
| 38 | * |
|
| 39 | * @param string $ad_ids Advertisement IDs |
|
| 40 | * @throws \phpbb\exception\http_exception |
|
| 41 | * @return \Symfony\Component\HttpFoundation\JsonResponse A Symfony JsonResponse object |
|
| 42 | */ |
|
| 43 | public function increment_views($ad_ids) |
|
| 44 | { |
|
| 45 | if ($this->request->is_ajax()) |
|
| 46 | { |
|
| 47 | $this->manager->increment_ads_views(explode('-', $ad_ids)); |
|
| 48 | ||
| 49 | return new \Symfony\Component\HttpFoundation\JsonResponse(); |
|
| 50 | } |
|
| 51 | ||
| 52 | throw new \phpbb\exception\http_exception(403, 'NOT_AUTHORISED'); |
|
| 53 | } |
|
| 54 | } |
|
| 55 | ||