Hello
I have 2 questions
- is there a way to activate domain access only on some node types and not all
- is there a way to define default value for the domain field for each node type
Thanks
| Comment | File | Size | Author |
|---|---|---|---|
| #40 | interdiff-2909853-38-to-40.txt | 947 bytes | johnjw59 |
| #40 | 2909853-domain_access-default-value-40.patch | 8.19 KB | johnjw59 |
| #38 | 2909853-domain_access-default-value-38.patch | 8.25 KB | johnjw59 |
| #36 | interdiff-2909853-24-to-33.txt | 717 bytes | xurizaemon |
| #33 | 2909853-domain_access-default-value-33.patch | 8.12 KB | flyke |
Issue fork domain-2909853
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
Comment #2
agentrickardOn point #1, not really. though you could delete the Domain field on the node type. I believe that would have the desired effect but have not tested it.
On point #2, You can set default values when configuring the field on each content type.
Comment #3
agentrickardSome followup after reviewing the code:
* If the node is not assigned to a domain, it should receive the 'all' grant, which would make it accessible to any user who can access content.
* If you delete the field on some node types, let me know if you get error messages from DomainAccessManager::getAccessValues() or similar. Those are easily corrected. That method currently assumes that the field is present.
Comment #4
agentrickardIt seems that in 8.4 at least, the default value setting is not present. That's probably because we use a 'default value callback' to set the default to the current domain.
Ideally, we would remove that callback, and setting the default value to 'current domain' would happen by default. That's a little tricky to implement.
You could probably write a small piece of code to remove the default value callback from the field, and that would then allow you to set this value within the field configuration.
Comment #5
superlolo95 commentedHello,
Thanks for the detailed feedback.
I finally find a workaround for my need which was to have domain menu access module enabled without the domain access module enabled.
I modified the domain menu access module (by duplicating some functions from the domain access module).
For the short term, this will be enough for me to go further in my project.
If I finally afterall need to active the domain access on a single node type, I will let you know about the results of my tests.
Thanks again.
Comment #6
agentrickardComment #7
geek-merlin#4: Thanks for the guidance, so to know what was intentional and what just a quick fix.
Removing the default_value_callback from field_domain_access in fact enables the default setting.
Digging into the source, i guess it's not a good idea to add magick _current (or _all) values to referencable entities.
So a battle plan might look like:
1a) remove default_value_callback in domain_access_confirm_fields()
1b) ... and add an upgrade path for field storage
2) Move the current logic to hook_entity_prepare_form
3) deprecate the callback
In followups,
X1) Make the logic ("When creating a new entity, populate with active domain if required") configurable. (We may want to add other options like "Preselect all domains" there)
X2) Revisit the logic in domain_access_form_alter if still needed (to set value to all-domains if no field access)
Comment #8
geek-merlinPatch flying in that implements this.
Tested manually:
* upgrade path
* field default can be edited
* nonempty field default is used in node create form
* empty field default for required field leads to current domain used (BC)
EDIT: Ups, tests seem to be off for this project.
Comment #9
rolfmeijer commentedConfirmed that the patch in #8 works as expected! Thank you, great work.
Comment #10
agentrickardI've been on vacation and will try to test this out before DrupalCON.
Comment #11
geek-merlinMultipatch flying in with one additional commit:
* Makes "add current domain" configurable/optional, including schema and upgrade path
Manually tested the setting and functionality on my box.
Comment #12
agentrickardNice work!
I think we would always set an empty value to the current domain, because that's the behavior in
domain_access_node_access_records(). In essence, this field is always "required" in that it is set automatically for users without advanced permissions.Because of that, I'm not sure we need the 3rd party settings?
Comment #13
geek-merlin> I'm not sure we need the 3rd party settings?
We have a use case for that: For some fields, we need a default value *and* additionally the current domain, for others, we only want the default value.
Comment #14
geek-merlinMoved a question about this to its own issue to not pollute this one: #3047514: Logic flaw in grants?
Comment #15
anruetherThe patch in #11 does work for me. It respects the current domain and sets the default domain correctly. I wonder if it would be useful to have the option " Send to all affiliates" thus having the same options as on the node form?
Comment #16
geek-merlin> I wonder if it would be useful to have the option " Send to all affiliates" thus having the same options as on the node form?
Good point. Note that that is a separate field (the default of which just works).
Comment #17
markdcUsing #11. Works well. 👍
Comment #18
agentrickardQueued for automated testing -- https://github.com/agentrickard/domain/pull/480
This patch also needs some tests of its own.
Comment #19
agentrickardAnd a thorough review of existing tests, such as
Drupal\Tests\domain_access\Functional\DomainAccessDefaultValueTest, which now fails.Comment #20
flyke commentedI can confirm that patch #11 adds default value settings for domain access fields. (added screenshots)
Comment #21
agentrickardBumping.
Comment #22
agentrickardUpdated patch.
Comment #24
agentrickardThe test fail is due to the fact that on install, the module should set the "add_current_domain" value to TRUE.
That replicates the current behavior and matches the isRequired() logic in the patch.
Comment #25
mrcdrx commentedThe patch in #24 works for me. However, when I export the config for this field, only the option 'add the current domain' is saved in the config, not the actual domain (alias).
Comment #26
klidifia commentedRe #25, 'add the current domain' is saved in config for all types on initial config export after patch applied -- fine.
I can then confirm that setting the defaults for a content type and exporting subsequently updates the config again as expected, and works.
Comment #28
anruether@agentrickard thanks for the patch! #24 works for me.
Just one thing to double-check: Is it expected behavior that a user needs the "publish on any domain" permission for the auto-assignment to work on any domain? That's how the patch currently works. Or is that permission just for users that shall be able to explicitly set a specific permission, with the possibility to deselect the current domain?
edit: What the permission primarily does is showing/hiding the domain_access field in the form. On first sight, it seems plausible to me to exempt the auto-assignment from the permission.
Comment #29
anruetherAnother aspect: The
Add current domain to default valuescheckbox also appears on the user domain_access field setting, but when checked it does not auto assign users on creation.Comment #30
petr illekHi,
just testing this module for upcoming project.
Would be great if there is automatic default value for the user profiles, similarly as explained in #12.
With the provided patch I can see the extra checkbox, but it is not working for users.
Comment #31
agentrickardComment #33
flyke commentedlatest patch, #24, used constant DOMAIN_ACCESS_FIELD instead of DomainAccessManagerInterface::DOMAIN_ACCESS_FIELD somewhere.
It gave me an error.
Comment #34
agentrickardMarking patches as "needs review" will trigger tests.
Comment #35
arakwarI have a situation where I'd like some users to be allowed to publish content on a second domain, but have everyone go trough the "main" domain to create content.
Is it something that this patch would help to cover ?
Comment #36
xurizaemonHere's interdiff for 24 to 33, it does look like 24 incorrectly referred to a constant that wasn't defined.
Comment #37
megan_m commentedThis patch no longer applies
Comment #38
johnjw59 commentedAttached is an updated patch for 2.0.0-beta2
Comment #39
keithlee_giai commentedcan confirm that @johnjw59 's patch works on 2.0.0-beta2 and the Oct dev version.
It would be ideal to have an option to choose which domain to be the default, though.
Comment #40
johnjw59 commentedAnother reroll against 2.0.0-beta3 this time.
Unfortunately the patch contains two update hooks that are now in use by the project, so if you're updating the module and had previously installed this patch you'll need to reset the schema version to 8000 in "key_value" table before updating, patching and running DB updates.
Comment #41
mably commentedCould we have a MR on 2.0.x please?
Comment #43
mably commentedMR created.
This looks like a good candidate for beta4.
But we need some RTBC love for that.
Comment #44
mably commentedComment #46
mably commentedComment #48
mably commentedI will provide a fix for the problem described in comment #29:
Looks like we simply need to handle the
registeroperation.Fix provided in issue #3564574: Add current domain option doesn't work when creating a new user.