Completed
Pull Request — master (#48)
by Jakub
09:18
created

admin_controller::ad_enable()   B

Complexity

Conditions 6
Paths 4

Size

Total Lines 28
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 9.1595

Importance

Changes 0
Metric Value
dl 0
loc 28
ccs 10
cts 18
cp 0.5556
rs 8.439
c 0
b 0
f 0
cc 6
eloc 13
nc 4
nop 1
crap 9.1595
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 46
	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 46
		$this->template = $template;
82 46
		$this->user = $user;
83 46
		$this->request = $request;
84 46
		$this->manager = $manager;
85 46
		$this->location_manager = $location_manager;
86 46
		$this->log = $log;
87 46
		$this->config_text = $config_text;
88 46
		$this->config = $config;
89 46
		$this->root_path = $root_path;
90 46
		$this->php_ext = $php_ext;
91 46
		$this->ext_path = $ext_path;
92 46
	}
93
94
	/**
95
	 * Process user request for manage mode
96
	 *
97
	 * @return void
98
	 */
99 6
	public function mode_manage()
100
	{
101 6
		$this->setup();
102
103 6
		if (!function_exists('user_get_id_name'))
104 6
		{
105
			include($this->root_path . 'includes/functions_user.' . $this->php_ext);
106
		}
107
108
		// Trigger specific action
109 6
		$action = $this->request->variable('action', '');
110 6
		if (in_array($action, array('add', 'edit', 'enable', 'disable', 'delete')))
111 6
		{
112 5
			$this->{'action_' . $action}();
113 5
		}
114
115
		// Otherwise default to this
116 6
		$this->list_ads();
117 6
	}
118
119
	/**
120
	 * Process user request for settings mode
121
	 *
122
	 * @return void
123
	 */
124 3
	public function mode_settings()
125
	{
126 3
		$this->setup();
127
128 3
		add_form_key('phpbb/ads/settings');
129 3
		if ($this->request->is_set_post('submit'))
130 3
		{
131
			// Validate form key
132 2
			if (!check_form_key('phpbb/ads/settings'))
133 2
			{
134 1
				$this->errors[] = $this->user->lang('FORM_INVALID');
135 1
			}
136
137 2
			if (empty($this->errors))
138 2
			{
139 1
				$this->config->set('phpbb_ads_adblocker_message', $this->request->variable('adblocker_message', 0));
140 1
				$this->config->set('phpbb_ads_enable_views', $this->request->variable('enable_views', 0));
141 1
				$this->config->set('phpbb_ads_enable_clicks', $this->request->variable('enable_clicks', 0));
142 1
				$this->config_text->set('phpbb_ads_hide_groups', json_encode($this->request->variable('hide_groups', array(0))));
143
144 1
				$this->success('ACP_AD_SETTINGS_SAVED');
145
			}
146
147 1
			$this->template->assign_vars(array(
148 1
				'S_ERROR'   => (bool) count($this->errors),
149 1
				'ERROR_MSG' => count($this->errors) ? implode('<br />', $this->errors) : '',
150 1
			));
151 1
		}
152
153 2
		$hide_groups = json_decode($this->config_text->get('phpbb_ads_hide_groups'), true);
154 2
		$groups = $this->manager->load_groups();
155 2
		foreach ($groups as $group)
156
		{
157 2
			$group_name = ($group['group_type'] == GROUP_SPECIAL) ? $this->user->lang('G_' . $group['group_name']) : $group['group_name'];
158
159 2
			$this->template->assign_block_vars('groups', array(
160 2
				'ID'         => $group['group_id'],
161 2
				'NAME'       => $group_name,
162 2
				'S_SELECTED' => in_array($group['group_id'], $hide_groups),
163 2
			));
164 2
		}
165
166 2
		$this->template->assign_vars(array(
167 2
			'U_ACTION'          => $this->u_action,
168 2
			'ADBLOCKER_MESSAGE' => $this->config['phpbb_ads_adblocker_message'],
169 2
			'ENABLE_VIEWS'      => $this->config['phpbb_ads_enable_views'],
170 2
			'ENABLE_CLICKS'     => $this->config['phpbb_ads_enable_clicks'],
171 2
		));
172 2
	}
173
174
	/**
175
	 * Set page url
176
	 *
177
	 * @param string $u_action Custom form action
178
	 * @return void
179
	 */
180 40
	public function set_page_url($u_action)
181
	{
182 40
		$this->u_action = $u_action;
183 40
	}
184
185
	/**
186
	 * Get ACP page title for Ads module
187
	 *
188
	 * @return string    Language string for Ads ACP module
189
	 */
190 1
	public function get_page_title()
191
	{
192 1
		return $this->user->lang('ACP_PHPBB_ADS_TITLE');
193
	}
194
195
	/**
196
	 * Add an advertisement
197
	 *
198
	 * @return void
199
	 */
200 13
	public function action_add()
201
	{
202 13
		$preview = $this->request->is_set_post('preview');
203 13
		$submit = $this->request->is_set_post('submit');
204
205 13
		add_form_key('phpbb/ads/add');
206 13
		if ($preview || $submit)
207 13
		{
208 12
			$data = $this->get_form_data('phpbb/ads/add');
209
210 View Code Duplication
			if ($preview)
211 12
			{
212 1
				$this->ad_preview($data['ad_code']);
213 1
			}
214
			else if (empty($this->errors))
215 11
			{
216 1
				$ad_id = $this->manager->insert_ad($data);
217 1
				$this->manager->insert_ad_locations($ad_id, $data['ad_locations']);
218
219 1
				$this->log('ADD', $data['ad_name']);
220
221 1
				$this->success('ACP_AD_ADD_SUCCESS');
222
			}
223
224 11
			$this->assign_locations($data);
225 11
			$this->assign_form_data($data);
226 11
		}
227
		else
228
		{
229 1
			$this->assign_locations();
230
		}
231
232
		// Set output vars for display in the template
233 12
		$this->template->assign_vars(array(
234 12
			'S_ADD_AD'           => true,
235 12
			'U_BACK'             => $this->u_action,
236 12
			'U_ACTION'           => "{$this->u_action}&amp;action=add",
237 12
			'PICKER_DATE_FORMAT' => self::DATE_FORMAT,
238 12
			'U_FIND_USERNAME'    => $this->get_find_username_link(),
239 12
		));
240 12
	}
241
242
	/**
243
	 * Edit an advertisement
244
	 *
245
	 * @return void
246
	 */
247 15
	public function action_edit()
248
	{
249 15
		$ad_id = $this->request->variable('id', 0);
250 15
		$preview = $this->request->is_set_post('preview');
251 15
		$submit = $this->request->is_set_post('submit');
252
253 15
		add_form_key('phpbb/ads/edit/' . $ad_id);
254 15
		if ($preview || $submit)
255 15
		{
256 13
			$data = $this->get_form_data('phpbb/ads/edit/' . $ad_id);
257
258
			if ($preview)
259 13
			{
260 1
				$this->ad_preview($data['ad_code']);
261 1
			}
262 View Code Duplication
			else if (empty($this->errors))
263 12
			{
264 2
				$success = $this->manager->update_ad($ad_id, $data);
265
266
				if ($success)
267 2
				{
268
					// Only insert new ad locations to DB when ad exists
269 1
					$this->manager->delete_ad_locations($ad_id);
270 1
					$this->manager->insert_ad_locations($ad_id, $data['ad_locations']);
271
272 1
					$this->log('EDIT', $data['ad_name']);
273
274 1
					$this->success('ACP_AD_EDIT_SUCCESS');
275
				}
276
277 1
				$this->error('ACP_AD_DOES_NOT_EXIST');
278
			}
279 11
		}
280
		else
281
		{
282 2
			$data = $this->manager->get_ad($ad_id);
283 2
			if (empty($data))
284 2
			{
285 1
				$this->error('ACP_AD_DOES_NOT_EXIST');
286
			}
287
288
			// Load ad template locations
289 1
			$data['ad_locations'] = $this->manager->get_ad_locations($ad_id);
290
		}
291
292
		// Set output vars for display in the template
293 12
		$this->template->assign_vars(array(
294 12
			'S_EDIT_AD'          => true,
295 12
			'EDIT_ID'            => $ad_id,
296 12
			'U_BACK'             => $this->u_action,
297 12
			'U_ACTION'           => "{$this->u_action}&amp;action=edit&amp;id=" . $ad_id,
298 12
			'PICKER_DATE_FORMAT' => self::DATE_FORMAT,
299 12
			'U_FIND_USERNAME'    => $this->get_find_username_link(),
300 12
		));
301 12
		$this->assign_locations($data);
302 12
		$this->assign_form_data($data);
303 12
	}
304
305
	/**
306
	 * Enable an advertisement
307
	 *
308
	 * @return void
309
	 */
310 3
	public function action_enable()
311
	{
312 3
		$this->ad_enable(true);
313 1
	}
314
315
	/**
316
	 * Disable an advertisement
317
	 *
318
	 * @return void
319
	 */
320 3
	public function action_disable()
321
	{
322 3
		$this->ad_enable(false);
323 1
	}
324
325
	/**
326
	 * Delete an advertisement
327
	 *
328
	 * @return void
329
	 */
330 3
	public function action_delete()
331
	{
332 3
		$ad_id = $this->request->variable('id', 0);
333
		if ($ad_id)
334 3
		{
335 3
			if (confirm_box(true))
336 3
			{
337
				// Get ad data so that we can log ad name
338 2
				$ad_data = $this->manager->get_ad($ad_id);
339
340
				// Delete ad and it's template locations
341 2
				$this->manager->delete_ad_locations($ad_id);
342 2
				$success = $this->manager->delete_ad($ad_id);
343
344
				// Only notify user on error or if not ajax
345 2
				if (!$success)
346 2
				{
347 1
					$this->error('ACP_AD_DELETE_ERRORED');
348
				}
349
				else
350
				{
351 1
					$this->log('DELETE', $ad_data['ad_name']);
352
353 1
					if (!$this->request->is_ajax())
354 1
					{
355 1
						$this->success('ACP_AD_DELETE_SUCCESS');
356
					}
357
				}
358
			}
359
			else
360
			{
361 1
				confirm_box(false, $this->user->lang('CONFIRM_OPERATION'), build_hidden_fields(array(
362 1
					'id'     => $ad_id,
363 1
					'i'      => $this->request->variable('i', ''),
364 1
					'mode'   => $this->request->variable('mode', ''),
365
					'action' => 'delete'
366 1
				)));
367
			}
368 1
		}
369 1
	}
370
371
	/**
372
	 * Display the ads
373
	 *
374
	 * @return void
375
	 */
376 1
	public function list_ads()
377
	{
378 1
		foreach ($this->manager->get_all_ads() as $row)
379
		{
380 1
			$ad_enabled = (int) $row['ad_enabled'];
381 1
			$ad_end_date = (int) $row['ad_end_date'];
382 1
			$ad_expired = $ad_end_date > 0 && $ad_end_date < time();
383 1
			if ($ad_expired && $ad_enabled)
384 1
			{
385 1
				$ad_enabled = 0;
386 1
				$this->manager->update_ad($row['ad_id'], array('ad_enabled' => 0));
387 1
			}
388
389 1
			$this->template->assign_block_vars('ads', array(
390 1
				'NAME'               => $row['ad_name'],
391 1
				'END_DATE'           => $ad_end_date ? $this->user->format_date($ad_end_date, self::DATE_FORMAT) : '',
392 1
				'VIEWS'              => $row['ad_views'],
393 1
				'CLICKS'             => $row['ad_clicks'],
394 1
				'VIEWS_LIMIT'        => $row['ad_views_limit'],
395 1
				'CLICKS_LIMIT'       => $row['ad_clicks_limit'],
396 1
				'S_END_DATE_EXPIRED' => $ad_expired,
397 1
				'S_ENABLED'          => $ad_enabled,
398 1
				'U_ENABLE'           => $this->u_action . '&amp;action=' . ($ad_enabled ? 'disable' : 'enable') . '&amp;id=' . $row['ad_id'],
399 1
				'U_EDIT'             => $this->u_action . '&amp;action=edit&amp;id=' . $row['ad_id'],
400 1
				'U_DELETE'           => $this->u_action . '&amp;action=delete&amp;id=' . $row['ad_id'],
401 1
			));
402 1
		}
403
404
		// Set output vars for display in the template
405 1
		$this->template->assign_vars(array(
406 1
			'U_ACTION_ADD'     => $this->u_action . '&amp;action=add',
407 1
			'S_VIEWS_ENABLED'  => $this->config['phpbb_ads_enable_views'],
408 1
			'S_CLICKS_ENABLED' => $this->config['phpbb_ads_enable_clicks'],
409 1
		));
410 1
	}
411
412
	/**
413
	 * Perform general tasks
414
	 *
415
	 * @return void
416
	 */
417 9
	protected function setup()
418
	{
419 9
		$this->user->add_lang_ext('phpbb/ads', 'acp');
420
421 9
		$this->template->assign_var('S_PHPBB_ADS', true);
422 9
	}
423
424
	/**
425
	 * Enable/disable an advertisement
426
	 *
427
	 * @param    bool $enable Enable or disable the advertisement?
428
	 * @return void
429
	 */
430 4
	protected function ad_enable($enable)
431
	{
432 4
		$ad_id = $this->request->variable('id', 0);
433
434 4
		$success = $this->manager->update_ad($ad_id, array(
435 4
			'ad_enabled' => (int) $enable,
436 4
		));
437
438
		// If AJAX was used, show user a result message
439 4
		if ($this->request->is_ajax())
440 4
		{
441
			$json_response = new \phpbb\json_response;
442
			$json_response->send(array(
443
				'text'  => $this->user->lang($enable ? 'ENABLED' : 'DISABLED'),
444
				'title' => $this->user->lang('AD_ENABLE_TITLE', (int) $enable),
445
			));
446
		}
447
448
		// Otherwise, show traditional infobox
449
		if ($success)
450 4
		{
451 2
			$this->success($enable ? 'ACP_AD_ENABLE_SUCCESS' : 'ACP_AD_DISABLE_SUCCESS');
452
		}
453
		else
454
		{
455 2
			$this->error($enable ? 'ACP_AD_ENABLE_ERRORED' : 'ACP_AD_DISABLE_ERRORED');
456
		}
457
	}
458
459
	/**
460
	 * Get admin form data.
461
	 *
462
	 * @param    string $form_name The form name.
463
	 * @return    array    Form data
464
	 */
465 25
	protected function get_form_data($form_name)
466
	{
467
		$data = array(
468 25
			'ad_name'         => $this->request->variable('ad_name', '', true),
469 25
			'ad_note'         => $this->request->variable('ad_note', '', true),
470 25
			'ad_code'         => $this->request->variable('ad_code', '', true),
471 25
			'ad_enabled'      => $this->request->variable('ad_enabled', 0),
472 25
			'ad_locations'    => $this->request->variable('ad_locations', array('')),
473 25
			'ad_end_date'     => $this->request->variable('ad_end_date', ''),
474 25
			'ad_priority'     => $this->request->variable('ad_priority', self::DEFAULT_PRIORITY),
475 25
			'ad_views_limit'  => $this->request->variable('ad_views_limit', 0),
476 25
			'ad_clicks_limit' => $this->request->variable('ad_clicks_limit', 0),
477 25
			'ad_owner'        => $this->request->variable('ad_owner', '', true),
478 25
		);
479
480
		// Validate form key
481 25
		if (!check_form_key($form_name))
482 25
		{
483 2
			$this->errors[] = $this->user->lang('FORM_INVALID');
484 2
		}
485
486
		// Validate ad name
487 25
		if ($data['ad_name'] === '')
488 25
		{
489 2
			$this->errors[] = $this->user->lang('AD_NAME_REQUIRED');
490 2
		}
491 25
		if (truncate_string($data['ad_name'], self::MAX_NAME_LENGTH) !== $data['ad_name'])
492 25
		{
493 2
			$this->errors[] = $this->user->lang('AD_NAME_TOO_LONG', self::MAX_NAME_LENGTH);
494 2
		}
495
496
		// Validate ad end date
497 25
		if (preg_match('#^\d{4}\-\d{2}\-\d{2}$#', $data['ad_end_date']))
498 25
		{
499 4
			$data['ad_end_date'] = (int) $this->user->get_timestamp_from_format(self::DATE_FORMAT, $data['ad_end_date']);
500
501 4
			if ($data['ad_end_date'] < time())
502 4
			{
503 2
				$this->errors[] = $this->user->lang('AD_END_DATE_INVALID');
504 2
			}
505 4
		}
506 21
		else if ($data['ad_end_date'] !== '')
507 21
		{
508 2
			$this->errors[] = $this->user->lang('AD_END_DATE_INVALID');
509 2
		}
510
		else
511
		{
512 19
			$data['ad_end_date'] = 0;
513
		}
514
515
		// Validate ad priority
516 25
		if ($data['ad_priority'] < 1 || $data['ad_priority'] > 10)
517 25
		{
518 6
			$this->errors[] = $this->user->lang('AD_PRIORITY_INVALID');
519 6
		}
520
521
		// Validate ad views limit
522 25
		if ($data['ad_views_limit'] < 0)
523 25
		{
524 2
			$this->errors[] = $this->user->lang('AD_VIEWS_LIMIT_INVALID');
525 2
		}
526
527
		// Validate ad clicks limit
528 25
		if ($data['ad_clicks_limit'] < 0)
529 25
		{
530 2
			$this->errors[] = $this->user->lang('AD_CLICKS_LIMIT_INVALID');
531 2
		}
532
533
		// Validate ad owner
534 25
		if (!empty($data['ad_owner']))
535 25
		{
536 4
			user_get_id_name($ad_owner_id, $data['ad_owner']);
0 ignored issues
show
Bug introduced by
The variable $ad_owner_id does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
537 4
			if (!empty($data['ad_owner'] && (!count($ad_owner_id) || ($data['ad_owner'] = $ad_owner_id[0]) === false)))
538 4
			{
539 2
				$this->errors[] = $this->user->lang('AD_OWNER_INVALID');
540 2
			}
541 4
		}
542
		else
543
		{
544 21
			$data['ad_owner'] = 0;
545
		}
546
547 25
		return $data;
548
	}
549
550
	/**
551
	 * Assign form data to the template.
552
	 *
553
	 * @param    array $data The form data.
554
	 * @return void
555
	 */
556 23
	protected function assign_form_data($data)
557
	{
558 23
		user_get_id_name($data['ad_owner'], $ad_owner_name);
0 ignored issues
show
Bug introduced by
The variable $ad_owner_name does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
559
560 23
		$this->template->assign_vars(array(
561 23
			'S_ERROR'   => (bool) count($this->errors),
562 23
			'ERROR_MSG' => count($this->errors) ? implode('<br />', $this->errors) : '',
563
564 23
			'AD_NAME'         => $data['ad_name'],
565 23
			'AD_NOTE'         => $data['ad_note'],
566 23
			'AD_CODE'         => $data['ad_code'],
567 23
			'AD_ENABLED'      => $data['ad_enabled'],
568 23
			'AD_END_DATE'     => $this->prepare_end_date($data['ad_end_date']),
569 23
			'AD_PRIORITY'     => $data['ad_priority'],
570 23
			'AD_VIEWS_LIMIT'  => $data['ad_views_limit'],
571 23
			'AD_CLICKS_LIMIT' => $data['ad_clicks_limit'],
572 23
			'AD_OWNER'        => isset($ad_owner_name[(int) $data['ad_owner'][0]]) ? $ad_owner_name[(int) $data['ad_owner'][0]] : $data['ad_owner'][0],
573 23
		));
574 23
	}
575
576
	/**
577
	 * Prepare end date for display
578
	 *
579
	 * @param    mixed $end_date End date.
580
	 * @return    string    End date prepared for display.
581
	 */
582 23
	protected function prepare_end_date($end_date)
583
	{
584 23
		if (empty($end_date))
585 23
		{
586 18
			return '';
587
		}
588
589 5
		if (is_numeric($end_date))
590 5
		{
591 3
			return $this->user->format_date($end_date, self::DATE_FORMAT);
592
		}
593
594 2
		return (string) $end_date;
595
	}
596
597
	/**
598
	 * Assign template locations data to the template.
599
	 *
600
	 * @param    mixed $data The form data or nothing.
601
	 * @return    void
602
	 */
603 24
	protected function assign_locations($data = false)
604
	{
605 24
		foreach ($this->location_manager->get_all_locations() as $location_id => $location_data)
606
		{
607 24
			$this->template->assign_block_vars('ad_locations', array(
608 24
				'LOCATION_ID'   => $location_id,
609 24
				'LOCATION_DESC' => $location_data['desc'],
610 24
				'LOCATION_NAME' => $location_data['name'],
611 24
				'S_SELECTED'    => $data ? in_array($location_id, $data['ad_locations']) : false,
612 24
			));
613 24
		}
614 24
	}
615
616
	/**
617
	 * Prepare advertisement preview
618
	 *
619
	 * @param    string $code Ad code to preview
620
	 * @return    void
621
	 */
622 2
	protected function ad_preview($code)
623
	{
624 2
		$this->template->assign_var('PREVIEW', htmlspecialchars_decode($code));
625 2
	}
626
627
	/**
628
	 * Print success message.
629
	 *
630
	 * It takes arguments in the form of a language key, followed by language substitution values.
631
	 */
632 6
	protected function success()
633
	{
634 6
		trigger_error(call_user_func_array(array($this->user, 'lang'), func_get_args()) . adm_back_link($this->u_action));
635
	}
636
637
	/**
638
	 * Print error message.
639
	 *
640
	 * It takes arguments in the form of a language key, followed by language substitution values.
641
	 */
642 5
	protected function error()
643
	{
644 5
		trigger_error(call_user_func_array(array($this->user, 'lang'), func_get_args()) . adm_back_link($this->u_action), E_USER_WARNING);
645
	}
646
647
	/**
648
	 * Log action
649
	 *
650
	 * @param    string $action  Performed action in uppercase
651
	 * @param    string $ad_name Advertisement name
652
	 * @return    void
653
	 */
654 3
	protected function log($action, $ad_name)
655
	{
656 3
		$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'ACP_PHPBB_ADS_' . $action . '_LOG', time(), array($ad_name));
657 3
	}
658
659 24
	protected function get_find_username_link()
660
	{
661 24
		return append_sid("{$this->root_path}memberlist.{$this->php_ext}", 'mode=searchuser&amp;form=acp_admanagement_add&amp;field=ad_owner&amp;select_single=true');
662
	}
663
}
664