Problem/Motivation

I believe because of the way Groups handles access control, even if you generate an access token for a piece of Group content, Groups isn't aware of this it will deny access. In my testing I could not get access_unpublished to work for any content which belongs to a group.

Steps to reproduce

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

I think Group's access control model needs to be extended per documentation at https://www.drupal.org/docs/contributed-modules/group/extending-groups-a.... In that overridden access control handler, it will need to check with access_unpublished_entity_access and use that as the access result. I have implemented this as a proof of concept - will submit a PR on drupalcode.

Remaining tasks

Code review - especially permissions handling. Test coverage.

User interface changes

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

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

msielski created an issue. See original summary.

craigperks’s picture

@msielski,

I don't suppose you managed to resolve this issue did you? I've run into exactly the same issue as the one you described above.

msielski’s picture

@craigperks, yes I did - I'll clean it up and post the code this evening.

msielski’s picture

recrit’s picture

Added a static patch of msielski's MR6 as of 2023-01-10 so that builds can use it without breaking on any future changes to the patch.

recrit’s picture

updated static patch with latest updates to the MR

recrit’s picture

Note on the current implementation: After changing the group permissions to allow new content types, you must clear the Drupal cache to rebuild the plugin info for "group_content_info" since it checks for the permission in the "hook_group_content_info_alter".

recrit’s picture

updated the static patch with latest MR updates

recrit’s picture

Note: Any patch in this issue depends on Group 1.x version since 2.x+ changes the hook to "hook_group_relation_type_alter"

dabbor’s picture

I've created a related ticket: "Support Group 2.x content" https://www.drupal.org/project/access_unpublished/issues/3405874 to adapt the solution to work with Group 2.x which was a significant modification.

I provided new MR in that new related issue + patch and interdiff in my comment: https://www.drupal.org/project/access_unpublished/issues/3405874#comment...

damienmckenna’s picture

Title: Support Group content » Support Group v1 content
Status: Active » Needs review

There's a patch and merge request, so let's update the status.

bilele123123’s picture

May I ask if anyone is running into this error?

LogicException: Cannot use an "access" handler without a "permission_provider" handler. in Drupal\group\Plugin\GroupContentAccessControlHandler::createInstance() (line 41 of modules/composer/group/src/Plugin/GroupContentAccessControlHandler.php).

Drupal\group\Plugin\GroupContentEnablerManager->createHandlerInstance('Drupal\access_unpublished_group\Plugin\AccessUnpublishedGroupContentAccessControlHandler', 'group_menu:menu', Array) (Line: 141)
Drupal\group\Plugin\GroupContentEnablerManager->getHandler('group_menu:menu', 'access') (Line: 166)
Drupal\group\Plugin\GroupContentEnablerManager->getAccessControlHandler('group_menu:menu') (Line: 351)
group_entity_access(Object, 'view', Object)
call_user_func_array(Object, Array) (Line: 409)
Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, 'group') (Line: 388)

mably made their first commit to this issue’s fork.

mably’s picture

Status: Needs review » Fixed

Pushed to the 1.x branch of the newly created contrib module:

https://www.drupal.org/project/access_unpublished_group

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.