diff options
author | flop25 <flop25@piwigo.org> | 2013-06-16 19:52:51 +0000 |
---|---|---|
committer | flop25 <flop25@piwigo.org> | 2013-06-16 19:52:51 +0000 |
commit | c17bc66aeb4cbbe4ec17b8b6b6ef9b3d66d89664 (patch) | |
tree | cee0b0443d131cf1fbd6cbc1f62c6070267d022e /admin/include/functions.php | |
parent | 272a55d377f104a03f3fd0d2cc3c0e8c6497e57b (diff) |
bug:2855
new otpion "inherit" for create_virtual_category(), and $conf['inheritance_by_default'] = false;
ToDo: album registred from Ftp
git-svn-id: http://piwigo.org/svn/trunk@23272 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin/include/functions.php')
-rw-r--r-- | admin/include/functions.php | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/admin/include/functions.php b/admin/include/functions.php index 02917394a..2a6084f8d 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -1303,7 +1303,36 @@ SELECT id, uppercats, global_rank, visible, status update_global_rank(); - if ('private' == $insert['status']) + if ('private' == $insert['status'] and ((isset($options['inherit']) and $options['inherit']) or $conf['inheritance_by_default']) ) + { + $query = ' + SELECT group_id + FROM '.GROUP_ACCESS_TABLE.' + WHERE cat_id = '.$insert['id_uppercat'].' + ;'; + $granted_grps = array_from_query($query, 'group_id'); + $inserts = array(); + foreach ($granted_grps as $granted_grp) + { + array_push( + $inserts, + array( + 'group_id' => $granted_grp, + 'cat_id' => $inserted_id + ) + ); + } + mass_inserts(GROUP_ACCESS_TABLE, array('group_id','cat_id'), $inserts); + + $query = ' + SELECT user_id + FROM '.USER_ACCESS_TABLE.' + WHERE cat_id = '.$insert['id_uppercat'].' + ;'; + $granted_users = array_from_query($query, 'user_id'); + add_permission_on_category($inserted_id, array_unique(array_merge(get_admins(), array($user['id']), $granted_users))); + } + else if ('private' == $insert['status']) { add_permission_on_category($inserted_id, array_unique(array_merge(get_admins(), array($user['id'])))); } |