Problem/Motivation

IEF works really well, but if the Group module is used on a project (e.g. for content access and permission handling), IEF can not be used within the groups context.

Steps to reproduce

  1. Install and enable IEF and Group modules.
  2. Set permissions on group level for the article bundle and remove the article permissions on global level.
  3. If the user is a group member, article can be accessed (but not for group outsiders).
  4. If using IEF to add new articles to an entity reference field, the dropdown to select the item type (article) is not shown.
  5. If permissions for article are set on the global level, this breaks the group permissions and makes limiting the visibility of articles to group members only impossible.

Proposed resolution

Minor modifications in IEF are necessary to enable the integration with the Group module.

  • We check, if the Group module is enabled and provide a checkbox in the field widget settings "Use item in group context".
  • We add a boolean value to the configuration.
  • If the user selects the items to be handled in the group context, we check, whether the group is in the route and if not, whether the parent node, which holds the field with the IEF widget has one.
  • We check, whether the current user has sufficient group permissions to add new items to the group. If not, we fall back to the default IEF access check.
  • If the added entity is new, we create the necessary group - entity relationship. This allows the new entity to fully adhere to group permissions.

Remaining tasks

Provide a patch to introduce the above modifications.

User interface changes

Add new checkbox to the widget settings "Use item in group context".
IEF widget settings

API changes

None

Data model changes

Add a new config value "use_group".

Comments

JordiK created an issue. See original summary.

jordik’s picture

Here is a patch, which enables IEF to be used in group context.
Would love to have the opinion of the maintainers on how to proceed further.

jordik’s picture

Issue summary: View changes
jordik’s picture

Status: Active » Needs review
geek-merlin’s picture

Status: Needs review » Postponed (maintainer needs more info)

As user of both modules, i like this. But as maintainer, my job is to not bloat the module.
This should be done in a glue module.
Of course you can and should file a task if this can not be done with existing hooks, and new ones are needed.

jordik’s picture

Status: Postponed (maintainer needs more info) » Needs review

Thank you, your answer is much appreciated.
A new hook in the function doSubmit in WidgetSubmit.php would be very helpful.
It should give modules the opportunity to react on the entity which was just saved.
For the group integration purposes the id is necessary to create the relationship, therefore we should trigger after the entity was initially saved.
What do you think about this approach? Any other ideas or paths we can explore here?

geek-merlin’s picture

That makes sense to me. Can you look if we already have such an issue, and if not, create something like "Add hook to allow other modules to react on IEF saved entities"?

jordik’s picture

A second hook will be necessary to give the opportunity to modify the $create_bundles array in InlineEntityFormComplex.php (Line 438).
It is the base for the dropdown list of entities to create.
Contrib modules will be able to implement custom access checks and populate this list.

Will open a separate issue for this and the hook in #7.

jordik’s picture

Checked the existing issues, could not find anything similar for 8.x-1.x.
Found a request for a save/delete hook in 7.x-1.x here: #2476505: New API hooks and rules integration for react on inline entity saves/deletes.
This gave me the idea that we can also implement a hook when an entity is not only created, but also deleted.

geek-merlin’s picture

Thanks! I'll think a bit about this...

jordik’s picture

Created a new issue #3197629: New API hooks to react on inline entity save/delete.
Added a patch, which enables three hooks as described above. Please review!
This issue can be closed.

podarok’s picture

Status: Needs review » Closed (outdated)

as per #11