Passed
Push — master ( e78604...9c0ac0 )
by Stanislav
32:56 queued 29:42
created

index::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 18
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 24
ccs 18
cts 18
cp 1
rs 9.7
cc 1
nc 1
nop 17
crap 1

How to fix   Many Parameters   

Many Parameters

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

There are several approaches to avoid long parameter lists:

1
<?php
2
3
/**
4
*
5
* @package phpBB Gallery Core
6
* @copyright (c) 2014 nickvergessen
7
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
8
*
9
*/
10
11
namespace phpbbgallery\core\controller;
12
13
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
	/**
67
	 * Constructor
68
	 *
69
	 * @param \phpbb\auth\auth                                          $auth      Auth object
70
	 * @param \phpbb\config\config                                      $config    Config object
71
	 * @param \phpbb\db\driver\driver|\phpbb\db\driver\driver_interface $db        Database object
72
	 * @param \phpbb\request\request                                    $request   Request object
73
	 * @param \phpbb\template\template                                  $template  Template object
74
	 * @param \phpbb\user                                               $user      User object
75
	 * @param \phpbb\language\language                                  $language
76
	 * @param \phpbb\controller\helper                                  $helper    Controller helper object
77
	 * @param \phpbbgallery\core\album\display                          $display   Albums display object
78
	 * @param \phpbbgallery\core\config                                 $gallery_config
79
	 * @param \phpbbgallery\core\auth\auth                              $gallery_auth
80
	 * @param \phpbb\pagination                                         $pagination
81
	 * @param \phpbbgallery\core\user                                   $gallery_user
82
	 * @param \phpbbgallery\core\search                                 $gallery_search
83
	 * @param \phpbbgallery\core\image\image                            $image
84
	 * @param string                                                    $root_path Root path
85
	 * @param string                                                    $php_ext   php file extension
86
	 */
87 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...
88
		\phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user, \phpbb\language\language $language,
89
		\phpbb\controller\helper $helper, \phpbbgallery\core\album\display $display, \phpbbgallery\core\config $gallery_config,
90
		\phpbbgallery\core\auth\auth $gallery_auth, \phpbbgallery\core\search $gallery_search, \phpbb\pagination $pagination,
91
		\phpbbgallery\core\user $gallery_user, \phpbbgallery\core\image\image $image,
92
		$root_path, $php_ext)
93
	{
94 7
		$this->auth = $auth;
95 7
		$this->config = $config;
96 7
		$this->db = $db;
97 7
		$this->request = $request;
98 7
		$this->template = $template;
99 7
		$this->user = $user;
100 7
		$this->language = $language;
101 7
		$this->helper = $helper;
102 7
		$this->display = $display;
103 7
		$this->gallery_config = $gallery_config;
104 7
		$this->gallery_auth = $gallery_auth;
105 7
		$this->gallery_search = $gallery_search;
106 7
		$this->pagination = $pagination;
107 7
		$this->gallery_user = $gallery_user;
108 7
		$this->image = $image;
109 7
		$this->root_path = $root_path;
110 7
		$this->php_ext = $php_ext;
111 7
	}
112
113
	/**
114
	* Index Controller
115
	*	Route: gallery
116
	*
117
	* @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...
118
	*/
119 4
	public function base()
120
	{
121
		// Display login box for guests and an error for users
122 4
		$this->gallery_auth->load_user_permissions($this->user->data['user_id']);
123 4
		$get_albums = $this->gallery_auth->acl_album_ids('a_list');
124 4
		if (empty($get_albums) && !$this->user->data['is_registered'])
125
		{
126
			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

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

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

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

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

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

335
			'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...
336 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

336
			'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...
337
338 4
			'U_GALLERY_SEARCH'				=> $this->helper->route('phpbbgallery_core_search'),
339 4
			'U_G_SEARCH_COMMENTED'			=> $this->config['phpbb_gallery_allow_comments'] && $show_comments ? $this->helper->route('phpbbgallery_core_search_commented') : false,
340
			//'U_G_SEARCH_CONTESTS'			=> $this->config['phpbb_gallery_allow_rates'] && $this->config['phpbb_gallery_contests_ended'] ? $this->helper->route('phpbbgallery_core_search_contests') : '',
341 4
			'U_G_SEARCH_RECENT'				=> $show_recent ? $this->helper->route('phpbbgallery_core_search_recent') : false,
342 4
			'U_G_SEARCH_RANDOM'				=> $show_random ? $this->helper->route('phpbbgallery_core_search_random') : false,
343 4
			'U_G_SEARCH_SELF'				=> $this->helper->route('phpbbgallery_core_search_egosearch'),
344 4
			'U_G_SEARCH_TOPRATED'			=> $this->config['phpbb_gallery_allow_rates'] ? $this->helper->route('phpbbgallery_core_search_toprated') : '',
345
		));
346 4
	}
347
348 4
	protected function display_legend()
349
	{
350 4
		$order_legend = ($this->config['legend_sort_groupname']) ? 'group_name' : 'group_legend';
351
352
		// Grab group details for legend display
353 4
		if ($this->auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))
354
		{
355
			$sql = 'SELECT group_id, group_name, group_colour, group_type, group_legend
356 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...
357
				WHERE group_legend > 0
358 1
				ORDER BY ' . $order_legend . ' ASC';
359
		}
360
		else
361
		{
362
			$sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type, g.group_legend
363 3
				FROM ' . GROUPS_TABLE . ' g
364 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...
365
					ON (
366
						g.group_id = ug.group_id
367 3
						AND ug.user_id = ' . $this->user->data['user_id'] . '
368
						AND ug.user_pending = 0
369
					)
370
				WHERE g.group_legend > 0
371 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...
372 3
				ORDER BY g.' . $order_legend . ' ASC';
373
		}
374 4
		$result = $this->db->sql_query($sql);
375
376 4
		$legend = array();
377 4
		while ($row = $this->db->sql_fetchrow($result))
378
		{
379
			$colour_text = ($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . '"' : '';
380
			$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...
381
382
			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...
383
			{
384
				$legend[] = '<span' . $colour_text . '>' . $group_name . '</span>';
385
			}
386
			else
387
			{
388
				$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

388
				$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...
389
			}
390
		}
391 4
		$this->db->sql_freeresult($result);
392
393 4
		$this->template->assign_vars(array(
394 4
			'LEGEND'	=> implode($this->language->lang('COMMA_SEPARATOR'), $legend),
395
		));
396 4
	}
397
398 4
	protected function display_brithdays()
399
	{
400
		// Generate birthday list if required ...
401 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'))
402
		{
403 1
			$this->template->assign_vars(array(
404 1
				'S_DISPLAY_BIRTHDAY_LIST'	=> true,
405
			));
406
407 1
			$time = $this->user->create_datetime();
408 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

408
			$now = /** @scrutinizer ignore-call */ phpbb_gmgetdate($time->getTimestamp() + $time->getOffset());
Loading history...
409
410
			// Display birthdays of 29th february on 28th february in non-leap-years
411 1
			$leap_year_birthdays = '';
412 1
			if ($now['mday'] == 28 && $now['mon'] == 2 && !$time->format('L'))
413
			{
414
				$leap_year_birthdays = " OR u.user_birthday LIKE '" . $this->db->sql_escape(sprintf('%2d-%2d-', 29, 2)) . "%'";
415
			}
416
417
			$sql = 'SELECT u.user_id, u.username, u.user_colour, u.user_birthday
418 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...
419 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...
420
				WHERE (b.ban_id IS NULL
421
					OR b.ban_exclude = 1)
422 1
					AND (u.user_birthday LIKE '" . $this->db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%' $leap_year_birthdays)
423 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...
424 1
			$result = $this->db->sql_query($sql);
425
426 1
			while ($row = $this->db->sql_fetchrow($result))
427
			{
428
				$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

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