aboutsummaryrefslogtreecommitdiffstats
path: root/admin/include/functions.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2013-10-18 20:56:05 +0000
committerplegall <plg@piwigo.org>2013-10-18 20:56:05 +0000
commitbc3fdf095789c2f006159a51e63b612f842c3c1d (patch)
tree34ec664e3c928123a5edcd3cfc3055a30fb49cee /admin/include/functions.php
parentc4529b1b9dc3de57c9269e5f2a4ecb4640a60aac (diff)
bug 2977 fixed: when moving an album, whatever the previous status
private/public we must remove irrelevant permissions (a public album can have hidden permission, ie list of groups/users permitted). I've also found a bug in the algorithm that selects users/groups to delete (reverse parameters in array_diff). git-svn-id: http://piwigo.org/svn/branches/2.5@24986 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin/include/functions.php39
1 files changed, 16 insertions, 23 deletions
diff --git a/admin/include/functions.php b/admin/include/functions.php
index 4e53d09e6..025fa4c04 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -1139,46 +1139,39 @@ SELECT status
{
foreach ($categories as $cat_id => $category)
{
- switch ($category['status'])
+ if ('public' == $category['status'])
{
- case 'public' :
- {
- set_cat_status(array($cat_id), 'private');
- break;
- }
- case 'private' :
- {
- $subcats = get_subcat_ids(array($cat_id));
+ set_cat_status(array($cat_id), 'private');
+ }
+
+ $subcats = get_subcat_ids(array($cat_id));
- foreach ($tables as $table => $field)
- {
- $query = '
+ foreach ($tables as $table => $field)
+ {
+ $query = '
SELECT '.$field.'
FROM '.$table.'
WHERE cat_id = '.$cat_id.'
;';
- $category_access = array_from_query($query, $field);
+ $category_access = array_from_query($query, $field);
- $query = '
+ $query = '
SELECT '.$field.'
FROM '.$table.'
WHERE cat_id = '.$new_parent.'
;';
- $parent_access = array_from_query($query, $field);
+ $parent_access = array_from_query($query, $field);
- $to_delete = array_diff($parent_access, $category_access);
+ $to_delete = array_diff($category_access, $parent_access);
- if (count($to_delete) > 0)
- {
- $query = '
+ if (count($to_delete) > 0)
+ {
+ $query = '
DELETE FROM '.$table.'
WHERE '.$field.' IN ('.implode(',', $to_delete).')
AND cat_id IN ('.implode(',', $subcats).')
;';
- pwg_query($query);
- }
- }
- break;
+ pwg_query($query);
}
}
}