Completed
Push — master ( 843c8c...eb00b7 )
by Stanislav
19s queued 15s
created

index   F

Complexity

Total Complexity 61

Size/Duplication

Total Lines 419
Duplicated Lines 0 %

Test Coverage

Coverage 84.97%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 61
eloc 214
c 3
b 0
f 0
dl 0
loc 419
ccs 164
cts 193
cp 0.8497
rs 3.52

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 24 1
F base() 0 112 17
C assign_dropdown_links() 0 40 16
B display_birthdays() 0 40 10
B display_legend() 0 47 9
B personal() 0 54 8

How to fix   Complexity   

Complex Class

Complex classes like index 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 index, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
/**
4
*
5
* @package phpBB Gallery Core
6
* @copyright (c) 2014 nickvergessen
7
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
8
*
9
*/
10
11
namespace phpbbgallery\core\controller;
12
13
class index
14
{
15
	/* @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...
16
	protected $auth;
17
18
	/* @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...
19
	protected $config;
20
21
	/* @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...
22
	protected $db;
23
24
	/* @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...
25
	protected $request;
26
27
	/* @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...
28
	protected $template;
29
30
	/* @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...
31
	protected $user;
32
33
	/** @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...
34
	protected $language;
35
36
	/* @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...
37
	protected $helper;
38
39
	/* @var \phpbbgallery\core\album\display */
40
	protected $display;
41
42
	/** @var \phpbbgallery\core\config  */
43
	protected $gallery_config;
44
45
	/** @var \phpbbgallery\core\auth\auth  */
46
	protected $gallery_auth;
47
48
	/** @var \phpbbgallery\core\search  */
49
	protected $gallery_search;
50
51
	/** @var \phpbb\pagination  */
0 ignored issues
show
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...
52
	protected $pagination;
53
54
	/** @var \phpbbgallery\core\user  */
55
	protected $gallery_user;
56
57
	/** @var \phpbbgallery\core\image\image  */
58
	protected $image;
59
60
	/* @var string */
61
	protected $root_path;
62
63
	/* @var string */
64
	protected $php_ext;
65
66
	const RRC_MODE_RECENT_COMMENTS = 4;
67
	const RRC_MODE_RANDOM_IMAGES   = 2;
68
	const RRC_MODE_RECENT_IMAGES   = 1;
69
	/**
70
	 * Constructor
71
	 *
72
	 * @param \phpbb\auth\auth                                          $auth      Auth object
73
	 * @param \phpbb\config\config                                      $config    Config object
74
	 * @param \phpbb\db\driver\driver|\phpbb\db\driver\driver_interface $db        Database object
75
	 * @param \phpbb\request\request                                    $request   Request object
76
	 * @param \phpbb\template\template                                  $template  Template object
77
	 * @param \phpbb\user                                               $user      User object
78
	 * @param \phpbb\language\language                                  $language
79
	 * @param \phpbb\controller\helper                                  $helper    Controller helper object
80
	 * @param \phpbbgallery\core\album\display                          $display   Albums display object
81
	 * @param \phpbbgallery\core\config                                 $gallery_config
82
	 * @param \phpbbgallery\core\auth\auth                              $gallery_auth
83
	 * @param \phpbb\pagination                                         $pagination
84
	 * @param \phpbbgallery\core\user                                   $gallery_user
85
	 * @param \phpbbgallery\core\search                                 $gallery_search
86
	 * @param \phpbbgallery\core\image\image                            $image
87
	 * @param string                                                    $root_path Root path
88
	 * @param string                                                    $php_ext   php file extension
89
	 */
90 7
	public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db,
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...
91
		\phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user, \phpbb\language\language $language,
92
		\phpbb\controller\helper $helper, \phpbbgallery\core\album\display $display, \phpbbgallery\core\config $gallery_config,
93
		\phpbbgallery\core\auth\auth $gallery_auth, \phpbbgallery\core\search $gallery_search, \phpbb\pagination $pagination,
94
		\phpbbgallery\core\user $gallery_user, \phpbbgallery\core\image\image $image,
95
		$root_path, $php_ext)
96
	{
97 7
		$this->auth = $auth;
98 7
		$this->config = $config;
99 7
		$this->db = $db;
100 7
		$this->request = $request;
101 7
		$this->template = $template;
102 7
		$this->user = $user;
103 7
		$this->language = $language;
104 7
		$this->helper = $helper;
105 7
		$this->display = $display;
106 7
		$this->gallery_config = $gallery_config;
107 7
		$this->gallery_auth = $gallery_auth;
108 7
		$this->gallery_search = $gallery_search;
109 7
		$this->pagination = $pagination;
110 7
		$this->gallery_user = $gallery_user;
111 7
		$this->image = $image;
112 7
		$this->root_path = $root_path;
113 7
		$this->php_ext = $php_ext;
114 7
	}
115
116
	/**
117
	* Index Controller
118
	*	Route: gallery
119
	*
120
	* @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...
121
	*/
122 4
	public function base()
123
	{
124
		// Display login box for guests and an error for users
125 4
		$this->gallery_auth->load_user_permissions($this->user->data['user_id']);
126 4
		$get_albums = $this->gallery_auth->acl_album_ids('a_list');
127 4
		if (empty($get_albums) && !$this->user->data['is_registered'])
128
		{
129
			login_box();
0 ignored issues
show
Bug introduced by
The function login_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

129
			/** @scrutinizer ignore-call */ 
130
   login_box();
Loading history...
130
		}
131 4
		$this->language->add_lang(array('gallery'), 'phpbbgallery/core');
132 4
		$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

132
		$this->display->display_albums(/** @scrutinizer ignore-type */ false, $this->config['load_moderators']);
Loading history...
133
134 4
		if ($this->gallery_config->get('pegas_index_album'))
135
		{
136 1
			$this->display->display_albums('personal', $this->config['load_moderators']);
137
		}
138
		else
139
		{
140 3
			$last_image = $this->image->get_last_image();
141 3
			if (empty($last_image))
142
			{
143 3
				$last_image['image_id'] = 0;
144
			}
145 3
			switch ($this->gallery_config->get('link_image_icon'))
146
			{
147 3
				case 'image_page':
148 2
					$action_image = $this->helper->route('phpbbgallery_core_image', array('image_id' => $last_image['image_id']));
149 2
				break;
150 1
				case 'image':
151
					$action_image = $this->helper->route('phpbbgallery_core_image_file_source', array('image_id' => $last_image['image_id']));
152
				break;
153
				default:
154 1
					$action_image = false;
155 1
				break;
156
			}
157
158 3
			$alphabet = range('a', 'z');
159 3
			$alpha_links = [];
160 3
			foreach ($alphabet as $char)
161
			{
162 3
				$alpha_links[] = '<a href="' . append_sid($this->helper->route('phpbbgallery_core_personal'), 'first_char=' . $char) . '">' . strtoupper($char) . '</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

162
				$alpha_links[] = '<a href="' . /** @scrutinizer ignore-call */ append_sid($this->helper->route('phpbbgallery_core_personal'), 'first_char=' . $char) . '">' . strtoupper($char) . '</a>';
Loading history...
163
			}
164 3
			$alpha_links[] = '<a href="' . append_sid($this->helper->route('phpbbgallery_core_personal'), 'first_char=other') . '">#</a>';
165
166 3
			$this->template->assign_vars(array(
167 3
				'S_USERS_PERSONAL_GALLERIES'	=> true,
168 3
				'U_USERS_PERSONAL_GALLERIES' => $this->helper->route('phpbbgallery_core_personal'),
169 3
				'U_PERSONAL_GALLERIES_IMAGES'	=> $this->gallery_config->get('num_images'),
170 3
				'U_PERSONAL_GALLERIES_LAST_IMAGE'	=> $this->helper->route('phpbbgallery_core_image_file_mini', array('image_id' => $last_image['image_id'])),
171 3
				'U_IMAGENAME'	=> ($last_image['image_id'] > 0) ? $last_image['image_name'] : false,
172 3
				'U_IMAGE_ACTION'	=> $action_image,
173 3
				'U_IMAGENAME_ACTION'	=> $this->helper->route('phpbbgallery_core_image', array('image_id' => $last_image['image_id'])),
174 3
				'U_TIME'	=> ($last_image['image_id'] > 0) ?  $this->user->format_date($last_image['image_time']) : false,
175 3
				'U_UPLOADER'	=> ($last_image['image_id'] > 0) ? get_username_string('full', $last_image['image_user_id'], $last_image['image_username'], $last_image['image_user_colour']) : false,
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

175
				'U_UPLOADER'	=> ($last_image['image_id'] > 0) ? /** @scrutinizer ignore-call */ get_username_string('full', $last_image['image_user_id'], $last_image['image_username'], $last_image['image_user_colour']) : false,
Loading history...
176 3
				'ALPHABET_NAVIGATION' => implode('&nbsp;', $alpha_links),
177
			));
178 3
			$this->gallery_user->set_user_id($this->user->data['user_id']);
179 3
			$personal_album = $this->gallery_user->get_own_root_album();
180 3
			if ($personal_album > 0)
181
			{
182 3
				$this->template->assign_vars(array(
183 3
					'S_PERSONAL_ALBUM'	=> true,
184 3
					'U_PERSONAL_ALBUM'	=> $this->helper->route('phpbbgallery_core_album', array('album_id' => $personal_album)),
185 3
					'U_PERSONAL_ALBUM_USER'	=> $this->user->data['username'],
186 3
					'U_PERSONAL_ALBUM_COLOR'	=> $this->user->data['user_colour'],
187
				));
188
			}
189
		}
190
191 4
		if ($this->gallery_config->get('rrc_gindex_mode'))
192
		{
193 1
			$config_value = $this->gallery_config->get('rrc_gindex_mode');
194
195 1
			$recent_comments = ($config_value & self::RRC_MODE_RECENT_COMMENTS) !== 0;
196 1
			$random_images   = ($config_value & self::RRC_MODE_RANDOM_IMAGES) !== 0;
197 1
			$recent_images   = ($config_value & self::RRC_MODE_RECENT_IMAGES) !== 0;
198
199
			// Now before build random and recent ... let's check if we have images that can build it
200 1
			if ($recent_images)
201
			{
202 1
				$this->template->assign_vars(array(
203 1
					'U_RECENT'	=> true,
204
				));
205 1
				$this->gallery_search->recent($this->gallery_config->get('pegas_index_rct_count'), -1);
206
			}
207 1
			if ($random_images)
208
			{
209
				$this->template->assign_vars(array(
210
					'U_RANDOM'	=> true,
211
				));
212
				$this->gallery_search->random($this->gallery_config->get('pegas_index_rnd_count'));
213
			}
214 1
			if ($recent_comments)
215
			{
216
				$this->template->assign_vars(array(
217
					'U_RECENT_COMMENTS'	=> true,
218
					'S_RECENT_COMMENTS' => $this->helper->route('phpbbgallery_core_search_commented'),
219
					'COMMENTS_EXPAND'	=> $this->gallery_config->get('rrc_gindex_comments') ? true : false,
220
				));
221
				$this->gallery_search->recent_comments($this->gallery_config->get('items_per_page'), 0, false);
222
			}
223
		}
224 4
		$this->display_legend();
225 4
		$this->display_birthdays();
226 4
		$this->assign_dropdown_links('phpbbgallery_core_index');
227
228 4
		$this->template->assign_block_vars('navlinks', array(
229 4
			'FORUM_NAME'	=> $this->language->lang('GALLERY'),
230 4
			'U_VIEW_FORUM'	=> $this->helper->route('phpbbgallery_core_index'),
231
		));
232
233 4
		return $this->helper->render('gallery/index_body.html', $this->language->lang('GALLERY'), 200, $this->gallery_config->get('disp_whoisonline'));
234
	}
235
236
	/**
237
	 * Personal Index Controller
238
	 *    Route: gallery/users
239
	 *
240
	 * @param $page
241
	 * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
242
	 */
243 3
	public function personal($page)
244
	{
245
		// Display login box for guests and an error for users
246 3
		$this->gallery_auth->load_user_permissions($this->user->data['user_id']);
247 3
		$get_albums = $this->gallery_auth->acl_album_ids('a_list');
248 3
		if (empty($get_albums) && !$this->user->data['is_registered'])
249
		{
250
			login_box();
0 ignored issues
show
Bug introduced by
The function login_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

250
			/** @scrutinizer ignore-call */ 
251
   login_box();
Loading history...
251
		}
252 3
		$this->language->add_lang(array('gallery'), 'phpbbgallery/core');
253 3
		$this->display->album_start = ($page - 1) * $this->gallery_config->get('items_per_page');
254 3
		$this->display->album_limit = $this->gallery_config->get('items_per_page');
255 3
		$this->display->album_mode = 'personal';
256 3
		$this->display->display_albums('personal', $this->config['load_moderators']);
257
258 3
		$this->pagination->generate_template_pagination(array(
259
			'routes' => array(
260 3
				'phpbbgallery_core_personal',
261
				'phpbbgallery_core_personal_page',),
262 3
				'params' => array()), 'pagination', 'page', $this->display->albums_total, $this->display->album_limit, $this->display->album_start
263
		);
264
265 3
		$this->template->assign_vars(array(
266 3
			'TOTAL_ALBUMS'	=> $this->language->lang('TOTAL_PEGAS_SHORT_SPRINTF', $this->display->albums_total),
267
		));
268
269 3
		if (!$this->gallery_config->get('pegas_index_album'))
270
		{
271
			$this->assign_dropdown_links('phpbbgallery_core_personal');
272
		}
273
274 3
		$first_char = $this->request->variable('first_char', '');
275 3
		$s_char_options = '<option value=""' . ((!$first_char) ? ' selected="selected"' : '') . '>' . $this->user->lang('ALL') . '</option>';
276
		// Loop the ASCII: a-z
277 3
		for ($i = 97; $i < 123; $i++)
278
		{
279 3
			$s_char_options .= '<option value="' . chr($i) . '"' . (($first_char == chr($i)) ? ' selected="selected"' : '') . '>' . chr($i - 32) . '</option>';
280
		}
281 3
		$s_char_options .= '<option value="other"' . (($first_char == 'other') ? ' selected="selected"' : '') . '>#</option>';
282
283 3
		$this->template->assign_vars(array(
284 3
			'S_CHAR_OPTIONS'				=> $s_char_options,
285
		));
286
287 3
		$this->template->assign_block_vars('navlinks', array(
288 3
			'FORUM_NAME'	=> $this->language->lang('GALLERY'),
289 3
			'U_VIEW_FORUM'	=> $this->helper->route('phpbbgallery_core_index'),
290
		));
291 3
		$this->template->assign_block_vars('navlinks', array(
292 3
			'FORUM_NAME'	=> $this->language->lang('PERSONAL_ALBUMS'),
293 3
			'U_VIEW_FORUM'	=> $this->helper->route('phpbbgallery_core_personal'),
294
		));
295
296 3
		return $this->helper->render('gallery/index_body.html', $this->language->lang('PERSONAL_ALBUMS'));
297
	}
298
299 4
	protected function assign_dropdown_links($base_route)
300
	{
301 4
		$this->gallery_auth->load_user_permissions($this->user->data['user_id']);
302
303
		// Now let's get display options
304 4
		$show_comments = $show_random = $show_recent = false;
305 4
		$show_options = $this->gallery_config->get('rrc_gindex_mode');
306 4
		if ($show_options >= 4)
307
		{
308
			$show_comments = true;
309
			$show_options = $show_options - 4;
310
		}
311 4
		if ($show_options >= 2)
312
		{
313
			$show_random = true;
314
			$show_options = $show_options - 2;
315
		}
316 4
		if ($show_options == 1)
317
		{
318 1
			$show_recent = true;
319
		}
320 4
		$this->template->assign_vars(array(
321 4
			'TOTAL_IMAGES'		=> ($this->gallery_config->get('disp_statistic')) ? $this->language->lang('TOTAL_IMAGES_SPRINTF', $this->gallery_config->get('num_images')) : '',
322 4
			'TOTAL_COMMENTS'	=> ($this->gallery_config->get('allow_comments')) ? $this->language->lang('TOTAL_COMMENTS_SPRINTF', $this->gallery_config->get('num_comments')) : '',
323 4
			'TOTAL_PGALLERIES'	=> ($this->gallery_auth->acl_check('a_list', \phpbbgallery\core\auth\auth::PERSONAL_ALBUM)) ? $this->language->lang('TOTAL_PEGAS_SPRINTF', $this->gallery_config->get('num_pegas')) : '',
324 4
			'NEWEST_PGALLERIES'	=> ($this->gallery_config->get('num_pegas')) ? sprintf($this->language->lang('NEWEST_PGALLERY'), '<a href="' . $this->helper->route('phpbbgallery_core_album', array('album_id' => $this->gallery_config->get('newest_pega_album_id'))) . '" '. ($this->gallery_config->get('newest_pega_user_colour') ? 'class="username-coloured" style="color: #' . $this->gallery_config->get('newest_pega_user_colour') . ';"' : 'class="username"') . '>' . $this->gallery_config->get('newest_pega_username') . '</a>') : '',
325
		));
326
327 4
		$this->template->assign_vars(array(
328 4
			'U_MCP'		=> ($this->gallery_auth->acl_check_global('m_')) ? $this->helper->route('phpbbgallery_core_moderate') : '',
329 4
			'U_MARK_ALBUMS'					=> ($this->user->data['is_registered']) ? $this->helper->route($base_route, array('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

329
			'U_MARK_ALBUMS'					=> ($this->user->data['is_registered']) ? $this->helper->route($base_route, array('hash' => /** @scrutinizer ignore-call */ generate_link_hash('global'), 'mark' => 'albums')) : '',
Loading history...
330 4
			'S_LOGIN_ACTION'			=> append_sid($this->root_path . 'ucp.' . $this->php_ext, 'mode=login&amp;redirect=' . urlencode($this->helper->route($base_route))),
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

330
			'S_LOGIN_ACTION'			=> /** @scrutinizer ignore-call */ append_sid($this->root_path . 'ucp.' . $this->php_ext, 'mode=login&amp;redirect=' . urlencode($this->helper->route($base_route))),
Loading history...
331
332 4
			'U_GALLERY_SEARCH'				=> $this->helper->route('phpbbgallery_core_search'),
333 4
			'U_G_SEARCH_COMMENTED'			=> $this->config['phpbb_gallery_allow_comments'] && $show_comments ? $this->helper->route('phpbbgallery_core_search_commented') : false,
334
			//'U_G_SEARCH_CONTESTS'			=> $this->config['phpbb_gallery_allow_rates'] && $this->config['phpbb_gallery_contests_ended'] ? $this->helper->route('phpbbgallery_core_search_contests') : '',
335 4
			'U_G_SEARCH_RECENT'				=> $show_recent ? $this->helper->route('phpbbgallery_core_search_recent') : false,
336 4
			'U_G_SEARCH_RANDOM'				=> $show_random ? $this->helper->route('phpbbgallery_core_search_random') : false,
337 4
			'U_G_SEARCH_SELF'				=> $this->helper->route('phpbbgallery_core_search_egosearch'),
338 4
			'U_G_SEARCH_TOPRATED'			=> $this->config['phpbb_gallery_allow_rates'] ? $this->helper->route('phpbbgallery_core_search_toprated') : '',
339
		));
340 4
	}
341
342 4
	protected function display_legend()
343
	{
344 4
		$order_legend = ($this->config['legend_sort_groupname']) ? 'group_name' : 'group_legend';
345
346
		// Grab group details for legend display
347 4
		if ($this->auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))
348
		{
349
			$sql = 'SELECT group_id, group_name, group_colour, group_type, group_legend
350 1
				FROM ' . GROUPS_TABLE . '
0 ignored issues
show
Bug introduced by
The constant phpbbgallery\core\controller\GROUPS_TABLE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
351
				WHERE group_legend > 0
352 1
				ORDER BY ' . $order_legend . ' ASC';
353
		}
354
		else
355
		{
356
			$sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type, g.group_legend
357 3
				FROM ' . GROUPS_TABLE . ' g
358 3
				LEFT JOIN ' . USER_GROUP_TABLE . ' ug
0 ignored issues
show
Bug introduced by
The constant phpbbgallery\core\controller\USER_GROUP_TABLE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
359
					ON (
360
						g.group_id = ug.group_id
361 3
						AND ug.user_id = ' . $this->user->data['user_id'] . '
362
						AND ug.user_pending = 0
363
					)
364
				WHERE g.group_legend > 0
365 3
					AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . (int) $this->user->data['user_id'] . ')
0 ignored issues
show
Bug introduced by
The constant phpbbgallery\core\controller\GROUP_HIDDEN was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
366 3
				ORDER BY g.' . $order_legend . ' ASC';
367
		}
368 4
		$result = $this->db->sql_query($sql);
369
370 4
		$legend = array();
371 4
		while ($row = $this->db->sql_fetchrow($result))
372
		{
373
			$colour_text = ($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . '"' : '';
374
			$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\controller\GROUP_SPECIAL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
375
376
			if ($row['group_name'] == 'BOTS' || ($this->user->data['user_id'] != ANONYMOUS && !$this->auth->acl_get('u_viewprofile')))
0 ignored issues
show
Bug introduced by
The constant phpbbgallery\core\controller\ANONYMOUS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
377
			{
378
				$legend[] = '<span' . $colour_text . '>' . $group_name . '</span>';
379
			}
380
			else
381
			{
382
				$legend[] = '<a' . $colour_text . ' 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

382
				$legend[] = '<a' . $colour_text . ' 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...
383
			}
384
		}
385 4
		$this->db->sql_freeresult($result);
386
387 4
		$this->template->assign_vars(array(
388 4
			'LEGEND'	=> implode($this->language->lang('COMMA_SEPARATOR'), $legend),
389
		));
390 4
	}
391
392 4
	protected function display_birthdays()
393
	{
394
		// Generate birthday list if required ...
395 4
		if ($this->config['load_birthdays'] && $this->config['allow_birthdays'] && $this->config['phpbb_gallery_disp_birthdays'] && $this->auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel'))
396
		{
397 1
			$this->template->assign_vars(array(
398 1
				'S_DISPLAY_BIRTHDAY_LIST'	=> true,
399
			));
400
401 1
			$time = $this->user->create_datetime();
402 1
			$now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset());
0 ignored issues
show
Bug introduced by
The function phpbb_gmgetdate 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

402
			$now = /** @scrutinizer ignore-call */ phpbb_gmgetdate($time->getTimestamp() + $time->getOffset());
Loading history...
403
404
			// Display birthdays of 29th February on 28th February in non-leap-years
405 1
			$leap_year_birthdays = '';
406 1
			if ($now['mday'] == 28 && $now['mon'] == 2 && !$time->format('L'))
407
			{
408
				$leap_year_birthdays = " OR u.user_birthday LIKE '" . $this->db->sql_escape(sprintf('%2d-%2d-', 29, 2)) . "%'";
409
			}
410
411
			$sql = 'SELECT u.user_id, u.username, u.user_colour, u.user_birthday
412 1
				FROM ' . USERS_TABLE . ' u
0 ignored issues
show
Bug introduced by
The constant phpbbgallery\core\controller\USERS_TABLE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
413 1
				LEFT JOIN ' . BANLIST_TABLE . " b ON (u.user_id = b.ban_userid)
0 ignored issues
show
Bug introduced by
The constant phpbbgallery\core\controller\BANLIST_TABLE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
414
				WHERE (b.ban_id IS NULL
415
					OR b.ban_exclude = 1)
416 1
					AND (u.user_birthday LIKE '" . $this->db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%' $leap_year_birthdays)
417 1
					AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
0 ignored issues
show
Bug introduced by
The constant phpbbgallery\core\controller\USER_NORMAL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The constant phpbbgallery\core\controller\USER_FOUNDER was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
418 1
			$result = $this->db->sql_query($sql);
419
420 1
			while ($row = $this->db->sql_fetchrow($result))
421
			{
422
				$birthday_username	= 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

422
				$birthday_username	= /** @scrutinizer ignore-call */ get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
Loading history...
423
				$birthday_year		= (int) substr($row['user_birthday'], -4);
424
				$birthday_age		= ($birthday_year) ? max(0, $now['year'] - $birthday_year) : '';
425
426
				$this->template->assign_block_vars('birthdays', array(
427
					'USERNAME'	=> $birthday_username,
428
					'AGE'		=> $birthday_age,
429
				));
430
			}
431 1
			$this->db->sql_freeresult($result);
432
		}
433 4
	}
434
435
}
436