Support Group 2.x content

Created on 4 December 2023, 7 months ago
Updated 22 May 2024, about 1 month ago

Problem/Motivation

There is an issue (feature request): "Support Group content" https://www.drupal.org/project/access_unpublished/issues/3280964 ✨ Support Group content Active that works for Group 1.x.

This issue focused on support of Group 2.x which has significantly modified access control.

The way Groups handles access control doesn't work natively with Access Unpublished for Group managed content.

Steps to reproduce

Quoting from https://www.drupal.org/project/access_unpublished/issues/3280964 ✨ Support Group content Active

Install Group, Group Node, and Access Unpublished. Setup a Group Type, and add allow content type to it. Create group content of that type. Create a link with Access Unpublished - it will result in Access Denied.

Proposed resolution

Modifying the work implemented in https://www.drupal.org/project/access_unpublished/issues/3280964 ✨ Support Group content Active (access_unpublished_group sub-module) to get it compatible with Group 2.x following the https://www.drupal.org/docs/extending-drupal/contributed-modules/contrib... β†’ and checking the differences in Group 1.x and Group 2.x codebase I found out that following had to be done:

  1. The hook_group_content_info_alter() changed to hook_group_relation_type_alter()but it still doesn't help and thus I haven't used it at all.
  2. The following service must be changed
    - From: plugin.manager.group_content_enabler (referring to Drupal\group\Plugin\GroupContentEnablerManager)
    - To: group_relation_type.manager (referring to Drupal\group\Plugin\Group\Relation\GroupRelationTypeManager)
  3. The interface of the plugin manager service above must be changed
    - From: GroupContentEnablerManagerInterface (name-spaced: Drupal\group\Plugin\GroupContentEnablerManagerInterface)
    - To: GroupRelationTypeManagerInterface (name-spaced: Drupal\group\Plugin\Group\Relation\GroupRelationTypeManagerInterface)
  4. The interface of the plugin must be changed
    - From: GroupContentEnablerInterface (name-spaced: Drupal\Group\Plugin\GroupContentEnablerInterface)
    - To: GroupRelationInterface (name-spaced: Drupal\group\Plugin\Group\Relation\GroupRelationInterface)
  5. The AccessUnpublishedGroupPermissions::buildPermissions() must have the following replaced
    - From: 'title' => 'Access unpublished ' . $plugin->getLabel(),
    - To: 'title' => 'Access unpublished ' . $plugin->getPluginDefinition()->get('label') ?? ''
  6. The interface for group content entity storage classes must be changed to interface for relationship entity storage classes
    - From: GroupContentStorageInterface (name-spaced: Drupal\group\Entity\Storage\GroupContentStorageInterface)
    - To: GroupRelationshipStorageInterface (name-spaced: Drupal\group\Entity\Storage\GroupRelationshipStorageInterface)
  7. The following method call must be changed
    - From: GroupContentInterface::getContentPlugin()
    - To: GroupRelationshipInterface::getPlugin()
  8. Implement ServiceProvider similarly as Group 2.x contrib does in its GroupServiceProvider (Drupal\group\GroupServiceProvider) to decorate the original access control services provided by Group 2.x or another module.
  9. The new decorated services are overriding the AccessControlInterface::entityAccess()

Remaining tasks

Code review / Test coverage (happy to get a help).

User interface changes

Quoting from https://www.drupal.org/project/access_unpublished/issues/3280964 ✨ Support Group content Active

The proof of concept adds group level permissions so access_unpublished can be allowed per group type and group role.

API changes

N/A

Data model changes

N/A

✨ Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia dabbor

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.69.0 2024