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

admin_controller::success()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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
* Admin controller
15
*/
16
class admin_controller
17
{
18
	const MAX_NAME_LENGTH = 255;
19
	const DATE_FORMAT = 'Y-m-d';
20
	const DEFAULT_PRIORITY = 5;
21
22
	/** @var \phpbb\template\template */
23
	protected $template;
24
25
	/** @var \phpbb\user */
26
	protected $user;
27
28
	/** @var \phpbb\request\request */
29
	protected $request;
30
31
	/** @var \phpbb\ads\ad\manager */
32
	protected $manager;
33
34
	/** @var \phpbb\ads\location\manager */
35
	protected $location_manager;
36
37
	/** @var \phpbb\log\log */
38
	protected $log;
39
40
	/** @var \phpbb\config\db_text */
41
	protected $config_text;
42
43
	/** @var \phpbb\config\config */
44
	protected $config;
45
46
	/** @var string root_path */
47
	protected $root_path;
48
49
	/** @var string php_ext */
50
	protected $php_ext;
51
52
	/** @var string ext_path */
53
	protected $ext_path;
54
55
	/** @var \auth_admin Auth admin */
56
	protected $auth_admin;
57
58
	/** @var string Custom form action */
59
	protected $u_action;
60
61
	/** @var array Form validation errors */
62
	protected $errors = array();
63
64
	/**
65
	* Constructor
66
	*
67
	* @param \phpbb\template\template				$template			Template object
68
	* @param \phpbb\user							$user				User object
69
	* @param \phpbb\request\request					$request			Request object
70
	* @param \phpbb\ads\ad\manager					$manager			Advertisement manager object
71
	* @param \phpbb\ads\location\manager			$location_manager	Template location manager object
72
	* @param \phpbb\log\log							$log				The phpBB log system
73
	* @param \phpbb\config\db_text					$config_text		Config text object
74
	* @param \phpbb\config\config					$config				Config object
75
	* @param string									$root_path			phpBB root path
76
	* @param string									$php_ext			PHP extension
77
	* @param string									$ext_path			Path to this extension
78
	*/
79
	public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\request\request $request, \phpbb\ads\ad\manager $manager, \phpbb\ads\location\manager $location_manager, \phpbb\log\log $log, \phpbb\config\db_text $config_text, \phpbb\config\config $config, $root_path, $php_ext, $ext_path)
80
	{
81
		$this->template = $template;
82
		$this->user = $user;
83
		$this->request = $request;
84
		$this->manager = $manager;
85
		$this->location_manager = $location_manager;
86
		$this->log = $log;
87
		$this->config_text = $config_text;
88
		$this->config = $config;
89
		$this->root_path = $root_path;
90
		$this->php_ext = $php_ext;
91
		$this->ext_path = $ext_path;
92
93
		if (!class_exists('auth_admin'))
94
		{
95
			include($this->root_path . 'includes/acp/auth.' . $this->php_ext);
96
		}
97
		$this->auth_admin = new \auth_admin();
98
	}
99
100
	/**
101
	* Process user request for manage mode
102
	*
103
	* @return void
104
	*/
105
	public function mode_manage()
106
	{
107
		$this->setup();
108
109
		// Trigger specific action
110
		$action = $this->request->variable('action', '');
111
		if (in_array($action, array('add', 'edit', 'enable', 'disable', 'delete')))
112
		{
113
			$this->{'action_' . $action}();
114
		}
115
116
		// Otherwise default to this
117
		$this->list_ads();
118
	}
119
120
	/**
121
	* Process user request for settings mode
122
	*
123
	* @return void
124
	*/
125
	public function mode_settings()
126
	{
127
		$this->setup();
128
129
		add_form_key('phpbb/ads/settings');
130
		if ($this->request->is_set_post('submit'))
131
		{
132
			// Validate form key
133
			if (!check_form_key('phpbb/ads/settings'))
134
			{
135
				$this->errors[] = $this->user->lang('FORM_INVALID');
136
			}
137
138
			if (empty($this->errors))
139
			{
140
				$this->config->set('phpbb_ads_adblocker_message', $this->request->variable('adblocker_message', 0));
141
				$this->config->set('phpbb_ads_enable_views', $this->request->variable('enable_views', 0));
142
				$this->config->set('phpbb_ads_enable_clicks', $this->request->variable('enable_clicks', 0));
143
				$this->config_text->set('phpbb_ads_hide_groups', json_encode($this->request->variable('hide_groups', array(0))));
144
145
				$this->success('ACP_AD_SETTINGS_SAVED');
146
			}
147
148
			$this->template->assign_vars(array(
149
				'S_ERROR'		=> (bool) count($this->errors),
150
				'ERROR_MSG'		=> count($this->errors) ? implode('<br />', $this->errors) : '',
151
			));
152
		}
153
154
		$hide_groups = json_decode($this->config_text->get('phpbb_ads_hide_groups'), true);
155
		$groups = $this->manager->load_groups();
156
		foreach ($groups as $group)
157
		{
158
			$group_name = ($group['group_type'] == GROUP_SPECIAL) ? $this->user->lang('G_' . $group['group_name']) : $group['group_name'];
159
160
			$this->template->assign_block_vars('groups', array(
161
				'ID'			=> $group['group_id'],
162
				'NAME'			=> $group_name,
163
				'S_SELECTED'	=> in_array($group['group_id'], $hide_groups),
164
			));
165
		}
166
167
		$this->template->assign_vars(array(
168
			'U_ACTION'			=> $this->u_action,
169
			'ADBLOCKER_MESSAGE'	=> $this->config['phpbb_ads_adblocker_message'],
170
			'ENABLE_VIEWS'		=> $this->config['phpbb_ads_enable_views'],
171
			'ENABLE_CLICKS'		=> $this->config['phpbb_ads_enable_clicks'],
172
		));
173
	}
174
175
	/**
176
	* Set page url
177
	*
178
	* @param string $u_action Custom form action
179
	* @return void
180
	*/
181
	public function set_page_url($u_action)
182
	{
183
		$this->u_action = $u_action;
184
	}
185
186
	/**
187
	* Get ACP page title for Ads module
188
	*
189
	* @return string	Language string for Ads ACP module
190
	*/
191
	public function get_page_title()
192
	{
193
		return $this->user->lang('ACP_PHPBB_ADS_TITLE');
194
	}
195
196
	/**
197
	* Add an advertisement
198
	*
199
	* @return void
200
	*/
201
	public function action_add()
202
	{
203
		$preview = $this->request->is_set_post('preview');
204
		$submit = $this->request->is_set_post('submit');
205
206
		add_form_key('phpbb/ads/add');
207
		if ($preview || $submit)
208
		{
209
			$data = $this->get_form_data('phpbb/ads/add');
210
211
			if ($preview)
212
			{
213
				$this->ad_preview($data['ad_code']);
214
			}
215 View Code Duplication
			else if (empty($this->errors))
216
			{
217
				$ad_id = $this->manager->insert_ad($data);
218
				$this->manager->insert_ad_locations($ad_id, $data['ad_locations']);
219
220
				// Add u_phpbb_ads_owner permission
221
				$this->auth_admin->acl_set('user', 0, $data['ad_owner'], array('u_phpbb_ads_owner'	=> 1));
222
223
				$this->log('ADD', $data['ad_name']);
224
225
				$this->success('ACP_AD_ADD_SUCCESS');
226
			}
227
228
			$this->assign_locations($data);
229
			$this->assign_form_data($data);
230
		}
231
		else
232
		{
233
			$this->assign_locations();
234
		}
235
236
		// Set output vars for display in the template
237
		$this->template->assign_vars(array(
238
			'S_ADD_AD'				=> true,
239
			'U_BACK'				=> $this->u_action,
240
			'U_ACTION'				=> "{$this->u_action}&amp;action=add",
241
			'PICKER_DATE_FORMAT'	=> self::DATE_FORMAT,
242
			'U_FIND_USERNAME'		=> append_sid("{$this->root_path}memberlist.{$this->php_ext}", 'mode=searchuser&amp;form=acp_addmanagement_add&amp;field=ad_owner'),
243
		));
244
	}
245
246
	/**
247
	* Edit an advertisement
248
	*
249
	* @return void
250
	*/
251
	public function action_edit()
252
	{
253
		$ad_id = $this->request->variable('id', 0);
254
		$preview = $this->request->is_set_post('preview');
255
		$submit = $this->request->is_set_post('submit');
256
257
		$ad = $this->manager->get_ad($ad_id);
258
		if (empty($ad))
259
		{
260
			$this->error('ACP_AD_DOES_NOT_EXIST');
261
		}
262
263
		add_form_key('phpbb/ads/edit/' . $ad_id);
264
		if ($preview || $submit)
265
		{
266
			$data = $this->get_form_data('phpbb/ads/edit/' . $ad_id);
267
268
			if ($preview)
269
			{
270
				$this->ad_preview($data['ad_code']);
271
			}
272
			else if (empty($this->errors))
273
			{
274
				// Delete u_phpbb_ads_owner permission if old owner owns no more ads
275 View Code Duplication
				if (count($this->manager->get_all_ads($ad['ad_owner'])) == 1)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
276
				{
277
					$this->auth_admin->acl_delete('user', $ad['ad_owner'], false, 'u_phpbb_ads_owner');
278
				}
279
280
				$success = $this->manager->update_ad($ad_id, $data);
281
282 View Code Duplication
				if ($success)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
283
				{
284
					// Only insert new ad locations to DB when ad exists
285
					$this->manager->delete_ad_locations($ad_id);
286
					$this->manager->insert_ad_locations($ad_id, $data['ad_locations']);
287
288
					// Add u_phpbb_ads_owner permission to new owner
289
					$this->auth_admin->acl_set('user', 0, $data['ad_owner'], array('u_phpbb_ads_owner'	=> 1));
290
291
					$this->log('EDIT', $data['ad_name']);
292
293
					$this->success('ACP_AD_EDIT_SUCCESS');
294
				}
295
296
				$this->error('ACP_AD_DOES_NOT_EXIST');
297
			}
298
		}
299
		else
300
		{
301
			$data = $ad;
302
303
			// Load ad template locations
304
			$data['ad_locations'] = $this->manager->get_ad_locations($ad_id);
305
		}
306
307
		// Set output vars for display in the template
308
		$this->template->assign_vars(array(
309
			'S_EDIT_AD'				=> true,
310
			'EDIT_ID'				=> $ad_id,
311
			'U_BACK'				=> $this->u_action,
312
			'U_ACTION'				=> "{$this->u_action}&amp;action=edit&amp;id=" . $ad_id,
313
			'PICKER_DATE_FORMAT'	=> self::DATE_FORMAT,
314
			'U_FIND_USERNAME'		=> append_sid("{$this->root_path}memberlist.{$this->php_ext}", 'mode=searchuser&amp;form=ucp&amp;field=add'),
315
		));
316
		$this->assign_locations($data);
317
		$this->assign_form_data($data);
318
	}
319
320
	/**
321
	* Enable an advertisement
322
	*
323
	* @return void
324
	*/
325
	public function action_enable()
326
	{
327
		$this->ad_enable(true);
328
	}
329
330
	/**
331
	* Disable an advertisement
332
	*
333
	* @return void
334
	*/
335
	public function action_disable()
336
	{
337
		$this->ad_enable(false);
338
	}
339
340
	/**
341
	* Delete an advertisement
342
	*
343
	* @return void
344
	*/
345
	public function action_delete()
346
	{
347
		$ad_id = $this->request->variable('id', 0);
348
		if ($ad_id)
349
		{
350
			if (confirm_box(true))
351
			{
352
				// Get ad data so that we can log ad name
353
				$ad_data = $this->manager->get_ad($ad_id);
354
355
				// Delete ad and it's template locations
356
				$this->manager->delete_ad_locations($ad_id);
357
				$success = $this->manager->delete_ad($ad_id);
358
359
				// Delete u_phpbb_ads_owner permission if old owner owns no more ads
360 View Code Duplication
				if (count($this->manager->get_all_ads($ad_data['ad_owner'])) == 1)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
361
				{
362
					$this->auth_admin->acl_delete('user', $ad_data['ad_owner'], false, 'u_phpbb_ads_owner');
363
				}
364
365
				// Only notify user on error or if not ajax
366
				if (!$success)
367
				{
368
					$this->error('ACP_AD_DELETE_ERRORED');
369
				}
370
				else
371
				{
372
					$this->log('DELETE', $ad_data['ad_name']);
373
374
					if (!$this->request->is_ajax())
375
					{
376
						$this->success('ACP_AD_DELETE_SUCCESS');
377
					}
378
				}
379
			}
380
			else
381
			{
382
				confirm_box(false, $this->user->lang('CONFIRM_OPERATION'), build_hidden_fields(array(
383
					'id'		=> $ad_id,
384
					'i'			=> $this->request->variable('i', ''),
385
					'mode'		=> $this->request->variable('mode', ''),
386
					'action'	=> 'delete'
387
				)));
388
			}
389
		}
390
	}
391
392
	/**
393
	* Display the ads
394
	*
395
	* @return void
396
	*/
397
	public function list_ads()
398
	{
399
		foreach ($this->manager->get_all_ads() as $row)
400
		{
401
			$ad_enabled = (int) $row['ad_enabled'];
402
			$ad_end_date = (int) $row['ad_end_date'];
403
			$ad_expired = $ad_end_date > 0 && $ad_end_date < time();
404
			if ($ad_expired && $ad_enabled)
405
			{
406
				$ad_enabled = 0;
407
				$this->manager->update_ad($row['ad_id'], array('ad_enabled' => 0));
408
			}
409
410
			$this->template->assign_block_vars('ads', array(
411
				'NAME'					=> $row['ad_name'],
412
				'END_DATE'				=> $ad_end_date ? $this->user->format_date($ad_end_date, self::DATE_FORMAT) : '',
413
				'VIEWS'					=> $row['ad_views'],
414
				'CLICKS'				=> $row['ad_clicks'],
415
				'VIEWS_LIMIT'			=> $row['ad_views_limit'],
416
				'CLICKS_LIMIT'			=> $row['ad_clicks_limit'],
417
				'S_END_DATE_EXPIRED'	=> $ad_expired,
418
				'S_ENABLED'				=> $ad_enabled,
419
				'U_ENABLE'				=> $this->u_action . '&amp;action=' . ($ad_enabled ? 'disable' : 'enable') . '&amp;id=' . $row['ad_id'],
420
				'U_EDIT'				=> $this->u_action . '&amp;action=edit&amp;id=' . $row['ad_id'],
421
				'U_DELETE'				=> $this->u_action . '&amp;action=delete&amp;id=' . $row['ad_id'],
422
			));
423
		}
424
425
		// Set output vars for display in the template
426
		$this->template->assign_vars(array(
427
			'U_ACTION_ADD'		=> $this->u_action . '&amp;action=add',
428
			'S_VIEWS_ENABLED'	=> $this->config['phpbb_ads_enable_views'],
429
			'S_CLICKS_ENABLED'	=> $this->config['phpbb_ads_enable_clicks'],
430
		));
431
	}
432
433
	/**
434
	* Perform general tasks
435
	*
436
	* @return void
437
	*/
438
	protected function setup()
439
	{
440
		$this->user->add_lang_ext('phpbb/ads', 'acp');
441
442
		$this->template->assign_var('S_PHPBB_ADS', true);
443
	}
444
445
	/**
446
	* Enable/disable an advertisement
447
	*
448
	* @param	bool	$enable	Enable or disable the advertisement?
449
	* @return void
450
	*/
451
	protected function ad_enable($enable)
452
	{
453
		$ad_id = $this->request->variable('id', 0);
454
455
		$success = $this->manager->update_ad($ad_id, array(
456
			'ad_enabled'	=> (int) $enable,
457
		));
458
459
		// If AJAX was used, show user a result message
460
		if ($this->request->is_ajax())
461
		{
462
			$json_response = new \phpbb\json_response;
463
			$json_response->send(array(
464
				'text'	=> $this->user->lang($enable ? 'ENABLED' : 'DISABLED'),
465
				'title'	=> $this->user->lang('AD_ENABLE_TITLE', (int) $enable),
466
			));
467
		}
468
469
		// Otherwise, show traditional infobox
470
		if ($success)
471
		{
472
			$this->success($enable ? 'ACP_AD_ENABLE_SUCCESS' : 'ACP_AD_DISABLE_SUCCESS');
473
		}
474
		else
475
		{
476
			$this->error($enable ? 'ACP_AD_ENABLE_ERRORED' : 'ACP_AD_DISABLE_ERRORED');
477
		}
478
	}
479
480
	/**
481
	* Get admin form data.
482
	*
483
	* @param	string	$form_name	The form name.
484
	* @return	array	Form data
485
	*/
486
	protected function get_form_data($form_name)
487
	{
488
		$data = array(
489
			'ad_name'			=> $this->request->variable('ad_name', '', true),
490
			'ad_note'			=> $this->request->variable('ad_note', '', true),
491
			'ad_code'			=> $this->request->variable('ad_code', '', true),
492
			'ad_enabled'		=> $this->request->variable('ad_enabled', 0),
493
			'ad_locations'		=> $this->request->variable('ad_locations', array('')),
494
			'ad_end_date'		=> $this->request->variable('ad_end_date', ''),
495
			'ad_priority'		=> $this->request->variable('ad_priority', self::DEFAULT_PRIORITY),
496
			'ad_views_limit'	=> $this->request->variable('ad_views_limit', 0),
497
			'ad_clicks_limit'	=> $this->request->variable('ad_clicks_limit', 0),
498
			'ad_owner'		=> $this->request->variable('ad_owner', '', true),
499
		);
500
501
		// Get owner id
502
		$data['ad_owner'] = $this->manager->get_owner_id_from_username($data['ad_owner']);
503
504
		// Validate form key
505
		if (!check_form_key($form_name))
506
		{
507
			$this->errors[] = $this->user->lang('FORM_INVALID');
508
		}
509
510
		// Validate ad name
511
		if ($data['ad_name'] === '')
512
		{
513
			$this->errors[] = $this->user->lang('AD_NAME_REQUIRED');
514
		}
515
		if (truncate_string($data['ad_name'], self::MAX_NAME_LENGTH) !== $data['ad_name'])
516
		{
517
			$this->errors[] = $this->user->lang('AD_NAME_TOO_LONG', self::MAX_NAME_LENGTH);
518
		}
519
520
		// Validate ad end date
521
		if (preg_match('#^\d{4}\-\d{2}\-\d{2}$#', $data['ad_end_date']))
522
		{
523
			$data['ad_end_date'] = (int) $this->user->get_timestamp_from_format(self::DATE_FORMAT, $data['ad_end_date']);
524
525
			if ($data['ad_end_date'] < time())
526
			{
527
				$this->errors[] = $this->user->lang('AD_END_DATE_INVALID');
528
			}
529
		}
530
		else if ($data['ad_end_date'] !== '')
531
		{
532
			$this->errors[] = $this->user->lang('AD_END_DATE_INVALID');
533
		}
534
		else
535
		{
536
			$data['ad_end_date'] = 0;
537
		}
538
539
		// Validate ad priority
540
		if ($data['ad_priority'] < 1 || $data['ad_priority'] > 10)
541
		{
542
			$this->errors[] = $this->user->lang('AD_PRIORITY_INVALID');
543
		}
544
545
		// Validate ad views limit
546
		if ($data['ad_views_limit'] < 0)
547
		{
548
			$this->errors[] = $this->user->lang('AD_VIEWS_LIMIT_INVALID');
549
		}
550
551
		// Validate ad clicks limit
552
		if ($data['ad_clicks_limit'] < 0)
553
		{
554
			$this->errors[] = $this->user->lang('AD_CLICKS_LIMIT_INVALID');
555
		}
556
557
		// Validate ad owner
558
		if ($data['ad_owner'] === false)
559
		{
560
			$this->errors[] = $this->user->lang('AD_OWNER_INVALID');
561
		}
562
563
		return $data;
564
	}
565
566
	/**
567
	* Assign form data to the template.
568
	*
569
	* @param	array	$data	The form data.
570
	* @return void
571
	*/
572
	protected function assign_form_data($data)
573
	{
574
		$this->template->assign_vars(array(
575
			'S_ERROR'		=> (bool) count($this->errors),
576
			'ERROR_MSG'		=> count($this->errors) ? implode('<br />', $this->errors) : '',
577
578
			'AD_NAME'			=> $data['ad_name'],
579
			'AD_NOTE'			=> $data['ad_note'],
580
			'AD_CODE'			=> $data['ad_code'],
581
			'AD_ENABLED'		=> $data['ad_enabled'],
582
			'AD_END_DATE'		=> $this->prepare_end_date($data['ad_end_date']),
583
			'AD_PRIORITY'		=> $data['ad_priority'],
584
			'AD_VIEWS_LIMIT'	=> $data['ad_views_limit'],
585
			'AD_CLICKS_LIMIT'	=> $data['ad_clicks_limit'],
586
			'AD_OWNER'		=> $this->manager->get_owner_username_from_id($data['ad_owner']),
587
		));
588
	}
589
590
	/**
591
	* Prepare end date for display
592
	*
593
	* @param	mixed	$end_date	End date.
594
	* @return	string	End date prepared for display.
595
	*/
596
	protected function prepare_end_date($end_date)
597
	{
598
		if (empty($end_date))
599
		{
600
			return '';
601
		}
602
603
		if (is_numeric($end_date))
604
		{
605
			return $this->user->format_date($end_date, self::DATE_FORMAT);
606
		}
607
608
		return (string) $end_date;
609
	}
610
611
	/**
612
	* Assign template locations data to the template.
613
	*
614
	* @param	mixed	$data	The form data or nothing.
615
	* @return	void
616
	*/
617
	protected function assign_locations($data = false)
618
	{
619
		foreach ($this->location_manager->get_all_locations() as $location_id => $location_data)
620
		{
621
			$this->template->assign_block_vars('ad_locations', array(
622
				'LOCATION_ID'	=> $location_id,
623
				'LOCATION_DESC'	=> $location_data['desc'],
624
				'LOCATION_NAME'	=> $location_data['name'],
625
				'S_SELECTED'	=> $data ? in_array($location_id, $data['ad_locations']) : false,
626
			));
627
		}
628
	}
629
630
	/**
631
	* Prepare advertisement preview
632
	*
633
	* @param	string	$code	Ad code to preview
634
	* @return	void
635
	*/
636
	protected function ad_preview($code)
637
	{
638
		$this->template->assign_var('PREVIEW', htmlspecialchars_decode($code));
639
	}
640
641
	/**
642
	* Print success message.
643
	*
644
	* It takes arguments in the form of a language key, followed by language substitution values.
645
	*/
646
	protected function success()
647
	{
648
		trigger_error(call_user_func_array(array($this->user, 'lang'), func_get_args()) . adm_back_link($this->u_action));
649
	}
650
651
	/**
652
	* Print error message.
653
	*
654
	* It takes arguments in the form of a language key, followed by language substitution values.
655
	*/
656
	protected function error()
657
	{
658
		trigger_error(call_user_func_array(array($this->user, 'lang'), func_get_args()) . adm_back_link($this->u_action), E_USER_WARNING);
659
	}
660
661
	/**
662
	* Log action
663
	*
664
	* @param	string	$action		Performed action in uppercase
665
	* @param	string	$ad_name	Advertisement name
666
	* @return	void
667
	*/
668
	protected function log($action, $ad_name)
669
	{
670
		$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'ACP_PHPBB_ADS_' . $action . '_LOG', time(), array($ad_name));
671
	}
672
}
673