Completed
Push — master ( eac471...13cf44 )
by Stanislav
21s queued 17s
created

index::display_birthdays()   B

Complexity

Conditions 10
Paths 7

Size

Total Lines 40
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 13.2218

Importance

Changes 0
Metric Value
eloc 22
c 0
b 0
f 0
dl 0
loc 40
ccs 15
cts 22
cp 0.6818
rs 7.6666
cc 10
nc 7
nop 0
crap 13.2218

How to fix   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
/**
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
			{
159 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

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

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

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

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

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

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

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

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