diff options
author | redmatrix <redmatrix@redmatrix.me> | 2015-08-06 17:09:09 -0700 |
---|---|---|
committer | redmatrix <redmatrix@redmatrix.me> | 2015-08-06 17:09:09 -0700 |
commit | 91bbfcf554d190c1956d16c652ceefb95a18735a (patch) | |
tree | 15f7e74bca33b308d7e048629bd036b78d481452 /include/photos.php | |
parent | 1b0cb9388cd5c416af5ba270127b14efdd1c0a6b (diff) | |
download | volse-hubzilla-91bbfcf554d190c1956d16c652ceefb95a18735a.tar.gz volse-hubzilla-91bbfcf554d190c1956d16c652ceefb95a18735a.tar.bz2 volse-hubzilla-91bbfcf554d190c1956d16c652ceefb95a18735a.zip |
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.
Diffstat (limited to 'include/photos.php')
-rw-r--r-- | include/photos.php | 40 |
1 files changed, 26 insertions, 14 deletions
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; |