From e7e4f19848d3f21808b937ab91bc69d12f7417eb Mon Sep 17 00:00:00 2001 From: Vinicius Rodrigues Pereira Date: Tue, 26 Mar 2024 10:40:00 -0300 Subject: [PATCH] Added group bulk-action to be enabled to new and old installation --- .../social_group/social_group.install | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/modules/social_features/social_group/social_group.install b/modules/social_features/social_group/social_group.install index 95e046f01c5..b174a581544 100644 --- a/modules/social_features/social_group/social_group.install +++ b/modules/social_features/social_group/social_group.install @@ -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(); } /** @@ -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. */ @@ -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. */