Skip to content

Commit

Permalink
Added group bulk-action to be enabled to new and old installation
Browse files Browse the repository at this point in the history
  • Loading branch information
vcsvinicius committed Mar 26, 2024
1 parent a77a072 commit e7e4f19
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions modules/social_features/social_group/social_group.install
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ function social_group_install(): void {
// Since we update group related permissions that touch node content we must
// also rebuild the node access permissions.
node_access_rebuild();

// Add group bulk action to people view.
_social_group_alter_admin_people_view();
}

/**
Expand Down Expand Up @@ -127,6 +130,29 @@ function social_group_update_last_removed() : int {
return 11902;
}

/**
* Update the user admin view with our custom action.
*
* Action ID: 'social_group_add_members_to_group_action'.
*/
function _social_group_alter_admin_people_view(): void {
// Get people view config.
$config = \Drupal::configFactory()->getEditable('views.view.user_admin_people');
$selected_actions = $config->get('display.default.display_options.fields.views_bulk_operations_bulk_form.selected_actions');

// Check if already have bulk action.
if (in_array('social_group_add_members_to_group_action', array_column(array_values($selected_actions), 'action_id'))) {
return;
}

// Add bulk action and save them.
$selected_actions[] = [
'action_id' => 'social_group_add_members_to_group_action',
];
$config->set('display.default.display_options.fields.views_bulk_operations_bulk_form.selected_actions', $selected_actions);
$config->save();
}

/**
* Cancel limit of outputted roles in views.view.group_manage_members.
*/
Expand Down Expand Up @@ -208,6 +234,13 @@ function social_group_update_12301(): void {
}
}

/**
* Add group bulk action to people view.
*/
function social_group_update_12302(): void {
_social_group_alter_admin_people_view();
}

/**
* Update old group types to flexible groups.
*/
Expand Down

0 comments on commit e7e4f19

Please sign in to comment.