|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* phpBB Gallery - Core Extension |
|
4
|
|
|
* |
|
5
|
|
|
* @package phpbbgallery/core |
|
6
|
|
|
* @author nickvergessen |
|
7
|
|
|
* @author satanasov |
|
8
|
|
|
* @author Leinad4Mind |
|
9
|
|
|
* @copyright 2014 nickvergessen, 2014- satanasov, 2018- Leinad4Mind |
|
10
|
|
|
* @license GPL-2.0-only |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace phpbbgallery\core\controller; |
|
14
|
|
|
|
|
15
|
|
|
class album |
|
16
|
|
|
{ |
|
17
|
|
|
/* @var \phpbb\config\config */ |
|
|
|
|
|
|
18
|
|
|
protected $config; |
|
19
|
|
|
|
|
20
|
|
|
/* @var \phpbb\controller\helper */ |
|
|
|
|
|
|
21
|
|
|
protected $helper; |
|
22
|
|
|
|
|
23
|
|
|
/* @var \phpbb\db\driver\driver */ |
|
|
|
|
|
|
24
|
|
|
protected $db; |
|
25
|
|
|
|
|
26
|
|
|
/* @var \phpbb\pagination */ |
|
|
|
|
|
|
27
|
|
|
protected $pagination; |
|
28
|
|
|
|
|
29
|
|
|
/* @var \phpbb\template\template */ |
|
|
|
|
|
|
30
|
|
|
protected $template; |
|
31
|
|
|
|
|
32
|
|
|
/* @var \phpbb\user */ |
|
|
|
|
|
|
33
|
|
|
protected $user; |
|
34
|
|
|
|
|
35
|
|
|
/** @var \phpbb\language\language */ |
|
|
|
|
|
|
36
|
|
|
protected $language; |
|
37
|
|
|
|
|
38
|
|
|
/* @var \phpbbgallery\core\album\display */ |
|
39
|
|
|
protected $display; |
|
40
|
|
|
|
|
41
|
|
|
/* @var \phpbbgallery\core\album\loader */ |
|
42
|
|
|
protected $loader; |
|
43
|
|
|
|
|
44
|
|
|
/* @var \phpbbgallery\core\auth\auth */ |
|
45
|
|
|
protected $auth; |
|
46
|
|
|
|
|
47
|
|
|
/* @var \phpbbgallery\core\auth\level */ |
|
48
|
|
|
protected $auth_level; |
|
49
|
|
|
|
|
50
|
|
|
/** @var \phpbbgallery\core\notification\helper */ |
|
51
|
|
|
protected $notifications_helper; |
|
52
|
|
|
|
|
53
|
|
|
/** @var \phpbbgallery\core\url */ |
|
54
|
|
|
protected $url; |
|
55
|
|
|
|
|
56
|
|
|
/** @var \phpbbgallery\core\image\image */ |
|
57
|
|
|
protected $image; |
|
58
|
|
|
|
|
59
|
|
|
/** @var \phpbbgallery\core\config */ |
|
60
|
|
|
protected $gallery_config; |
|
61
|
|
|
|
|
62
|
|
|
/** @var \phpbb\request\request */ |
|
|
|
|
|
|
63
|
|
|
protected $request; |
|
64
|
|
|
|
|
65
|
|
|
/** @var \phpbbgallery\core\contest */ |
|
66
|
|
|
protected $contest; |
|
67
|
|
|
|
|
68
|
|
|
/* @var string */ |
|
69
|
|
|
protected $table_images; |
|
70
|
|
|
|
|
71
|
|
|
const ALBUM_SHOW_IP = 128; |
|
72
|
|
|
const ALBUM_SHOW_RATINGS = 64; |
|
73
|
|
|
const ALBUM_SHOW_USERNAME = 32; |
|
74
|
|
|
const ALBUM_SHOW_VIEWS = 16; |
|
75
|
|
|
const ALBUM_SHOW_TIME = 8; |
|
76
|
|
|
const ALBUM_SHOW_IMAGENAME = 4; |
|
77
|
|
|
const ALBUM_SHOW_COMMENTS = 2; |
|
78
|
|
|
const ALBUM_SHOW_ALBUM = 1; |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Constructor |
|
82
|
|
|
* |
|
83
|
|
|
* @param \phpbb\config\config $config Config object |
|
84
|
|
|
* @param \phpbb\controller\helper $helper Controller helper object |
|
85
|
|
|
* @param \phpbb\db\driver\driver|\phpbb\db\driver\driver_interface $db Database object |
|
86
|
|
|
* @param \phpbb\pagination $pagination Pagination object |
|
87
|
|
|
* @param \phpbb\template\template $template Template object |
|
88
|
|
|
* @param \phpbb\user $user User object |
|
89
|
|
|
* @param \phpbb\language\language $language |
|
90
|
|
|
* @param \phpbbgallery\core\album\display $display Albums display object |
|
91
|
|
|
* @param \phpbbgallery\core\album\loader $loader Albums display object |
|
92
|
|
|
* @param \phpbbgallery\core\auth\auth $auth Gallery auth object |
|
93
|
|
|
* @param \phpbbgallery\core\auth\level $auth_level Gallery auth level object |
|
94
|
|
|
* @param \phpbbgallery\core\config $gallery_config |
|
95
|
|
|
* @param \phpbbgallery\core\notification\helper $notifications_helper |
|
96
|
|
|
* @param \phpbbgallery\core\url $url |
|
97
|
|
|
* @param \phpbbgallery\core\image\image $image |
|
98
|
|
|
* @param \phpbb\request\request $request |
|
99
|
|
|
* @param string $images_table Gallery image table |
|
100
|
|
|
*/ |
|
101
|
3 |
|
public function __construct(\phpbb\config\config $config, \phpbb\controller\helper $helper, |
|
102
|
|
|
\phpbb\db\driver\driver_interface $db, \phpbb\pagination $pagination, |
|
|
|
|
|
|
103
|
|
|
\phpbb\template\template $template, \phpbb\user $user, \phpbb\language\language $language, |
|
104
|
|
|
\phpbbgallery\core\album\display $display, \phpbbgallery\core\album\loader $loader, |
|
105
|
|
|
\phpbbgallery\core\auth\auth $auth, \phpbbgallery\core\auth\level $auth_level, |
|
106
|
|
|
\phpbbgallery\core\config $gallery_config, \phpbbgallery\core\notification\helper $notifications_helper, |
|
107
|
|
|
\phpbbgallery\core\url $url, \phpbbgallery\core\image\image $image, \phpbb\request\request $request, |
|
108
|
|
|
\phpbbgallery\core\contest $contest, |
|
109
|
|
|
$images_table) |
|
110
|
|
|
{ |
|
111
|
3 |
|
$this->config = $config; |
|
112
|
3 |
|
$this->helper = $helper; |
|
113
|
3 |
|
$this->db = $db; |
|
114
|
3 |
|
$this->pagination = $pagination; |
|
115
|
3 |
|
$this->template = $template; |
|
116
|
3 |
|
$this->user = $user; |
|
117
|
3 |
|
$this->language = $language; |
|
118
|
3 |
|
$this->display = $display; |
|
119
|
3 |
|
$this->loader = $loader; |
|
120
|
3 |
|
$this->auth = $auth; |
|
121
|
3 |
|
$this->auth_level = $auth_level; |
|
122
|
3 |
|
$this->notifications_helper = $notifications_helper; |
|
123
|
3 |
|
$this->url = $url; |
|
124
|
3 |
|
$this->image = $image; |
|
125
|
3 |
|
$this->gallery_config = $gallery_config; |
|
126
|
3 |
|
$this->request = $request; |
|
127
|
3 |
|
$this->contest = $contest; |
|
128
|
3 |
|
$this->table_images = $images_table; |
|
129
|
3 |
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* Album Controller |
|
133
|
|
|
* Route: gallery/album/{album_id} |
|
134
|
|
|
* |
|
135
|
|
|
* @param int $album_id Root Album ID |
|
136
|
|
|
* @param int $page |
|
137
|
|
|
* @return \Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
|
|
|
|
|
138
|
|
|
*/ |
|
139
|
3 |
|
public function base($album_id, $page = 0) |
|
140
|
|
|
{ |
|
141
|
3 |
|
$album_id = (int) $album_id; |
|
142
|
3 |
|
$this->language->add_lang(array('gallery'), 'phpbbgallery/core'); |
|
143
|
|
|
|
|
144
|
|
|
try |
|
145
|
|
|
{ |
|
146
|
3 |
|
$this->loader->load($album_id); |
|
147
|
|
|
} |
|
148
|
1 |
|
catch (\Exception $e) |
|
149
|
|
|
{ |
|
150
|
1 |
|
throw new \phpbb\exception\http_exception(404, 'ALBUM_NOT_EXIST'); |
|
|
|
|
|
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
2 |
|
$album_data = $this->loader->get($album_id); |
|
154
|
|
|
|
|
155
|
2 |
|
if ($album_data['album_type'] == (int) \phpbbgallery\core\block::TYPE_CONTEST) |
|
156
|
|
|
{ |
|
157
|
|
|
if ($album_data['contest_id'] && $album_data['contest_marked'] && (($album_data['contest_start'] + $album_data['contest_end']) < time())) |
|
158
|
|
|
{ |
|
159
|
|
|
$contest_end_time = $album_data['contest_start'] + $album_data['contest_end']; |
|
160
|
|
|
$this->contest->end($album_id, $album_data['contest_id'], $contest_end_time); |
|
161
|
|
|
|
|
162
|
|
|
$album_contest_data['contest_marked'] = (int) \phpbbgallery\core\block::NO_CONTEST; |
|
|
|
|
|
|
163
|
|
|
} |
|
164
|
|
|
} |
|
165
|
2 |
|
$this->check_permissions($album_id, $album_data['album_user_id'], $album_data['album_auth_access']); |
|
166
|
2 |
|
$this->auth_level->display($album_id, $album_data['album_status'], $album_data['album_user_id']); |
|
167
|
|
|
|
|
168
|
2 |
|
$this->display->generate_navigation($album_data); |
|
169
|
2 |
|
$this->display->display_albums($album_data, $this->config['load_moderators']); |
|
170
|
|
|
|
|
171
|
2 |
|
$page_title = $album_data['album_name']; |
|
172
|
2 |
|
if ($page > 1) |
|
173
|
|
|
{ |
|
174
|
|
|
$page_title .= ' - ' . $this->language->lang('PAGE_TITLE_NUMBER', $page); |
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
2 |
|
if ($this->config['load_moderators']) |
|
178
|
|
|
{ |
|
179
|
1 |
|
$moderators = $this->display->get_moderators($album_id); |
|
|
|
|
|
|
180
|
1 |
|
if (!empty($moderators[$album_id])) |
|
181
|
|
|
{ |
|
182
|
1 |
|
$moderators = $moderators[$album_id]; |
|
183
|
1 |
|
$l_moderator = (sizeof($moderators) == 1) ? $this->language->lang('MODERATOR') : $this->language->lang('MODERATORS'); |
|
184
|
1 |
|
$this->template->assign_vars(array( |
|
185
|
1 |
|
'L_MODERATORS' => $l_moderator, |
|
186
|
1 |
|
'MODERATORS' => implode($this->language->lang('COMMA_SEPARATOR'), $moderators), |
|
187
|
|
|
)); |
|
188
|
|
|
} |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
2 |
|
if ($this->auth->acl_check('m_', $album_id, $album_data['album_user_id'])) |
|
192
|
|
|
{ |
|
193
|
2 |
|
$this->template->assign_var('U_MCP', $this->helper->route( |
|
194
|
2 |
|
'phpbbgallery_core_moderate_album', |
|
195
|
2 |
|
array('album_id' => (int) $album_id) |
|
196
|
|
|
)); |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
2 |
|
if ((!$album_data['album_user_id'] || $album_data['album_user_id'] == $this->user->data['user_id']) |
|
200
|
2 |
|
&& ($this->user->data['user_id'] == ANONYMOUS || $this->auth->acl_check('i_upload', $album_id, $album_data['album_user_id']))) |
|
|
|
|
|
|
201
|
|
|
{ |
|
202
|
2 |
|
if (!array_key_exists('contest_start', $album_data)) |
|
203
|
|
|
{ |
|
204
|
2 |
|
$this->template->assign_var('U_UPLOAD_IMAGE', $this->helper->route( |
|
205
|
2 |
|
'phpbbgallery_core_album_upload', |
|
206
|
2 |
|
array('album_id' => (int) $album_id) |
|
207
|
|
|
)); |
|
208
|
|
|
} |
|
209
|
|
|
else |
|
210
|
|
|
{ |
|
211
|
|
|
if ($album_data['contest_start'] + $album_data['contest_rating'] > time()) |
|
212
|
|
|
{ |
|
213
|
|
|
$this->template->assign_var('U_UPLOAD_IMAGE', $this->helper->route( |
|
214
|
|
|
'phpbbgallery_core_album_upload', |
|
215
|
|
|
array('album_id' => (int) $album_id) |
|
216
|
|
|
)); |
|
217
|
|
|
} |
|
218
|
|
|
} |
|
219
|
|
|
} |
|
220
|
|
|
|
|
221
|
2 |
|
$this->template->assign_vars(array( |
|
222
|
2 |
|
'S_IS_POSTABLE' => $album_data['album_type'] != (int) \phpbbgallery\core\block::TYPE_CAT, |
|
223
|
2 |
|
'S_IS_LOCKED' => $album_data['album_status'] == (int) \phpbbgallery\core\block::ALBUM_LOCKED, |
|
224
|
|
|
|
|
225
|
2 |
|
'U_RETURN_LINK' => $this->helper->route('phpbbgallery_core_index'), |
|
226
|
2 |
|
'L_RETURN_LINK' => $this->language->lang('RETURN_TO_GALLERY'), |
|
227
|
2 |
|
'S_ALBUM_ACTION' => $this->helper->route('phpbbgallery_core_album', array('album_id' => (int) $album_id)), |
|
228
|
2 |
|
'S_IS_WATCHED' => $this->notifications_helper->get_watched_album($album_id) ? true : false, |
|
229
|
2 |
|
'U_WATCH_TOGGLE' => $this->helper->route('phpbbgallery_core_album_watch', array('album_id' => (int) $album_id)), |
|
230
|
|
|
)); |
|
231
|
|
|
|
|
232
|
2 |
|
if ($album_data['album_type'] != (int) \phpbbgallery\core\block::TYPE_CAT |
|
233
|
2 |
|
&& $album_data['album_images_real'] > 0) |
|
234
|
|
|
{ |
|
235
|
2 |
|
$this->display_images($album_id, $album_data, ($page - 1) * (int) $this->config['phpbb_gallery_items_per_page'], (int) $this->config['phpbb_gallery_items_per_page']); |
|
236
|
|
|
} |
|
237
|
|
|
|
|
238
|
|
|
// phpbb_ext_gallery_core_misc::markread('album', $album_id); |
|
239
|
|
|
|
|
240
|
2 |
|
return $this->helper->render('gallery/album_body.html', $page_title); |
|
241
|
|
|
} |
|
242
|
|
|
|
|
243
|
|
|
/** |
|
244
|
|
|
* @param $album_id |
|
245
|
|
|
* @param $album_data |
|
246
|
|
|
* @param $start |
|
247
|
|
|
* @param $limit |
|
248
|
|
|
*/ |
|
249
|
2 |
|
protected function display_images($album_id, $album_data, $start, $limit) |
|
250
|
|
|
{ |
|
251
|
2 |
|
$sort_days = $this->request->variable('st', 0); |
|
252
|
2 |
|
$sort_key = $this->request->variable('sk', ($album_data['album_sort_key']) ? $album_data['album_sort_key'] : $this->config['phpbb_gallery_default_sort_key']); |
|
253
|
2 |
|
$sort_dir = $this->request->variable('sd', ($album_data['album_sort_dir']) ? $album_data['album_sort_dir'] : $this->config['phpbb_gallery_default_sort_dir']); |
|
254
|
|
|
|
|
255
|
2 |
|
$image_status_check = ' AND image_status <> ' . (int) \phpbbgallery\core\block::STATUS_UNAPPROVED; |
|
|
|
|
|
|
256
|
|
|
|
|
257
|
2 |
|
$image_counter = $album_data['album_images']; |
|
|
|
|
|
|
258
|
|
|
|
|
259
|
2 |
|
$user_id = $this->user->data['user_id']; |
|
260
|
2 |
|
$album_owner_id = $album_data['album_user_id']; |
|
261
|
|
|
|
|
262
|
2 |
|
if ($this->auth->acl_check('m_status', $album_id, $album_owner_id)) |
|
263
|
|
|
{ |
|
264
|
|
|
$image_status_check = ''; |
|
265
|
|
|
$image_counter = $album_data['album_images_real']; |
|
266
|
|
|
} |
|
267
|
|
|
else |
|
268
|
|
|
{ |
|
269
|
2 |
|
$image_status_check = " AND (image_status <> " . (int) \phpbbgallery\core\block::STATUS_UNAPPROVED . " OR image_user_id = $user_id)"; |
|
270
|
|
|
|
|
271
|
|
|
$sql = 'SELECT COUNT(*) AS total_images |
|
272
|
2 |
|
FROM ' . $this->table_images . ' |
|
273
|
2 |
|
WHERE image_album_id = ' . (int) $album_id . " |
|
274
|
2 |
|
AND (image_status <> " . (int) \phpbbgallery\core\block::STATUS_UNAPPROVED . " OR image_user_id = $user_id) |
|
275
|
2 |
|
AND image_status <> " . (int) \phpbbgallery\core\block::STATUS_ORPHAN; |
|
276
|
2 |
|
$result = $this->db->sql_query($sql); |
|
277
|
2 |
|
$image_counter = (int) $this->db->sql_fetchfield('total_images'); |
|
278
|
2 |
|
$this->db->sql_freeresult($result); |
|
279
|
|
|
} |
|
280
|
|
|
|
|
281
|
2 |
|
if (in_array($sort_key, array('r', 'ra'))) |
|
282
|
|
|
{ |
|
283
|
|
|
$sql_help_sort = ', image_id ' . (($sort_dir == 'd') ? 'ASC' : 'DESC'); |
|
284
|
|
|
} |
|
285
|
|
|
else |
|
286
|
|
|
{ |
|
287
|
2 |
|
$sql_help_sort = ', image_id ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); |
|
288
|
|
|
} |
|
289
|
|
|
|
|
290
|
2 |
|
$limit_days = array(); |
|
291
|
|
|
$sort_by_text = array( |
|
292
|
2 |
|
't' => $this->language->lang('TIME'), |
|
293
|
2 |
|
'n' => $this->language->lang('IMAGE_NAME'), |
|
294
|
2 |
|
'vc' => $this->language->lang('GALLERY_VIEWS'), |
|
295
|
2 |
|
'u' => $this->language->lang('SORT_USERNAME'), |
|
296
|
|
|
); |
|
297
|
|
|
$sort_by_sql = array( |
|
298
|
2 |
|
't' => 'image_time', |
|
299
|
|
|
'n' => 'image_name_clean', |
|
300
|
|
|
'vc' => 'image_view_count', |
|
301
|
|
|
'u' => 'image_username_clean', |
|
302
|
|
|
); |
|
303
|
|
|
|
|
304
|
2 |
|
if ($this->config['phpbb_gallery_allow_rates']) |
|
305
|
|
|
{ |
|
306
|
1 |
|
$sort_by_text['ra'] = $this->language->lang('RATING'); |
|
307
|
1 |
|
$sort_by_sql['ra'] = 'image_rate_points'; |
|
308
|
1 |
|
$sort_by_text['r'] = $this->language->lang('RATES_COUNT'); |
|
309
|
1 |
|
$sort_by_sql['r'] = 'image_rates'; |
|
310
|
|
|
} |
|
311
|
2 |
|
if ($this->config['phpbb_gallery_allow_comments']) |
|
312
|
|
|
{ |
|
313
|
1 |
|
$sort_by_text['c'] = $this->language->lang('COMMENTS'); |
|
314
|
1 |
|
$sort_by_sql['c'] = 'image_comments'; |
|
315
|
1 |
|
$sort_by_text['lc'] = $this->language->lang('NEW_COMMENT'); |
|
316
|
1 |
|
$sort_by_sql['lc'] = 'image_last_comment'; |
|
317
|
|
|
} |
|
318
|
2 |
|
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); |
|
|
|
|
|
|
319
|
2 |
|
$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); |
|
320
|
|
|
|
|
321
|
2 |
|
$this->template->assign_block_vars('imageblock', array( |
|
322
|
2 |
|
'BLOCK_NAME' => $album_data['album_name'], |
|
323
|
|
|
)); |
|
324
|
|
|
|
|
325
|
2 |
|
$images = []; |
|
|
|
|
|
|
326
|
|
|
$sql = 'SELECT * |
|
327
|
2 |
|
FROM ' . $this->table_images . ' |
|
328
|
2 |
|
WHERE image_album_id = ' . (int) $album_id . " |
|
329
|
2 |
|
$image_status_check |
|
330
|
2 |
|
AND image_status <> " . (int) \phpbbgallery\core\block::STATUS_ORPHAN . " |
|
331
|
2 |
|
ORDER BY $sql_sort_order" . $sql_help_sort; |
|
332
|
2 |
|
$result = $this->db->sql_query_limit($sql, $limit, $start); |
|
333
|
|
|
|
|
334
|
|
|
// Now let's get display options |
|
335
|
2 |
|
$show_options = (int) $this->gallery_config->get('album_display'); |
|
336
|
2 |
|
$show_ip = ($show_options & self::ALBUM_SHOW_IP) !== 0; |
|
337
|
2 |
|
$show_ratings = ($show_options & self::ALBUM_SHOW_RATINGS) !== 0; |
|
338
|
2 |
|
$show_username = ($show_options & self::ALBUM_SHOW_USERNAME) !== 0; |
|
339
|
2 |
|
$show_views = ($show_options & self::ALBUM_SHOW_VIEWS) !== 0; |
|
340
|
2 |
|
$show_time = ($show_options & self::ALBUM_SHOW_TIME) !== 0; |
|
341
|
2 |
|
$show_imagename = ($show_options & self::ALBUM_SHOW_IMAGENAME) !== 0; |
|
342
|
2 |
|
$show_comments = ($show_options & self::ALBUM_SHOW_COMMENTS) !== 0; |
|
343
|
2 |
|
$show_album = ($show_options & self::ALBUM_SHOW_ALBUM) !== 0; |
|
344
|
|
|
|
|
345
|
2 |
|
if (!empty($album_data['contest_marked']) && $album_data['contest_marked']) |
|
346
|
|
|
{ |
|
347
|
|
|
$show_ratings = false; |
|
348
|
|
|
} |
|
349
|
|
|
|
|
350
|
2 |
|
while ($row = $this->db->sql_fetchrow($result)) |
|
351
|
|
|
{ |
|
352
|
|
|
// Assign the image to the template-block |
|
353
|
2 |
|
$image_data = array_merge($album_data, $row); |
|
354
|
2 |
|
$album_status = $image_data['album_status']; |
|
355
|
2 |
|
$album_user_id = $image_data['album_user_id']; |
|
356
|
|
|
|
|
357
|
|
|
//@todo: $rating = new phpbb_gallery_image_rating($image_data['image_id'], $image_data, $image_data); |
|
358
|
2 |
|
$image_data['rating'] = '0';//@todo: $rating->get_image_rating(false, false); |
|
359
|
|
|
//@todo: unset($rating); |
|
360
|
|
|
|
|
361
|
2 |
|
$s_user_allowed = (($image_data['image_user_id'] == $this->user->data['user_id']) && ($album_status != (int) \phpbbgallery\core\block::ALBUM_LOCKED)); |
|
362
|
|
|
|
|
363
|
2 |
|
switch ($this->gallery_config->get('link_thumbnail')) |
|
364
|
|
|
{ |
|
365
|
2 |
|
case 'image_page': |
|
366
|
1 |
|
$action = $this->helper->route('phpbbgallery_core_image', array('image_id' => $row['image_id'])); |
|
367
|
1 |
|
break; |
|
368
|
1 |
|
case 'image': |
|
369
|
1 |
|
$action = $this->helper->route('phpbbgallery_core_image_file_source', array('image_id' => $row['image_id'])); |
|
370
|
1 |
|
break; |
|
371
|
|
|
default: |
|
372
|
|
|
$action = false; |
|
373
|
|
|
break; |
|
374
|
|
|
} |
|
375
|
2 |
|
switch ($this->gallery_config->get('link_image_name')) |
|
376
|
|
|
{ |
|
377
|
2 |
|
case 'image_page': |
|
378
|
1 |
|
$action_image = $this->helper->route('phpbbgallery_core_image', array('image_id' => $row['image_id'])); |
|
379
|
1 |
|
break; |
|
380
|
1 |
|
case 'image': |
|
381
|
1 |
|
$action_image = $this->helper->route('phpbbgallery_core_image_file_source', array('image_id' => $row['image_id'])); |
|
382
|
1 |
|
break; |
|
383
|
|
|
default: |
|
384
|
|
|
$action_image = false; |
|
385
|
|
|
break; |
|
386
|
|
|
} |
|
387
|
2 |
|
$s_allowed_delete = (($this->auth->acl_check('i_delete', $image_data['image_album_id'], $album_user_id) && $s_user_allowed) || $this->auth->acl_check('m_delete', $image_data['image_album_id'], $album_user_id)); |
|
388
|
2 |
|
$s_allowed_edit = (($this->auth->acl_check('i_edit', $image_data['image_album_id'], $album_user_id) && $s_user_allowed) || $this->auth->acl_check('m_edit', $image_data['image_album_id'], $album_user_id)); |
|
389
|
2 |
|
$s_quick_mod = ($s_allowed_delete || $s_allowed_edit || $this->auth->acl_check('m_status', $image_data['image_album_id'], $album_user_id) || $this->auth->acl_check('m_move', $image_data['image_album_id'], $album_user_id)); |
|
|
|
|
|
|
390
|
|
|
|
|
391
|
2 |
|
$s_username_hidden = $image_data['image_contest'] && !$this->auth->acl_check('m_status', $image_data['image_album_id'], $album_user_id) && ($this->user->data['user_id'] != $image_data['image_user_id'] || $image_data['image_user_id'] == ANONYMOUS); |
|
|
|
|
|
|
392
|
2 |
|
$this->template->assign_block_vars('imageblock.image', array( |
|
393
|
2 |
|
'IMAGE_ID' => (int) $image_data['image_id'], |
|
394
|
2 |
|
'U_IMAGE' => $action_image, |
|
395
|
2 |
|
'UC_IMAGE_NAME' => $show_imagename ? htmlspecialchars_decode($image_data['image_name'], ENT_COMPAT) : false, |
|
396
|
2 |
|
'U_ALBUM' => $show_album ? $this->helper->route('phpbbgallery_core_album', array('album_id' => (int) $album_data['album_id'])) : false, |
|
397
|
2 |
|
'ALBUM_NAME' => $show_album ? $album_data['album_name'] : false, |
|
398
|
2 |
|
'IMAGE_VIEWS' => $show_views ? (int) $image_data['image_view_count'] : -1, |
|
399
|
|
|
//'UC_THUMBNAIL' => 'self::generate_link('thumbnail', $phpbb_ext_gallery->config->get('link_thumbnail'), $image_data['image_id'], $image_data['image_name'], $image_data['image_album_id']), |
|
400
|
2 |
|
'UC_THUMBNAIL' => $this->helper->route('phpbbgallery_core_image_file_mini', array('image_id' => $image_data['image_id'])), |
|
401
|
2 |
|
'UC_THUMBNAIL_ACTION' => $action, |
|
402
|
2 |
|
'S_UNAPPROVED' => ($this->auth->acl_check('m_status', $image_data['image_album_id'], $album_user_id) && ($image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_UNAPPROVED)) ? true : false, |
|
403
|
2 |
|
'S_LOCKED' => ($image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_LOCKED) ? true : false, |
|
404
|
2 |
|
'S_REPORTED' => ($this->auth->acl_check('m_report', $image_data['image_album_id'], $album_user_id) && $image_data['image_reported']) ? true : false, |
|
405
|
2 |
|
'POSTER' => ($show_username) ? (($s_username_hidden) ? $this->language->lang('CONTEST_USERNAME') : get_username_string('full', $image_data['image_user_id'], $image_data['image_username'], $image_data['image_user_colour'])) : false, |
|
|
|
|
|
|
406
|
2 |
|
'TIME' => $show_time ? $this->user->format_date($image_data['image_time']) : false, |
|
407
|
|
|
|
|
408
|
2 |
|
'S_RATINGS' => ($this->config['phpbb_gallery_allow_rates'] == 1 && $show_ratings) ? ($image_data['image_rates'] > 0 ? $image_data['image_rate_avg'] / 100 : $this->language->lang('NOT_RATED')) : false, |
|
409
|
2 |
|
'U_RATINGS' => $this->helper->route('phpbbgallery_core_image', array('image_id' => $image_data['image_id'])) . '#rating', |
|
410
|
2 |
|
'L_COMMENTS' => ($image_data['image_comments'] == 1) ? $this->language->lang('COMMENT') : $this->language->lang('COMMENTS'), |
|
411
|
2 |
|
'S_COMMENTS' => ($this->config['phpbb_gallery_allow_comments'] && $this->auth->acl_check('c_read', $image_data['image_album_id'], $album_user_id) && $show_comments) ? (($image_data['image_comments']) ? $image_data['image_comments'] : $this->language->lang('NO_COMMENTS')) : '', |
|
412
|
2 |
|
'U_COMMENTS' => $this->helper->route('phpbbgallery_core_image', array('image_id' => $image_data['image_id'])) . '#comments', |
|
413
|
|
|
|
|
414
|
2 |
|
'U_USER_IP' => $show_ip && $this->auth->acl_check('m_status', $image_data['image_album_id'], $album_user_id) ? $image_data['image_user_ip'] : false, |
|
415
|
2 |
|
'S_IMAGE_REPORTED' => $image_data['image_reported'], |
|
416
|
2 |
|
'U_IMAGE_REPORTED' => '',//($image_data['image_reported']) ? $phpbb_ext_gallery->url->append_sid('mcp', "mode=report_details&album_id={$image_data['image_album_id']}&option_id=" . $image_data['image_reported']) : '', |
|
417
|
2 |
|
'S_STATUS_APPROVED' => ($image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_APPROVED) ? true : false, |
|
418
|
2 |
|
'S_STATUS_UNAPPROVED' => ($image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_UNAPPROVED) ? true : false, |
|
419
|
2 |
|
'S_STATUS_UNAPPROVED_ACTION' => ($this->auth->acl_check('m_status', $image_data['image_album_id'], $album_user_id) && $image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_UNAPPROVED) ? $this->helper->route('phpbbgallery_core_moderate_image_approve', array('image_id' => $image_data['image_id'])) : '', |
|
420
|
2 |
|
'S_STATUS_LOCKED' => ($image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_LOCKED) ? true : false, |
|
421
|
|
|
|
|
422
|
2 |
|
'U_REPORT' => ($this->auth->acl_check('m_report', $image_data['image_album_id'], $album_user_id) && $image_data['image_reported']) ? '123'/*$this->url->append_sid('mcp', "mode=report_details&album_id={$image_data['image_album_id']}&option_id=" . $image_data['image_reported'])*/ : '', |
|
423
|
2 |
|
'U_STATUS' => '',//($this->auth->acl_check('m_status', $image_data['image_album_id'], $album_user_id)) ? $phpbb_ext_gallery->url->append_sid('mcp', "mode=queue_details&album_id={$image_data['image_album_id']}&option_id=" . $image_data['image_id']) : '', |
|
424
|
2 |
|
'L_STATUS' => ($image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_UNAPPROVED) ? $this->language->lang('APPROVE_IMAGE') : (($image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_APPROVED) ? $this->language->lang('CHANGE_IMAGE_STATUS') : $this->language->lang('UNLOCK_IMAGE')), |
|
425
|
|
|
|
|
426
|
2 |
|
'S_CONTEST_RANK' => $image_data['image_contest_rank'], |
|
427
|
|
|
)); |
|
428
|
|
|
} |
|
429
|
2 |
|
$this->db->sql_freeresult($result); |
|
430
|
|
|
|
|
431
|
2 |
|
$this->pagination->generate_template_pagination(array( |
|
432
|
|
|
'routes' => array( |
|
433
|
2 |
|
'phpbbgallery_core_album', |
|
434
|
|
|
'phpbbgallery_core_album_page', |
|
435
|
|
|
), |
|
436
|
|
|
'params' => array( |
|
437
|
2 |
|
'album_id' => (int) $album_id, |
|
438
|
2 |
|
'sk' => $sort_key, |
|
439
|
2 |
|
'sd' => $sort_dir, |
|
440
|
2 |
|
'st' => $sort_days, |
|
441
|
|
|
), |
|
442
|
2 |
|
), 'pagination', 'page', $image_counter, $limit, $start); |
|
443
|
|
|
|
|
444
|
2 |
|
$this->template->assign_vars(array( |
|
445
|
2 |
|
'TOTAL_IMAGES' => $this->language->lang('VIEW_ALBUM_IMAGES', $image_counter), |
|
446
|
2 |
|
'S_SELECT_SORT_DIR' => $s_sort_dir, |
|
447
|
2 |
|
'S_SELECT_SORT_KEY' => $s_sort_key, |
|
448
|
|
|
)); |
|
449
|
2 |
|
} |
|
450
|
|
|
|
|
451
|
|
|
/** |
|
452
|
|
|
* @param $album_id |
|
453
|
|
|
* @return \Symfony\Component\HttpFoundation\Response |
|
454
|
|
|
*/ |
|
455
|
|
|
public function watch($album_id) |
|
456
|
|
|
{ |
|
457
|
|
|
$album_id = (int) $album_id; |
|
458
|
|
|
$this->language->add_lang(array('gallery'), 'phpbbgallery/core'); |
|
459
|
|
|
|
|
460
|
|
|
$album_data = $this->loader->get($album_id); |
|
461
|
|
|
|
|
462
|
|
|
$this->check_permissions($album_id, $album_data['album_user_id'], $album_data['album_auth_access']); |
|
463
|
|
|
if (confirm_box(true)) |
|
|
|
|
|
|
464
|
|
|
{ |
|
465
|
|
|
$back_link = $this->helper->route('phpbbgallery_core_album', array('album_id' => (int) $album_id)); |
|
466
|
|
|
if ($this->notifications_helper->get_watched_album($album_id) == 1) |
|
467
|
|
|
{ |
|
468
|
|
|
$this->notifications_helper->remove_albums($album_id); |
|
469
|
|
|
$this->template->assign_vars(array( |
|
470
|
|
|
'INFORMATION' => $this->language->lang('UNWATCH_ALBUM'), |
|
471
|
|
|
)); |
|
472
|
|
|
$this->url->meta_refresh(3, $back_link); |
|
473
|
|
|
return $this->helper->render('gallery/message.html', $this->language->lang('GALLERY')); |
|
474
|
|
|
} |
|
475
|
|
|
else |
|
476
|
|
|
{ |
|
477
|
|
|
$this->notifications_helper->add_albums($album_id); |
|
478
|
|
|
$this->template->assign_vars(array( |
|
479
|
|
|
'INFORMATION' => $this->language->lang('WATCH_ALBUM'), |
|
480
|
|
|
)); |
|
481
|
|
|
$this->url->meta_refresh(3, $back_link); |
|
482
|
|
|
return $this->helper->render('gallery/message.html', $this->language->lang('GALLERY')); |
|
483
|
|
|
} |
|
484
|
|
|
} |
|
485
|
|
|
else |
|
486
|
|
|
{ |
|
487
|
|
|
if ($this->notifications_helper->get_watched_album($album_id) == 1) |
|
488
|
|
|
{ |
|
489
|
|
|
$lang = $this->language->lang('UNWATCH_ALBUM'); |
|
490
|
|
|
} |
|
491
|
|
|
else |
|
492
|
|
|
{ |
|
493
|
|
|
$lang = $this->language->lang('WATCH_ALBUM'); |
|
494
|
|
|
} |
|
495
|
|
|
$s_hidden_fields = ''; |
|
496
|
|
|
confirm_box(false, $lang, $s_hidden_fields); |
|
497
|
|
|
} |
|
498
|
|
|
//return $this->helper->render('gallery/moderate_approve.html', $this->language->lang('GALLERY')); |
|
499
|
|
|
} |
|
500
|
|
|
|
|
501
|
|
|
/** |
|
502
|
|
|
* @param int $album_id |
|
503
|
|
|
* @param $owner_id |
|
504
|
|
|
* @param $album_auth_level |
|
505
|
|
|
* @internal param array $album_data |
|
506
|
|
|
*/ |
|
507
|
2 |
|
protected function check_permissions($album_id, $owner_id, $album_auth_level) |
|
508
|
|
|
{ |
|
509
|
2 |
|
$this->auth->load_user_permissions($this->user->data['user_id']); |
|
510
|
2 |
|
$zebra_array = $this->auth->get_user_zebra($this->user->data['user_id']); |
|
511
|
2 |
|
if (!$this->auth->acl_check('i_view', $album_id, $owner_id) || $this->auth->get_zebra_state($zebra_array, (int) $owner_id, (int) $album_id) < (int) $album_auth_level) |
|
512
|
|
|
{ |
|
513
|
|
|
if ($this->user->data['is_bot']) |
|
514
|
|
|
{ |
|
515
|
|
|
// Redirect bots back to the index |
|
516
|
|
|
redirect($this->helper->route('phpbbgallery_core_index')); |
|
|
|
|
|
|
517
|
|
|
} |
|
518
|
|
|
|
|
519
|
|
|
// Display login box for guests and an error for users |
|
520
|
|
|
if (!$this->user->data['is_registered']) |
|
521
|
|
|
{ |
|
522
|
|
|
login_box(); |
|
|
|
|
|
|
523
|
|
|
} |
|
524
|
|
|
else |
|
525
|
|
|
{ |
|
526
|
|
|
//return $this->error('NOT_AUTHORISED', 403); |
|
527
|
|
|
trigger_error($this->language->lang('NOT_AUTHORISED')); |
|
528
|
|
|
} |
|
529
|
|
|
} |
|
530
|
2 |
|
} |
|
531
|
|
|
} |
|
532
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths