Skip to content

Commit

Permalink
Ensure that non-admins are able to download their own admins-only files.
Browse files Browse the repository at this point in the history
See #3334.
  • Loading branch information
boonebgorges committed Jun 13, 2024
1 parent e739af1 commit 2e0abd9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions wp-content/mu-plugins/openlab-group-document-privacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ function cac_catch_group_doc_request() {

$user_can_download = true;

$user_is_creator = (int) $document->user_id === (int) bp_loggedin_user_id();

if ( 'admins' === $doc_privacy ) {
$user_can_download = groups_is_user_admin( bp_loggedin_user_id(), $group_id );
$user_can_download = groups_is_user_admin( bp_loggedin_user_id(), $group_id ) || $user_is_creator;
} elseif ( 'members' === $doc_privacy ) {
$user_can_download = groups_is_user_member( bp_loggedin_user_id(), $group_id );
$user_can_download = groups_is_user_member( bp_loggedin_user_id(), $group_id ) || $user_is_creator;
} elseif ( 'public' !== $group->status ) {
// If the group is not public, then the user must be logged in and
// a member of the group to download the document
Expand Down

0 comments on commit 2e0abd9

Please sign in to comment.