diff options
author | flop25 <flop25@piwigo.org> | 2013-06-19 20:39:44 +0000 |
---|---|---|
committer | flop25 <flop25@piwigo.org> | 2013-06-19 20:39:44 +0000 |
commit | af51f55815da3bb39f738795e6f0313fa550c49e (patch) | |
tree | a6a949c14cff56282be8c171ac02fbb307123aee /admin | |
parent | 5937d97b601fae48de42062faa804a30e0b0065a (diff) |
bug:2855
$conf['inheritance_by_default'] applies on FTP added albums
git-svn-id: http://piwigo.org/svn/trunk@23376 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r-- | admin/site_update.php | 89 |
1 files changed, 88 insertions, 1 deletions
diff --git a/admin/site_update.php b/admin/site_update.php index c705d3690..687061449 100644 --- a/admin/site_update.php +++ b/admin/site_update.php @@ -266,6 +266,7 @@ SELECT id_uppercat, MAX(rank)+1 AS next_rank $db_categories[$insert{'id'}] = array( 'id' => $insert['id'], + 'parent' => $parent, 'status' => $insert['status'], 'visible' => $insert['visible'], 'uppercats' => $insert['uppercats'], @@ -298,11 +299,97 @@ SELECT id_uppercat, MAX(rank)+1 AS next_rank // add default permissions to categories $category_ids = array(); + $category_up = array(); foreach ($inserts as $category) { $category_ids[] = $category['id']; + $category_up[] = $category['id_uppercat']; + } + $category_up=implode(',',array_unique($category_up)); + if ($conf['inheritance_by_default']) + { + $query = ' + SELECT * + FROM '.GROUP_ACCESS_TABLE.' + WHERE cat_id IN ('.$category_up.') + ;'; + $result = pwg_query($query); + $granted_grps = array(); + while ($row = pwg_db_fetch_assoc($result)) + { + if (is_null($granted_grps[$row['cat_id']])) + { + $granted_grps[$row['cat_id']]=array(); + } + array_push( + $granted_grps, + array( + $row['cat_id'] => array_push($granted_grps[$row['cat_id']],$row['group_id']) + ) + ); + } + $insert_granted_grps=array(); + foreach ($category_ids as $ids) + { + $parent=$db_categories[$ids]['parent']; + foreach ($granted_grps[$parent] as $granted_grp) + { + array_push( + $insert_granted_grps, + array( + 'group_id' => $granted_grp, + 'cat_id' => $ids + ) + ); + + } + } + + mass_inserts(GROUP_ACCESS_TABLE, array('group_id','cat_id'), $insert_granted_grps); + + $query = ' + SELECT * + FROM '.USER_ACCESS_TABLE.' + WHERE cat_id IN ('.$category_up.') + ;'; + $result = pwg_query($query); + $granted_users = array(); + while ($row = pwg_db_fetch_assoc($result)) + { + if (is_null($granted_users[$row['cat_id']])) + { + $granted_users[$row['cat_id']]=array(); + } + array_push( + $granted_users, + array( + $row['cat_id'] => array_push($granted_users[$row['cat_id']],$row['user_id']) + ) + ); + } + $insert_granted_users=array(); + foreach ($category_ids as $ids) + { + $parent=$db_categories[$ids]['parent']; + foreach ($granted_users[$parent] as $granted_user) + { + array_push( + $insert_granted_users, + array( + 'user_id' => $granted_user, + 'cat_id' => $ids + ) + ); + + } + } + mass_inserts(USER_ACCESS_TABLE, array('user_id','cat_id'), $insert_granted_users); + + } + else + { + add_permission_on_category($category_ids, get_admins()); } - add_permission_on_category($category_ids, get_admins()); } $counts['new_categories'] = count($inserts); |