|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* phpBB Gallery - Core Extension |
|
4
|
|
|
* |
|
5
|
|
|
* @package phpbbgallery/core |
|
6
|
|
|
* @author nickvergessen |
|
7
|
|
|
* @author satanasov |
|
8
|
|
|
* @author Leinad4Mind |
|
9
|
|
|
* @copyright 2007-2012 nickvergessen, 2014- satanasov, 2018- Leinad4Mind |
|
10
|
|
|
* @license GPL-2.0-only |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @ignore |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
namespace phpbbgallery\core\acp; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @package acp |
|
21
|
|
|
*/ |
|
22
|
|
|
class permissions_module |
|
23
|
|
|
{ |
|
24
|
|
|
/** @var */ |
|
25
|
|
|
var $u_action; |
|
26
|
|
|
|
|
27
|
|
|
/** @var */ |
|
28
|
|
|
var $language; |
|
29
|
|
|
|
|
30
|
|
|
/** @var string */ |
|
31
|
|
|
var $tpl_name; |
|
32
|
|
|
|
|
33
|
|
|
/** @var string */ |
|
34
|
|
|
var $page_title; |
|
35
|
|
|
|
|
36
|
|
|
public function main($id, $mode) |
|
37
|
|
|
{ |
|
38
|
|
|
global $user, $permissions, $phpbb_container, $gallery_url, $gallery_auth, $gallery_cache, $gallery_user; |
|
39
|
|
|
global $request; |
|
40
|
|
|
|
|
41
|
|
|
// Init auth |
|
42
|
|
|
$gallery_cache = $phpbb_container->get('phpbbgallery.core.cache'); |
|
43
|
|
|
$gallery_user = $phpbb_container->get('phpbbgallery.core.user'); |
|
44
|
|
|
$gallery_auth = $phpbb_container->get('phpbbgallery.core.auth'); |
|
45
|
|
|
$gallery_url = $phpbb_container->get('phpbbgallery.core.url'); |
|
46
|
|
|
$this->language = $phpbb_container->get('language'); |
|
47
|
|
|
|
|
48
|
|
|
$this->language->add_lang(array('gallery_acp', 'gallery'), 'phpbbgallery/core'); |
|
49
|
|
|
$this->tpl_name = 'gallery_permissions'; |
|
50
|
|
|
$this->page_title = $this->language->lang('ALBUM_AUTH_TITLE'); |
|
51
|
|
|
add_form_key('acp_gallery'); |
|
|
|
|
|
|
52
|
|
|
$submit = (isset($_POST['submit_edit_options'])) ? true : ((isset($_POST['submit_add_options'])) ? true : false); |
|
53
|
|
|
$action = $request->variable('action', ''); |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* All our beautiful permissions |
|
57
|
|
|
*/ |
|
58
|
|
|
if (!isset($permissions)) |
|
59
|
|
|
{ |
|
60
|
|
|
$permissions = new \stdClass(); |
|
61
|
|
|
} |
|
62
|
|
|
$permissions->cats['full'] = array( |
|
63
|
|
|
'i' => array('i_view', 'i_watermark', 'i_upload', 'i_approve', 'i_edit', 'i_delete', 'i_report', 'i_rate'), |
|
64
|
|
|
'c' => array('c_read', 'c_post', 'c_edit', 'c_delete'), |
|
65
|
|
|
'm' => array('m_comments', 'm_delete', 'm_edit', 'm_move', 'm_report', 'm_status'), |
|
66
|
|
|
'misc' => array('a_list', 'i_count', 'i_unlimited', 'a_count', 'a_unlimited', 'a_restrict'), |
|
67
|
|
|
); |
|
68
|
|
|
$permissions->p_masks['full'] = array_merge($permissions->cats['full']['i'], $permissions->cats['full']['c'], $permissions->cats['full']['m'], $permissions->cats['full']['misc']); |
|
69
|
|
|
|
|
70
|
|
|
// Permissions for the normal albums |
|
71
|
|
|
$permissions->cats[$gallery_auth::PUBLIC_ALBUM] = array( |
|
72
|
|
|
'i' => array('i_view', 'i_watermark', 'i_upload', 'i_approve', 'i_edit', 'i_delete', 'i_report', 'i_rate'), |
|
73
|
|
|
'c' => array('c_read', 'c_post', 'c_edit', 'c_delete'), |
|
74
|
|
|
'm' => array('m_comments', 'm_delete', 'm_edit', 'm_move', 'm_report', 'm_status'), |
|
75
|
|
|
'misc' => array('a_list', 'i_count', 'i_unlimited'/*, 'a_count', 'a_unlimited', 'a_restrict'*/), |
|
76
|
|
|
); |
|
77
|
|
|
$permissions->p_masks[$gallery_auth::PUBLIC_ALBUM] = array_merge($permissions->cats[$gallery_auth::PUBLIC_ALBUM]['i'], $permissions->cats[$gallery_auth::PUBLIC_ALBUM]['c'], $permissions->cats[$gallery_auth::PUBLIC_ALBUM]['m'], $permissions->cats[$gallery_auth::PUBLIC_ALBUM]['misc']); |
|
78
|
|
|
$permissions->p_masks_anti[$gallery_auth::PUBLIC_ALBUM] = array('a_count', 'a_unlimited', 'a_restrict'); |
|
79
|
|
|
|
|
80
|
|
|
// Permissions for own personal albums |
|
81
|
|
|
// Note: we set i_view to 1 as default on storing the permissions |
|
82
|
|
|
$permissions->cats[$gallery_auth::OWN_ALBUM] = array( |
|
83
|
|
|
'i' => array(/*'i_view', */'i_watermark', 'i_upload', 'i_approve', 'i_edit', 'i_delete', 'i_report', 'i_rate'), |
|
84
|
|
|
'c' => array('c_read', 'c_post', 'c_edit', 'c_delete'), |
|
85
|
|
|
'm' => array('m_comments', 'm_delete', 'm_edit', 'm_move', 'm_report', 'm_status'), |
|
86
|
|
|
'misc' => array('a_list', 'i_count', 'i_unlimited', 'a_count', 'a_unlimited', 'a_restrict'), |
|
87
|
|
|
); |
|
88
|
|
|
$permissions->p_masks[$gallery_auth::OWN_ALBUM] = array_merge($permissions->cats[$gallery_auth::OWN_ALBUM]['i'], $permissions->cats[$gallery_auth::OWN_ALBUM]['c'], $permissions->cats[$gallery_auth::OWN_ALBUM]['m'], $permissions->cats[$gallery_auth::OWN_ALBUM]['misc']); |
|
89
|
|
|
$permissions->p_masks_anti[$gallery_auth::OWN_ALBUM] = array();// Note: we set i_view to 1 as default, so it's not needed on anti array('i_view'); |
|
90
|
|
|
|
|
91
|
|
|
// Permissions for personal albums of other users |
|
92
|
|
|
// Note: Do !NOT! hide the i_upload. It's used for the moving-permissions |
|
93
|
|
|
$permissions->cats[$gallery_auth::PERSONAL_ALBUM] = array( |
|
94
|
|
|
'i' => array('i_view', 'i_watermark', 'i_upload', /*'i_approve', 'i_edit', 'i_delete', */'i_report', 'i_rate'), |
|
95
|
|
|
'c' => array('c_read', 'c_post', 'c_edit', 'c_delete'), |
|
96
|
|
|
'm' => array('m_comments', 'm_delete', 'm_edit', 'm_move', 'm_report', 'm_status'), |
|
97
|
|
|
'misc' => array('a_list'/*, 'i_count', 'i_unlimited', 'a_count', 'a_unlimited', 'a_restrict'*/), |
|
98
|
|
|
); |
|
99
|
|
|
$permissions->p_masks[$gallery_auth::PERSONAL_ALBUM] = array_merge($permissions->cats[$gallery_auth::PERSONAL_ALBUM]['i'], $permissions->cats[$gallery_auth::PERSONAL_ALBUM]['c'], $permissions->cats[$gallery_auth::PERSONAL_ALBUM]['m'], $permissions->cats[$gallery_auth::PERSONAL_ALBUM]['misc']); |
|
100
|
|
|
$permissions->p_masks_anti[$gallery_auth::PERSONAL_ALBUM] = array('i_approve', 'i_edit', 'i_delete', 'i_count', 'i_unlimited', 'a_count', 'a_unlimited', 'a_restrict'); |
|
101
|
|
|
|
|
102
|
|
|
switch ($mode) |
|
103
|
|
|
{ |
|
104
|
|
|
case 'manage': |
|
105
|
|
|
switch ($action) |
|
106
|
|
|
{ |
|
107
|
|
|
case 'set': |
|
108
|
|
|
$this->permissions_set(); |
|
109
|
|
|
break; |
|
110
|
|
|
|
|
111
|
|
|
case 'v_mask': |
|
112
|
|
|
if (!$submit) |
|
113
|
|
|
{ |
|
114
|
|
|
$this->permissions_v_mask(); |
|
115
|
|
|
} |
|
116
|
|
|
else |
|
117
|
|
|
{ |
|
118
|
|
|
$this->permissions_p_mask(); |
|
119
|
|
|
} |
|
120
|
|
|
break; |
|
121
|
|
|
|
|
122
|
|
|
default: |
|
123
|
|
|
$this->permissions_c_mask(); |
|
124
|
|
|
break; |
|
125
|
|
|
} |
|
126
|
|
|
break; |
|
127
|
|
|
|
|
128
|
|
|
case 'copy': |
|
129
|
|
|
$this->copy_album_permissions(); |
|
130
|
|
|
break; |
|
131
|
|
|
|
|
132
|
|
|
default: |
|
133
|
|
|
trigger_error('NO_MODE', E_USER_ERROR); |
|
134
|
|
|
break; |
|
135
|
|
|
} |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
function permissions_c_mask() |
|
|
|
|
|
|
139
|
|
|
{ |
|
140
|
|
|
global $template, $phpbb_container, $gallery_auth; |
|
141
|
|
|
// Init album |
|
142
|
|
|
$gallery_album = $phpbb_container->get('phpbbgallery.core.album'); |
|
143
|
|
|
|
|
144
|
|
|
// Send constants to the template |
|
145
|
|
|
$template->assign_vars(array( |
|
146
|
|
|
'C_OWN_PERSONAL_ALBUMS' => $gallery_auth::OWN_ALBUM, |
|
147
|
|
|
'C_PERSONAL_ALBUMS' => $gallery_auth::PERSONAL_ALBUM, |
|
148
|
|
|
)); |
|
149
|
|
|
|
|
150
|
|
|
$template->assign_vars(array( |
|
151
|
|
|
'U_ACTION' => $this->u_action . '&action=v_mask', |
|
152
|
|
|
'S_PERMISSION_C_MASK' => true, |
|
153
|
|
|
'ALBUM_LIST' => $gallery_album->get_albumbox(true, '', $gallery_auth::SETTING_PERMISSIONS), |
|
154
|
|
|
)); |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
private function permissions_v_mask() |
|
158
|
|
|
{ |
|
159
|
|
|
global $cache, $db, $template, $user, $table_prefix, $phpbb_container; |
|
160
|
|
|
global $request, $gallery_auth, $gallery_url; |
|
161
|
|
|
|
|
162
|
|
|
// Init auth |
|
163
|
|
|
$this->language = $phpbb_container->get('language'); |
|
164
|
|
|
|
|
165
|
|
|
$this->language->add_lang('acp/permissions'); |
|
166
|
|
|
|
|
167
|
|
|
$submit = (isset($_POST['submit'])) ? true : false; |
|
|
|
|
|
|
168
|
|
|
$delete = (isset($_POST['delete'])) ? true : false; |
|
169
|
|
|
$album_id = $request->variable('album_id', array(0)); |
|
170
|
|
|
$group_id = $request->variable('group_id', array(0)); |
|
171
|
|
|
$user_id = $request->variable('user_id', array(0)); |
|
172
|
|
|
$p_system = $request->variable('p_system', 0); |
|
173
|
|
|
|
|
174
|
|
|
if (!$p_system && !sizeof($album_id)) |
|
175
|
|
|
{ |
|
176
|
|
|
trigger_error('NO_PERMISSIONS_SELECTED', E_USER_WARNING); |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
// Delete permissions |
|
180
|
|
|
if ($delete) |
|
181
|
|
|
{ |
|
182
|
|
|
// Delete group permissions |
|
183
|
|
|
if (!empty($group_id)) |
|
184
|
|
|
{ |
|
185
|
|
|
// Get the possible outdated p_masks |
|
186
|
|
|
$sql = 'SELECT perm_role_id |
|
187
|
|
|
FROM ' . $table_prefix . 'gallery_permissions |
|
188
|
|
|
WHERE ' . ((!$p_system) ? $db->sql_in_set('perm_album_id', $album_id) : $db->sql_in_set('perm_system', $p_system)) . ' |
|
189
|
|
|
AND ' . $db->sql_in_set('perm_group_id', $group_id); |
|
190
|
|
|
$result = $db->sql_query($sql); |
|
191
|
|
|
|
|
192
|
|
|
$outdated_p_masks = array(); |
|
193
|
|
|
while ($row = $db->sql_fetchrow($result)) |
|
194
|
|
|
{ |
|
195
|
|
|
$outdated_p_masks[] = $row['perm_role_id']; |
|
196
|
|
|
} |
|
197
|
|
|
$db->sql_freeresult($result); |
|
198
|
|
|
|
|
199
|
|
|
// Delete the permissions and moderators |
|
200
|
|
|
$sql = 'DELETE FROM ' . $table_prefix . 'gallery_permissions |
|
201
|
|
|
WHERE ' . ((!$p_system) ? $db->sql_in_set('perm_album_id', $album_id) : $db->sql_in_set('perm_system', $p_system)) . ' |
|
202
|
|
|
AND ' . $db->sql_in_set('perm_group_id', $group_id); |
|
203
|
|
|
$db->sql_query($sql); |
|
204
|
|
|
if (!$p_system) |
|
205
|
|
|
{ |
|
206
|
|
|
// We do not display the moderators on personals so, just on albums |
|
207
|
|
|
$sql = 'DELETE FROM ' . $table_prefix . 'gallery_modscache |
|
208
|
|
|
WHERE ' . $db->sql_in_set('album_id', $album_id) . ' |
|
209
|
|
|
AND ' . $db->sql_in_set('group_id', $group_id); |
|
210
|
|
|
$db->sql_query($sql); |
|
211
|
|
|
} |
|
212
|
|
|
|
|
213
|
|
|
// Check for further usage |
|
214
|
|
|
$sql = 'SELECT perm_role_id |
|
215
|
|
|
FROM ' . $table_prefix . 'gallery_permissions |
|
216
|
|
|
WHERE ' . $db->sql_in_set('perm_role_id', $outdated_p_masks, false, true); |
|
217
|
|
|
$result = $db->sql_query($sql); |
|
218
|
|
|
|
|
219
|
|
|
$still_used_p_masks = array(); |
|
220
|
|
|
while ($row = $db->sql_fetchrow($result)) |
|
221
|
|
|
{ |
|
222
|
|
|
$still_used_p_masks[] = $row['perm_role_id']; |
|
223
|
|
|
} |
|
224
|
|
|
$db->sql_freeresult($result); |
|
225
|
|
|
|
|
226
|
|
|
// Delete the p_masks, which are no longer used |
|
227
|
|
|
$sql = 'DELETE FROM ' . $table_prefix . 'gallery_roles |
|
228
|
|
|
WHERE ' . $db->sql_in_set('role_id', $outdated_p_masks, false, true) . ' |
|
229
|
|
|
AND ' . $db->sql_in_set('role_id', $still_used_p_masks, true, true); |
|
230
|
|
|
$db->sql_query($sql); |
|
231
|
|
|
} |
|
232
|
|
|
|
|
233
|
|
|
// Delete user permissions |
|
234
|
|
|
if (!empty($user_id)) |
|
235
|
|
|
{ |
|
236
|
|
|
// Get the possible outdated p_masks |
|
237
|
|
|
$sql = 'SELECT perm_role_id |
|
238
|
|
|
FROM ' . $table_prefix . 'gallery_permissions |
|
239
|
|
|
WHERE ' . ((!$p_system) ? $db->sql_in_set('perm_album_id', $album_id) : $db->sql_in_set('perm_system', $p_system)) . ' |
|
240
|
|
|
AND ' . $db->sql_in_set('perm_user_id', $user_id); |
|
241
|
|
|
$result = $db->sql_query($sql); |
|
242
|
|
|
|
|
243
|
|
|
$outdated_p_masks = array(); |
|
244
|
|
|
while ($row = $db->sql_fetchrow($result)) |
|
245
|
|
|
{ |
|
246
|
|
|
$outdated_p_masks[] = $row['perm_role_id']; |
|
247
|
|
|
} |
|
248
|
|
|
$db->sql_freeresult($result); |
|
249
|
|
|
|
|
250
|
|
|
// Delete the permissions and moderators |
|
251
|
|
|
$sql = 'DELETE FROM ' . $table_prefix . 'gallery_permissions |
|
252
|
|
|
WHERE ' . ((!$p_system) ? $db->sql_in_set('perm_album_id', $album_id) : $db->sql_in_set('perm_system', $p_system)) . ' |
|
253
|
|
|
AND ' . $db->sql_in_set('perm_user_id', $user_id); |
|
254
|
|
|
$db->sql_query($sql); |
|
255
|
|
|
if (!$p_system) |
|
256
|
|
|
{ |
|
257
|
|
|
// We do not display the moderators on personals so, just on albums |
|
258
|
|
|
$sql = 'DELETE FROM ' . $table_prefix . 'gallery_modscache |
|
259
|
|
|
WHERE ' . $db->sql_in_set('album_id', $album_id) . ' |
|
260
|
|
|
AND ' . $db->sql_in_set('user_id', $user_id); |
|
261
|
|
|
$db->sql_query($sql); |
|
262
|
|
|
} |
|
263
|
|
|
|
|
264
|
|
|
// Check for further usage |
|
265
|
|
|
$sql = 'SELECT perm_role_id |
|
266
|
|
|
FROM ' . $table_prefix . 'gallery_permissions |
|
267
|
|
|
WHERE ' . $db->sql_in_set('perm_role_id', $outdated_p_masks, false, true); |
|
268
|
|
|
$result = $db->sql_query($sql); |
|
269
|
|
|
|
|
270
|
|
|
$still_used_p_masks = array(); |
|
271
|
|
|
while ($row = $db->sql_fetchrow($result)) |
|
272
|
|
|
{ |
|
273
|
|
|
$still_used_p_masks[] = $row['perm_role_id']; |
|
274
|
|
|
} |
|
275
|
|
|
$db->sql_freeresult($result); |
|
276
|
|
|
|
|
277
|
|
|
// Delete the p_masks, which are no longer used |
|
278
|
|
|
$sql = 'DELETE FROM ' . $table_prefix . 'gallery_roles |
|
279
|
|
|
WHERE ' . $db->sql_in_set('role_id', $outdated_p_masks, false, true) . ' |
|
280
|
|
|
AND ' . $db->sql_in_set('role_id', $still_used_p_masks, true, true); |
|
281
|
|
|
$db->sql_query($sql); |
|
282
|
|
|
} |
|
283
|
|
|
|
|
284
|
|
|
// Only clear if we did something |
|
285
|
|
|
if (!empty($group_id) || !empty($user_id)) |
|
286
|
|
|
{ |
|
287
|
|
|
$cache->destroy('sql', $table_prefix . 'gallery_permissions'); |
|
288
|
|
|
$cache->destroy('sql', $table_prefix . 'gallery_roles'); |
|
289
|
|
|
$cache->destroy('sql', $table_prefix . 'gallery_modscache'); |
|
290
|
|
|
$gallery_auth->set_user_permissions('all', ''); |
|
291
|
|
|
} |
|
292
|
|
|
} |
|
293
|
|
|
|
|
294
|
|
|
if (!$p_system) |
|
295
|
|
|
{ |
|
296
|
|
|
// Get the album names of the selected albums |
|
297
|
|
|
$sql = 'SELECT album_name |
|
298
|
|
|
FROM ' . $table_prefix . 'gallery_albums |
|
299
|
|
|
WHERE ' . $db->sql_in_set('album_id', $album_id, false, true) . ' |
|
300
|
|
|
ORDER BY left_id'; |
|
301
|
|
|
$result = $db->sql_query($sql); |
|
302
|
|
|
|
|
303
|
|
|
$a_names = array(); |
|
304
|
|
|
while ($row = $db->sql_fetchrow($result)) |
|
305
|
|
|
{ |
|
306
|
|
|
$a_names[] = $row['album_name']; |
|
307
|
|
|
} |
|
308
|
|
|
$db->sql_freeresult($result); |
|
309
|
|
|
} |
|
310
|
|
|
|
|
311
|
|
|
// Get the groups for selected album/p_system |
|
312
|
|
|
$sql_array = array( |
|
313
|
|
|
'SELECT' => 'g.group_name, g.group_id, g.group_type', |
|
314
|
|
|
'FROM' => array(GROUPS_TABLE => 'g'), |
|
|
|
|
|
|
315
|
|
|
|
|
316
|
|
|
'LEFT_JOIN' => array( |
|
317
|
|
|
array( |
|
318
|
|
|
'FROM' => array($table_prefix . 'gallery_permissions' => 'p'), |
|
319
|
|
|
'ON' => 'p.perm_group_id = g.group_id', |
|
320
|
|
|
), |
|
321
|
|
|
), |
|
322
|
|
|
|
|
323
|
|
|
'WHERE' => ((!$p_system) ? $db->sql_in_set('p.perm_album_id', $album_id, false, true) : $db->sql_in_set('p.perm_system', $p_system, false, true)), |
|
324
|
|
|
'GROUP_BY' => 'g.group_id, g.group_type, g.group_name', |
|
325
|
|
|
); |
|
326
|
|
|
$sql = $db->sql_build_query('SELECT', $sql_array); |
|
327
|
|
|
$result = $db->sql_query($sql); |
|
328
|
|
|
|
|
329
|
|
|
$set_groups = array(); |
|
330
|
|
|
$s_defined_group_options = ''; |
|
331
|
|
|
while ($row = $db->sql_fetchrow($result)) |
|
332
|
|
|
{ |
|
333
|
|
|
$set_groups[] = $row['group_id']; |
|
334
|
|
|
$s_defined_group_options .= '<option value="' . $row['group_id'] . '">' . (($row['group_type'] == GROUP_SPECIAL) ? $this->language->lang('G_' . $row['group_name']) : $row['group_name']) . '</option>'; |
|
|
|
|
|
|
335
|
|
|
} |
|
336
|
|
|
$db->sql_freeresult($result); |
|
337
|
|
|
|
|
338
|
|
|
// Get the other groups, so that the user can add them |
|
339
|
|
|
$sql = 'SELECT group_name, group_id, group_type |
|
340
|
|
|
FROM ' . GROUPS_TABLE . ' |
|
341
|
|
|
WHERE ' . $db->sql_in_set('group_id', $set_groups, true, true); |
|
342
|
|
|
$result = $db->sql_query($sql); |
|
343
|
|
|
|
|
344
|
|
|
$s_add_group_options = ''; |
|
345
|
|
|
while ($row = $db->sql_fetchrow($result)) |
|
346
|
|
|
{ |
|
347
|
|
|
$s_add_group_options .= '<option value="' . $row['group_id'] . '">' . (($row['group_type'] == GROUP_SPECIAL) ? $this->language->lang('G_' . $row['group_name']) : $row['group_name']) . '</option>'; |
|
348
|
|
|
} |
|
349
|
|
|
$db->sql_freeresult($result); |
|
350
|
|
|
|
|
351
|
|
|
// Get the users for selected album/p_system |
|
352
|
|
|
$sql_array = array( |
|
353
|
|
|
'SELECT' => 'u.username, u.user_id', |
|
354
|
|
|
'FROM' => array(USERS_TABLE => 'u'), |
|
|
|
|
|
|
355
|
|
|
|
|
356
|
|
|
'LEFT_JOIN' => array( |
|
357
|
|
|
array( |
|
358
|
|
|
'FROM' => array($table_prefix . 'gallery_permissions' => 'p'), |
|
359
|
|
|
'ON' => 'p.perm_user_id = u.user_id', |
|
360
|
|
|
), |
|
361
|
|
|
), |
|
362
|
|
|
|
|
363
|
|
|
'WHERE' => ((!$p_system) ? $db->sql_in_set('p.perm_album_id', $album_id, false, true) : $db->sql_in_set('p.perm_system', $p_system, false, true)), |
|
364
|
|
|
'GROUP_BY' => 'u.user_id, u.username', |
|
365
|
|
|
); |
|
366
|
|
|
$sql = $db->sql_build_query('SELECT', $sql_array); |
|
367
|
|
|
$result = $db->sql_query($sql); |
|
368
|
|
|
|
|
369
|
|
|
$set_users = array(); |
|
370
|
|
|
$s_defined_user_options = ''; |
|
371
|
|
|
while ($row = $db->sql_fetchrow($result)) |
|
372
|
|
|
{ |
|
373
|
|
|
$set_users[] = $row['user_id']; |
|
374
|
|
|
$s_defined_user_options .= '<option value="' . $row['user_id'] . '">' . $row['username'] . '</option>'; |
|
375
|
|
|
} |
|
376
|
|
|
$db->sql_freeresult($result); |
|
377
|
|
|
|
|
378
|
|
|
// Setting permissions screen |
|
379
|
|
|
$s_hidden_fields = build_hidden_fields(array( |
|
|
|
|
|
|
380
|
|
|
'album_id' => $album_id, |
|
381
|
|
|
'p_system' => $p_system, |
|
382
|
|
|
)); |
|
383
|
|
|
|
|
384
|
|
|
$template->assign_vars(array( |
|
385
|
|
|
'S_HIDDEN_FIELDS' => $s_hidden_fields, |
|
386
|
|
|
'U_ACTION' => $this->u_action . '&action=v_mask', |
|
387
|
|
|
'S_PERMISSION_V_MASK' => true, |
|
388
|
|
|
|
|
389
|
|
|
'C_MASKS_NAMES' => (!$p_system) ? implode(', ', $a_names) : (($p_system == $gallery_auth::OWN_ALBUM) ? $this->language->lang('OWN_PERSONAL_ALBUMS') : $this->language->lang('PERSONAL_ALBUMS')), |
|
|
|
|
|
|
390
|
|
|
'L_C_MASKS' => $this->language->lang('ALBUMS'), |
|
391
|
|
|
|
|
392
|
|
|
'S_CAN_SELECT_GROUP' => true, |
|
393
|
|
|
'S_DEFINED_GROUP_OPTIONS' => $s_defined_group_options, |
|
394
|
|
|
'S_ADD_GROUP_OPTIONS' => $s_add_group_options, |
|
395
|
|
|
|
|
396
|
|
|
'S_CAN_SELECT_USER' => true, |
|
397
|
|
|
'S_DEFINED_USER_OPTIONS' => $s_defined_user_options, |
|
398
|
|
|
'U_FIND_USERNAME' => $gallery_url->append_sid('phpbb', 'memberlist', 'mode=searchuser&form=add_user&field=username&select_single=true'), |
|
399
|
|
|
'ANONYMOUS_USER_ID' => ANONYMOUS, |
|
|
|
|
|
|
400
|
|
|
)); |
|
401
|
|
|
} |
|
402
|
|
|
|
|
403
|
|
|
private function permissions_p_mask() |
|
404
|
|
|
{ |
|
405
|
|
|
global $db, $permissions, $template, $user, $phpbb_ext_gallery, $phpbb_dispatcher, $table_prefix, $table_name, $users_table, $phpbb_container; |
|
406
|
|
|
global $request, $gallery_cache, $gallery_url; |
|
407
|
|
|
|
|
408
|
|
|
$permissions_table = $table_prefix . 'gallery_permissions'; |
|
|
|
|
|
|
409
|
|
|
$roles_table = $table_prefix . 'gallery_roles'; |
|
|
|
|
|
|
410
|
|
|
// Init auth |
|
411
|
|
|
$gallery_user = $phpbb_container->get('phpbbgallery.core.user'); |
|
|
|
|
|
|
412
|
|
|
$phpbb_ext_gallery_core_auth = $phpbb_container->get('phpbbgallery.core.auth'); |
|
413
|
|
|
$this->language = $phpbb_container->get('language'); |
|
414
|
|
|
|
|
415
|
|
|
$this->language->add_lang('acp/permissions'); |
|
416
|
|
|
|
|
417
|
|
|
if (!check_form_key('acp_gallery')) |
|
|
|
|
|
|
418
|
|
|
{ |
|
419
|
|
|
trigger_error('FORM_INVALID'); |
|
420
|
|
|
} |
|
421
|
|
|
|
|
422
|
|
|
$album_id = $request->variable('album_id', array(0)); |
|
423
|
|
|
$group_id = $request->variable('group_id', array(0)); |
|
424
|
|
|
$user_id = $request->variable('user_id', array(0)); |
|
425
|
|
|
$username = $request->variable('username', array(''), true); |
|
426
|
|
|
$usernames = $request->variable('usernames', '', true); |
|
427
|
|
|
$p_system = $request->variable('p_system', 0); |
|
428
|
|
|
|
|
429
|
|
|
// Map usernames to ids and vice versa |
|
430
|
|
|
if ($usernames) |
|
431
|
|
|
{ |
|
432
|
|
|
$username = explode("\n", $usernames); |
|
433
|
|
|
} |
|
434
|
|
|
unset($usernames); |
|
435
|
|
|
|
|
436
|
|
|
if (sizeof($username) && !sizeof($user_id)) |
|
437
|
|
|
{ |
|
438
|
|
|
if (!function_exists('user_get_id_name')) |
|
439
|
|
|
{ |
|
440
|
|
|
$gallery_url->_include('functions_user', 'phpbb'); |
|
441
|
|
|
} |
|
442
|
|
|
user_get_id_name($user_id, $username); |
|
443
|
|
|
|
|
444
|
|
|
if (!sizeof($user_id)) |
|
445
|
|
|
{ |
|
446
|
|
|
trigger_error($this->language->lang('SELECTED_USER_NOT_EXIST') . adm_back_link($this->u_action), E_USER_WARNING); |
|
|
|
|
|
|
447
|
|
|
} |
|
448
|
|
|
} |
|
449
|
|
|
unset($username); |
|
450
|
|
|
|
|
451
|
|
|
if (!sizeof($group_id) && !sizeof($user_id)) |
|
452
|
|
|
{ |
|
453
|
|
|
trigger_error('NO_VICTIM_SELECTED', E_USER_WARNING); |
|
454
|
|
|
} |
|
455
|
|
|
else if (sizeof($group_id)) |
|
456
|
|
|
{ |
|
457
|
|
|
$victim_mode = 'group'; |
|
458
|
|
|
$victim_id = $group_id; |
|
459
|
|
|
} |
|
460
|
|
|
else |
|
461
|
|
|
{ |
|
462
|
|
|
$victim_mode = 'user'; |
|
463
|
|
|
$victim_id = $user_id; |
|
464
|
|
|
} |
|
465
|
|
|
|
|
466
|
|
|
// Create the loops for the javascript |
|
467
|
|
|
for ($i = 0; $i < sizeof($permissions->cats[$p_system]); $i++) |
|
|
|
|
|
|
468
|
|
|
{ |
|
469
|
|
|
$template->assign_block_vars('c_rows', array()); |
|
470
|
|
|
} |
|
471
|
|
|
|
|
472
|
|
|
if ($victim_mode == 'group') |
|
|
|
|
|
|
473
|
|
|
{ |
|
474
|
|
|
// Get the group information |
|
475
|
|
|
$sql = 'SELECT group_name, group_id, group_type, group_colour |
|
476
|
|
|
FROM ' . GROUPS_TABLE . ' |
|
|
|
|
|
|
477
|
|
|
WHERE ' . $db->sql_in_set('group_id', $victim_id); |
|
|
|
|
|
|
478
|
|
|
$result = $db->sql_query($sql); |
|
479
|
|
|
|
|
480
|
|
|
$victim_list = array(); |
|
481
|
|
|
while ($row = $db->sql_fetchrow($result)) |
|
482
|
|
|
{ |
|
483
|
|
|
$row['group_name'] = (($row['group_type'] == GROUP_SPECIAL) ? $this->language->lang('G_' . $row['group_name']) : $row['group_name']); |
|
|
|
|
|
|
484
|
|
|
$victim_row = array( |
|
485
|
|
|
'victim_id' => $row['group_id'], |
|
486
|
|
|
'victim_name' => $row['group_name'], |
|
487
|
|
|
'victim_colour' => $row['group_colour'], |
|
488
|
|
|
); |
|
489
|
|
|
$victim_list[$row['group_id']] = $victim_row; |
|
490
|
|
|
} |
|
491
|
|
|
$db->sql_freeresult($result); |
|
492
|
|
|
} |
|
493
|
|
|
else |
|
494
|
|
|
{ |
|
495
|
|
|
// Get the user information |
|
496
|
|
|
$sql = 'SELECT username, user_id, user_colour |
|
497
|
|
|
FROM ' . USERS_TABLE . ' |
|
|
|
|
|
|
498
|
|
|
WHERE ' . $db->sql_in_set('user_id', $victim_id); |
|
499
|
|
|
$result = $db->sql_query($sql); |
|
500
|
|
|
|
|
501
|
|
|
$victim_list = array(); |
|
502
|
|
|
while ($row = $db->sql_fetchrow($result)) |
|
503
|
|
|
{ |
|
504
|
|
|
$victim_row = array( |
|
505
|
|
|
'victim_id' => $row['user_id'], |
|
506
|
|
|
'victim_name' => $row['username'], |
|
507
|
|
|
'victim_colour' => $row['user_colour'], |
|
508
|
|
|
); |
|
509
|
|
|
$victim_list[$row['user_id']] = $victim_row; |
|
510
|
|
|
} |
|
511
|
|
|
$db->sql_freeresult($result); |
|
512
|
|
|
} |
|
513
|
|
|
|
|
514
|
|
|
// Fetch the full-permissions-tree |
|
515
|
|
|
$sql = 'SELECT perm_role_id, perm_group_id, perm_user_id, perm_album_id |
|
516
|
|
|
FROM ' . $table_prefix . 'gallery_permissions |
|
517
|
|
|
WHERE ' . ((!$p_system) ? $db->sql_in_set('perm_album_id', $album_id) : $db->sql_in_set('perm_system', $p_system)) . ' |
|
518
|
|
|
AND ' . $db->sql_in_set('perm_' . $victim_mode . '_id', $victim_id); |
|
519
|
|
|
$result = $db->sql_query($sql); |
|
520
|
|
|
|
|
521
|
|
|
$p_masks = $fetch_roles = array(); |
|
522
|
|
|
while ($row = $db->sql_fetchrow($result)) |
|
523
|
|
|
{ |
|
524
|
|
|
$fetch_roles[] = $row['perm_role_id']; |
|
525
|
|
|
$p_masks[((!$p_system) ? $row['perm_album_id'] : $p_system)][$row['perm_' . $victim_mode . '_id']] = $row['perm_role_id']; |
|
526
|
|
|
} |
|
527
|
|
|
$db->sql_freeresult($result); |
|
528
|
|
|
|
|
529
|
|
|
// Fetch the roles |
|
530
|
|
|
$roles = array(); |
|
531
|
|
|
if (!empty($fetch_roles)) |
|
532
|
|
|
{ |
|
533
|
|
|
$sql = 'SELECT * |
|
534
|
|
|
FROM ' . $table_prefix . 'gallery_roles |
|
535
|
|
|
WHERE ' . $db->sql_in_set('role_id', $fetch_roles); |
|
536
|
|
|
$result = $db->sql_query($sql); |
|
537
|
|
|
|
|
538
|
|
|
while ($row = $db->sql_fetchrow($result)) |
|
539
|
|
|
{ |
|
540
|
|
|
$roles[$row['role_id']] = $row; |
|
541
|
|
|
} |
|
542
|
|
|
$db->sql_freeresult($result); |
|
543
|
|
|
} |
|
544
|
|
|
|
|
545
|
|
|
// Album permissions |
|
546
|
|
|
if (!$p_system) |
|
547
|
|
|
{ |
|
548
|
|
|
$album_list = $gallery_cache->get('albums'); |
|
549
|
|
|
foreach ($album_id as $album) |
|
550
|
|
|
{ |
|
551
|
|
|
$album_row = $album_list[$album]; |
|
552
|
|
|
$template->assign_block_vars('c_mask', array( |
|
553
|
|
|
'C_MASK_ID' => $album_row['album_id'], |
|
554
|
|
|
'C_MASK_NAME' => $album_row['album_name'], |
|
555
|
|
|
'INHERIT_C_MASKS' => $this->inherit_albums($album_list, $album_id, $album_row['album_id']), |
|
556
|
|
|
)); |
|
557
|
|
|
foreach ($victim_id as $victim) |
|
558
|
|
|
{ |
|
559
|
|
|
$victim_row = $victim_list[$victim]; |
|
560
|
|
|
$template->assign_block_vars('c_mask.v_mask', array( |
|
561
|
|
|
'VICTIM_ID' => $victim_row['victim_id'], |
|
562
|
|
|
'VICTIM_NAME' => '<span' . (($victim_row['victim_colour']) ? (' style="color: #' . $victim_row['victim_colour'] . '"') : '') . '>' . $victim_row['victim_name'] . '</span>', |
|
563
|
|
|
'INHERIT_VICTIMS' => $this->inherit_victims($album_list, $album_id, $victim_list, $album_row['album_id'], $victim_row['victim_id']), |
|
564
|
|
|
)); |
|
565
|
|
|
$role_id = (isset($p_masks[$album_row['album_id']][$victim_row['victim_id']])) ? $p_masks[$album_row['album_id']][$victim_row['victim_id']] : 0; |
|
566
|
|
|
foreach ($permissions->cats[$p_system] as $category => $permission_values) |
|
567
|
|
|
{ |
|
568
|
|
|
$acl_s_never = $acl_s_no = $acl_s_yes = 0; |
|
569
|
|
|
foreach ($permission_values as $permission) |
|
570
|
|
|
{ |
|
571
|
|
|
if (substr($permission, -6, 6) != '_count') |
|
572
|
|
|
{ |
|
573
|
|
|
if (isset($roles[$role_id][$permission]) && ($roles[$role_id][$permission] == $phpbb_ext_gallery_core_auth::ACL_YES)) |
|
574
|
|
|
{ |
|
575
|
|
|
$acl_s_yes++; |
|
576
|
|
|
} |
|
577
|
|
|
else if (isset($roles[$role_id][$permission]) && ($roles[$role_id][$permission] == $phpbb_ext_gallery_core_auth::ACL_NEVER)) |
|
578
|
|
|
{ |
|
579
|
|
|
$acl_s_never++; |
|
580
|
|
|
} |
|
581
|
|
|
else if (isset($roles[$role_id][$permission]) && ($roles[$role_id][$permission] == $phpbb_ext_gallery_core_auth::ACL_NO)) |
|
582
|
|
|
{ |
|
583
|
|
|
$acl_s_no++; |
|
584
|
|
|
} |
|
585
|
|
|
} |
|
586
|
|
|
} |
|
587
|
|
|
$template->assign_block_vars('c_mask.v_mask.category', array( |
|
588
|
|
|
'CAT_NAME' => $this->language->lang('PERMISSION_' . strtoupper($category)), |
|
589
|
|
|
'PERM_GROUP_ID' => $category, |
|
590
|
|
|
'S_YES' => ($acl_s_yes && !$acl_s_never && !$acl_s_no) ? true : false, |
|
591
|
|
|
'S_NEVER' => ($acl_s_never && !$acl_s_yes && !$acl_s_no) ? true : false, |
|
592
|
|
|
'S_NO' => ($acl_s_no && !$acl_s_never && !$acl_s_yes) ? true : false, |
|
593
|
|
|
)); |
|
594
|
|
|
foreach ($permission_values as $permission) |
|
595
|
|
|
{ |
|
596
|
|
|
$key = 'PERMISSION_' . strtoupper($permission); |
|
597
|
|
|
$key_explain = $key . '_EXPLAIN'; |
|
598
|
|
|
$template->assign_block_vars('c_mask.v_mask.category.mask', array( |
|
599
|
|
|
'PERMISSION' => $this->language->lang($key), |
|
600
|
|
|
'PERMISSION_EXPLAIN' => ($this->language->lang_raw($key_explain) !== $key_explain) ? $this->language->lang($key_explain) : '', |
|
601
|
|
|
'S_FIELD_NAME' => 'setting[' . $album_row['album_id'] . '][' . $victim_row['victim_id'] . '][' . $permission . ']', |
|
602
|
|
|
'S_NO' => ((isset($roles[$role_id][$permission]) && ($roles[$role_id][$permission] == $phpbb_ext_gallery_core_auth::ACL_NO)) ? true : false), |
|
603
|
|
|
'S_YES' => ((isset($roles[$role_id][$permission]) && ($roles[$role_id][$permission] == $phpbb_ext_gallery_core_auth::ACL_YES)) ? true : false), |
|
604
|
|
|
'S_NEVER' => ((isset($roles[$role_id][$permission]) && ($roles[$role_id][$permission] == $phpbb_ext_gallery_core_auth::ACL_NEVER)) ? true : false), |
|
605
|
|
|
'S_VALUE' => ((isset($roles[$role_id][$permission])) ? $roles[$role_id][$permission] : 0), |
|
606
|
|
|
'S_COUNT_FIELD' => (substr($permission, -6, 6) == '_count') ? true : false, |
|
607
|
|
|
)); |
|
608
|
|
|
} |
|
609
|
|
|
} |
|
610
|
|
|
} |
|
611
|
|
|
} |
|
612
|
|
|
} |
|
613
|
|
|
else |
|
614
|
|
|
{ |
|
615
|
|
|
$template->assign_block_vars('c_mask', array( |
|
616
|
|
|
'C_MASK_ID' => $p_system, |
|
617
|
|
|
'C_MASK_NAME' => (($p_system == $phpbb_ext_gallery_core_auth::OWN_ALBUM) ? $this->language->lang('OWN_PERSONAL_ALBUMS') : $this->language->lang('PERSONAL_ALBUMS')), |
|
618
|
|
|
)); |
|
619
|
|
|
foreach ($victim_id as $victim) |
|
620
|
|
|
{ |
|
621
|
|
|
$victim_row = $victim_list[$victim]; |
|
622
|
|
|
$template->assign_block_vars('c_mask.v_mask', array( |
|
623
|
|
|
'VICTIM_ID' => $victim_row['victim_id'], |
|
624
|
|
|
'VICTIM_NAME' => '<span' . (($victim_row['victim_colour']) ? (' style="color: #' . $victim_row['victim_colour'] . '"') : '') . '>' . $victim_row['victim_name'] . '</span>', |
|
625
|
|
|
'INHERIT_VICTIMS' => $this->p_system_inherit_victims($p_system, $victim_list, $victim_row['victim_id']), |
|
626
|
|
|
)); |
|
627
|
|
|
$role_id = (isset($p_masks[$p_system][$victim_row['victim_id']])) ? $p_masks[$p_system][$victim_row['victim_id']] : 0; |
|
628
|
|
|
foreach ($permissions->cats[$p_system] as $category => $permission_values) |
|
629
|
|
|
{ |
|
630
|
|
|
$template->assign_block_vars('c_mask.v_mask.category', array( |
|
631
|
|
|
'CAT_NAME' => $this->language->lang('PERMISSION_' . strtoupper($category)), |
|
632
|
|
|
'PERM_GROUP_ID' => $category, |
|
633
|
|
|
)); |
|
634
|
|
|
foreach ($permission_values as $permission) |
|
635
|
|
|
{ |
|
636
|
|
|
$key = 'PERMISSION_' . strtoupper($permission); |
|
637
|
|
|
$key_explain = $key . '_EXPLAIN'; |
|
638
|
|
|
$template->assign_block_vars('c_mask.v_mask.category.mask', array( |
|
639
|
|
|
'PERMISSION' => $this->language->lang($key), |
|
640
|
|
|
'PERMISSION_EXPLAIN' => ($this->language->lang_raw($key_explain) !== $key_explain) ? $this->language->lang($key_explain) : '', |
|
641
|
|
|
'S_FIELD_NAME' => 'setting[' . $p_system . '][' . $victim_row['victim_id'] . '][' . $permission . ']', |
|
642
|
|
|
'S_NO' => ((isset($roles[$role_id][$permission]) && ($roles[$role_id][$permission] == $phpbb_ext_gallery_core_auth::ACL_NO)) ? true : false), |
|
643
|
|
|
'S_YES' => ((isset($roles[$role_id][$permission]) && ($roles[$role_id][$permission] == $phpbb_ext_gallery_core_auth::ACL_YES)) ? true : false), |
|
644
|
|
|
'S_NEVER' => ((isset($roles[$role_id][$permission]) && ($roles[$role_id][$permission] == $phpbb_ext_gallery_core_auth::ACL_NEVER)) ? true : false), |
|
645
|
|
|
'S_VALUE' => ((isset($roles[$role_id][$permission])) ? $roles[$role_id][$permission] : 0), |
|
646
|
|
|
'S_COUNT_FIELD' => (substr($permission, -6, 6) == '_count') ? true : false, |
|
647
|
|
|
)); |
|
648
|
|
|
} |
|
649
|
|
|
} |
|
650
|
|
|
} |
|
651
|
|
|
} |
|
652
|
|
|
|
|
653
|
|
|
// Setting permissions screen |
|
654
|
|
|
$s_hidden_fields = build_hidden_fields(array( |
|
|
|
|
|
|
655
|
|
|
'user_id' => $user_id, |
|
656
|
|
|
'group_id' => $group_id, |
|
657
|
|
|
'album_id' => $album_id, |
|
658
|
|
|
'p_system' => $p_system, |
|
659
|
|
|
)); |
|
660
|
|
|
|
|
661
|
|
|
$template->assign_vars(array( |
|
662
|
|
|
'S_HIDDEN_FIELDS' => $s_hidden_fields, |
|
663
|
|
|
'U_ACTION' => $this->u_action . '&action=set', |
|
664
|
|
|
'S_PERMISSION_P_MASK' => true, |
|
665
|
|
|
)); |
|
666
|
|
|
} |
|
667
|
|
|
|
|
668
|
|
|
private function permissions_set() |
|
669
|
|
|
{ |
|
670
|
|
|
global $cache, $db, $permissions, $template, $user, $phpbb_ext_gallery, $phpbb_dispatcher, $table_prefix, $table_name, $phpbb_container; |
|
671
|
|
|
global $request; |
|
672
|
|
|
|
|
673
|
|
|
$permissions_table = $table_prefix . 'gallery_permissions'; |
|
674
|
|
|
$roles_table = $table_prefix . 'gallery_roles'; |
|
675
|
|
|
$users_table = $table_prefix . 'gallery_users'; |
|
|
|
|
|
|
676
|
|
|
// Init auth |
|
677
|
|
|
$gallery_cache = $phpbb_container->get('phpbbgallery.core.cache'); |
|
678
|
|
|
$gallery_user = $phpbb_container->get('phpbbgallery.core.user'); |
|
|
|
|
|
|
679
|
|
|
$phpbb_ext_gallery_core_auth = $phpbb_container->get('phpbbgallery.core.auth'); |
|
680
|
|
|
|
|
681
|
|
|
// Send constants to the template |
|
682
|
|
|
$submit = (isset($_POST['submit'])) ? true : false; |
|
683
|
|
|
$album_id = $request->variable('album_id', array(0)); |
|
684
|
|
|
$group_id = $request->variable('group_id', array(0)); |
|
685
|
|
|
$user_id = $request->variable('user_id', array(0)); |
|
686
|
|
|
$p_system = $request->variable('p_system', $phpbb_ext_gallery_core_auth::PUBLIC_ALBUM); |
|
687
|
|
|
|
|
688
|
|
|
if (!sizeof($group_id) && !sizeof($user_id)) |
|
689
|
|
|
{ |
|
690
|
|
|
trigger_error('NO_VICTIM_SELECTED', E_USER_WARNING); |
|
691
|
|
|
} |
|
692
|
|
|
else if (sizeof($group_id)) |
|
693
|
|
|
{ |
|
694
|
|
|
$victim_mode = 'group'; |
|
695
|
|
|
$victim_id = $group_id; |
|
|
|
|
|
|
696
|
|
|
} |
|
697
|
|
|
else |
|
698
|
|
|
{ |
|
699
|
|
|
$victim_mode = 'user'; |
|
700
|
|
|
$victim_id = $user_id; |
|
701
|
|
|
} |
|
702
|
|
|
|
|
703
|
|
|
if ($submit) |
|
704
|
|
|
{ |
|
705
|
|
|
if (!check_form_key('acp_gallery')) |
|
|
|
|
|
|
706
|
|
|
{ |
|
707
|
|
|
trigger_error('FORM_INVALID', E_USER_WARNING); |
|
708
|
|
|
} |
|
709
|
|
|
$coal = $gallery_cache->get('albums'); |
|
710
|
|
|
|
|
711
|
|
|
/** |
|
712
|
|
|
* Grab the permissions |
|
713
|
|
|
* |
|
714
|
|
|
* includes/acp/acp_permissions.php says: |
|
715
|
|
|
* // We obtain and check $_POST['setting'][$ug_id][$forum_id] directly and not using request_var() because request_var() |
|
716
|
|
|
* // currently does not support the amount of dimensions required. ;) |
|
717
|
|
|
*/ |
|
718
|
|
|
// $auth_settings = request_var('setting', array(0 => array(0 => array('' => 0)))); |
|
719
|
|
|
$requests = $request->variable('setting', array(0 => array(0 => array('' => 0)))); |
|
720
|
|
|
$p_mask_count = 0; |
|
721
|
|
|
$auth_settings = $p_mask_storage = $c_mask_storage = $v_mask_storage = array(); |
|
722
|
|
|
foreach ($requests as $c_mask => $v_sets) |
|
723
|
|
|
{ |
|
724
|
|
|
$c_mask = (int) $c_mask; |
|
725
|
|
|
$c_mask_storage[] = $c_mask; |
|
726
|
|
|
$auth_settings[$c_mask] = array(); |
|
727
|
|
|
foreach ($v_sets as $v_mask => $p_sets) |
|
728
|
|
|
{ |
|
729
|
|
|
$v_mask = (int) $v_mask; |
|
730
|
|
|
$v_mask_storage[] = $v_mask; |
|
731
|
|
|
$auth_settings[$c_mask][$v_mask] = array(); |
|
732
|
|
|
$is_moderator = false; |
|
733
|
|
|
foreach ($p_sets as $p_mask => $value) |
|
734
|
|
|
{ |
|
735
|
|
|
if (!in_array($p_mask, $permissions->p_masks[$p_system])) |
|
736
|
|
|
{ |
|
737
|
|
|
// An admin tried to set a non-existing permission. Hacking attempt?! |
|
738
|
|
|
trigger_error('HACKING_ATTEMPT', E_USER_WARNING); |
|
739
|
|
|
} |
|
740
|
|
|
// Casted all values to integer and checked all strings whether they are permissions! |
|
741
|
|
|
// Should be fine than for the .com MOD-Team now =) |
|
742
|
|
|
$value = (int) $value; |
|
743
|
|
|
if (substr($p_mask, -6, 6) == '_count') |
|
744
|
|
|
{ |
|
745
|
|
|
$auth_settings[$c_mask][$v_mask][$p_mask] = $value; |
|
746
|
|
|
} |
|
747
|
|
|
else |
|
748
|
|
|
{ |
|
749
|
|
|
$auth_settings[$c_mask][$v_mask][$p_mask] = ($value == ACL_YES) ? $phpbb_ext_gallery_core_auth::ACL_YES : (($value == ACL_NEVER) ? $phpbb_ext_gallery_core_auth::ACL_NEVER : $phpbb_ext_gallery_core_auth::ACL_NO); |
|
|
|
|
|
|
750
|
|
|
// Do we have moderators? |
|
751
|
|
|
if ((substr($p_mask, 0, 2) == 'm_') && ($value == ACL_YES)) |
|
752
|
|
|
{ |
|
753
|
|
|
$is_moderator = true; |
|
754
|
|
|
} |
|
755
|
|
|
} |
|
756
|
|
|
} |
|
757
|
|
|
// Need to set a defaults here: view your own personal album images |
|
758
|
|
|
if ($p_system == $phpbb_ext_gallery_core_auth::OWN_ALBUM) |
|
759
|
|
|
{ |
|
760
|
|
|
$auth_settings[$c_mask][$v_mask]['i_view'] = $phpbb_ext_gallery_core_auth::ACL_YES; |
|
761
|
|
|
} |
|
762
|
|
|
|
|
763
|
|
|
$p_mask_storage[$p_mask_count]['p_mask'] = $auth_settings[$c_mask][$v_mask]; |
|
764
|
|
|
$p_mask_storage[$p_mask_count]['is_moderator'] = $is_moderator; |
|
765
|
|
|
$p_mask_storage[$p_mask_count]['usage'][] = array('c_mask' => $c_mask, 'v_mask' => $v_mask); |
|
766
|
|
|
$auth_settings[$c_mask][$v_mask] = $p_mask_count; |
|
767
|
|
|
$p_mask_count++; |
|
768
|
|
|
} |
|
769
|
|
|
} |
|
770
|
|
|
/** |
|
771
|
|
|
* Inherit the permissions |
|
772
|
|
|
*/ |
|
773
|
|
|
$inherit = $request->variable('setting', array(0 => array('' => 0))); |
|
774
|
|
|
foreach ($inherit as $c_mask => $v_sets) |
|
775
|
|
|
{ |
|
776
|
|
|
$c_mask = (int) $c_mask; |
|
777
|
|
|
foreach ($v_sets as $v_mask => $i_mask) |
|
778
|
|
|
{ |
|
779
|
|
|
if (($v_mask == 'full') && $i_mask) |
|
780
|
|
|
{ |
|
781
|
|
|
$i_mask = (int) $i_mask; |
|
782
|
|
|
// Inherit all permissions of an other c_mask |
|
783
|
|
|
if (isset($auth_settings[$i_mask])) |
|
784
|
|
|
{ |
|
785
|
|
|
if ($this->inherit_albums($coal, $c_mask_storage, $c_mask, $i_mask)) |
|
786
|
|
|
{ |
|
787
|
|
|
foreach ($auth_settings[$c_mask] as $v_mask => $p_mask) |
|
|
|
|
|
|
788
|
|
|
{ |
|
789
|
|
|
// You are not able to inherit a later c_mask, so we can remove the p_mask from the storage, |
|
790
|
|
|
// and just use the same p_mask |
|
791
|
|
|
unset($p_mask_storage[$auth_settings[$c_mask][$v_mask]]); |
|
792
|
|
|
$auth_settings[$c_mask][$v_mask] = $auth_settings[$i_mask][$v_mask]; |
|
793
|
|
|
$p_mask_storage[$auth_settings[$c_mask][$v_mask]]['usage'][] = array('c_mask' => $c_mask, 'v_mask' => $v_mask); |
|
794
|
|
|
} |
|
795
|
|
|
// We take all permissions of another c_mask, so: |
|
796
|
|
|
break; |
|
797
|
|
|
} |
|
798
|
|
|
else |
|
799
|
|
|
{ |
|
800
|
|
|
// The chosen option was disabled: Hacking attempt?! |
|
801
|
|
|
trigger_error('HACKING_ATTEMPT', E_USER_WARNING); |
|
802
|
|
|
} |
|
803
|
|
|
} |
|
804
|
|
|
} |
|
805
|
|
|
else if ($i_mask) |
|
806
|
|
|
{ |
|
807
|
|
|
// Inherit permissions of one [c_mask][v_mask] |
|
808
|
|
|
$v_mask = (int) $v_mask; |
|
809
|
|
|
list($ci_mask, $vi_mask) = explode("_", $i_mask); |
|
810
|
|
|
$ci_mask = (int) $ci_mask; |
|
811
|
|
|
$vi_mask = (int) $vi_mask; |
|
812
|
|
|
if (isset($auth_settings[$ci_mask][$vi_mask])) |
|
813
|
|
|
{ |
|
814
|
|
|
$no_hacking_attempt = ((!$p_system) ? $this->inherit_victims($coal, $c_mask_storage, $v_mask_storage, $c_mask, $v_mask, $ci_mask, $vi_mask) : $this->p_system_inherit_victims($p_system, $v_mask_storage, $v_mask, $vi_mask)); |
|
815
|
|
|
if ($no_hacking_attempt) |
|
816
|
|
|
{ |
|
817
|
|
|
// You are not able to inherit a later c_mask, so we can remove the p_mask from the storage, |
|
818
|
|
|
// and just use the same p_mask |
|
819
|
|
|
if (isset($auth_settings[$c_mask][$v_mask])) |
|
820
|
|
|
{ |
|
821
|
|
|
// Should exist, but didn't on testing so only do it, when it does exist |
|
822
|
|
|
unset($p_mask_storage[$auth_settings[$c_mask][$v_mask]]); |
|
823
|
|
|
} |
|
824
|
|
|
$auth_settings[$c_mask][$v_mask] = $auth_settings[$ci_mask][$vi_mask]; |
|
825
|
|
|
$p_mask_storage[$auth_settings[$c_mask][$v_mask]]['usage'][] = array('c_mask' => $c_mask, 'v_mask' => $v_mask); |
|
826
|
|
|
} |
|
827
|
|
|
else |
|
828
|
|
|
{ |
|
829
|
|
|
// The chosen option was disabled: Hacking attempt?! |
|
830
|
|
|
trigger_error('HACKING_ATTEMPT', E_USER_WARNING); |
|
831
|
|
|
} |
|
832
|
|
|
} |
|
833
|
|
|
} |
|
834
|
|
|
} |
|
835
|
|
|
} |
|
836
|
|
|
unset($auth_settings); |
|
837
|
|
|
|
|
838
|
|
|
// Get the possible outdated p_masks |
|
839
|
|
|
$sql = 'SELECT perm_role_id |
|
840
|
|
|
FROM ' . $permissions_table . ' |
|
841
|
|
|
WHERE ' . ((!$p_system) ? $db->sql_in_set('perm_album_id', $album_id) : $db->sql_in_set('perm_system', $p_system)) . ' |
|
842
|
|
|
AND ' . $db->sql_in_set('perm_' . $victim_mode . '_id', $v_mask_storage); |
|
|
|
|
|
|
843
|
|
|
$result = $db->sql_query($sql); |
|
844
|
|
|
|
|
845
|
|
|
$outdated_p_masks = array(); |
|
846
|
|
|
while ($row = $db->sql_fetchrow($result)) |
|
847
|
|
|
{ |
|
848
|
|
|
$outdated_p_masks[] = $row['perm_role_id']; |
|
849
|
|
|
} |
|
850
|
|
|
$db->sql_freeresult($result); |
|
851
|
|
|
|
|
852
|
|
|
// Delete the permissions and moderators |
|
853
|
|
|
$sql = 'DELETE FROM ' . $permissions_table . ' |
|
854
|
|
|
WHERE ' . ((!$p_system) ? $db->sql_in_set('perm_album_id', $album_id) : $db->sql_in_set('perm_system', $p_system)) . ' |
|
855
|
|
|
AND ' . $db->sql_in_set('perm_' . $victim_mode . '_id', $v_mask_storage); |
|
856
|
|
|
$db->sql_query($sql); |
|
857
|
|
|
if (!$p_system) |
|
858
|
|
|
{ |
|
859
|
|
|
$sql = 'DELETE FROM ' . $table_prefix . 'gallery_modscache |
|
860
|
|
|
WHERE ' . $db->sql_in_set('album_id', $c_mask_storage) . ' |
|
861
|
|
|
AND ' . $db->sql_in_set($victim_mode . '_id', $v_mask_storage); |
|
862
|
|
|
$db->sql_query($sql); |
|
863
|
|
|
} |
|
864
|
|
|
|
|
865
|
|
|
// Check for further usage |
|
866
|
|
|
$sql = 'SELECT perm_role_id |
|
867
|
|
|
FROM ' . $permissions_table . ' |
|
868
|
|
|
WHERE ' . $db->sql_in_set('perm_role_id', $outdated_p_masks, false, true); |
|
869
|
|
|
$result = $db->sql_query($sql); |
|
870
|
|
|
|
|
871
|
|
|
$still_used_p_masks = array(); |
|
872
|
|
|
while ($row = $db->sql_fetchrow($result)) |
|
873
|
|
|
{ |
|
874
|
|
|
$still_used_p_masks[] = $row['perm_role_id']; |
|
875
|
|
|
} |
|
876
|
|
|
$db->sql_freeresult($result); |
|
877
|
|
|
|
|
878
|
|
|
// Delete the p_masks, which are no longer used |
|
879
|
|
|
$sql = 'DELETE FROM ' . $roles_table . ' |
|
880
|
|
|
WHERE ' . $db->sql_in_set('role_id', $outdated_p_masks, false, true) . ' |
|
881
|
|
|
AND ' . $db->sql_in_set('role_id', $still_used_p_masks, true, true); |
|
882
|
|
|
$db->sql_query($sql); |
|
883
|
|
|
|
|
884
|
|
|
$group_names = array(); |
|
|
|
|
|
|
885
|
|
|
if (!$p_system) |
|
886
|
|
|
{ |
|
887
|
|
|
if ($victim_mode == 'group') |
|
888
|
|
|
{ |
|
889
|
|
|
// Get group_name's for the GALLERY_MODSCACHE_TABLE |
|
890
|
|
|
$sql = 'SELECT group_id, group_name |
|
891
|
|
|
FROM ' . GROUPS_TABLE . ' |
|
|
|
|
|
|
892
|
|
|
WHERE ' . $db->sql_in_set('group_id', $v_mask_storage); |
|
893
|
|
|
$result = $db->sql_query($sql); |
|
894
|
|
|
|
|
895
|
|
|
while ($row = $db->sql_fetchrow($result)) |
|
896
|
|
|
{ |
|
897
|
|
|
$victim_names[$row['group_id']] = $row['group_name']; |
|
898
|
|
|
} |
|
899
|
|
|
$db->sql_freeresult($result); |
|
900
|
|
|
} |
|
901
|
|
|
else |
|
902
|
|
|
{ |
|
903
|
|
|
// Get username's for the GALLERY_MODSCACHE_TABLE |
|
904
|
|
|
$sql = 'SELECT user_id, username |
|
905
|
|
|
FROM ' . USERS_TABLE . ' |
|
|
|
|
|
|
906
|
|
|
WHERE ' . $db->sql_in_set('user_id', $v_mask_storage); |
|
907
|
|
|
$result = $db->sql_query($sql); |
|
908
|
|
|
|
|
909
|
|
|
while ($row = $db->sql_fetchrow($result)) |
|
910
|
|
|
{ |
|
911
|
|
|
$victim_names[$row['user_id']] = $row['username']; |
|
912
|
|
|
} |
|
913
|
|
|
$db->sql_freeresult($result); |
|
914
|
|
|
} |
|
915
|
|
|
} |
|
916
|
|
|
|
|
917
|
|
|
$sql_permissions = $sql_moderators = array(); |
|
918
|
|
|
foreach ($p_mask_storage as $p_set) |
|
919
|
|
|
{ |
|
920
|
|
|
// Check whether the p_mask is already in the DB |
|
921
|
|
|
$sql_where = ''; |
|
922
|
|
|
foreach ($p_set['p_mask'] as $p_mask => $value) |
|
923
|
|
|
{ |
|
924
|
|
|
$sql_where .= (($sql_where) ? ' AND ' : '') . $p_mask . ' = ' . $value; |
|
925
|
|
|
} |
|
926
|
|
|
// Check back, so we don't give more permissions than the admin wants to |
|
927
|
|
|
$check_permissions_to_default = array_diff($permissions->p_masks_anti[$p_system], $p_set['p_mask']); |
|
928
|
|
|
foreach ($check_permissions_to_default as $p_mask) |
|
929
|
|
|
{ |
|
930
|
|
|
$sql_where .= (($sql_where) ? ' AND ' : '') . $p_mask . ' = 0'; |
|
931
|
|
|
} |
|
932
|
|
|
|
|
933
|
|
|
$role_id = 0; |
|
|
|
|
|
|
934
|
|
|
$sql = 'SELECT role_id |
|
935
|
|
|
FROM ' . $roles_table . " |
|
936
|
|
|
WHERE $sql_where"; |
|
937
|
|
|
$result = $db->sql_query_limit($sql, 1); |
|
938
|
|
|
$role_id = (int) $db->sql_fetchfield('role_id'); |
|
939
|
|
|
$db->sql_freeresult($result); |
|
940
|
|
|
|
|
941
|
|
|
if (!$role_id) |
|
942
|
|
|
{ |
|
943
|
|
|
// Note: Do not collect the roles to insert, to deny doubles and we need the ID! |
|
944
|
|
|
$sql = 'INSERT INTO ' . $roles_table . ' ' . $db->sql_build_array('INSERT', $p_set['p_mask']); |
|
945
|
|
|
$db->sql_query($sql); |
|
946
|
|
|
$role_id = $db->sql_nextid(); |
|
947
|
|
|
} |
|
948
|
|
|
|
|
949
|
|
|
foreach ($p_set['usage'] as $usage) |
|
950
|
|
|
{ |
|
951
|
|
|
if (!$p_system) |
|
952
|
|
|
{ |
|
953
|
|
|
$sql_permissions[] = array( |
|
954
|
|
|
'perm_role_id' => $role_id, |
|
955
|
|
|
'perm_album_id' => $usage['c_mask'], |
|
956
|
|
|
'perm_' . $victim_mode . '_id' => $usage['v_mask'], |
|
957
|
|
|
); |
|
958
|
|
|
if ($p_set['is_moderator']) |
|
959
|
|
|
{ |
|
960
|
|
|
if ($victim_mode == 'group') |
|
961
|
|
|
{ |
|
962
|
|
|
$sql_moderators[] = array( |
|
963
|
|
|
'album_id' => $usage['c_mask'], |
|
964
|
|
|
'group_id' => $usage['v_mask'], |
|
965
|
|
|
'group_name' => $victim_names[$usage['v_mask']], |
|
|
|
|
|
|
966
|
|
|
); |
|
967
|
|
|
} |
|
968
|
|
|
else |
|
969
|
|
|
{ |
|
970
|
|
|
$sql_moderators[] = array( |
|
971
|
|
|
'album_id' => $usage['c_mask'], |
|
972
|
|
|
'user_id' => $usage['v_mask'], |
|
973
|
|
|
'username' => $victim_names[$usage['v_mask']], |
|
974
|
|
|
); |
|
975
|
|
|
} |
|
976
|
|
|
} |
|
977
|
|
|
} |
|
978
|
|
|
else |
|
979
|
|
|
{ |
|
980
|
|
|
$sql_permissions[] = array( |
|
981
|
|
|
'perm_role_id' => $role_id, |
|
982
|
|
|
'perm_system' => $usage['c_mask'], |
|
983
|
|
|
'perm_' . $victim_mode . '_id' => $usage['v_mask'], |
|
984
|
|
|
); |
|
985
|
|
|
} |
|
986
|
|
|
} |
|
987
|
|
|
} |
|
988
|
|
|
$db->sql_multi_insert($permissions_table, $sql_permissions); |
|
989
|
|
|
$db->sql_multi_insert($table_prefix . 'gallery_modscache', $sql_moderators); |
|
990
|
|
|
|
|
991
|
|
|
$cache->destroy('sql', $permissions_table); |
|
992
|
|
|
$cache->destroy('sql', $roles_table); |
|
993
|
|
|
$cache->destroy('sql', $table_prefix . 'gallery_modscache'); |
|
994
|
|
|
$phpbb_ext_gallery_core_auth->set_user_permissions('all', ''); |
|
995
|
|
|
|
|
996
|
|
|
trigger_error($this->language->lang('PERMISSIONS_STORED') . adm_back_link($this->u_action)); |
|
|
|
|
|
|
997
|
|
|
} |
|
998
|
|
|
trigger_error('HACKING_ATTEMPT', E_USER_WARNING); |
|
999
|
|
|
} |
|
1000
|
|
|
|
|
1001
|
|
|
/** |
|
1002
|
|
|
* Handles copying permissions from one album to others |
|
1003
|
|
|
*/ |
|
1004
|
|
|
private function copy_album_permissions() |
|
1005
|
|
|
{ |
|
1006
|
|
|
global $cache, $db, $template, $user, $table_prefix, $phpbb_dispatcher, $table_name, $users_table, $phpbb_container; |
|
1007
|
|
|
global $request; |
|
1008
|
|
|
|
|
1009
|
|
|
$albums_table = $table_prefix . 'gallery_albums'; |
|
1010
|
|
|
$roles_table = $table_prefix . 'gallery_roles'; |
|
|
|
|
|
|
1011
|
|
|
$permissions_table = $table_prefix . 'gallery_permissions'; |
|
1012
|
|
|
$modscache_table = $table_prefix . 'gallery_modscache'; |
|
1013
|
|
|
$gallery_cache = $phpbb_container->get('phpbbgallery.core.cache'); |
|
|
|
|
|
|
1014
|
|
|
$gallery_user = $phpbb_container->get('phpbbgallery.core.user'); |
|
|
|
|
|
|
1015
|
|
|
$phpbb_ext_gallery_core_auth = $phpbb_container->get('phpbbgallery.core.auth'); |
|
1016
|
|
|
|
|
1017
|
|
|
// Init album |
|
1018
|
|
|
$phpbb_ext_gallery_core_album = $phpbb_container->get('phpbbgallery.core.album'); |
|
1019
|
|
|
$this->language = $phpbb_container->get('language'); |
|
1020
|
|
|
|
|
1021
|
|
|
$submit = isset($_POST['submit']) ? true : false; |
|
1022
|
|
|
|
|
1023
|
|
|
if ($submit) |
|
1024
|
|
|
{ |
|
1025
|
|
|
$src = $request->variable('src_album_id', 0); |
|
1026
|
|
|
$dest = $request->variable('dest_album_ids', array(0)); |
|
1027
|
|
|
|
|
1028
|
|
|
$sql = 'SELECT album_id |
|
1029
|
|
|
FROM ' . $albums_table . ' |
|
1030
|
|
|
WHERE album_id = ' . (int) $src; |
|
1031
|
|
|
$result = $db->sql_query($sql); |
|
1032
|
|
|
$src = (int) $db->sql_fetchfield('album_id'); |
|
1033
|
|
|
$db->sql_freeresult($result); |
|
1034
|
|
|
|
|
1035
|
|
|
if (!$src) |
|
1036
|
|
|
{ |
|
1037
|
|
|
trigger_error($this->language->lang('SELECTED_ALBUM_NOT_EXIST') . adm_back_link($this->u_action), E_USER_WARNING); |
|
|
|
|
|
|
1038
|
|
|
} |
|
1039
|
|
|
|
|
1040
|
|
|
if (!sizeof($dest)) |
|
1041
|
|
|
{ |
|
1042
|
|
|
trigger_error($this->language->lang('SELECTED_ALBUM_NOT_EXIST') . adm_back_link($this->u_action), E_USER_WARNING); |
|
1043
|
|
|
} |
|
1044
|
|
|
|
|
1045
|
|
|
if (confirm_box(true)) |
|
|
|
|
|
|
1046
|
|
|
{ |
|
1047
|
|
|
$sql = 'SELECT * |
|
1048
|
|
|
FROM ' . $permissions_table . ' |
|
1049
|
|
|
WHERE perm_album_id = ' . (int) $src; |
|
1050
|
|
|
$result = $db->sql_query($sql); |
|
1051
|
|
|
while ($row = $db->sql_fetchrow($result)) |
|
1052
|
|
|
{ |
|
1053
|
|
|
foreach ($dest as $album_id) |
|
1054
|
|
|
{ |
|
1055
|
|
|
$perm_data[] = array( |
|
1056
|
|
|
'perm_role_id' => $row['perm_role_id'], |
|
1057
|
|
|
'perm_album_id' => $album_id, |
|
1058
|
|
|
'perm_user_id' => $row['perm_user_id'], |
|
1059
|
|
|
'perm_group_id' => $row['perm_group_id'], |
|
1060
|
|
|
'perm_system' => $row['perm_system'], |
|
1061
|
|
|
); |
|
1062
|
|
|
} |
|
1063
|
|
|
} |
|
1064
|
|
|
$db->sql_freeresult($result); |
|
1065
|
|
|
|
|
1066
|
|
|
$modscache_ary = array(); |
|
1067
|
|
|
$sql = 'SELECT * FROM ' . $modscache_table . ' |
|
1068
|
|
|
WHERE album_id = ' . (int) $src; |
|
1069
|
|
|
$result = $db->sql_query($sql); |
|
1070
|
|
|
while ($row = $db->sql_fetchrow($result)) |
|
1071
|
|
|
{ |
|
1072
|
|
|
foreach ($dest as $album_id) |
|
1073
|
|
|
{ |
|
1074
|
|
|
$modscache_ary[] = array( |
|
1075
|
|
|
'album_id' => $album_id, |
|
1076
|
|
|
'user_id' => $row['user_id'], |
|
1077
|
|
|
'username' => $row['username'], |
|
1078
|
|
|
'group_id' => $row['group_id'], |
|
1079
|
|
|
'group_name' => $row['group_name'], |
|
1080
|
|
|
'display_on_index' => $row['display_on_index'], |
|
1081
|
|
|
); |
|
1082
|
|
|
} |
|
1083
|
|
|
} |
|
1084
|
|
|
$db->sql_freeresult($result); |
|
1085
|
|
|
|
|
1086
|
|
|
$sql = 'DELETE FROM ' . $permissions_table . ' |
|
1087
|
|
|
WHERE ' . $db->sql_in_set('perm_album_id', $dest); |
|
1088
|
|
|
$db->sql_query($sql); |
|
1089
|
|
|
|
|
1090
|
|
|
$sql = 'DELETE FROM ' . $modscache_table . ' |
|
1091
|
|
|
WHERE ' . $db->sql_in_set('album_id', $dest); |
|
1092
|
|
|
$db->sql_query($sql); |
|
1093
|
|
|
|
|
1094
|
|
|
$db->sql_multi_insert($permissions_table, $perm_data); |
|
|
|
|
|
|
1095
|
|
|
$db->sql_multi_insert($modscache_table, $modscache_ary); |
|
1096
|
|
|
|
|
1097
|
|
|
$cache->destroy('sql', $modscache_table); |
|
1098
|
|
|
$cache->destroy('sql', $permissions_table); |
|
1099
|
|
|
$phpbb_ext_gallery_core_auth->set_user_permissions('all', ''); |
|
1100
|
|
|
|
|
1101
|
|
|
trigger_error($this->language->lang('COPY_PERMISSIONS_SUCCESSFUL') . adm_back_link($this->u_action)); |
|
1102
|
|
|
} |
|
1103
|
|
|
else |
|
1104
|
|
|
{ |
|
1105
|
|
|
$s_hidden_fields = array( |
|
1106
|
|
|
'submit' => $submit, |
|
1107
|
|
|
'src_album_id' => $src, |
|
1108
|
|
|
'dest_album_ids' => $dest, |
|
1109
|
|
|
); |
|
1110
|
|
|
|
|
1111
|
|
|
$s_hidden_fields = build_hidden_fields($s_hidden_fields); |
|
|
|
|
|
|
1112
|
|
|
|
|
1113
|
|
|
confirm_box(false, $this->language->lang('COPY_PERMISSIONS_CONFIRM'), $s_hidden_fields); |
|
1114
|
|
|
} |
|
1115
|
|
|
} |
|
1116
|
|
|
|
|
1117
|
|
|
$template->assign_vars(array( |
|
1118
|
|
|
'S_ALBUM_OPTIONS' => $phpbb_ext_gallery_core_album->get_albumbox(true, ''), |
|
1119
|
|
|
'S_COPY_PERMISSIONS' => true, |
|
1120
|
|
|
)); |
|
1121
|
|
|
} |
|
1122
|
|
|
|
|
1123
|
|
|
/** |
|
1124
|
|
|
* Create the drop-down-options to inherit the c_masks |
|
1125
|
|
|
* or check, whether the chosen option is valid |
|
1126
|
|
|
* @param $cache_obtain_album_list |
|
1127
|
|
|
* @param $allowed_albums |
|
1128
|
|
|
* @param $album_id |
|
1129
|
|
|
* @param int $check_inherit_album |
|
1130
|
|
|
* @return bool|string |
|
1131
|
|
|
*/ |
|
1132
|
|
|
private function inherit_albums($cache_obtain_album_list, $allowed_albums, $album_id, $check_inherit_album = 0) |
|
1133
|
|
|
{ |
|
1134
|
|
|
global $user, $phpbb_container; |
|
1135
|
|
|
|
|
1136
|
|
|
$this->language = $phpbb_container->get('language'); |
|
1137
|
|
|
$disabled = false; |
|
1138
|
|
|
|
|
1139
|
|
|
$return = ''; |
|
1140
|
|
|
$return .= '<option value="0" selected="selected">' . $this->language->lang('NO_INHERIT') . '</option>'; |
|
1141
|
|
|
foreach ($cache_obtain_album_list as $album) |
|
1142
|
|
|
{ |
|
1143
|
|
|
if (in_array($album['album_id'], $allowed_albums)) |
|
1144
|
|
|
{ |
|
1145
|
|
|
// We found the requested album: return true! |
|
1146
|
|
|
if ($check_inherit_album && ($album['album_id'] == $check_inherit_album)) |
|
1147
|
|
|
{ |
|
1148
|
|
|
return true; |
|
1149
|
|
|
} |
|
1150
|
|
|
if ($album['album_id'] == $album_id) |
|
1151
|
|
|
{ |
|
1152
|
|
|
$disabled = true; |
|
1153
|
|
|
// Could we find the requested album so far? No? Hacking attempt?! |
|
1154
|
|
|
if ($check_inherit_album) |
|
1155
|
|
|
{ |
|
1156
|
|
|
return false; |
|
1157
|
|
|
} |
|
1158
|
|
|
} |
|
1159
|
|
|
$return .= '<option value="' . $album['album_id'] . '"'; |
|
1160
|
|
|
if ($disabled) |
|
1161
|
|
|
{ |
|
1162
|
|
|
$return .= ' disabled="disabled" class="disabled-option"'; |
|
1163
|
|
|
} |
|
1164
|
|
|
$return .= '>' . $album['album_name'] . '</option>'; |
|
1165
|
|
|
} |
|
1166
|
|
|
} |
|
1167
|
|
|
// Could we not find the requested album even here? |
|
1168
|
|
|
if ($check_inherit_album) |
|
1169
|
|
|
{ |
|
1170
|
|
|
// Something went really wrong here! |
|
1171
|
|
|
return false; |
|
1172
|
|
|
} |
|
1173
|
|
|
return $return; |
|
1174
|
|
|
} |
|
1175
|
|
|
|
|
1176
|
|
|
/** |
|
1177
|
|
|
* Create the drop-down-options to inherit the v_masks |
|
1178
|
|
|
* or check, whether the chosen option is valid |
|
1179
|
|
|
* @param $cache_obtain_album_list |
|
1180
|
|
|
* @param $allowed_albums |
|
1181
|
|
|
* @param $allowed_victims |
|
1182
|
|
|
* @param $album_id |
|
1183
|
|
|
* @param $victim_id |
|
1184
|
|
|
* @param int $check_inherit_album |
|
1185
|
|
|
* @param int $check_inherit_victim |
|
1186
|
|
|
* @return bool|string |
|
1187
|
|
|
*/ |
|
1188
|
|
|
private function inherit_victims($cache_obtain_album_list, $allowed_albums, $allowed_victims, $album_id, $victim_id, $check_inherit_album = 0, $check_inherit_victim = 0) |
|
1189
|
|
|
{ |
|
1190
|
|
|
global $user; |
|
1191
|
|
|
|
|
1192
|
|
|
$disabled = false; |
|
1193
|
|
|
// We submit a "wrong" array on the check (to make it more easy) so we convert it here |
|
1194
|
|
|
if ($check_inherit_album && $check_inherit_victim) |
|
1195
|
|
|
{ |
|
1196
|
|
|
$converted_victims = array(); |
|
1197
|
|
|
foreach ($allowed_victims as $victim) |
|
1198
|
|
|
{ |
|
1199
|
|
|
$converted_victims[] = array( |
|
1200
|
|
|
'victim_id' => $victim, |
|
1201
|
|
|
'victim_name' => '', |
|
1202
|
|
|
); |
|
1203
|
|
|
} |
|
1204
|
|
|
$allowed_victims = $converted_victims; |
|
1205
|
|
|
unset ($converted_victims); |
|
1206
|
|
|
} |
|
1207
|
|
|
|
|
1208
|
|
|
$return = ''; |
|
1209
|
|
|
$return .= '<option value="0" selected="selected">' . $this->language->lang('NO_INHERIT') . '</option>'; |
|
1210
|
|
|
foreach ($cache_obtain_album_list as $album) |
|
1211
|
|
|
{ |
|
1212
|
|
|
if (in_array($album['album_id'], $allowed_albums)) |
|
1213
|
|
|
{ |
|
1214
|
|
|
$return .= '<option value="0" disabled="disabled" class="disabled-option">' . $album['album_name'] . '</option>'; |
|
1215
|
|
|
foreach ($allowed_victims as $victim) |
|
1216
|
|
|
{ |
|
1217
|
|
|
// We found the requested album_group: return true! |
|
1218
|
|
|
if ($check_inherit_album && $check_inherit_victim && (($album['album_id'] == $check_inherit_album) && ($victim['victim_id'] == $check_inherit_victim))) |
|
1219
|
|
|
{ |
|
1220
|
|
|
return true; |
|
1221
|
|
|
} |
|
1222
|
|
|
if (($album['album_id'] == $album_id) && ($victim['victim_id'] == $victim_id)) |
|
1223
|
|
|
{ |
|
1224
|
|
|
$disabled = true; |
|
1225
|
|
|
// Could we find the requested album_victim so far? No? Hacking attempt?! |
|
1226
|
|
|
if ($check_inherit_album && $check_inherit_victim) |
|
1227
|
|
|
{ |
|
1228
|
|
|
return false; |
|
1229
|
|
|
} |
|
1230
|
|
|
} |
|
1231
|
|
|
$return .= '<option value="' . $album['album_id'] . '_' . $victim['victim_id'] . '"'; |
|
1232
|
|
|
if ($disabled) |
|
1233
|
|
|
{ |
|
1234
|
|
|
$return .= ' disabled="disabled" class="disabled-option"'; |
|
1235
|
|
|
} |
|
1236
|
|
|
$return .= '> ' . $album['album_name'] . ' >>> ' . $victim['victim_name'] . '</option>'; |
|
1237
|
|
|
} |
|
1238
|
|
|
} |
|
1239
|
|
|
} |
|
1240
|
|
|
// Could we not find the requested album_victim even here? |
|
1241
|
|
|
if ($check_inherit_album && $check_inherit_victim) |
|
1242
|
|
|
{ |
|
1243
|
|
|
// Something went really wrong here! |
|
1244
|
|
|
return false; |
|
1245
|
|
|
} |
|
1246
|
|
|
return $return; |
|
1247
|
|
|
} |
|
1248
|
|
|
|
|
1249
|
|
|
/** |
|
1250
|
|
|
* Create the drop-down-options to inherit the v_masks |
|
1251
|
|
|
* or check, whether the chosen option is valid |
|
1252
|
|
|
* @param $p_system |
|
1253
|
|
|
* @param $allowed_victims |
|
1254
|
|
|
* @param $victim_id |
|
1255
|
|
|
* @param int $check_inherit_victim |
|
1256
|
|
|
* @return bool|string |
|
1257
|
|
|
*/ |
|
1258
|
|
|
private function p_system_inherit_victims($p_system, $allowed_victims, $victim_id, $check_inherit_victim = 0) |
|
1259
|
|
|
{ |
|
1260
|
|
|
global $user, $phpbb_container; |
|
1261
|
|
|
|
|
1262
|
|
|
$phpbb_ext_gallery_core_auth = $phpbb_container->get('phpbbgallery.core.auth'); |
|
1263
|
|
|
|
|
1264
|
|
|
$disabled = false; |
|
1265
|
|
|
// We submit a "wrong" array on the check (to make it more easy) so we convert it here |
|
1266
|
|
|
if ($check_inherit_victim) |
|
1267
|
|
|
{ |
|
1268
|
|
|
$converted_groups = array(); |
|
|
|
|
|
|
1269
|
|
|
foreach ($allowed_victims as $victim) |
|
1270
|
|
|
{ |
|
1271
|
|
|
$converted_victims[] = array( |
|
1272
|
|
|
'victim_id' => $victim, |
|
1273
|
|
|
'victim_name' => '', |
|
1274
|
|
|
); |
|
1275
|
|
|
} |
|
1276
|
|
|
$allowed_victims = $converted_victims; |
|
|
|
|
|
|
1277
|
|
|
unset ($converted_victims); |
|
1278
|
|
|
} |
|
1279
|
|
|
|
|
1280
|
|
|
$return = ''; |
|
1281
|
|
|
$return .= '<option value="0" selected="selected">' . $this->language->lang('NO_INHERIT') . '</option>'; |
|
1282
|
|
|
foreach ($allowed_victims as $victim) |
|
1283
|
|
|
{ |
|
1284
|
|
|
// We found the requested {$p_system}_victim: return true! |
|
1285
|
|
|
if ($check_inherit_victim && ($victim['victim_id'] == $check_inherit_victim)) |
|
1286
|
|
|
{ |
|
1287
|
|
|
return true; |
|
1288
|
|
|
} |
|
1289
|
|
|
if ($victim['victim_id'] == $victim_id) |
|
1290
|
|
|
{ |
|
1291
|
|
|
$disabled = true; |
|
1292
|
|
|
// Could we find the requested {$p_system}_victim so far? No? Hacking attempt?! |
|
1293
|
|
|
if ($check_inherit_victim) |
|
1294
|
|
|
{ |
|
1295
|
|
|
return false; |
|
1296
|
|
|
} |
|
1297
|
|
|
} |
|
1298
|
|
|
$return .= '<option value="' . $p_system . '_' . $victim['victim_id'] . '"'; |
|
1299
|
|
|
if ($disabled) |
|
1300
|
|
|
{ |
|
1301
|
|
|
$return .= ' disabled="disabled" class="disabled-option"'; |
|
1302
|
|
|
} |
|
1303
|
|
|
$return .= '> ' . (($p_system == $phpbb_ext_gallery_core_auth::OWN_ALBUM) ? $this->language->lang('OWN_PERSONAL_ALBUMS') : $this->language->lang('PERSONAL_ALBUMS')) . ' >>> ' . $victim['victim_name'] . '</option>'; |
|
1304
|
|
|
} |
|
1305
|
|
|
// Could we not find the requested {$p_system}_victim even here? |
|
1306
|
|
|
if ($check_inherit_victim) |
|
1307
|
|
|
{ |
|
1308
|
|
|
// Something went really wrong here! |
|
1309
|
|
|
return false; |
|
1310
|
|
|
} |
|
1311
|
|
|
return $return; |
|
1312
|
|
|
} |
|
1313
|
|
|
} |
|
1314
|
|
|
|