Completed
Push — master ( bc8d98...2a7858 )
by Stanislav
24s queued 18s
created

moderate   F

Complexity

Total Complexity 122

Size/Duplication

Total Lines 855
Duplicated Lines 0 %

Test Coverage

Coverage 9.48%

Importance

Changes 9
Bugs 0 Features 0
Metric Value
wmc 122
eloc 469
c 9
b 0
f 0
dl 0
loc 855
ccs 42
cts 443
cp 0.0948
rs 2

11 Methods

Rating   Name   Duplication   Size   Complexity  
D queue_approve() 0 94 22
D reports() 0 65 18
A __construct() 0 27 1
B base() 0 41 11
B action_log() 0 33 11
F album_overview() 0 115 24
F image() 0 142 21
A approve() 0 54 5
A lock() 0 29 3
A move() 0 39 3
A unapprove() 0 30 3

How to fix   Complexity   

Complex Class

Complex classes like moderate often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use moderate, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
/**
4
*
5
* @package phpBB Gallery Core
6
* @copyright (c) 2014 nickvergessen | 2025 Leinad4Mind
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 2
	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 2
		$this->config = $config;
114 2
		$this->request = $request;
115 2
		$this->template = $template;
116 2
		$this->user = $user;
117 2
		$this->language = $language;
118 2
		$this->helper = $helper;
119 2
		$this->display = $display;
120 2
		$this->moderate = $moderate;
121 2
		$this->gallery_auth = $gallery_auth;
122 2
		$this->misc = $misc;
123 2
		$this->album = $album;
124 2
		$this->image = $image;
125 2
		$this->notification_helper = $notification_helper;
126 2
		$this->url = $url;
127 2
		$this->gallery_log = $gallery_log;
128 2
		$this->report = $report;
129 2
		$this->user_loader = $user_loader;
130 2
		$this->root_path = $root_path;
131 2
		$this->php_ext = $php_ext;
132 2
	}
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 2
	public function base($album_id = 0)
142
	{
143 2
		$this->gallery_auth->load_user_permissions($this->user->data['user_id']);
144 2
		$album_backlink = $album_id === 0 ? $this->helper->route('phpbbgallery_core_moderate') : $this->helper->route('phpbbgallery_core_moderate_album', array('album_id'	=> $album_id));
145 2
		$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 2
		if ($album_id === 0)
147
		{
148 2
			if (!$this->gallery_auth->acl_check_global('m_'))
149
			{
150 2
				$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 2
		$this->language->add_lang(array('gallery_mcp', 'gallery'), 'phpbbgallery/core');
162 2
		$this->language->add_lang('mcp');
163 2
		$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 2
		$this->report->build_list($album_id, 1, 5);
168 2
		$this->moderate->build_list($album_id, 1, 5);
169 2
		$this->gallery_log->build_list('moderator', 5, 1, $album_id);
170
171 2
		$this->template->assign_vars(array(
172 2
			'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 2
			'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 2
			'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 2
			'U_ALBUM_OVERVIEW'				=> $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_view', array('album_id' => $album_id)) : false,
176 2
			'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 2
			'U_ALBUM_NAME'					=> $album_id > 0 ? $album['album_name'] : false,
178
			'U_OVERVIEW'					=> true,
179
		));
180
181 2
		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_permissions($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_permissions($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/moderate/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_permissions($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
				$message = '';
429
				switch ($action)
430
				{
431
					case 'approve':
432
						$this->image->approve_images($actions_array, $album_id);
433
						$this->album->update_info($album_id);
434
						$message = $this->language->lang('WAITING_APPROVED_IMAGE', count($actions_array));
435
					break;
436
437
					case 'unapprove':
438
						$this->image->unapprove_images($actions_array, $album_id);
439
						$this->album->update_info($album_id);
440
						$message = $this->language->lang('WAITING_UNAPPROVED_IMAGE', count($actions_array));
441
					break;
442
443
					case 'lock':
444
						$this->image->lock_images($actions_array, $album_id);
445
						$this->album->update_info($album_id);
446
						$message = $this->language->lang('WAITING_LOCKED_IMAGE', count($actions_array));
447
					break;
448
449
					case 'delete':
450
						$this->moderate->delete_images($actions_array);
451
						$this->album->update_info($album_id);
452
						$message = $this->language->lang('DELETED_IMAGES', count($actions_array));
453
					break;
454
455
					case 'move':
456
						$this->image->move_image($actions_array, $moving_target);
457
						$this->album->update_info($album_id);
458
						$this->album->update_info($moving_target);
459
						$message = $this->language->lang('MOVED_IMAGES', count($actions_array));
460
					break;
461
462
					case 'report':
463
						$this->report->close_reports_by_image($actions_array);
464
						$message = $this->language->lang('WAITING_REPORTED_DONE', count($actions_array));
465
					break;
466
				}
467
468
				if (!empty($message))
469
				{
470
					$this->url->meta_refresh(3, $back_link);
471
					trigger_error($message);
472
				}
473
			}
474
			else
475
			{
476
				$s_hidden_fields = '<input type="hidden" name="select_action" value="' . $action . '" />';
477
				$s_hidden_fields .= '<input type="hidden" name="back_link" value="' . $back_link . '" />';
478
				foreach ($actions_array as $var)
479
				{
480
					$s_hidden_fields .= '<input type="hidden" name="action[]" value="' . $var . '" />';
481
				}
482
				if ($action == 'report')
483
				{
484
					confirm_box(false, $this->language->lang('REPORT_A_CLOSE2_CONFIRM'), $s_hidden_fields);
485
				}
486
				if ($action == 'move')
487
				{
488
					$category_select = $this->album->get_albumbox(false, 'moving_target', $album_id, 'm_move', $album_id);
489
					$this->template->assign_vars(array(
490
						'S_MOVING_IMAGES'	=> true,
491
						'S_ALBUM_SELECT'	=> $category_select,
492
						'S_HIDDEN_FIELDS'	=> $s_hidden_fields,
493
					));
494
					return $this->helper->render('gallery/mcp_body.html', $this->language->lang('GALLERY'));
495
				}
496
				else
497
				{
498
					confirm_box(false, $this->language->lang('QUEUES_A_' . strtoupper($action) . '2_CONFIRM'), $s_hidden_fields);
499
				}
500
			}
501
		}
502
		$this->gallery_auth->load_user_permissions($this->user->data['user_id']);
503
		$album_backlink = $album_id === 0 ? $this->helper->route('phpbbgallery_core_moderate') : $this->helper->route('phpbbgallery_core_moderate_album', array('album_id'	=> $album_id));
504
		$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

504
		$album_loginlink = /** @scrutinizer ignore-call */ append_sid($this->root_path . 'ucp.' . $this->php_ext . '?mode=login');
Loading history...
505
		if ($album_id === 0)
506
		{
507
			if (!$this->gallery_auth->acl_check_global('m_'))
508
			{
509
				$this->misc->not_authorised($album_backlink, $album_loginlink, 'LOGIN_EXPLAIN_UPLOAD');
510
			}
511
		}
512
		else
513
		{
514
			$album = $this->album->get_info($album_id);
515
			if (!$this->gallery_auth->acl_check('m_', $album['album_id'], $album['album_user_id']))
516
			{
517
				$this->misc->not_authorised($album_backlink, $album_loginlink, 'LOGIN_EXPLAIN_UPLOAD');
518
			}
519
		}
520
		$this->template->assign_vars(array(
521
			'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'),
522
			'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'),
523
			'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'),
524
			'U_ALBUM_OVERVIEW'				=> $album_id > 0 ? $this->helper->route('phpbbgallery_core_moderate_view', array('album_id' => $album_id)) : false,
525
			'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'),
526
			'U_ALBUM_NAME'					=> $album_id > 0 ? $album['album_name'] : false,
527
		));
528
		$this->moderate->album_overview($album_id, $page);
529
		return $this->helper->render('gallery/moderate_album_overview.html', $this->language->lang('GALLERY'));
530
	}
531
532
	/**
533
	 * Index Controller
534
	 *    Route: gallery/moderate/image/{image_id}
535
	 *
536
	 * @param $image_id
537
	 * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
538
	 */
539
	public function image($image_id)
540
	{
541
		$this->language->add_lang(array('gallery_mcp', 'gallery'), 'phpbbgallery/core');
542
		$this->language->add_lang('mcp');
543
		$quick_action = $this->request->variable('action', '');
544
545
		// If we have quick mode (EDIT, DELETE) just send us to the page we need
546
		switch ($quick_action)
547
		{
548
			case 'images_move':
549
				$route = $this->helper->route('phpbbgallery_core_moderate_image_move', array('image_id'	=> $image_id));
550
				$redirect = new RedirectResponse($route);
551
				$redirect->send();
552
			break;
553
			case 'image_edit':
554
				$route = $this->helper->route('phpbbgallery_core_image_edit', array('image_id'	=> $image_id));
555
				$redirect = new RedirectResponse($route);
556
				$redirect->send();
557
			break;
558
			case 'images_unapprove':
559
				$route = $this->helper->route('phpbbgallery_core_moderate_image_unapprove', array('image_id'	=> $image_id));
560
				$redirect = new RedirectResponse($route);
561
				$redirect->send();
562
			break;
563
			case 'images_approve':
564
				$route = $this->helper->route('phpbbgallery_core_moderate_image_approve', array('image_id'	=> $image_id));
565
				$redirect = new RedirectResponse($route);
566
				$redirect->send();
567
			break;
568
			case 'images_lock':
569
				$route = $this->helper->route('phpbbgallery_core_moderate_image_lock', array('image_id'	=> $image_id));
570
				$redirect = new RedirectResponse($route);
571
				$redirect->send();
572
			break;
573
			case 'images_delete':
574
				$route = $this->helper->route('phpbbgallery_core_image_delete', array('image_id'	=> $image_id));
575
				$redirect = new RedirectResponse($route);
576
				$redirect->send();
577
			break;
578
			case 'reports_close':
579
				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

579
				if (/** @scrutinizer ignore-call */ confirm_box(true))
Loading history...
580
				{
581
					$back_link =  $this->helper->route('phpbbgallery_core_moderate_image', array('image_id' => $image_id));
582
					$this->report->close_reports_by_image($image_id);
583
					$message = $this->language->lang('WAITING_REPORTED_DONE', 1);
584
					$this->url->meta_refresh(3, $back_link);
585
					trigger_error($message);
586
				}
587
				else
588
				{
589
					$s_hidden_fields = '<input type="hidden" name="action" value="reports_close" />';
590
					confirm_box(false, $this->language->lang('REPORT_A_CLOSE2_CONFIRM'), $s_hidden_fields);
591
				}
592
			break;
593
			case 'reports_open':
594
				$route = $this->helper->route('phpbbgallery_core_image_report', array('image_id'	=> $image_id));
595
				$redirect = new RedirectResponse($route);
596
				$redirect->send();
597
			break;
598
		}
599
		$image_data = $this->image->get_image_data($image_id);
600
		$album_data = $this->album->get_info($image_data['image_album_id']);
601
		$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...
602
		$open_report = false;
603
		$report_data = $this->report->get_data_by_image($image_id);
604
		foreach ($report_data as $var)
605
		{
606
			$users_array[$var['reporter_id']] = array('');
607
			$users_array[$var['report_manager']] = array('');
608
			if ($var['report_status'] == 1)
609
			{
610
				$open_report = true;
611
			}
612
		}
613
		$users_array[$image_data['image_user_id']] = array('');
614
		$this->user_loader->load_users(array_keys($users_array));
615
		// Now let's get some ACL
616
		$select_select = '<option value="" selected="selected">' . $this->language->lang('CHOOSE_ACTION') . '</option>';
617
		$this->gallery_auth->load_user_permissions($this->user->data['user_id']);
618
		if ($this->gallery_auth->acl_check('m_status', $album_data['album_id'], $album_data['album_user_id']))
619
		{
620
			if ($image_data['image_status'] == 0)
621
			{
622
				$select_select .= '<option value="images_approve">' . $this->language->lang('QUEUE_A_APPROVE') . '</option>';
623
				$select_select .= '<option value="images_lock">' . $this->language->lang('QUEUE_A_LOCK') . '</option>';
624
			}
625
			if ($image_data['image_status'] == 1)
626
			{
627
				$select_select .= '<option value="images_unapprove">' . $this->language->lang('QUEUE_A_UNAPPROVE') . '</option>';
628
				$select_select .= '<option value="images_lock">' . $this->language->lang('QUEUE_A_LOCK') . '</option>';
629
			}
630
			else
631
			{
632
				$select_select .= '<option value="images_approve">' . $this->language->lang('QUEUE_A_APPROVE') . '</option>';
633
				$select_select .= '<option value="images_unapprove">' . $this->language->lang('QUEUE_A_UNAPPROVE') . '</option>';
634
			}
635
		}
636
		if ($this->gallery_auth->acl_check('m_delete', $album_data['album_id'], $album_data['album_user_id']))
637
		{
638
			$select_select .= '<option value="images_delete">' . $this->language->lang('QUEUE_A_DELETE') . '</option>';
639
		}
640
		if ($this->gallery_auth->acl_check('m_move', $album_data['album_id'], $album_data['album_user_id']))
641
		{
642
			$select_select .= '<option value="images_move">' . $this->language->lang('QUEUES_A_MOVE') . '</option>';
643
		}
644
		if ($this->gallery_auth->acl_check('m_report', $album_data['album_id'], $album_data['album_user_id']))
645
		{
646
			if ($open_report)
647
			{
648
				$select_select .= '<option value="reports_close">' . $this->language->lang('REPORT_A_CLOSE') . '</option>';
649
			}
650
			else
651
			{
652
				$select_select .= '<option value="reports_open">' . $this->language->lang('REPORT_A_OPEN') . '</option>';
653
			}
654
		}
655
		$this->template->assign_vars(array(
656
			'ALBUM_NAME'		=> $album_data['album_name'],
657
			'U_VIEW_ALBUM'		=> $this->helper->route('phpbbgallery_core_moderate_album', array('album_id' => $image_data['image_album_id'])),
658
			'U_EDIT_IMAGE'		=> $this->helper->route('phpbbgallery_core_image_edit', array('image_id'	=> $image_id)),
659
			'U_DELETE_IMAGE'	=> $this->helper->route('phpbbgallery_core_image_delete', array('image_id'	=> $image_id)),
660
			'IMAGE_NAME'		=> $image_data['image_name'],
661
			'IMAGE_TIME'		=> $this->user->format_date($image_data['image_time']),
662
			'UPLOADER'			=> $this->user_loader->get_username($image_data['image_user_id'], 'full'),
663
			'U_MOVE_IMAGE'		=> $this->helper->route('phpbbgallery_core_moderate_image_move', array('image_id'	=> $image_id)),
664
			'STATUS'			=> $this->language->lang('QUEUE_STATUS_' . $image_data['image_status']),
665
			'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']),
666
			'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

666
			'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...
667
			'U_SELECT'			=> $select_select,
668
			'S_MCP_ACTION'		=> $this->helper->route('phpbbgallery_core_moderate_image', array('image_id' => $image_id)),
669
		));
670
		foreach ($report_data as $var)
671
		{
672
			$this->template->assign_block_vars('reports', array(
673
				'REPORTER'		=> $this->user_loader->get_username($var['reporter_id'], 'full'),
674
				'REPORT_TIME'	=> $this->user->format_date($var['report_time']),
675
				'REPORT_NOTE'	=> $var['report_note'],
676
				'STATUS'		=> $var['report_status'],
677
				'MANAGER'		=> $var['report_manager'] != 0 ?  $this->user_loader->get_username($var['report_manager'], 'full') : false,
678
			));
679
		}
680
		return $this->helper->render('gallery/moderate_image_overview.html', $this->language->lang('GALLERY'));
681
	}
682
683
	/**
684
	 * Index Controller
685
	 *    Route: gallery/moderate/image/{image_id}/approve
686
	 *
687
	 * @param $image_id
688
	 * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
689
	 */
690
	public function approve($image_id)
691
	{
692
		$image_data = $this->image->get_image_data($image_id);
693
		$album_data = $this->album->get_info($image_data['image_album_id']);
694
695
		$album_backlink = $this->helper->route('phpbbgallery_core_album', array('album_id' => $image_data['image_album_id']));
696
		$image_backlink = $this->helper->route('phpbbgallery_core_image', array('image_id' => $image_id));
697
		$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

697
		$album_loginlink = /** @scrutinizer ignore-call */ append_sid($this->root_path . 'ucp.' . $this->php_ext . '?mode=login');
Loading history...
698
		$meta_refresh_time = 2;
699
		$this->gallery_auth->load_user_permissions($this->user->data['user_id']);
700
		if (!$this->gallery_auth->acl_check('m_status', $image_data['image_album_id'], $album_data['album_user_id']))
701
		{
702
			$this->misc->not_authorised($album_backlink, $album_loginlink, 'LOGIN_EXPLAIN_UPLOAD');
703
		}
704
		$action_ary = $this->request->variable('action', array('' => 0));
705
		$action_ary = array_keys($action_ary);
706
		$action = $action_ary[0] ?? 'approve';
707
708
		if ($action == 'disapprove')
709
		{
710
			$redirect = new RedirectResponse($this->helper->route('phpbbgallery_core_image_delete', array('image_id'	=> $image_id)));
711
			$redirect->send();
712
		}
713
		$show_notify = true;
714
		$this->language->add_lang(array('gallery_mcp', 'gallery'), 'phpbbgallery/core');
715
		$this->language->add_lang('mcp');
716
		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

716
		if (/** @scrutinizer ignore-call */ confirm_box(true))
Loading history...
717
		{
718
			$np = $this->request->variable('notify_poster', '');
719
			$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...
720
			$image_id_ary = array($image_id);
721
			$this->image->approve_images($image_id_ary, $album_data['album_id']);
722
			$this->album->update_info($album_data['album_id']);
723
			// So we need to see if there are still unapproved images in the album
724
			$this->notification_helper->read('approval', $album_data['album_id']);
725
			$message = $this->language->lang('WAITING_APPROVED_IMAGE', 1);
726
			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

726
			/** @scrutinizer ignore-call */ 
727
   meta_refresh($meta_refresh_time, $image_backlink);
Loading history...
727
			trigger_error($message);
728
		}
729
		else
730
		{
731
			$this->template->assign_vars(array(
732
				'S_NOTIFY_POSTER'			=> $show_notify,
733
				'S_' . strtoupper($action)	=> true,
734
				'S_CONFIRM_ACTION'	=> $this->helper->route('phpbbgallery_core_moderate_image_approve', array('image_id' => $image_id)),
735
			));
736
			$action_msg = $this->language->lang('QUEUES_A_APPROVE2_CONFIRM');
737
			$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

737
			$s_hidden_fields = /** @scrutinizer ignore-call */ build_hidden_fields(array(
Loading history...
738
				'action'		=> 'approve',
739
			));
740
			confirm_box(false, $action_msg, $s_hidden_fields, 'mcp_approve.html');
741
		}
742
743
		return $this->helper->render('gallery/moderate_overview.html', $this->language->lang('GALLERY'));
744
	}
745
746
	/**
747
	 * Index Controller
748
	 *    Route: gallery/moderate/image/{image_id}/unapprove
749
	 *
750
	 * @param $image_id
751
	 * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
752
	 */
753
	public function unapprove($image_id)
754
	{
755
		$image_data = $this->image->get_image_data($image_id);
756
		$album_data = $this->album->get_info($image_data['image_album_id']);
757
758
		$album_backlink = $this->helper->route('phpbbgallery_core_index');
759
		$image_backlink = $this->helper->route('phpbbgallery_core_image', array('image_id' => $image_id));
760
		$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

760
		$album_loginlink = /** @scrutinizer ignore-call */ append_sid($this->root_path . 'ucp.' . $this->php_ext . '?mode=login');
Loading history...
761
		$meta_refresh_time = 2;
762
		$this->gallery_auth->load_user_permissions($this->user->data['user_id']);
763
		if (!$this->gallery_auth->acl_check('m_status', $image_data['image_album_id'], $album_data['album_user_id']))
764
		{
765
			$this->misc->not_authorised($album_backlink, $album_loginlink, 'LOGIN_EXPLAIN_UPLOAD');
766
		}
767
768
		$this->language->add_lang(array('gallery_mcp', 'gallery'), 'phpbbgallery/core');
769
		$this->language->add_lang('mcp');
770
		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

770
		if (/** @scrutinizer ignore-call */ confirm_box(true))
Loading history...
771
		{
772
			$image_id_ary = array($image_id);
773
			$this->image->unapprove_images($image_id_ary, $album_data['album_id']);
774
			// To DO - add notification
775
			$message = sprintf($this->language->lang('WAITING_UNAPPROVED_IMAGE', 1));
776
			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

776
			/** @scrutinizer ignore-call */ 
777
   meta_refresh($meta_refresh_time, $image_backlink);
Loading history...
777
			trigger_error($message);
778
		}
779
		else
780
		{
781
			$s_hidden_fields = '';
782
			confirm_box(false, 'QUEUE_A_UNAPPROVE2', $s_hidden_fields);
783
		}
784
	}
785
786
	/**
787
	 * Index Controller
788
	 *    Route: gallery/moderate/image/{image_id}/move
789
	 *
790
	 * @param $image_id
791
	 * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
792
	 */
793
	public function move($image_id): \Symfony\Component\HttpFoundation\Response
794
	{
795
		$image_data = $this->image->get_image_data($image_id);
796
		$album_id = $image_data['image_album_id'];
797
		//$user_id = $image_data['image_user_id'];
798
		$album_data =  $this->album->get_info($album_id);
799
		$album_backlink = $this->helper->route('phpbbgallery_core_album', array('album_id' => $album_id));
800
		$image_backlink = $this->helper->route('phpbbgallery_core_image', array('image_id' => $image_id));
801
		$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

801
		$album_loginlink = /** @scrutinizer ignore-call */ append_sid($this->root_path . 'ucp.' . $this->php_ext . '?mode=login');
Loading history...
802
		$meta_refresh_time = 2;
803
		$this->language->add_lang(array('gallery_mcp', 'gallery'), 'phpbbgallery/core');
804
		$this->gallery_auth->load_user_permissions($this->user->data['user_id']);
805
		if (!$this->gallery_auth->acl_check('m_move', $image_data['image_album_id'], $album_data['album_user_id']))
806
		{
807
			$this->misc->not_authorised($album_backlink, $album_loginlink, 'LOGIN_EXPLAIN_UPLOAD');
808
		}
809
		$moving_target = $this->request->variable('moving_target', '');
810
811
		if ($moving_target)
812
		{
813
			$target = array($image_id);
814
			$this->image->move_image($target, $moving_target);
815
			$message = sprintf($this->language->lang('IMAGES_MOVED', 1));
816
			$this->album->update_info($album_id);
817
			$this->album->update_info($moving_target);
818
			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

818
			/** @scrutinizer ignore-call */ 
819
   meta_refresh($meta_refresh_time, $image_backlink);
Loading history...
819
			trigger_error($message);
820
		}
821
		else
822
		{
823
			$category_select = $this->album->get_albumbox(false, 'moving_target', $album_id, 'm_move', $album_id);
824
			$this->template->assign_vars(array(
825
				'S_MOVING_IMAGES'	=> true,
826
				'S_ALBUM_SELECT'	=> $category_select,
827
				//'S_HIDDEN_FIELDS'	=> $s_hidden_fields,
828
			));
829
		}
830
831
		return $this->helper->render('gallery/mcp_body.html', $this->language->lang('GALLERY'));
832
	}
833
834
	/**
835
	 * Index Controller
836
	 *    Route: gallery/moderate/image/{image_id}/lock
837
	 *
838
	 * @param $image_id
839
	 * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
840
	 */
841
	public function lock($image_id)
842
	{
843
		$image_data = $this->image->get_image_data($image_id);
844
		$album_id = $image_data['image_album_id'];
845
		//$user_id = $image_data['image_user_id'];
846
		$album_data =  $this->album->get_info($album_id);
847
		$album_backlink = $this->helper->route('phpbbgallery_core_album', array('album_id' => $album_id));
848
		$image_backlink = $this->helper->route('phpbbgallery_core_image', array('image_id' => $image_id));
849
		$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

849
		$album_loginlink = /** @scrutinizer ignore-call */ append_sid($this->root_path . 'ucp.' . $this->php_ext . '?mode=login');
Loading history...
850
		$meta_refresh_time = 2;
851
		$this->language->add_lang(array('gallery_mcp', 'gallery'), 'phpbbgallery/core');
852
		$this->gallery_auth->load_user_permissions($this->user->data['user_id']);
853
		if (!$this->gallery_auth->acl_check('m_status', $image_data['image_album_id'], $album_data['album_user_id']))
854
		{
855
			$this->misc->not_authorised($album_backlink, $album_loginlink, 'LOGIN_EXPLAIN_UPLOAD');
856
		}
857
		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

857
		if (/** @scrutinizer ignore-call */ confirm_box(true))
Loading history...
858
		{
859
			$image_id_ary = array($image_id);
860
			$this->image->lock_images($image_id_ary, $album_data['album_id']);
861
			// To DO - add notification
862
			$message = sprintf($this->language->lang('WAITING_LOCKED_IMAGE',1));
863
			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

863
			/** @scrutinizer ignore-call */ 
864
   meta_refresh($meta_refresh_time, $image_backlink);
Loading history...
864
			trigger_error($message);
865
		}
866
		else
867
		{
868
			$s_hidden_fields = '';
869
			confirm_box(false, 'QUEUE_A_LOCK2', $s_hidden_fields);
870
		}
871
	}
872
}
873