display::generate_navigation()   B
last analyzed

Complexity

Conditions 11
Paths 4

Size

Total Lines 61
Code Lines 34

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 20
CRAP Score 19.4497

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 34
c 1
b 0
f 0
dl 0
loc 61
ccs 20
cts 34
cp 0.5881
rs 7.3166
cc 11
nc 4
nop 1
crap 19.4497

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * phpBB Gallery - Core Extension
4
 *
5
 * @package   phpbbgallery/core
6
 * @author    nickvergessen
7
 * @author    satanasov
8
 * @author    Leinad4Mind
9
 * @copyright 2014 nickvergessen, 2014- satanasov, 2018- Leinad4Mind
10
 * @license   GPL-2.0-only
11
 */
12
13
namespace phpbbgallery\core\album;
14
15
class display
16
{
17
	protected $auth;
18
	protected $config;
19
	protected $db;
20
	protected $helper;
21
	protected $pagination;
22
	protected $request;
23
	protected $template;
24
	protected $user;
25
	protected $gallery_auth;
26
	protected $gallery_user;
27
	protected $misc;
28
	protected $root_path;
29
	protected $php_ext;
30
	protected $table_albums;
31
	protected $table_contests;
32
	protected $table_moderators;
33
	protected $table_tracking;
34
	protected $language;
35
	public $album_start;
36
	public $album_limit;
37
	public $albums_total;
38
	public $album_mode;
39
40 19
	public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\controller\helper $helper,
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...
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...
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...
41
								\phpbb\db\driver\driver_interface $db, \phpbb\pagination $pagination,
0 ignored issues
show
Bug introduced by
The type phpbb\db\driver\driver_interface 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...
Bug introduced by
The type phpbb\pagination 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...
42
								\phpbb\request\request $request, \phpbb\template\template $template,
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...
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...
43
								\phpbb\user $user, \phpbb\language\language $language, \phpbbgallery\core\auth\auth $gallery_auth,
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...
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...
44
								\phpbbgallery\core\user $gallery_user, \phpbbgallery\core\misc $misc,
45
								$root_path, $php_ext, $albums_table, $contests_table, $tracking_table, $moderators_table)
46
	{
47 19
		$this->auth = $auth;
48 19
		$this->config = $config;
49 19
		$this->helper = $helper;
50 19
		$this->db = $db;
51 19
		$this->pagination = $pagination;
52 19
		$this->request = $request;
53 19
		$this->template = $template;
54 19
		$this->user = $user;
55 19
		$this->language = $language;
56 19
		$this->gallery_auth = $gallery_auth;
57 19
		$this->gallery_user = $gallery_user;
58 19
		$this->misc = $misc;
59 19
		$this->root_path = $root_path;
60 19
		$this->php_ext = $php_ext;
61 19
		$this->table_albums = $albums_table;
62 19
		$this->table_contests = $contests_table;
63 19
		$this->table_tracking = $tracking_table;
64 19
		$this->table_moderators = $moderators_table;
65 19
	}
66
67
	/**
68
	 * Get album branch
69
	 *
70
	 * borrowed from phpBB3
71
	 * @author: phpBB Group
72
	 * @function: get_forum_branch
73
	 * @param $branch_user_id
74
	 * @param $album_id
75
	 * @param string $type
76
	 * @param string $order
77
	 * @param bool $include_album
78
	 * @return array
79
	 */
80 4
	public function get_branch($branch_user_id, $album_id, $type = 'all', $order = 'descending', $include_album = true)
81
	{
82 4
		switch ($type)
83
		{
84 4
			case 'parents':
85
				$condition = 'a1.left_id BETWEEN a2.left_id AND a2.right_id';
86
			break;
87
88 4
			case 'children':
89 1
				$condition = 'a2.left_id BETWEEN a1.left_id AND a1.right_id';
90 1
			break;
91
92
			default:
93 3
				$condition = 'a2.left_id BETWEEN a1.left_id AND a1.right_id OR a1.left_id BETWEEN a2.left_id AND a2.right_id';
94 3
			break;
95
		}
96
97 4
		$rows = array();
98
99
		$sql = 'SELECT a2.*
100 4
			FROM ' . $this->table_albums . ' a1
101 4
			LEFT JOIN ' . $this->table_albums . ' a2 ON (' . $condition .') AND a2.album_user_id = ' . (int) $branch_user_id .'
102 4
			WHERE a1.album_id = ' . (int) $album_id . '
103 4
				AND a1.album_user_id = ' . (int) $branch_user_id . '
104 4
			ORDER BY a2.left_id ' . (($order == 'descending') ? 'ASC' : 'DESC');
105 4
		$result = $this->db->sql_query($sql);
106
107 4
		while ($row = $this->db->sql_fetchrow($result))
108
		{
109 4
			if (!$include_album && $row['album_id'] == $album_id)
110
			{
111 1
				continue;
112
			}
113
114 4
			$rows[] = $row;
115
		}
116 4
		$this->db->sql_freeresult($result);
117
118 4
		return $rows;
119
	}
120
121
	/**
122
	 * Create album navigation links for given album, create parent
123
	 * list if currently null, assign basic album info to template
124
	 *
125
	 * borrowed from phpBB3
126
	 * @author: phpBB Group
127
	 * @function: generate_forum_nav
128
	 * @param $album_data
129
	 */
130 4
	public function generate_navigation($album_data)
131
	{
132
		// Add gallery menu entry
133
		// TO DO !!! THIS SHOULD BE MOVED TO MENU CREATOR!!
134 4
		$this->template->assign_block_vars('navlinks', array(
135 4
			'FORUM_NAME'   => $this->language->lang('GALLERY'),
136 4
			'U_VIEW_FORUM'   => $this->helper->route('phpbbgallery_core_index'),
137
		));
138
		// Get album parents
139 4
		$album_parents = $this->get_parents($album_data);
140
141
		// Display username for personal albums
142 4
		if ($album_data['album_user_id'] > (int) \phpbbgallery\core\block::PUBLIC_ALBUM)
143
		{
144
			$sql = 'SELECT user_id, username, user_colour
145
				FROM ' . USERS_TABLE . '
0 ignored issues
show
Bug introduced by
The constant phpbbgallery\core\album\USERS_TABLE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
146
				WHERE user_id = ' . (int) $album_data['album_user_id'];
147
			$result = $this->db->sql_query($sql);
148
149
			while ($row = $this->db->sql_fetchrow($result))
0 ignored issues
show
Unused Code introduced by
The assignment to $row is dead and can be removed.
Loading history...
150
			{
151
				$this->template->assign_block_vars('navlinks', array(
152
					'FORUM_NAME'	=> $this->language->lang('PERSONAL_ALBUMS'),
153
					'U_VIEW_FORUM'	=> $this->helper->route('phpbbgallery_core_personal'),
154
				));
155
			}
156
			$this->db->sql_freeresult($result);
157
		}
158
159
		// Build navigation links
160 4
		if (!empty($album_parents))
161
		{
162
			foreach ($album_parents as $parent_album_id => $parent_data)
163
			{
164
				list($parent_name, $parent_type) = array_values($parent_data);
165
166
				$this->template->assign_block_vars('navlinks', array(
167
					'FORUM_NAME'	=> $parent_name,
168
					'FORUM_ID'		=> $parent_album_id,
169
					'U_VIEW_FORUM'	=> $this->helper->route('phpbbgallery_core_album', array('album_id' => (int) $parent_album_id)),
170
				));
171
			}
172
		}
173
174 4
		$this->template->assign_block_vars('navlinks', array(
175 4
			'FORUM_NAME'	=> $album_data['album_name'],
176 4
			'FORUM_ID'		=> $album_data['album_id'],
177 4
			'U_VIEW_FORUM'	=> $this->helper->route('phpbbgallery_core_album', array('album_id' => (int) $album_data['album_id'])),
178
		));
179
180 4
		$this->template->assign_vars(array(
181 4
			'ALBUM_ID' 		=> $album_data['album_id'],
182 4
			'ALBUM_NAME'	=> $album_data['album_name'],
183 4
			'ALBUM_DESC'	=> generate_text_for_display($album_data['album_desc'], $album_data['album_desc_uid'], $album_data['album_desc_bitfield'], $album_data['album_desc_options']),
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

183
			'ALBUM_DESC'	=> /** @scrutinizer ignore-call */ generate_text_for_display($album_data['album_desc'], $album_data['album_desc_uid'], $album_data['album_desc_bitfield'], $album_data['album_desc_options']),
Loading history...
184 4
			'ALBUM_CONTEST_START'	=> ($album_data['album_type'] == (int) \phpbbgallery\core\block::TYPE_CONTEST) ? $this->language->lang('CONTEST_START' . ((($album_data['contest_start']) < time())? 'ED' : 'S'), $this->user->format_date(($album_data['contest_start']), false, true)) : '',
185 4
			'ALBUM_CONTEST_RATING'	=> ($album_data['album_type'] == (int) \phpbbgallery\core\block::TYPE_CONTEST) ? $this->language->lang('CONTEST_RATING_START' . ((($album_data['contest_start'] + $album_data['contest_rating']) < time())? 'ED' : 'S'), $this->user->format_date(($album_data['contest_start'] + $album_data['contest_rating']), false, true)) : '',
186 4
			'ALBUM_CONTEST_END'		=> ($album_data['album_type'] == (int) \phpbbgallery\core\block::TYPE_CONTEST) ? $this->language->lang('CONTEST_END' . ((($album_data['contest_start'] + $album_data['contest_end']) < time())? 'ED' : 'S'), $this->user->format_date(($album_data['contest_start'] + $album_data['contest_end']), false, true)) : '',
187 4
			'U_VIEW_ALBUM'	=> $this->helper->route('phpbbgallery_core_album', array('album_id' => (int) $album_data['album_id'])),
188
		));
189
190 4
		return;
191
	}
192
193
	/**
194
	 * Returns album parents as an array. Get them from album_data if available, or update the database otherwise
195
	 *
196
	 * borrowed from phpBB3
197
	 * @author: phpBB Group
198
	 * @function: get_forum_parents
199
	 * @param $album_data
200
	 * @return array|mixed
201
	 */
202 4
	public function get_parents($album_data)
203
	{
204 4
		$album_parents = [];
205
206 4
		if ($album_data['parent_id'] > 0)
207
		{
208
			if ($album_data['album_parents'] == '')
209
			{
210
				$sql = 'SELECT album_id, album_name, album_type
211
					FROM ' . $this->table_albums . '
212
					WHERE left_id < ' . (int) $album_data['left_id'] . '
213
						AND right_id > ' . (int) $album_data['right_id'] . '
214
						AND album_user_id = ' . (int) $album_data['album_user_id'] . '
215
					ORDER BY left_id ASC';
216
217
				$result = $this->db->sql_query($sql);
218
219
				while ($row = $this->db->sql_fetchrow($result))
220
				{
221
					$album_parents[$row['album_id']] = [$row['album_name'], (int) $row['album_type']];
222
				}
223
				$this->db->sql_freeresult($result);
224
225
				$album_data['album_parents'] = serialize($album_parents);
226
227
				$sql = 'UPDATE ' . $this->table_albums . "
228
					SET album_parents = '" . $this->db->sql_escape($album_data['album_parents']) . "'
229
					WHERE parent_id = " . (int) $album_data['parent_id'];
230
				$this->db->sql_query($sql);
231
			}
232
			else
233
			{
234
				$album_parents = @unserialize($album_data['album_parents']);
235
			}
236
		}
237
238 4
		return $album_parents;
239
	}
240
241
242
	/**
243
	 * Obtain list of moderators of each album
244
	 *
245
	 * borrowed from phpBB3
246
	 * @author: phpBB Group
247
	 * @function: get_forum_moderators
248
	 * @param bool $album_id
249
	 * @return array
250
	 */
251 1
	public function get_moderators($album_id = false)
252
	{
253 1
		$album_id_ary = $album_moderators = array();
254
255 1
		if ($album_id !== false)
256
		{
257 1
			if (!is_array($album_id))
0 ignored issues
show
introduced by
The condition is_array($album_id) is always false.
Loading history...
258
			{
259 1
				$album_id = array($album_id);
260
			}
261
262
			// Exchange key/value pair to be able to faster check for the album id existence
263 1
			$album_id_ary = array_flip($album_id);
264
		}
265
266
		$sql_array = array(
267 1
			'SELECT'	=> 'm.*, u.user_colour, g.group_colour, g.group_type',
268 1
			'FROM'		=> array($this->table_moderators => 'm'),
269
270
			'LEFT_JOIN'	=> array(
271
				array(
272 1
					'FROM'	=> array(USERS_TABLE => 'u'),
0 ignored issues
show
Bug introduced by
The constant phpbbgallery\core\album\USERS_TABLE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
273 1
					'ON'	=> 'm.user_id = u.user_id',
274
				),
275
				array(
276 1
					'FROM'	=> array(GROUPS_TABLE => 'g'),
0 ignored issues
show
Bug introduced by
The constant phpbbgallery\core\album\GROUPS_TABLE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
277 1
					'ON'	=> 'm.group_id = g.group_id',
278
				),
279
			),
280
281 1
			'WHERE'		=> 'm.display_on_index = 1',
282 1
			'ORDER_BY'	=> 'm.group_id ASC, m.user_id ASC',
283
		);
284
285
		// We query every album here because for caching we should not have any parameter.
286 1
		$sql = $this->db->sql_build_query('SELECT', $sql_array);
287 1
		$result = $this->db->sql_query($sql, 3600);
288
289 1
		while ($row = $this->db->sql_fetchrow($result))
290
		{
291 1
			$a_id = (int) $row['album_id'];
292
293 1
			if (!isset($album_id_ary[$a_id]))
294
			{
295 1
				continue;
296
			}
297
298 1
			if (!empty($row['user_id']))
299
			{
300
				$album_moderators[$a_id][] = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
0 ignored issues
show
Bug introduced by
The function get_username_string 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

300
				$album_moderators[$a_id][] = /** @scrutinizer ignore-call */ get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
Loading history...
301
			}
302
			else
303
			{
304 1
				$group_name = (($row['group_type'] == GROUP_SPECIAL) ? $this->language->lang('G_' . $row['group_name']) : $row['group_name']);
0 ignored issues
show
Bug introduced by
The constant phpbbgallery\core\album\GROUP_SPECIAL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
305
306 1
				if ($this->user->data['user_id'] != ANONYMOUS && !$this->auth->acl_get('u_viewprofile'))
0 ignored issues
show
Bug introduced by
The constant phpbbgallery\core\album\ANONYMOUS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
307
				{
308 1
					$album_moderators[$a_id][] = '<span' . (($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . ';"' : '') . '>' . $group_name . '</span>';
309
				}
310
				else
311
				{
312
					$album_moderators[$a_id][] = '<a' . (($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . ';"' : '') . ' href="' . append_sid($this->root_path . 'memberlist.' . $this->php_ext, 'mode=group&amp;g=' . $row['group_id']) . '">' . $group_name . '</a>';
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

312
					$album_moderators[$a_id][] = '<a' . (($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . ';"' : '') . ' href="' . /** @scrutinizer ignore-call */ append_sid($this->root_path . 'memberlist.' . $this->php_ext, 'mode=group&amp;g=' . $row['group_id']) . '">' . $group_name . '</a>';
Loading history...
313
				}
314
			}
315
		}
316 1
		$this->db->sql_freeresult($result);
317
318 1
		return $album_moderators;
319
	}
320
321
	/**
322
	 * Display albums
323
	 *
324
	 * borrowed from phpBB3
325
	 * @author: phpBB Group
326
	 * @function: display_forums
327
	 * @param string $root_data
328
	 * @param bool $display_moderators
329
	 * @param bool $return_moderators
330
	 * @return array
331
	 */
332 11
	public function display_albums($root_data = '', $display_moderators = true, $return_moderators = false)
333
	{
334 11
		$album_rows = $subalbums = $album_ids = $album_ids_moderator = $album_moderators = $active_album_ary = array();
335 11
		$parent_id = $visible_albums = 0;
336
		//$mode = $this->request->variable('mode', '');
337 11
		$mode = $this->album_mode;
338
		// Mark albums read?
339 11
		$mark_read = $this->request->variable('mark', '');
340
341 11
		if ($mark_read == 'all')
342
		{
343
			$mark_read = '';
344
		}
345
346 11
		if (!$root_data)
347
		{
348 6
			if ($mark_read == 'albums')
349
			{
350
				$mark_read = 'all';
351
			}
352 6
			$root_data = array('album_id' => (int) \phpbbgallery\core\block::PUBLIC_ALBUM);
353 6
			$sql_where = 'a.album_user_id = ' . (int) \phpbbgallery\core\block::PUBLIC_ALBUM;
354
		}
355 6
		else if ($root_data == 'personal')
356
		{
357 4
			if ($mark_read == 'albums')
358
			{
359
				$mark_read = 'all';
360
			}
361 4
			$root_data = array('album_id' => 0);
362 4
			$sql_where = 'a.album_user_id > ' . (int) \phpbbgallery\core\block::PUBLIC_ALBUM;
363 4
			$num_pegas = $this->config['phpbb_gallery_num_pegas'];
0 ignored issues
show
Unused Code introduced by
The assignment to $num_pegas is dead and can be removed.
Loading history...
364 4
			$first_char = strtolower($this->request->variable('first_char', ''));
365
366 4
			if ($first_char == 'other')
367
			{
368
				// Loop the ASCII: a-z
369
				for ($i = 97; $i < 123; $i++)
370
				{
371
					$sql_where .= ' AND u.username_clean NOT ' . $this->db->sql_like_expression(chr($i) . $this->db->any_char);
372
				}
373
			}
374 4
			else if ($first_char)
375
			{
376
				$sql_where .= ' AND u.username_clean ' . $this->db->sql_like_expression(substr($first_char, 0, 1) . $this->db->any_char);
377
			}
378
379 4
			if ($first_char)
380
			{
381
				// We do not view all personal albums, so we need to recount, for the pagination.
382
				$sql_array = array(
383
					'SELECT'		=> 'count(a.album_id) as pgalleries',
384
					'FROM'			=> array($this->table_albums => 'a'),
385
386
					'LEFT_JOIN'		=> array(
387
						array(
388
							'FROM'		=> array(USERS_TABLE => 'u'),
0 ignored issues
show
Bug introduced by
The constant phpbbgallery\core\album\USERS_TABLE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
389
							'ON'		=> 'u.user_id = a.album_user_id',
390
						),
391
					),
392
393
					'WHERE'			=> 'a.parent_id = 0 AND ' . $sql_where,
394
				);
395
				$sql = $this->db->sql_build_query('SELECT', $sql_array);
396
				$result = $this->db->sql_query($sql);
397
				$num_pegas = $this->db->sql_fetchfield('pgalleries');
398
				$this->db->sql_freeresult($result);
399
			}
400
401 4
			$mode_personal = true;
402 4
			$start = $this->album_start;
403
			//$limit = $this->config['phpbb_gallery_pegas_per_page'];
404 4
			$limit = $this->album_limit;
405
			/*$this->template->assign_vars(array(
406
				'PAGINATION'				=> $this->pagination->generate_template_pagination(array(
407
						//todo 'mode=' . $mode . (($first_char) ? '&amp;first_char=' . $first_char : '')
408
					), 'pagination', 'page', $num_pegas, $limit, $start),
409
				'TOTAL_PGALLERIES_SHORT'	=> $this->user->lang('TOTAL_PEGAS_SHORT_SPRINTF', $num_pegas),
410
				'PAGE_NUMBER'				=> $this->pagination->on_page($num_pegas, $limit, $start),
411
			));
412
			$this->pagination->generate_template_pagination(array(
413
				'routes' => array(
414
					'phpbbgallery_core_search_recent',
415
					'phpbbgallery_core_search_recent_page',),
416
					'params' => array()), 'pagination', 'page', $num_pegas, $limit, $start
417
			);*/
418
		}
419
		else
420
		{
421 2
			$sql_where = 'a.left_id > ' . $root_data['left_id'] . ' AND a.left_id < ' . $root_data['right_id'] . ' AND a.album_user_id = ' . $root_data['album_user_id'];
422
		}
423
424
		$sql_array = array(
425 11
			'SELECT'	=> 'a.*, at.mark_time',
426 11
			'FROM'		=> array($this->table_albums => 'a'),
427
428
			'LEFT_JOIN'	=> array(
429
				array(
430 11
					'FROM'	=> array($this->table_tracking => 'at'),
431 11
					'ON'	=> 'at.user_id = ' . $this->user->data['user_id'] . ' AND a.album_id = at.album_id'
432
				)
433
			),
434
435 11
			'ORDER_BY'	=> 'a.album_user_id, a.left_id',
436
		);
437
438 11
		if (isset($mode_personal))
439
		{
440 4
			$sql_array['LEFT_JOIN'][] = array(
441 4
				'FROM'	=> array(USERS_TABLE => 'u'),
442 4
				'ON'	=> 'u.user_id = a.album_user_id',
443
			);
444 4
			$sql_array['ORDER_BY'] = 'u.username_clean, a.left_id';
445
		}
446
447 11
		$sql_array['LEFT_JOIN'][] = array(
448 11
			'FROM'	=> array($this->table_contests => 'c'),
449 11
			'ON'	=> 'c.contest_album_id = a.album_id',
450
		);
451 11
		$sql_array['SELECT'] = $sql_array['SELECT'] . ', c.contest_marked';
452
453 11
		$sql = $this->db->sql_build_query('SELECT', array(
454 11
			'SELECT'	=> $sql_array['SELECT'],
455 11
			'FROM'		=> $sql_array['FROM'],
456 11
			'LEFT_JOIN'	=> $sql_array['LEFT_JOIN'],
457 11
			'WHERE'		=> $sql_where,
458 11
			'ORDER_BY'	=> $sql_array['ORDER_BY'],
459
		));
460
461 11
		$result = $this->db->sql_query($sql);
462
463 11
		$album_tracking_info = array();
464 11
		$branch_root_id = $root_data['album_id'];
465 11
		$zebra_array = $this->gallery_auth->get_user_zebra($this->user->data['user_id']);
466 11
		$listable = $this->gallery_auth->acl_album_ids('a_list');
467 11
		while ($row = $this->db->sql_fetchrow($result))
468
		{
469 9
			$album_id = $row['album_id'];
470
			//if user has no right to see the album - skip it here!
471 9
			if (!in_array($album_id, $listable))
0 ignored issues
show
Bug introduced by
It seems like $listable can also be of type true; however, parameter $haystack of in_array() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

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

471
			if (!in_array($album_id, /** @scrutinizer ignore-type */ $listable))
Loading history...
472
			{
473 7
				continue;
474
			}
475
			// Mark albums read?
476 7
			if ($mark_read == 'albums' || $mark_read == 'all')
477
			{
478
				if ($this->gallery_auth->acl_check('a_list', $album_id, $row['album_user_id']))
479
				{
480
					$album_ids[] = $album_id;
481
					continue;
482
				}
483
			}
484
485
			// Category with no members
486 7
			if (!$row['album_type'] && ($row['left_id'] + 1 == $row['right_id']))
487
			{
488
				continue;
489
			}
490
491
			// Skip branch
492 7
			if (isset($right_id))
493
			{
494
				if ($row['left_id'] < $right_id)
495
				{
496
					continue;
497
				}
498
				unset($right_id);
499
			}
500
501
			// if this is invisible due zebra ... make it go away
502 7
			if ($this->gallery_auth->get_zebra_state($zebra_array, (int) $row['album_user_id'], (int) $row['album_id']) < (int) $row['album_auth_access'])
503
			{
504
				continue;
505
			}
506
507 7
			if (false)//@todo !$this->gallery_auth->acl_check('a_list', $album_id, $row['album_user_id']))
508
			{
509
				// if the user does not have permissions to list this album, skip everything until next branch
510
				$right_id = $row['right_id'];
511
				continue;
512
			}
513
514 7
			$album_tracking_info[$album_id] = (!empty($row['mark_time'])) ? $row['mark_time'] : $this->gallery_user->get_data('user_lastmark');
515
516 7
			if ($row['parent_id'] == $root_data['album_id'] || $row['parent_id'] == $branch_root_id)
517
			{
518 7
				if ($row['album_type'])
519
				{
520 7
					$album_ids_moderator[] = (int) $album_id;
521
				}
522
523
				// Direct child of current branch
524 7
				$parent_id = $album_id;
525 7
				$album_rows[$album_id] = $row;
526
527 7
				if (!$row['album_type'] && $row['parent_id'] == $root_data['album_id'])
528
				{
529
					$branch_root_id = $album_id;
530
				}
531 7
				$album_rows[$parent_id]['album_id_last_image'] = $row['album_id'];
532 7
				$album_rows[$parent_id]['album_type_last_image'] = $row['album_type'];
533 7
				$album_rows[$parent_id]['album_contest_marked'] = $row['contest_marked'];
534 7
				$album_rows[$parent_id]['orig_album_last_image_time'] = $row['album_last_image_time'];
535
			}
536 5
			else if ($row['album_type'])
537
			{
538 5
				$subalbums[$parent_id][$album_id]['display'] = ($row['display_on_index']) ? true : false;
539 5
				$subalbums[$parent_id][$album_id]['name'] = $row['album_name'];
540 5
				$subalbums[$parent_id][$album_id]['orig_album_last_image_time'] = $row['album_last_image_time'];
541 5
				$subalbums[$parent_id][$album_id]['children'] = array();
542
543 5
				if (isset($subalbums[$parent_id][$row['parent_id']]) && !$row['display_on_index'])
544
				{
545
					$subalbums[$parent_id][$row['parent_id']]['children'][] = $album_id;
546
				}
547
548 5
				$album_rows[$parent_id]['album_images'] += $row['album_images'];
549 5
				$album_rows[$parent_id]['album_images_real'] += $row['album_images_real'];
550
551 5
				if ($row['album_last_image_time'] > $album_rows[$parent_id]['album_last_image_time'])
552
				{
553
					$album_rows[$parent_id]['album_last_image_id'] = $row['album_last_image_id'];
554
					$album_rows[$parent_id]['album_last_image_name'] = $row['album_last_image_name'];
555
					$album_rows[$parent_id]['album_last_image_time'] = $row['album_last_image_time'];
556
					$album_rows[$parent_id]['album_last_user_id'] = $row['album_last_user_id'];
557
					$album_rows[$parent_id]['album_last_username'] = $row['album_last_username'];
558
					$album_rows[$parent_id]['album_last_user_colour'] = $row['album_last_user_colour'];
559
					$album_rows[$parent_id]['album_type_last_image'] = $row['album_type'];
560
					$album_rows[$parent_id]['album_contest_marked'] = $row['contest_marked'];
561
					$album_rows[$parent_id]['album_id_last_image'] = $album_id;
562
				}
563
			}
564
		}
565 11
		$this->db->sql_freeresult($result);
566
567
		// Handle marking albums
568 11
		if ($mark_read == 'albums' || $mark_read == 'all')
569
		{
570
			$redirect = build_url('mark');
0 ignored issues
show
Bug introduced by
The function build_url 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

570
			$redirect = /** @scrutinizer ignore-call */ build_url('mark');
Loading history...
571
			$token = $this->request->variable('hash', '');
572
			if (check_link_hash($token, 'global'))
0 ignored issues
show
Bug introduced by
The function check_link_hash 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

572
			if (/** @scrutinizer ignore-call */ check_link_hash($token, 'global'))
Loading history...
573
			{
574
				if ($mark_read == 'all')
575
				{
576
					$this->misc->markread('all');
577
					$message = $this->language->lang('RETURN_INDEX', '<a href="' . $redirect . '">', '</a>');
578
				}
579
				else
580
				{
581
					$this->misc->markread('albums', $album_ids);
0 ignored issues
show
Bug introduced by
$album_ids of type array is incompatible with the type boolean expected by parameter $album_id of phpbbgallery\core\misc::markread(). ( Ignorable by Annotation )

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

581
					$this->misc->markread('albums', /** @scrutinizer ignore-type */ $album_ids);
Loading history...
582
					$message = $this->language->lang('RETURN_ALBUM', '<a href="' . $redirect . '">', '</a>');
583
				}
584
				meta_refresh(3, $redirect);
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

584
				/** @scrutinizer ignore-call */ 
585
    meta_refresh(3, $redirect);
Loading history...
585
				trigger_error($this->language->lang('ALBUMS_MARKED') . '<br /><br />' . $message);
586
			}
587
			else
588
			{
589
				$message = $this->language->lang('RETURN_PAGE', '<a href="' . $redirect . '">', '</a>');
590
				meta_refresh(3, $redirect);
591
				trigger_error($message);
592
			}
593
		}
594
595
		// Grab moderators ... if necessary
596 11
		if ($display_moderators)
597
		{
598 1
			if ($return_moderators)
599
			{
600
				$album_ids_moderator[] = $root_data['album_id'];
601
			}
602 1
			$this->get_moderators($album_moderators);
0 ignored issues
show
Bug introduced by
$album_moderators of type array is incompatible with the type boolean expected by parameter $album_id of phpbbgallery\core\album\display::get_moderators(). ( Ignorable by Annotation )

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

602
			$this->get_moderators(/** @scrutinizer ignore-type */ $album_moderators);
Loading history...
603
		}
604
605
		// Used to tell whatever we have to create a dummy category or not.
606 11
		$last_catless = true;
607 11
		foreach ($album_rows as $row)
608
		{
609
			// Empty category
610 7
			if (($row['parent_id'] == $root_data['album_id']) && ($row['album_type'] == (int) \phpbbgallery\core\block::TYPE_CAT))
611
			{
612
				$this->template->assign_block_vars('albumrow', array(
613
					'S_IS_CAT'				=> true,
614
					'ALBUM_ID'				=> $row['album_id'],
615
					'ALBUM_NAME'			=> $row['album_name'],
616
					'ALBUM_DESC'			=> generate_text_for_display($row['album_desc'], $row['album_desc_uid'], $row['album_desc_bitfield'], $row['album_desc_options']),
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

616
					'ALBUM_DESC'			=> /** @scrutinizer ignore-call */ generate_text_for_display($row['album_desc'], $row['album_desc_uid'], $row['album_desc_bitfield'], $row['album_desc_options']),
Loading history...
617
					'ALBUM_FOLDER_IMG'		=> '',
618
					'ALBUM_FOLDER_IMG_SRC'	=> '',
619
					'ALBUM_IMAGE'			=> ($row['album_image']) ? $row['album_image'] : '',
620
					'U_VIEWALBUM'			=> $this->helper->route('phpbbgallery_core_album', array('album_id' => (int) $row['album_id'])),
621
				));
622
623
				continue;
624
			}
625
626 7
			$visible_albums++;
627 7
			if (($mode == 'personal') && (($visible_albums <= $start) || ($visible_albums > ($start + $limit))))
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $start does not seem to be defined for all execution paths leading up to this point.
Loading history...
Comprehensibility Best Practice introduced by
The variable $limit does not seem to be defined for all execution paths leading up to this point.
Loading history...
628
			{
629 1
				continue;
630
			}
631
632 7
			$album_id = $row['album_id'];
633 7
			$album_unread = (isset($album_tracking_info[$album_id]) && ($row['orig_album_last_image_time'] > $album_tracking_info[$album_id]) && ($this->user->data['user_id'] != ANONYMOUS)) ? true : false;
0 ignored issues
show
Bug introduced by
The constant phpbbgallery\core\album\ANONYMOUS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
634
635 7
			$folder_alt = $l_subalbums = '';
636 7
			$subalbums_list = array();
637
638
			// Generate list of subalbums if we need to
639 7
			if (isset($subalbums[$album_id]))
640
			{
641 5
				foreach ($subalbums[$album_id] as $subalbum_id => $subalbum_row)
642
				{
643 5
					$subalbum_unread = (isset($album_tracking_info[$subalbum_id]) && $subalbum_row['orig_album_last_image_time'] > $album_tracking_info[$subalbum_id] && ($this->user->data['user_id'] != ANONYMOUS)) ? true : false;
644
645 5
					if (!$subalbum_unread && !empty($subalbum_row['children']) && ($this->user->data['user_id'] != ANONYMOUS))
646
					{
647
						foreach ($subalbum_row['children'] as $child_id)
648
						{
649
							if (isset($album_tracking_info[$child_id]) && $subalbums[$album_id][$child_id]['orig_album_last_image_time'] > $album_tracking_info[$child_id])
650
							{
651
								// Once we found an unread child album, we can drop out of this loop
652
								$subalbum_unread = true;
653
								break;
654
							}
655
						}
656
					}
657
658 5
					if ($subalbum_row['display'] && $subalbum_row['name'])
659
					{
660 5
						$subalbums_list[] = array(
661 5
							'link'		=> $this->helper->route('phpbbgallery_core_album', array('album_id' => (int) $subalbum_id)),
662 5
							'name'		=> $subalbum_row['name'],
663 5
							'unread'	=> $subalbum_unread,
664
						);
665
					}
666
					else
667
					{
668
						unset($subalbums[$album_id][$subalbum_id]);
669
					}
670
671 5
					if ($subalbum_unread)
672
					{
673
						$album_unread = true;
674
					}
675
				}
676
677 5
				$l_subalbums = (sizeof($subalbums[$album_id]) == 1) ? $this->language->lang('SUBALBUM') : $this->language->lang('SUBALBUMS');
678 5
				$folder_image = ($album_unread) ? 'forum_unread_subforum' : 'forum_read_subforum';
679
			}
680
			else
681
			{
682 3
				$folder_alt = ($album_unread) ? 'NEW_IMAGES' : 'NO_NEW_IMAGES';
683 3
				$folder_image = ($album_unread) ? 'forum_unread' : 'forum_read';
684
			}
685 7
			if ($row['album_status'] == (int) \phpbbgallery\core\block::ALBUM_LOCKED)
686
			{
687
				$folder_image = ($album_unread) ? 'forum_unread_locked' : 'forum_read_locked';
688
				$folder_alt = 'ALBUM_LOCKED';
689
			}
690
691
			// Create last post link information, if appropriate
692 7
			if ($row['album_last_image_id'])
693
			{
694 5
				$lastimage_time = $this->user->format_date($row['album_last_image_time']);
695 5
				$lastimage_album_type = $row['album_type_last_image'];
696 5
				$lastimage_contest_marked = $row['album_contest_marked'];
697
				// phpbb_ext_gallery_core_image::generate_link('fake_thumbnail', $phpbb_ext_gallery->config->get('link_thumbnail'), $lastimage_image_id, $lastimage_name, $lastimage_album_id);
698 5
				$lastimage_uc_fake_thumbnail = $row['album_image'] ? generate_board_url() . '/' . $row['album_image'] : $this->helper->route('phpbbgallery_core_image_file_mini', array('image_id' => $row['album_last_image_id']));
0 ignored issues
show
Bug introduced by
The function generate_board_url 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

698
				$lastimage_uc_fake_thumbnail = $row['album_image'] ? /** @scrutinizer ignore-call */ generate_board_url() . '/' . $row['album_image'] : $this->helper->route('phpbbgallery_core_image_file_mini', array('image_id' => $row['album_last_image_id']));
Loading history...
699 5
				$lastimage_uc_fake_thumbnail_url = $row['album_image'] ? generate_board_url() . '/' . $row['album_image'] : $this->helper->route('phpbbgallery_core_image', array('image_id' => $row['album_last_image_id']));
700
				// phpbb_ext_gallery_core_image::generate_link('thumbnail', $phpbb_ext_gallery->config->get('link_thumbnail'), $lastimage_image_id, $lastimage_name, $lastimage_album_id);
701 5
				$lastimage_uc_thumbnail = $row['album_image'] ? generate_board_url() . '/' . $row['album_image'] : $this->helper->route('phpbbgallery_core_image_file_mini', array('image_id' => $row['album_last_image_id']));
702
				// phpbb_ext_gallery_core_image::generate_link('image_name', $phpbb_ext_gallery->config->get('link_image_name'), $lastimage_image_id, $lastimage_name, $lastimage_album_id);
703 5
				$lastimage_uc_name = '';//@todo phpbb_ext_gallery_core_image::generate_link('image_name', $phpbb_ext_gallery->config->get('link_image_name'), $lastimage_image_id, $lastimage_name, $lastimage_album_id);
704
				// phpbb_ext_gallery_core_image::generate_link('lastimage_icon', $phpbb_ext_gallery->config->get('link_image_icon'), $lastimage_image_id, $lastimage_name, $lastimage_album_id);
705 5
				$lastimage_uc_icon = '';//@todo phpbb_ext_gallery_core_image::generate_link('lastimage_icon', $phpbb_ext_gallery->config->get('link_image_icon'), $lastimage_image_id, $lastimage_name, $lastimage_album_id);
706
			}
707
			else
708
			{
709 3
				$lastimage_time = $lastimage_album_type = $lastimage_contest_marked = 0;
710 3
				$lastimage_uc_fake_thumbnail = $lastimage_uc_fake_thumbnail_url = $lastimage_uc_thumbnail = $lastimage_uc_name = $lastimage_uc_icon = '';
0 ignored issues
show
Unused Code introduced by
The assignment to $lastimage_uc_fake_thumbnail is dead and can be removed.
Loading history...
Unused Code introduced by
The assignment to $lastimage_uc_fake_thumbnail_url is dead and can be removed.
Loading history...
Unused Code introduced by
The assignment to $lastimage_uc_thumbnail is dead and can be removed.
Loading history...
711 3
				$lastimage_uc_fake_thumbnail = $lastimage_uc_fake_thumbnail_url = $lastimage_uc_thumbnail = $this->helper->route('phpbbgallery_core_image_file_mini', array('image_id' => 0));
712
			}
713
714
			// Output moderator listing ... if applicable
715 7
			$l_moderator = $moderators_list = '';
716 7
			if ($display_moderators && !empty($album_moderators[$album_id]))
717
			{
718
				$l_moderator = (sizeof($album_moderators[$album_id]) == 1) ? $this->language->lang('MODERATOR') : $this->language->lang('MODERATORS');
719
				$moderators_list = implode(', ', $album_moderators[$album_id]);
720
			}
721
722 7
			$s_subalbums_list = array();
723 7
			foreach ($subalbums_list as $subalbum)
724
			{
725 5
				$s_subalbums_list[] = '<a href="' . $subalbum['link'] . '" class="subforum ' . (($subalbum['unread']) ? 'unread' : 'read') . '" title="' . (($subalbum['unread']) ? $this->language->lang('NEW_IMAGES') : $this->language->lang('NO_NEW_IMAGES')) . '">' . $subalbum['name'] . '</a>';
726
			}
727 7
			$s_subalbums_list = (string) implode(', ', $s_subalbums_list);
728 7
			$catless = ($row['parent_id'] == $root_data['album_id']) ? true : false;
729
730 7
			$s_username_hidden = ($lastimage_album_type == (int) \phpbbgallery\core\block::TYPE_CONTEST) && $lastimage_contest_marked && !$this->gallery_auth->acl_check('m_status', $album_id, $row['album_user_id']) && ($this->user->data['user_id'] != $row['album_last_user_id'] || $row['album_last_user_id'] == ANONYMOUS);
731
732 7
			$this->template->assign_block_vars('albumrow', array(
733 7
				'S_IS_CAT'			=> false,
734 7
				'S_NO_CAT'			=> $catless && !$last_catless,
735 7
				'S_LOCKED_ALBUM'	=> ($row['album_status'] == (int) \phpbbgallery\core\block::ALBUM_LOCKED) ? true : false,
736 7
				'S_UNREAD_ALBUM'	=> ($album_unread) ? true : false,
737 7
				'S_LIST_SUBALBUMS'	=> ($row['display_subalbum_list']) ? true : false,
738 7
				'S_SUBALBUMS'		=> (sizeof($subalbums_list)) ? true : false,
739
740 7
				'ALBUM_ID'				=> (int) $row['album_id'],
741 7
				'ALBUM_NAME'			=> $row['album_name'],
742 7
				'ALBUM_DESC'			=> generate_text_for_display($row['album_desc'], $row['album_desc_uid'], $row['album_desc_bitfield'], $row['album_desc_options']),
743 7
				'IMAGES'				=> (int) $row['album_images'],
744 7
				'UNAPPROVED_IMAGES'		=> ($this->gallery_auth->acl_check('m_status', $album_id, $row['album_user_id'])) ? ($row['album_images_real'] - $row['album_images']) : 0,
745 7
				'ALBUM_IMG_STYLE'		=> $folder_image,
746 7
				'ALBUM_FOLDER_IMG'		=> $this->user->img($folder_image, $folder_alt),
747 7
				'ALBUM_FOLDER_IMG_ALT'	=> $this->language->lang($folder_alt) ? $this->language->lang($folder_alt) : '',
748 7
				'ALBUM_IMAGE'			=> ($row['album_image']) ? $row['album_image'] : '',
749 7
				'LAST_IMAGE_TIME'		=> $lastimage_time,
750 7
				'LAST_USER_FULL'		=> ($s_username_hidden) ? $this->language->lang('CONTEST_USERNAME') : get_username_string('full', $row['album_last_user_id'], $row['album_last_username'], $row['album_last_user_colour']),
0 ignored issues
show
Bug introduced by
The function get_username_string 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

750
				'LAST_USER_FULL'		=> ($s_username_hidden) ? $this->language->lang('CONTEST_USERNAME') : /** @scrutinizer ignore-call */ get_username_string('full', $row['album_last_user_id'], $row['album_last_username'], $row['album_last_user_colour']),
Loading history...
751 7
				'UC_THUMBNAIL'			=> $this->config['phpbb_gallery_mini_thumbnail_disp'] ? $lastimage_uc_thumbnail : '',
752 7
				'UC_FAKE_THUMBNAIL'		=> $this->config['phpbb_gallery_mini_thumbnail_disp'] ? $lastimage_uc_fake_thumbnail : '',
753 7
				'UC_IMAGE_URL'			=> $this->config['phpbb_gallery_mini_thumbnail_disp'] ? $lastimage_uc_fake_thumbnail_url : '',
754 7
				'UC_IMAGE_NAME'			=> $lastimage_uc_name,
755 7
				'UC_LASTIMAGE_ICON'		=> $lastimage_uc_icon,
756 7
				'ALBUM_COLOUR'			=> get_username_string('colour', $row['album_last_user_id'], $row['album_last_username'], $row['album_last_user_colour']),
757 7
				'MODERATORS'			=> $moderators_list,
758 7
				'SUBALBUMS'				=> $s_subalbums_list,
759
760 7
				'L_SUBALBUM_STR'		=> $l_subalbums,
761 7
				'L_ALBUM_FOLDER_ALT'	=> $folder_alt,
762 7
				'L_MODERATOR_STR'		=> $l_moderator,
763
764 7
				'U_VIEWALBUM'			=> $this->helper->route('phpbbgallery_core_album', array('album_id' => (int) $row['album_id'])),
765
			));
766
767
			// Assign subforums loop for style authors
768 7
			foreach ($subalbums_list as $subalbum)
769
			{
770 5
				$this->template->assign_block_vars('albumrow.subalbum', array(
771 5
					'U_SUBALBUM'	=> $subalbum['link'],
772 5
					'SUBALBUM_NAME'	=> $subalbum['name'],
773 5
					'S_UNREAD'		=> $subalbum['unread'],
774
				));
775
			}
776
777 7
			$last_catless = $catless;
778
		}
779
780 11
		$this->template->assign_vars(array(
781 11
			'U_MARK_ALBUMS'		=> ($this->user->data['is_registered']) ? $this->helper->route('phpbbgallery_core_album', array('album_id' => (int) $root_data['album_id'], 'hash' => generate_link_hash('global'), 'mark' => 'albums')) : '',
0 ignored issues
show
Bug introduced by
The function generate_link_hash 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

781
			'U_MARK_ALBUMS'		=> ($this->user->data['is_registered']) ? $this->helper->route('phpbbgallery_core_album', array('album_id' => (int) $root_data['album_id'], 'hash' => /** @scrutinizer ignore-call */ generate_link_hash('global'), 'mark' => 'albums')) : '',
Loading history...
782 11
			'S_HAS_SUBALBUM'	=> ($visible_albums) ? true : false,
783 11
			'L_SUBFORUM'		=> ($visible_albums == 1) ? $this->language->lang('SUBALBUM') : $this->language->lang('SUBALBUMS'),
784 11
			'LAST_POST_IMG'		=> $this->user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
785 11
			'FAKE_THUMB_SIZE'	=> $this->config['phpbb_gallery_mini_thumbnail_size'],
786
		));
787
788 11
		if ($return_moderators)
789
		{
790
			return array($active_album_ary, $album_moderators);
791
		}
792
793 11
		$this->albums_total = $visible_albums;
794
795 11
		return array($active_album_ary, array());
796
	}
797
}
798