From c17bc66aeb4cbbe4ec17b8b6b6ef9b3d66d89664 Mon Sep 17 00:00:00 2001 From: flop25 Date: Sun, 16 Jun 2013 19:52:51 +0000 Subject: 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 --- admin/include/functions.php | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'admin/include/functions.php') 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'])))); } -- cgit v1.2.3