Skip to content

Commit

Permalink
PROD-7433 - Add param for group to check logged user is group organis…
Browse files Browse the repository at this point in the history
…er/moderator
  • Loading branch information
jitendrabanjara1991 committed May 16, 2024
1 parent 5a3d95e commit b6a5d9c
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions src/bp-templates/bp-nouveau/includes/groups/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,22 +450,28 @@ function bp_nouveau_groups_invites_custom_message( $message = '' ) {
* Format a Group for a json reply
*
* @since BuddyPress 3.0.0
*
* @param object $item The group object
*
* @return array $args The group data.
*/
function bp_nouveau_prepare_group_for_js( $item ) {
if ( empty( $item->id ) ) {
return array();
}

$item_avatar_url = bp_disable_group_avatar_uploads() ? '' : bp_core_fetch_avatar( array(
'item_id' => $item->id,
'object' => 'group',
'type' => 'thumb',
'width' => 100,
'height' => 100,
'html' => false
) );
$item_avatar_url = bp_disable_group_avatar_uploads() ? '' : bp_core_fetch_avatar(
array(
'item_id' => $item->id,
'object' => 'group',
'type' => 'thumb',
'width' => 100,
'height' => 100,
'html' => false,
)
);

return array(
$args = array(
'id' => $item->id,
'name' => bp_get_group_name( $item ),
'avatar_url' => $item_avatar_url,
Expand All @@ -475,6 +481,15 @@ function bp_nouveau_prepare_group_for_js( $item ) {
'group_document' => ( bp_is_active( 'document' ) && bp_is_group_document_support_enabled() && bb_document_user_can_upload( bp_loggedin_user_id(), $item->id ) ),
'group_video' => ( bp_is_active( 'video' ) && bp_is_group_video_support_enabled() && bb_video_user_can_upload( bp_loggedin_user_id(), $item->id ) ),
);

$args['allow_schedule'] = 'disabled';
$is_admin = groups_is_user_admin( bp_loggedin_user_id(), $item->id );
$is_mod = groups_is_user_mod( bp_loggedin_user_id(), $item->id );
if ( $is_admin || $is_mod ) {
$args['allow_schedule'] = 'enabled';
}

return $args;
}

/**
Expand Down

0 comments on commit b6a5d9c

Please sign in to comment.