From 91bbfcf554d190c1956d16c652ceefb95a18735a Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 6 Aug 2015 17:09:09 -0700 Subject: photo permission inheritance. We want to use the folder permissions unless specific permissions have been set to over-ride them. If nothing is set, use the channel default. We may have to mess with his further in the case of somebody trying to create a public photo directory when their normal permissions are set to private. Kind of a chicken/egg problem because the folder permissions will be empty. --- include/photos.php | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) (limited to 'include/photos.php') diff --git a/include/photos.php b/include/photos.php index 46d4b810c..7437d6aa9 100644 --- a/include/photos.php +++ b/include/photos.php @@ -50,20 +50,32 @@ function photo_upload($channel, $observer, $args) { else $visible = 0; - $str_group_allow = perms2str(((is_array($args['group_allow'])) ? $args['group_allow'] : explode(',',$args['group_allow']))); - $str_contact_allow = perms2str(((is_array($args['contact_allow'])) ? $args['contact_allow'] : explode(',',$args['contact_allow']))); - $str_group_deny = perms2str(((is_array($args['group_deny'])) ? $args['group_deny'] : explode(',',$args['group_deny']))); - $str_contact_deny = perms2str(((is_array($args['contact_deny'])) ? $args['contact_deny'] : explode(',',$args['contact_deny']))); - - - if( (! array_key_exists('group_allow',$args)) - && (! array_key_exists('contact_allow',$args)) - && (! array_key_exists('group_deny',$args)) - && (! array_key_exists('contact_deny',$args))) { - $str_group_allow = $channel['channel_allow_gid']; - $str_contact_allow = $channel['channel_allow_cid']; - $str_group_deny = $channel['channel_deny_gid']; - $str_contact_deny = $channel['channel_deny_cid']; + // Set to default channel permissions. If the parent directory (album) has permissions set, + // use those instead. If we have specific permissions supplied, they take precedence over + // all other settings. + + $str_group_allow = $channel['channel_allow_gid']; + $str_contact_allow = $channel['channel_allow_cid']; + $str_group_deny = $channel['channel_deny_gid']; + $str_contact_deny = $channel['channel_deny_cid']; + + if($args['directory']) { + $str_group_allow = $args['directory']['allow_gid']; + $str_contact_allow = $args['directory']['allow_cid']; + $str_group_deny = $args['directory']['deny_gid']; + $str_contact_deny = $args['directory']['deny_cid']; + } + + if( (array_key_exists('group_allow',$args)) + || (array_key_exists('contact_allow',$args)) + || (array_key_exists('group_deny',$args)) + || (array_key_exists('contact_deny',$args))) { + + $str_group_allow = perms2str(((is_array($args['group_allow'])) ? $args['group_allow'] : explode(',',$args['group_allow']))); + $str_contact_allow = perms2str(((is_array($args['contact_allow'])) ? $args['contact_allow'] : explode(',',$args['contact_allow']))); + $str_group_deny = perms2str(((is_array($args['group_deny'])) ? $args['group_deny'] : explode(',',$args['group_deny']))); + $str_contact_deny = perms2str(((is_array($args['contact_deny'])) ? $args['contact_deny'] : explode(',',$args['contact_deny']))); + } $os_storage = 0; -- cgit v1.2.3