Problem

When I use the domain_access module, I can restrict the access for content editing to only people which are assigned to the proper domains. But, the content translate functionality is still not restricted. So even if I can choose to let an editor to edit or not a node on his domains, I cannot choose to let the user translate or not that content.

Solution proposal

The domain_access module could expose special permissions for content translation: "Translate any content on assigned domains" and "%type_name: Translate any content on assigned domains".

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

vasi1186 created an issue. See original summary.

vasi1186’s picture

Attached is a first draft of the solution proposal. It still misses the tests.

agentrickard’s picture

This is a really interesting problem space, and I'd love for some of the other multilingual users to weigh in.

This generally makes sense to me, but I don't have a great use-case for it.

Note that Domain Access permissions are stored separately for each translation, but I think this is an extension of the ability to view/create new translations, akin to domain_access_node_create_access().

Code note:

The first function has a hard dependency on Content Translation (content_translation_translate_access($entity);. That suggests the need for a submodule that declares a dependency on content_translation.

vasi1186’s picture

Regarding the use-case, here is a simple one (also exposed in the description) which can happen basically to any multilingual site: an editor does not have access to edit nodes on the domains which are not assigned to him, but because he has translation permissions for content in general, he still has the possibility to create translations, which basically means he can 'edit' (I am fully aware this is not an edit, and the original node does not get any changes) that node in a particular language, even if the node does not belong to one of his domains. At least this gives the impression that you have editing abilities on that node even if you are not supposed to. And we have a client who specifically requested that, so an editor from a domain should be just a simple visitor in regards to node operations for another domain.

The question is if that should really be implemented in the domain_access module, or in a separate one. And if that module should be part of the domain core modules, or a simple contrib module. Suggestions are welcome!

agentrickard’s picture

I'm ok adding this to Domain Access, so long as we remove the hard dependency on Content Translation. (We'd have to wrap that in IF checks).

Really, this looks like a core bug to me. content_translation_translate_access() really should be alterable, but is not.

agentrickard’s picture

Title: Content translation permissions for domains » Content translation permissions and node access
Project: Domain » Drupal core
Version: 8.x-1.x-dev » 8.3.x-dev
Component: Code » content_translation.module
Issue tags: -permissions +D8MI

I'm going to pop this over into the core queue for comment from the translation system maintainers. The questions here are:twofold:

* Should translators be able to create a translation for content that they cannot edit?

The original use-case here is that translators can access the translation overview page for nodes they cannot access. Should that be allowed by ore?

* Should the permission to grant translation creation be extensible / overridable via hook?

So if core thinks that condition one is ok, can we make content_translation_translate_access() fire a hook or event so that contrib modules can alter that behavior the way we do with hook_node_access / hook_node_create_access().

vasi1186’s picture

Attached a new patch that fixes a bug in the previous one. In the previous one, even if you were an admin, you could not translate content unless you were assigned a domain. There should be now a permission for that.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

andreyjan’s picture

Recreated the patch to take into account changes in Drupal core 8.5.0

andreyjan’s picture

This issue probably should be moved rather to Domain Access then Core.

idebr’s picture

#6.1

* Should translators be able to create a translation for content that they cannot edit?
* Should the permission to grant translation creation be extensible / overridable via hook?

There is currently only a global permission to translate content that is separate to node (update) access.

An issue to introduce a hook_entity_translation_access() for use cases such as Domains is available at #2918354: Add hook_entity_translation_access()

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

bhavanasisarath’s picture

When i am upgrading the core to 8.7.1, patch #10 is failing to apply.
Is anyone having latest patch of this to support 8.7.x

Berdir’s picture

The patch is not for core but domain_access, so it can't apply here.

> * Should translators be able to create a translation for content that they cannot edit?

Yes, I think the current permissions are specifically tailored to use cases where translators can *only* translate (but can translate anything of a certain bundle). I agree that this is not flexible enough for many use cases.

I'd love feedback on #2972308: Allow users to translate content they can edit, which I think would make this work without any changes in domain_access.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

dvmanjunath’s picture

Recreated the patch https://www.drupal.org/project/drupal/issues/2866583#comment-12527212 to take into account changes in Drupal core 8.9 and making it compatible with Drupal 9.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.