Passed
Push — master ( f1c6dd...70a9c8 )
by Stanislav
03:08
created

moderate::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 19
dl 0
loc 27
rs 9.6333
c 2
b 0
f 0
cc 1
nc 1
nop 19

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
/**
4
*
5
* @package phpBB Gallery Core
6
* @copyright (c) 2014 nickvergessen
7
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
8
*
9
*/
10
11
namespace phpbbgallery\core\controller;
12
13
use Symfony\Component\HttpFoundation\RedirectResponse;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpFoundation\RedirectResponse 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...
14
15
class moderate
16
{
17
	/* @var \phpbb\auth\auth */
0 ignored issues
show
Bug introduced by
The type phpbb\auth\auth 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...
18
	protected $auth;
19
20
	/* @var \phpbb\config\config */
0 ignored issues
show
Bug introduced by
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...
21
	protected $config;
22
23
	/* @var \phpbb\db\driver\driver */
0 ignored issues
show
Bug introduced by
The type phpbb\db\driver\driver 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...
24
	protected $db;
25
26
	/* @var \phpbb\request\request */
0 ignored issues
show
Bug introduced by
The type phpbb\request\request 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...
27
	protected $request;
28
29
	/* @var \phpbb\template\template */
0 ignored issues
show
Bug introduced by
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...
30
	protected $template;
31
32
	/* @var \phpbb\user */
0 ignored issues
show
Bug introduced by
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...
33
	protected $user;
34
35
	/** @var \phpbb\language\language  */
0 ignored issues
show
Bug introduced by
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...
36
	protected $language;
37
38
	/* @var \phpbb\controller\helper */
0 ignored issues
show
Bug introduced by
The type phpbb\controller\helper 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...
39
	protected $helper;
40
41
	/* @var \phpbbgallery\core\album\display */
42
	protected $display;
43
44
	/** @var \phpbbgallery\core\moderate  */
45
	protected $moderate;
46
47
	/** @var \phpbbgallery\core\auth\auth  */
48
	protected $gallery_auth;
49
50
	/** @var \phpbbgallery\core\misc  */
51
	protected $misc;
52
53
	/** @var \phpbbgallery\core\album\album  */
54
	protected $album;
55
56
	/** @var \phpbbgallery\core\image\image  */
57
	protected $image;
58
59
	/** @var \phpbbgallery\core\notification\helper  */
60
	protected $notification_helper;
61
62
	/** @var \phpbbgallery\core\url  */
63
	protected $url;
64
65
	/** @var \phpbbgallery\core\log  */
66
	protected $gallery_log;
67
68
	/** @var \phpbbgallery\core\report  */
69
	protected $report;
70
71
	/** @var \phpbb\user_loader  */
0 ignored issues
show
Bug introduced by
The type phpbb\user_loader 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...
72
	protected $user_loader;
73
74
	/* @var string */
75
	protected $root_path;
76
77
	/* @var string */
78
	protected $php_ext;
79
80
	/**
81
	 * Constructor
82
	 *
83
	 * @param \phpbb\config\config                   $config    Config object
84
	 * @param \phpbb\request\request                 $request   Request object
85
	 * @param \phpbb\template\template               $template  Template object
86
	 * @param \phpbb\user                            $user      User object
87
	 * @param \phpbb\language\language               $language
88
	 * @param \phpbb\controller\helper               $helper    Controller helper object
89
	 * @param \phpbbgallery\core\album\display       $display   Albums display object
90
	 * @param \phpbbgallery\core\moderate            $moderate
91
	 * @param \phpbbgallery\core\auth\auth           $gallery_auth
92
	 * @param \phpbbgallery\core\misc                $misc
93
	 * @param \phpbbgallery\core\album\album         $album
94
	 * @param \phpbbgallery\core\image\image         $image
95
	 * @param \phpbbgallery\core\notification\helper $notification_helper
96
	 * @param \phpbbgallery\core\url                 $url
97
	 * @param \phpbbgallery\core\log                 $gallery_log
98
	 * @param \phpbbgallery\core\report              $report
99
	 * @param \phpbb\user_loader                     $user_loader
100
	 * @param string                                 $root_path Root path
101
	 * @param string                                 $php_ext   php file extension
102
	 * @internal param \phpbb\auth\auth $auth Auth object
103
	 * @internal param \phpbb\db\driver\driver|\phpbb\db\driver\driver_interface $db Database object
104
	 */
105
	public function __construct(\phpbb\config\config $config, \phpbb\request\request $request,
106
		\phpbb\template\template $template, \phpbb\user $user, \phpbb\language\language $language,
107
		\phpbb\controller\helper $helper, \phpbbgallery\core\album\display $display, \phpbbgallery\core\moderate $moderate,
108
		\phpbbgallery\core\auth\auth $gallery_auth, \phpbbgallery\core\misc $misc, \phpbbgallery\core\album\album $album, \phpbbgallery\core\image\image $image,
109
		\phpbbgallery\core\notification\helper $notification_helper, \phpbbgallery\core\url $url, \phpbbgallery\core\log $gallery_log,
110
		\phpbbgallery\core\report $report, \phpbb\user_loader $user_loader,
111
		$root_path, $php_ext)
112
	{
113
		$this->config = $config;
114
		$this->request = $request;
115
		$this->template = $template;
116
		$this->user = $user;
117
		$this->language = $language;
118
		$this->helper = $helper;
119
		$this->display = $display;
120
		$this->moderate = $moderate;
121
		$this->gallery_auth = $gallery_auth;
122
		$this->misc = $misc;
123
		$this->album = $album;
124
		$this->image = $image;
125
		$this->notification_helper = $notification_helper;
126
		$this->url = $url;
127
		$this->gallery_log = $gallery_log;
128
		$this->report = $report;
129
		$this->user_loader = $user_loader;
130
		$this->root_path = $root_path;
131
		$this->php_ext = $php_ext;
132
	}
133
134
	/**
135
	 * Index Controller
136
	 *    Route: gallery/modarate
137
	 *
138
	 * @param int $album_id
139
	 * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpFoundation\Response 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...
140
	 */
141
	public function base($album_id = 0)
142
	{
143
		$this->gallery_auth->load_user_premissions($this->user->data['user_id']);
144
		$album_backlink = $album_id === 0 ? $this->helper->route('phpbbgallery_core_moderate') : $this->helper->route('phpbbgallery_core_moderate_album', array('album_id'	=> $album_id));
145
		$album_loginlink = append_sid($this->root_path . 'ucp.' . $this->php_ext . '?mode=login');
0 ignored issues
show
Bug introduced by
The function append_sid was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

145
		$album_loginlink = /** @scrutinizer ignore-call */ append_sid($this->root_path . 'ucp.' . $this->php_ext . '?mode=login');
Loading history...
146
		if ($album_id === 0)
147
		{
148
			if (!$this->gallery_auth->acl_check_global('m_'))
149
			{
150
				$this->misc->not_authorised($album_backlink, $album_loginlink, 'LOGIN_EXPLAIN_UPLOAD');
151
			}
152
		}
153
		else
154
		{
155
			$album = $this->album->get_info($album_id);
156
			if (!$this->gallery_auth->acl_check('m_', $album['album_id'], $album['album_user_id']))
157
			{
158
				$this->misc->not_authorised($album_backlink, $album_loginlink, 'LOGIN_EXPLAIN_UPLOAD');
159
			}
160
		}
161
		$this->language->add_lang(array('gallery_mcp', 'gallery'), 'phpbbgallery/core');
162
		$this->language->add_lang('mcp');
163
		$this->display->display_albums(false, $this->config['load_moderators']);
0 ignored issues
show
Bug introduced by
false of type false is incompatible with the type string expected by parameter $root_data of phpbbgallery\core\album\display::display_albums(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

163
		$this->display->display_albums(/** @scrutinizer ignore-type */ false, $this->config['load_moderators']);
Loading history...
164
		// This is the overview page, so we will need to create some queries
165
		// We will use the special moderate helper
166
167
		$this->report->build_list($album_id, 1, 5);
168
		$this->moderate->build_list($album_id, 1, 5);
169
		$this->gallery_log->build_list('moderator', 5, 1, $album_id);
170
171
		$this->template->assign_vars(array(
172
			'U_GALLERY_MODERATE_OVERVIEW'	=> $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_album', array('album_id' => $album_id)) : $this->helper->route('phpbbgallery_core_moderate'),
173
			'U_GALLERY_MODERATE_APPROVE'	=> $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_queue_approve_album', array('album_id' => $album_id)) : $this->helper->route('phpbbgallery_core_moderate_queue_approve'),
174
			'U_GALLERY_MODERATE_REPORT'		=> $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_reports_album', array('album_id' => $album_id)) : $this->helper->route('phpbbgallery_core_moderate_reports'),
175
			'U_ALBUM_OVERVIEW'				=> $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_view', array('album_id' => $album_id)) : false,
176
			'U_GALLERY_MCP_LOGS'			=> $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_action_log_album', array('album_id' => $album_id)) : $this->helper->route('phpbbgallery_core_moderate_action_log'),
177
			'U_ALBUM_NAME'					=> $album_id > 0 ? $album['album_name'] : false,
178
			'U_OVERVIEW'					=> true,
179
		));
180
181
		return $this->helper->render('gallery/moderate_overview.html', $this->language->lang('GALLERY'));
182
	}
183
184
	/**
185
	 * Index Controller
186
	 *    Route: gallery/modarate/approve
187
	 *
188
	 * @param $page
189
	 * @param $album_id
190
	 * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
191
	 */
192
	public function queue_approve($page, $album_id)
193
	{
194
		$approve_ary = $this->request->variable('approval', array('' => array(0)));
195
		$action_ary = $this->request->variable('action', array('' => 0));
196
		$back_link = $this->request->variable('back_link', $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_queue_approve_album', array('album_id' => $album_id)) : $this->helper->route('phpbbgallery_core_moderate_queue_approve'));
197
		foreach ($action_ary as $act => $garb)
198
		{
199
			$action = $act;
200
		}
201
202
		$this->language->add_lang(array('gallery_mcp', 'gallery'), 'phpbbgallery/core');
203
		$this->language->add_lang('mcp');
204
205
		$this->gallery_auth->load_user_premissions($this->user->data['user_id']);
206
		$album_backlink = $album_id === 0 ? $this->helper->route('phpbbgallery_core_moderate') : $this->helper->route('phpbbgallery_core_moderate_album', array('album_id'	=> $album_id));
207
		$album_loginlink = append_sid($this->root_path . 'ucp.' . $this->php_ext . '?mode=login');
0 ignored issues
show
Bug introduced by
The function append_sid was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

207
		$album_loginlink = /** @scrutinizer ignore-call */ append_sid($this->root_path . 'ucp.' . $this->php_ext . '?mode=login');
Loading history...
208
		if ($album_id === 0)
209
		{
210
			if (!$this->gallery_auth->acl_check_global('m_status'))
211
			{
212
				$this->misc->not_authorised($album_backlink, $album_loginlink, 'LOGIN_EXPLAIN_UPLOAD');
213
			}
214
		}
215
		else
216
		{
217
			$album = $this->album->get_info($album_id);
218
			if (!$this->gallery_auth->acl_check('m_status', $album['album_id'], $album['album_user_id']))
219
			{
220
				$this->misc->not_authorised($album_backlink, $album_loginlink, 'LOGIN_EXPLAIN_UPLOAD');
221
			}
222
		}
223
		if (!empty($approve_ary))
224
		{
225
			if (confirm_box(true))
0 ignored issues
show
Bug introduced by
The function confirm_box was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

225
			if (/** @scrutinizer ignore-call */ confirm_box(true))
Loading history...
226
			{
227
				if ($action == 'approve')
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $action seems to be defined by a foreach iteration on line 197. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
228
				{
229
					$count = 0;
230
					foreach ($approve_ary as $album_id => $approve_array)
0 ignored issues
show
introduced by
$album_id is overwriting one of the parameters of this function.
Loading history...
231
					{
232
						$this->image->approve_images($approve_array, $album_id);
233
						$this->album->update_info($album_id);
234
						$count = $count + count($approve_array);
235
					}
236
237
					$message = $this->language->lang('WAITING_APPROVED_IMAGE', $count);
238
					$this->url->meta_refresh(3, $back_link);
239
					trigger_error($message);
240
				}
241
				if ($action == 'disapprove')
242
				{
243
					$count = 0;
244
					foreach ($approve_ary as $album_id => $delete_array)
0 ignored issues
show
introduced by
$album_id is overwriting one of the parameters of this function.
Loading history...
245
					{
246
						// Let's load info for images, so we can
247
						$filenames = $this->image->get_filenames($delete_array);
248
						// Let's log the action
249
						foreach ($filenames as $name)
250
						{
251
							$this->gallery_log->add_log('moderator', 'disapprove', $album_id, 0, array('LOG_GALLERY_DISAPPROVED', $name));
252
						}
253
						$this->moderate->delete_images($delete_array);
254
						$count = $count + count($delete_array);
255
					}
256
					$message = $this->language->lang('WAITING_DISPPROVED_IMAGE', $count);
257
					$this->url->meta_refresh(3, $back_link);
258
					trigger_error($message);
259
				}
260
			}
261
			else
262
			{
263
				$s_hidden_fields = '<input type="hidden" name="action['.$action.']" value="' . $action . '" />';
264
				$s_hidden_fields .= '<input type="hidden" name="back_link" value="' . $back_link . '" />';
265
				foreach ($approve_ary as $id => $var)
266
				{
267
					foreach ($var as $var1)
268
					{
269
						$s_hidden_fields .= '<input type="hidden" name="approval[' . $id . '][]" value="' . $var1 . '" />';
270
					}
271
				}
272
				confirm_box(false, $this->language->lang('QUEUES_A_' . strtoupper($action) . '2_CONFIRM'), $s_hidden_fields);
273
			}
274
		}
275
276
		$this->template->assign_vars(array(
277
			'U_GALLERY_MODERATE_OVERVIEW'	=> $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_album', array('album_id' => $album_id)) : $this->helper->route('phpbbgallery_core_moderate'),
278
			'U_GALLERY_MODERATE_APPROVE'	=> $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_queue_approve_album', array('album_id' => $album_id)) : $this->helper->route('phpbbgallery_core_moderate_queue_approve'),
279
			'U_GALLERY_MODERATE_REPORT'		=> $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_reports_album', array('album_id' => $album_id)) : $this->helper->route('phpbbgallery_core_moderate_reports'),
280
			'U_ALBUM_OVERVIEW'				=> $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_view', array('album_id' => $album_id)) : false,
281
			'U_GALLERY_MCP_LOGS'			=> $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_action_log_album', array('album_id' => $album_id)) : $this->helper->route('phpbbgallery_core_moderate_action_log'),
282
			'U_ALBUM_NAME'					=> $album_id > 0 ? $album['album_name'] : false,
283
		));
284
		$this->moderate->build_list($album_id, $page);
285
		return $this->helper->render('gallery/moderate_approve.html', $this->language->lang('GALLERY'));
286
	}
287
288
	/**
289
	 * Index Controller
290
	 *    Route: gallery/modarate/actions
291
	 *
292
	 * @param $page
293
	 * @param $album_id
294
	 * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
295
	 */
296
	public function action_log($page, $album_id)
297
	{
298
		$this->language->add_lang(array('gallery_mcp', 'gallery'), 'phpbbgallery/core');
299
		$this->language->add_lang('mcp');
300
301
		$this->gallery_auth->load_user_premissions($this->user->data['user_id']);
302
		$album_backlink = $album_id === 0 ? $this->helper->route('phpbbgallery_core_moderate') : $this->helper->route('phpbbgallery_core_moderate_album', array('album_id'	=> $album_id));
303
		$album_loginlink = append_sid($this->root_path . 'ucp.' . $this->php_ext . '?mode=login');
0 ignored issues
show
Bug introduced by
The function append_sid was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

303
		$album_loginlink = /** @scrutinizer ignore-call */ append_sid($this->root_path . 'ucp.' . $this->php_ext . '?mode=login');
Loading history...
304
		if ($album_id === 0)
305
		{
306
			if (!$this->gallery_auth->acl_check_global('m_'))
307
			{
308
				$this->misc->not_authorised($album_backlink, $album_loginlink, 'LOGIN_EXPLAIN_UPLOAD');
309
			}
310
		}
311
		else
312
		{
313
			$album = $this->album->get_info($album_id);
314
			if (!$this->gallery_auth->acl_check('m_', $album['album_id'], $album['album_user_id']))
315
			{
316
				$this->misc->not_authorised($album_backlink, $album_loginlink, 'LOGIN_EXPLAIN_UPLOAD');
317
			}
318
		}
319
		$this->template->assign_vars(array(
320
			'U_GALLERY_MODERATE_OVERVIEW'	=> $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_album', array('album_id' => $album_id)) : $this->helper->route('phpbbgallery_core_moderate'),
321
			'U_GALLERY_MODERATE_APPROVE'	=> $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_queue_approve_album', array('album_id' => $album_id)) : $this->helper->route('phpbbgallery_core_moderate_queue_approve'),
322
			'U_GALLERY_MODERATE_REPORT'		=> $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_reports_album', array('album_id' => $album_id)) : $this->helper->route('phpbbgallery_core_moderate_reports'),
323
			'U_ALBUM_OVERVIEW'				=> $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_view', array('album_id' => $album_id)) : false,
324
			'U_GALLERY_MCP_LOGS'			=> $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_action_log_album', array('album_id' => $album_id)) : $this->helper->route('phpbbgallery_core_moderate_action_log'),
325
			'U_ALBUM_NAME'					=> $album_id > 0 ? $album['album_name'] : false,
326
		));
327
		$this->gallery_log->build_list('moderator', 0, $page, $album_id);
328
		return $this->helper->render('gallery/moderate_actions.html', $this->language->lang('GALLERY'));
329
	}
330
331
	/**
332
	 * Index Controller
333
	 *    Route: gallery/modarate/reports
334
	 *
335
	 * @param $page
336
	 * @param $album_id
337
	 * @param $status
338
	 * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
339
	 */
340
	public function reports($page, $album_id, $status)
341
	{
342
		$report_ary = $this->request->variable('report', array(0));
343
		$action_ary = $this->request->variable('action', array('' => 0));
344
		$back_link = $this->request->variable('back_link', $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_reports_album', array('album_id' => $album_id)) : $this->helper->route('phpbbgallery_core_moderate_reports'));
345
		foreach ($action_ary as $act => $garb)
346
		{
347
			$action = $act;
348
		}
349
350
		$this->language->add_lang(array('gallery_mcp', 'gallery'), 'phpbbgallery/core');
351
		$this->language->add_lang('mcp');
352
353
		if (!empty($report_ary))
354
		{
355
			if (confirm_box(true))
0 ignored issues
show
Bug introduced by
The function confirm_box was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

355
			if (/** @scrutinizer ignore-call */ confirm_box(true))
Loading history...
356
			{
357
				$this->report->close_reports_by_image($report_ary);
358
				$message = $this->language->lang('WAITING_REPORTED_DONE', count($report_ary));
359
				$this->url->meta_refresh(3, $back_link);
360
				trigger_error($message);
361
			}
362
			else
363
			{
364
				$s_hidden_fields = '<input type="hidden" name="action['.$action.']" value="' . $action . '" />';
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $action seems to be defined by a foreach iteration on line 345. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
365
				$s_hidden_fields .= '<input type="hidden" name="back_link" value="' . $back_link . '" />';
366
				foreach ($report_ary as $var)
367
				{
368
					$s_hidden_fields .= '<input type="hidden" name="report[]" value="' . $var . '" />';
369
				}
370
				confirm_box(false, $this->language->lang('REPORTS_A_CLOSE2_CONFIRM'), $s_hidden_fields);
371
			}
372
		}
373
		$this->gallery_auth->load_user_premissions($this->user->data['user_id']);
374
		$album_backlink = $album_id === 0 ? $this->helper->route('phpbbgallery_core_moderate') : $this->helper->route('phpbbgallery_core_moderate_album', array('album_id'	=> $album_id));
375
		$album_loginlink = append_sid($this->root_path . 'ucp.' . $this->php_ext . '?mode=login');
0 ignored issues
show
Bug introduced by
The function append_sid was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

375
		$album_loginlink = /** @scrutinizer ignore-call */ append_sid($this->root_path . 'ucp.' . $this->php_ext . '?mode=login');
Loading history...
376
		if ($album_id === 0)
377
		{
378
			if (!$this->gallery_auth->acl_check_global('m_report'))
379
			{
380
				$this->misc->not_authorised($album_backlink, $album_loginlink, 'LOGIN_EXPLAIN_UPLOAD');
381
			}
382
		}
383
		else
384
		{
385
			$album = $this->album->get_info($album_id);
386
			if (!$this->gallery_auth->acl_check('m_report', $album['album_id'], $album['album_user_id']))
387
			{
388
				$this->misc->not_authorised($album_backlink, $album_loginlink, 'LOGIN_EXPLAIN_UPLOAD');
389
			}
390
		}
391
392
		$this->template->assign_vars(array(
393
			'U_GALLERY_MODERATE_OVERVIEW'	=> $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_album', array('album_id' => $album_id)) : $this->helper->route('phpbbgallery_core_moderate'),
394
			'U_GALLERY_MODERATE_APPROVE'	=> $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_queue_approve_album', array('album_id' => $album_id)) : $this->helper->route('phpbbgallery_core_moderate_queue_approve'),
395
			'U_GALLERY_MODERATE_REPORT'		=> $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_reports_album', array('album_id' => $album_id)) : $this->helper->route('phpbbgallery_core_moderate_reports'),
396
			'U_ALBUM_OVERVIEW'				=> $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_view', array('album_id' => $album_id)) : false,
397
			'U_GALLERY_MODERATE_REPORT_CLOSED'		=> $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_reports_closed_album', array('album_id' => $album_id)) : $this->helper->route('phpbbgallery_core_moderate_reports_closed'),
398
			'U_GALLERY_MCP_LOGS'			=> $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_action_log_album', array('album_id' => $album_id)) : $this->helper->route('phpbbgallery_core_moderate_action_log'),
399
			'U_ALBUM_NAME'					=> $album_id > 0 ? $album['album_name'] : false,
400
			'U_STATUS'						=> $status == 1 ? true : false,
401
		));
402
403
		$this->report->build_list($album_id, $page, $this->config['phpbb_gallery_items_per_page'], $status);
404
		return $this->helper->render('gallery/moderate_reports.html', $this->language->lang('GALLERY'));
405
	}
406
407
	/**
408
	 * Moderate Controller
409
	 *    Route: gallery/moderate/{album_id}/list
410
	 *
411
	 * @param $album_id
412
	 * @param $page
413
	 * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
414
	 */
415
	public function album_overview($album_id, $page)
416
	{
417
		$this->language->add_lang(array('gallery_mcp', 'gallery'), 'phpbbgallery/core');
418
		$this->language->add_lang('mcp');
419
420
		$actions_array = $this->request->variable('action', array(0));
421
		$action = $this->request->variable('select_action', '');
422
		$back_link = $this->request->variable('back_link', $this->helper->route('phpbbgallery_core_moderate_view', array('album_id' => $album_id)));
423
		$moving_target = $this->request->variable('moving_target', '');
424
		if (!empty($actions_array))
425
		{
426
			if (confirm_box(true) || $moving_target)
0 ignored issues
show
Bug introduced by
The function confirm_box was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

426
			if (/** @scrutinizer ignore-call */ confirm_box(true) || $moving_target)
Loading history...
427
			{
428
				switch ($action)
429
				{
430
					case 'approve':
431
						$this->image->approve_images($actions_array, $album_id);
432
						$this->album->update_info($album_id);
433
434
						$message = $this->language->lang('WAITING_APPROVED_IMAGE', count($actions_array));
435
						$this->url->meta_refresh(3, $back_link);
436
						trigger_error($message);
437
					break;
438
					case 'unapprove':
439
						$this->image->unapprove_images($actions_array, $album_id);
440
						$this->album->update_info($album_id);
441
442
						$message = $this->language->lang('WAITING_UNAPPROVED_IMAGE', count($actions_array));
443
						$this->url->meta_refresh(3, $back_link);
444
						trigger_error($message);
445
					break;
446
					case 'lock':
447
						$this->image->lock_images($actions_array, $album_id);
448
						$this->album->update_info($album_id);
449
450
						$message = $this->language->lang('WAITING_LOCKED_IMAGE', count($actions_array));
451
						$this->url->meta_refresh(3, $back_link);
452
						trigger_error($message);
453
					break;
454
					case 'delete':
455
						$this->moderate->delete_images($actions_array);
456
						$this->album->update_info($album_id);
457
458
						$message = $this->language->lang('DELETED_IMAGES', count($actions_array));
459
						$this->url->meta_refresh(3, $back_link);
460
						trigger_error($message);
461
					break;
462
					case 'move':
463
						$this->image->move_image($actions_array, $moving_target);
464
						$this->album->update_info($album_id);
465
						$this->album->update_info($moving_target);
466
467
						$message = $this->language->lang('MOVED_IMAGES', count($actions_array));
468
						$this->url->meta_refresh(3, $back_link);
469
						trigger_error($message);
470
					break;
471
					case 'report':
472
						$this->report->close_reports_by_image($actions_array);
473
						$message = $this->language->lang('WAITING_REPORTED_DONE', count($actions_array));
474
						$this->url->meta_refresh(3, $back_link);
475
						trigger_error($message);
476
					break;
477
				}
478
			}
479
			else
480
			{
481
				$s_hidden_fields = '<input type="hidden" name="select_action" value="' . $action . '" />';
482
				$s_hidden_fields .= '<input type="hidden" name="back_link" value="' . $back_link . '" />';
483
				foreach ($actions_array as $var)
484
				{
485
					$s_hidden_fields .= '<input type="hidden" name="action[]" value="' . $var . '" />';
486
				}
487
				if ($action == 'report')
488
				{
489
					confirm_box(false, $this->language->lang('REPORT_A_CLOSE2_CONFIRM'), $s_hidden_fields);
490
				}
491
				if ($action == 'move')
492
				{
493
					$category_select = $this->album->get_albumbox(false, 'moving_target', $album_id, 'm_move', $album_id);
494
					$this->template->assign_vars(array(
495
						'S_MOVING_IMAGES'	=> true,
496
						'S_ALBUM_SELECT'	=> $category_select,
497
						'S_HIDDEN_FIELDS'	=> $s_hidden_fields,
498
					));
499
					return $this->helper->render('gallery/mcp_body.html', $this->language->lang('GALLERY'));
500
				}
501
				else
502
				{
503
					confirm_box(false, $this->language->lang('QUEUES_A_' . strtoupper($action) . '2_CONFIRM'), $s_hidden_fields);
504
				}
505
			}
506
		}
507
		$this->gallery_auth->load_user_premissions($this->user->data['user_id']);
508
		$album_backlink = $album_id === 0 ? $this->helper->route('phpbbgallery_core_moderate') : $this->helper->route('phpbbgallery_core_moderate_album', array('album_id'	=> $album_id));
509
		$album_loginlink = append_sid($this->root_path . 'ucp.' . $this->php_ext . '?mode=login');
0 ignored issues
show
Bug introduced by
The function append_sid was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

509
		$album_loginlink = /** @scrutinizer ignore-call */ append_sid($this->root_path . 'ucp.' . $this->php_ext . '?mode=login');
Loading history...
510
		if ($album_id === 0)
511
		{
512
			if (!$this->gallery_auth->acl_check_global('m_'))
513
			{
514
				$this->misc->not_authorised($album_backlink, $album_loginlink, 'LOGIN_EXPLAIN_UPLOAD');
515
			}
516
		}
517
		else
518
		{
519
			$album = $this->album->get_info($album_id);
520
			if (!$this->gallery_auth->acl_check('m_', $album['album_id'], $album['album_user_id']))
521
			{
522
				$this->misc->not_authorised($album_backlink, $album_loginlink, 'LOGIN_EXPLAIN_UPLOAD');
523
			}
524
		}
525
		$this->template->assign_vars(array(
526
			'U_GALLERY_MODERATE_OVERVIEW'	=> $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_album', array('album_id' => $album_id)) : $this->helper->route('phpbbgallery_core_moderate'),
527
			'U_GALLERY_MODERATE_APPROVE'	=> $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_queue_approve_album', array('album_id' => $album_id)) : $this->helper->route('phpbbgallery_core_moderate_queue_approve'),
528
			'U_GALLERY_MODERATE_REPORT'		=> $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_reports_album', array('album_id' => $album_id)) : $this->helper->route('phpbbgallery_core_moderate_reports'),
529
			'U_ALBUM_OVERVIEW'				=> $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_view', array('album_id' => $album_id)) : false,
530
			'U_GALLERY_MCP_LOGS'			=> $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_action_log_album', array('album_id' => $album_id)) : $this->helper->route('phpbbgallery_core_moderate_action_log'),
531
			'U_ALBUM_NAME'					=> $album_id > 0 ? $album['album_name'] : false,
532
		));
533
		$this->moderate->album_overview($album_id, $page);
534
		return $this->helper->render('gallery/moderate_album_overview.html', $this->language->lang('GALLERY'));
535
	}
536
537
	/**
538
	 * Index Controller
539
	 *    Route: gallery/modarate/image/{image_id}
540
	 *
541
	 * @param $image_id
542
	 * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
543
	 */
544
	public function image($image_id)
545
	{
546
		$this->language->add_lang(array('gallery_mcp', 'gallery'), 'phpbbgallery/core');
547
		$this->language->add_lang('mcp');
548
		$quick_action = $this->request->variable('action', '');
549
550
		// If we have quick mode (EDIT, DELETE) just send us to the page we need
551
		switch ($quick_action)
552
		{
553
			case 'images_move':
554
				$route = $this->helper->route('phpbbgallery_core_moderate_image_move', array('image_id'	=> $image_id));
555
				$redirect = new RedirectResponse($route);
556
				$redirect->send();
557
			break;
558
			case 'image_edit':
559
				$route = $this->helper->route('phpbbgallery_core_image_edit', array('image_id'	=> $image_id));
560
				$redirect = new RedirectResponse($route);
561
				$redirect->send();
562
			break;
563
			case 'images_unapprove':
564
				$route = $this->helper->route('phpbbgallery_core_moderate_image_unapprove', array('image_id'	=> $image_id));
565
				$redirect = new RedirectResponse($route);
566
				$redirect->send();
567
			break;
568
			case 'images_approve':
569
				$route = $this->helper->route('phpbbgallery_core_moderate_image_approve', array('image_id'	=> $image_id));
570
				$redirect = new RedirectResponse($route);
571
				$redirect->send();
572
			break;
573
			case 'images_lock':
574
				$route = $this->helper->route('phpbbgallery_core_moderate_image_lock', array('image_id'	=> $image_id));
575
				$redirect = new RedirectResponse($route);
576
				$redirect->send();
577
			break;
578
			case 'images_delete':
579
				$route = $this->helper->route('phpbbgallery_core_image_delete', array('image_id'	=> $image_id));
580
				$redirect = new RedirectResponse($route);
581
				$redirect->send();
582
			break;
583
			case 'reports_close':
584
				if (confirm_box(true))
0 ignored issues
show
Bug introduced by
The function confirm_box was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

584
				if (/** @scrutinizer ignore-call */ confirm_box(true))
Loading history...
585
				{
586
					$back_link =  $this->helper->route('phpbbgallery_core_moderate_image', array('image_id' => $image_id));
587
					$this->report->close_reports_by_image($image_id);
588
					$message = $this->language->lang('WAITING_REPORTED_DONE', 1);
589
					$this->url->meta_refresh(3, $back_link);
590
					trigger_error($message);
591
				}
592
				else
593
				{
594
					$s_hidden_fields = '<input type="hidden" name="action" value="reports_close" />';
595
					confirm_box(false, $this->language->lang('REPORT_A_CLOSE2_CONFIRM'), $s_hidden_fields);
596
				}
597
			break;
598
			case 'reports_open':
599
				$route = $this->helper->route('phpbbgallery_core_image_report', array('image_id'	=> $image_id));
600
				$redirect = new RedirectResponse($route);
601
				$redirect->send();
602
			break;
603
		}
604
		$image_data = $this->image->get_image_data($image_id);
605
		$album_data = $this->album->get_info($image_data['image_album_id']);
606
		$users_array = $report_data = array();
0 ignored issues
show
Unused Code introduced by
The assignment to $report_data is dead and can be removed.
Loading history...
607
		$open_report = false;
608
		$report_data = $this->report->get_data_by_image($image_id);
609
		foreach ($report_data as $var)
610
		{
611
			$users_array[$var['reporter_id']] = array('');
612
			$users_array[$var['report_manager']] = array('');
613
			if ($var['report_status'] == 1)
614
			{
615
				$open_report = true;
616
			}
617
		}
618
		$users_array[$image_data['image_user_id']] = array('');
619
		$this->user_loader->load_users(array_keys($users_array));
620
		// Now let's get some ACL
621
		$select_select = '<option value="" selected="selected">' . $this->language->lang('CHOOSE_ACTION') . '</option>';
622
		$this->gallery_auth->load_user_premissions($this->user->data['user_id']);
623
		if ($this->gallery_auth->acl_check('m_status', $album_data['album_id'], $album_data['album_user_id']))
624
		{
625
			if ($image_data['image_status'] == 0)
626
			{
627
				$select_select .= '<option value="images_approve">' . $this->language->lang('QUEUE_A_APPROVE') . '</option>';
628
				$select_select .= '<option value="images_lock">' . $this->language->lang('QUEUE_A_LOCK') . '</option>';
629
			}
630
			if ($image_data['image_status'] == 1)
631
			{
632
				$select_select .= '<option value="images_unapprove">' . $this->language->lang('QUEUE_A_UNAPPROVE') . '</option>';
633
				$select_select .= '<option value="images_lock">' . $this->language->lang('QUEUE_A_LOCK') . '</option>';
634
			}
635
			else
636
			{
637
				$select_select .= '<option value="images_approve">' . $this->language->lang('QUEUE_A_APPROVE') . '</option>';
638
				$select_select .= '<option value="images_unapprove">' . $this->language->lang('QUEUE_A_UNAPPROVE') . '</option>';
639
			}
640
		}
641
		if ($this->gallery_auth->acl_check('m_delete', $album_data['album_id'], $album_data['album_user_id']))
642
		{
643
			$select_select .= '<option value="images_delete">' . $this->language->lang('QUEUE_A_DELETE') . '</option>';
644
		}
645
		if ($this->gallery_auth->acl_check('m_move', $album_data['album_id'], $album_data['album_user_id']))
646
		{
647
			$select_select .= '<option value="images_move">' . $this->language->lang('QUEUES_A_MOVE') . '</option>';
648
		}
649
		if ($this->gallery_auth->acl_check('m_report', $album_data['album_id'], $album_data['album_user_id']))
650
		{
651
			if ($open_report)
652
			{
653
				$select_select .= '<option value="reports_close">' . $this->language->lang('REPORT_A_CLOSE') . '</option>';
654
			}
655
			else
656
			{
657
				$select_select .= '<option value="reports_open">' . $this->language->lang('REPORT_A_OPEN') . '</option>';
658
			}
659
		}
660
		$this->template->assign_vars(array(
661
			'ALBUM_NAME'		=> $album_data['album_name'],
662
			'U_VIEW_ALBUM'		=> $this->helper->route('phpbbgallery_core_moderate_album', array('album_id' => $image_data['image_album_id'])),
663
			'U_EDIT_IMAGE'		=> $this->helper->route('phpbbgallery_core_image_edit', array('image_id'	=> $image_id)),
664
			'U_DELETE_IMAGE'	=> $this->helper->route('phpbbgallery_core_image_delete', array('image_id'	=> $image_id)),
665
			'IMAGE_NAME'		=> $image_data['image_name'],
666
			'IMAGE_TIME'		=> $this->user->format_date($image_data['image_time']),
667
			'UPLOADER'			=> $this->user_loader->get_username($image_data['image_user_id'], 'full'),
668
			'U_MOVE_IMAGE'		=> $this->helper->route('phpbbgallery_core_moderate_image_move', array('image_id'	=> $image_id)),
669
			'STATUS'			=> $this->language->lang('QUEUE_STATUS_' . $image_data['image_status']),
670
			'UC_IMAGE'			=> $this->image->generate_link('medium', $this->config['phpbb_gallery_link_thumbnail'], $image_data['image_id'], $image_data['image_name'], $image_data['image_album_id']),
671
			'IMAGE_DESC'		=> generate_text_for_display($image_data['image_desc'], $image_data['image_desc_uid'], $image_data['image_desc_bitfield'], 7),
0 ignored issues
show
Bug introduced by
The function generate_text_for_display was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

671
			'IMAGE_DESC'		=> /** @scrutinizer ignore-call */ generate_text_for_display($image_data['image_desc'], $image_data['image_desc_uid'], $image_data['image_desc_bitfield'], 7),
Loading history...
672
			'U_SELECT'			=> $select_select,
673
			'S_MCP_ACTION'		=> $this->helper->route('phpbbgallery_core_moderate_image', array('image_id' => $image_id)),
674
		));
675
		foreach ($report_data as $var)
676
		{
677
			$this->template->assign_block_vars('reports', array(
678
				'REPORTER'		=> $this->user_loader->get_username($var['reporter_id'], 'full'),
679
				'REPORT_TIME'	=> $this->user->format_date($var['report_time']),
680
				'REPORT_NOTE'	=> $var['report_note'],
681
				'STATUS'		=> $var['report_status'],
682
				'MANAGER'		=> $var['report_manager'] != 0 ?  $this->user_loader->get_username($var['report_manager'], 'full') : false,
683
			));
684
		}
685
		return $this->helper->render('gallery/moderate_image_overview.html', $this->language->lang('GALLERY'));
686
	}
687
688
	/**
689
	 * Index Controller
690
	 *    Route: gallery/modarate/image/{image_id}/approve
691
	 *
692
	 * @param $image_id
693
	 * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
694
	 */
695
	public function approve($image_id)
696
	{
697
		$image_data = $this->image->get_image_data($image_id);
698
		$album_data = $this->album->get_info($image_data['image_album_id']);
699
700
		$album_backlink = $this->helper->route('phpbbgallery_core_album', array('album_id' => $image_data['image_album_id']));
701
		$image_backlink = $this->helper->route('phpbbgallery_core_image', array('image_id' => $image_id));
0 ignored issues
show
Unused Code introduced by
The assignment to $image_backlink is dead and can be removed.
Loading history...
702
		$album_loginlink = append_sid($this->root_path . 'ucp.' . $this->php_ext . '?mode=login');
0 ignored issues
show
Bug introduced by
The function append_sid was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

702
		$album_loginlink = /** @scrutinizer ignore-call */ append_sid($this->root_path . 'ucp.' . $this->php_ext . '?mode=login');
Loading history...
703
		$meta_refresh_time = 2;
0 ignored issues
show
Unused Code introduced by
The assignment to $meta_refresh_time is dead and can be removed.
Loading history...
704
		$this->gallery_auth->load_user_premissions($this->user->data['user_id']);
705
		if (!$this->gallery_auth->acl_check('m_status', $image_data['image_album_id'], $album_data['album_user_id']))
706
		{
707
			$this->misc->not_authorised($album_backlink, $album_loginlink, 'LOGIN_EXPLAIN_UPLOAD');
708
		}
709
		$action_ary = $this->request->variable('action', array('' => 0));
710
		$action_ary = array_keys($action_ary);
711
		$action = $action_ary[0];
712
713
		if ($action == 'disapprove')
714
		{
715
			$redirect = new RedirectResponse($this->helper->route('phpbbgallery_core_image_delete', array('image_id'	=> $image_id)));
716
			$redirect->send();
717
		}
718
		$show_notify = true;
719
		$this->language->add_lang(array('gallery_mcp', 'gallery'), 'phpbbgallery/core');
720
		$this->language->add_lang('mcp');
721
		if (confirm_box(true))
0 ignored issues
show
Bug introduced by
The function confirm_box was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

721
		if (/** @scrutinizer ignore-call */ confirm_box(true))
Loading history...
722
		{
723
			$np = $this->request->variable('notify_poster', '');
724
			$notify_poster = ($action == 'approve' && $np);
0 ignored issues
show
Unused Code introduced by
The assignment to $notify_poster is dead and can be removed.
Loading history...
725
			$image_id_ary = array($image_id);
726
			$this->image->approve_images($image_id_ary, $album_data['album_id']);
727
			$this->album->update_info($album_data['album_id']);
728
			// So we need to see if there are still unapproved images in the album
729
			$this->notification_helper->read('approval', $album_data['album_id']);
730
			$message = $this->language->lang('WAITING_APPROVED_IMAGE', 1);
731
			//meta_refresh($meta_refresh_time, $image_backlink);
732
			$this->template->assign_vars(array(
733
				'INFORMATION'	=> $message
734
			));
735
			return $this->helper->render('gallery/message.html', $this->language->lang('GALLERY'));
736
			//trigger_error($message);
737
		}
738
		else
739
		{
740
			$this->template->assign_vars(array(
741
				'S_NOTIFY_POSTER'			=> $show_notify,
742
				'S_' . strtoupper($action)	=> true,
743
				'S_CONFIRM_ACTION'	=> $this->helper->route('phpbbgallery_core_moderate_image_approve', array('image_id' => $image_id)),
744
			));
745
			$action_msg = $this->language->lang('QUEUES_A_APPROVE2_CONFIRM');
746
			$s_hidden_fields = build_hidden_fields(array(
0 ignored issues
show
Bug introduced by
The function build_hidden_fields was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

746
			$s_hidden_fields = /** @scrutinizer ignore-call */ build_hidden_fields(array(
Loading history...
747
				'action'		=> 'approve',
748
			));
749
			confirm_box(false, $action_msg, $s_hidden_fields, 'mcp_approve.html');
750
		}
751
752
		return $this->helper->render('gallery/moderate_overview.html', $this->language->lang('GALLERY'));
753
	}
754
755
	/**
756
	 * Index Controller
757
	 *    Route: gallery/modarate/image/{image_id}/unapprove
758
	 *
759
	 * @param $image_id
760
	 * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
761
	 */
762
	public function unapprove($image_id)
763
	{
764
		$image_data = $this->image->get_image_data($image_id);
765
		$album_data = $this->album->get_info($image_data['image_album_id']);
766
767
		$album_backlink = $this->helper->route('phpbbgallery_core_index');
768
		$image_backlink = $this->helper->route('phpbbgallery_core_image', array('image_id' => $image_id));
769
		$album_loginlink = append_sid($this->root_path . 'ucp.' . $this->php_ext . '?mode=login');
0 ignored issues
show
Bug introduced by
The function append_sid was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

769
		$album_loginlink = /** @scrutinizer ignore-call */ append_sid($this->root_path . 'ucp.' . $this->php_ext . '?mode=login');
Loading history...
770
		$meta_refresh_time = 2;
771
		$this->gallery_auth->load_user_premissions($this->user->data['user_id']);
772
		if (!$this->gallery_auth->acl_check('m_status', $image_data['image_album_id'], $album_data['album_user_id']))
773
		{
774
			$this->misc->not_authorised($album_backlink, $album_loginlink, 'LOGIN_EXPLAIN_UPLOAD');
775
		}
776
777
		$this->language->add_lang(array('gallery_mcp', 'gallery'), 'phpbbgallery/core');
778
		$this->language->add_lang('mcp');
779
		if (confirm_box(true))
0 ignored issues
show
Bug introduced by
The function confirm_box was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

779
		if (/** @scrutinizer ignore-call */ confirm_box(true))
Loading history...
780
		{
781
			$image_id_ary = array($image_id);
782
			$this->image->unapprove_images($image_id_ary, $album_data['album_id']);
783
			// To DO - add notification
784
			$message = sprintf($this->language->lang('WAITING_UNAPPROVED_IMAGE', 1));
785
			meta_refresh($meta_refresh_time, $image_backlink);
0 ignored issues
show
Bug introduced by
The function meta_refresh was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

785
			/** @scrutinizer ignore-call */ 
786
   meta_refresh($meta_refresh_time, $image_backlink);
Loading history...
786
			trigger_error($message);
787
		}
788
		else
789
		{
790
			$s_hidden_fields = '';
791
			confirm_box(false, 'QUEUE_A_UNAPPROVE2', $s_hidden_fields);
792
		}
793
	}
794
795
	/**
796
	 * Index Controller
797
	 *    Route: gallery/modarate/image/{image_id}/move
798
	 *
799
	 * @param $image_id
800
	 * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
801
	 */
802
	public function move($image_id): \Symfony\Component\HttpFoundation\Response
803
	{
804
		$image_data = $this->image->get_image_data($image_id);
805
		$album_id = $image_data['image_album_id'];
806
		//$user_id = $image_data['image_user_id'];
807
		$album_data =  $this->album->get_info($album_id);
808
		$album_backlink = $this->helper->route('phpbbgallery_core_album', array('album_id' => $album_id));
809
		$image_backlink = $this->helper->route('phpbbgallery_core_image', array('image_id' => $image_id));
810
		$album_loginlink = append_sid($this->root_path . 'ucp.' . $this->php_ext . '?mode=login');
0 ignored issues
show
Bug introduced by
The function append_sid was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

810
		$album_loginlink = /** @scrutinizer ignore-call */ append_sid($this->root_path . 'ucp.' . $this->php_ext . '?mode=login');
Loading history...
811
		$meta_refresh_time = 2;
812
		$this->language->add_lang(array('gallery_mcp', 'gallery'), 'phpbbgallery/core');
813
		$this->gallery_auth->load_user_premissions($this->user->data['user_id']);
814
		if (!$this->gallery_auth->acl_check('m_move', $image_data['image_album_id'], $album_data['album_user_id']))
815
		{
816
			$this->misc->not_authorised($album_backlink, $album_loginlink, 'LOGIN_EXPLAIN_UPLOAD');
817
		}
818
		$moving_target = $this->request->variable('moving_target', '');
819
820
		if ($moving_target)
821
		{
822
			$target = array($image_id);
823
			$this->image->move_image($target, $moving_target);
824
			$message = sprintf($this->language->lang('IMAGES_MOVED', 1));
825
			$this->album->update_info($album_id);
826
			$this->album->update_info($moving_target);
827
			meta_refresh($meta_refresh_time, $image_backlink);
0 ignored issues
show
Bug introduced by
The function meta_refresh was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

827
			/** @scrutinizer ignore-call */ 
828
   meta_refresh($meta_refresh_time, $image_backlink);
Loading history...
828
			trigger_error($message);
829
		}
830
		else
831
		{
832
			$category_select = $this->album->get_albumbox(false, 'moving_target', $album_id, 'm_move', $album_id);
833
			$this->template->assign_vars(array(
834
				'S_MOVING_IMAGES'	=> true,
835
				'S_ALBUM_SELECT'	=> $category_select,
836
				//'S_HIDDEN_FIELDS'	=> $s_hidden_fields,
837
			));
838
		}
839
840
		return $this->helper->render('gallery/mcp_body.html', $this->language->lang('GALLERY'));
841
	}
842
843
	/**
844
	 * Index Controller
845
	 *    Route: gallery/modarate/image/{image_id}/lock
846
	 *
847
	 * @param $image_id
848
	 * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
849
	 */
850
	public function lock($image_id)
851
	{
852
		$image_data = $this->image->get_image_data($image_id);
853
		$album_id = $image_data['image_album_id'];
854
		//$user_id = $image_data['image_user_id'];
855
		$album_data =  $this->album->get_info($album_id);
856
		$album_backlink = $this->helper->route('phpbbgallery_core_album', array('album_id' => $album_id));
857
		$image_backlink = $this->helper->route('phpbbgallery_core_image', array('image_id' => $image_id));
858
		$album_loginlink = append_sid($this->root_path . 'ucp.' . $this->php_ext . '?mode=login');
0 ignored issues
show
Bug introduced by
The function append_sid was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

858
		$album_loginlink = /** @scrutinizer ignore-call */ append_sid($this->root_path . 'ucp.' . $this->php_ext . '?mode=login');
Loading history...
859
		$meta_refresh_time = 2;
860
		$this->language->add_lang(array('gallery_mcp', 'gallery'), 'phpbbgallery/core');
861
		$this->gallery_auth->load_user_premissions($this->user->data['user_id']);
862
		if (!$this->gallery_auth->acl_check('m_status', $image_data['image_album_id'], $album_data['album_user_id']))
863
		{
864
			$this->misc->not_authorised($album_backlink, $album_loginlink, 'LOGIN_EXPLAIN_UPLOAD');
865
		}
866
		if (confirm_box(true))
0 ignored issues
show
Bug introduced by
The function confirm_box was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

866
		if (/** @scrutinizer ignore-call */ confirm_box(true))
Loading history...
867
		{
868
			$image_id_ary = array($image_id);
869
			$this->image->lock_images($image_id_ary, $album_data['album_id']);
870
			// To DO - add notification
871
			$message = sprintf($this->language->lang('WAITING_LOCKED_IMAGE',1));
872
			meta_refresh($meta_refresh_time, $image_backlink);
0 ignored issues
show
Bug introduced by
The function meta_refresh was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

872
			/** @scrutinizer ignore-call */ 
873
   meta_refresh($meta_refresh_time, $image_backlink);
Loading history...
873
			trigger_error($message);
874
		}
875
		else
876
		{
877
			$s_hidden_fields = '';
878
			confirm_box(false, 'QUEUE_A_LOCK2', $s_hidden_fields);
879
		}
880
	}
881
}
882