It took me some time to understand how to configure the module to control where users publish content but finally I think I got it (I domain module behaviours I have to set only show on selected sites and then on node settings I have to uncheck the node types that I want to control).
I created a role with permissions (create story, edit own story, delete own story, publish only from assigned domains and publish to assigned domains)
I create a user assigning him the previous role and assigning him to two domains.
When I go to create a story I receive this notice:
* Notice: Undefined property: stdClass::$nid in domain_form_alter() (line 1906 of /home/manfer/public_html/drupal7/sites/all/modules/domain/domain.module).
* Notice: Undefined property: stdClass::$domain_site in domain_form_alter() (line 1929 of /home/manfer/public_html/drupal7/sites/all/modules/domain/domain.module).
Those are only notices and the content is published anyway if you submit it. But the content can be seen on all affiliates though published only to one affiliate, the teaser is shown on all home pages of all affiliates. On other affiliates that the one it is published to, if you try to visit the node (not the teaser in front page) you receive then an access deny page. Maybe this one should be another issue, I don't know.
| Comment | File | Size | Author |
|---|---|---|---|
| #47 | 771454-domain-notice.patch | 1.22 KB | agentrickard |
| #46 | domain-771454-46.patch | 1.22 KB | mikeytown2 |
| #42 | domain-771454-42.patch | 888 bytes | mikeytown2 |
| #39 | domain-771454-39.patch | 886 bytes | mikeytown2 |
| #35 | 771454-notices.patch | 3.83 KB | agentrickard |
Comments
Comment #1
agentrickardThe notices are a minor error that need to be corrected. Thanks. They are harmless to the functionality.
The visibility issue may be based on your permission level, especially if you are user 1. See the README.txt for details. You may need to turn on the 'enforce rules on administrators' behavior.
Comment #2
manfer commentedWhat I say about seeing the story (published only for one domain) on all domains is for all roles, anonymous users included can see that teaser on all affiliates front pages. If they try to visit that node they get to an access deny page on all affiliates except on the one the content has been published to but they can see the teaser version on front page of all affiliates.
User 1 can see that content on all affiliates both the teaser on front pages of every affiliate and the whole story too in all affiliates.
The user that published the content, let's call it an editor, works exactly as the anonymous user. He sees teaser on front pages of all affiliates, if he tries to visit the node he receives an access deny page except on the affiliate where he has published that content. The only difference with anonymous is that in the affiliate where he has published the content he can both visit and edit it as expected.
Comment #3
agentrickardWas does the debug mode tell you? I certainly don't see this behavior.
Make sure your user roles can't 'administer nodes' (D6) or 'bypass node access' (D7),
Comment #4
manfer commentedNo, the custom role I created has not those permissions, so the users I use to test only have the default permissions of an authenticated user on a drupal installation (I haven't touched that at all) and the permissions of my custom role (create new article content, edit own article content, delete own article content, publish to any assigned domains, publish only from any assigned domain).
I can confirm those users has not 'administer nodes' on D6 not 'bypass node access' on D7.
I would try to turn on debug mode.
Comment #5
manfer commentedThe debug mode says:
Assigned domains:
* All affiliates
* One
So it is showing the All affiliates to those contents that are published by an editor only to a specific domain. When that editor creates the content he is presented only with checboxes of the domains he is assigned to, there is not Send to all affiliates checkbox for that user. And the configuration behaviour is New content settings (Only show on selected sites). And node settings none of the contents are selected.
It seems the "Send to all affiliates" is aplied though that user can't decide that and has not that checkbox in his creation form. Content posted by that user should show only, Assigned domains: One.
The weird thing is that when trying to visit that node from any domain different than One it gets an access deny page as if All affiliates were not being applied which is the correct behaviour.
--------------------------------------
In 6.x where those teaser are not appearing in content published that way (publishing only to one domain the same way with an editor that only can check domains he is assigned to) it shows:
Assigned domains
* One
--------------------------------------
Comment #6
manfer commentedI have done other test and is that with "Restrict node views for administrators" you would not be able to see that weird thing of getting to an access deny on those nodes. For those users seems as it is interpreting -all affiliates, One- and correctly.
I don't understand whats wrong. And as I'm not too familiar with the module I'm always thinking I'm doing something wrong. :)
It is not easy to do the test and many times I have to try to do same thing in 6.x to see the difference.
I'm going to delete all published content and only publish one again. As much content I publish more difficult is for me then find the problematic content.
Comment #7
agentrickardYou need to disable the auto-assignment of nodes to all affiliates. See 4.3.1 and 4.8 of README.txt.
Comment #8
manfer commentedI think I have it correctly configured. On Settings->Domain Module Behaviours->New content settings I have selected, "Only show on selected sites", and on Node Settings->Domain Node Types, I have both article and page unchecked.
Debug mode shows "All affiliates" assigned.
In respect to the teaser they appear in all front pages of all domains and for all users. As if all affiliates is assigned.
But as I mention, for non admin users, when you visit those nodes work as if they had not "all affiliates" assigned, being able to see the complete article in domains it has been published to, but getting the access deny page on domains the article has not been published too.
Admin user, on the other hand, can visit those nodes from all of the domains as if "all affiliates" were assigned, even with "Restrict node views for administrators".
Comment #9
agentrickardAlso make sure you didn't turn on Domain Strict by accident. That would explain this behavior.
Comment #10
manfer commentedThe only module enabled is Domain Access.
Domain Strict or any other Domain Access submodule are all disabled.
Comment #11
agentrickardThanks. Any other modules that might interfere?
Comment #12
manfer commentedNo, it is a drupal7-alpha3 installation with only Domain Access installed.
The only change to the default drupal installation is finally I disabled overlay. Other than that the only modules installed are the default drupal core modules.
No other module has been installed. No one, even no one installed and uninstalled.
Only domain package was uploaded and domain access installed.
Comment #13
agentrickardI think Devel Node Access is working for D7. Install Devel module and see what it tells you.
Comment #14
manfer commentedOk, I attach two screenshots with all the information I can gather with devel node access and domain access information blocks. And here is the rest of information to better understand all the info in screenshots.
Tests system: Drupal7-alpha3 (overlay disabled), with modules Domain Access 7.x-2.0-beta1 (only domain access enabled), and Devel 7.x-1.0-beta1 (only devel node access enabled).
Domain Access installation: modified function domain_unserialize in domain.bootstrap.inc, it directly returns unserialize object instead of passing it first throuhg pg_unescape_bytea.
Domain Access Settings: "Only show on selected sites" with all domain node types unchecked in node settings.
Custom Roles: "editor" with permissions "Publish content to any assigned domain", "Create new Article content", "Edit own Article content" and "Delete own Article content".
Users: "manfer" is user1, "prueba" and "fernando" are editors.
Actual domain: Two.
Actual node: "Solo en Two" published by user "prueba" only to domain "Two".
-------------------------------
When user "prueba" creates content he is presented with the correct affiliate publishing options form where he only can choose which domains to publish from those he has assigned.
When user "prueba" edits the node "Solo en Two":
-------------------------------
Comment #15
manfer commentedThis is really annoying, I even can't believe it I have not idea what is happening.
But after installing devel node access, I decided to publish with that user a new article to only one domain (domain One). It finished with:
After that surprise, I even published another article to only one domain with same user (this time domain Two). It finished with:
Since that moment it started to work as expected.
So, I was totally confused, again thinking I'm making some mistake, I decided to start from scratch. I deleted the database and drupal files and started a new install. Well, the test confirmed in the new install with all configuration looking totally correct, the problem appears. And again any article published finishes with the wrong:
And what it is worst as explained in some of the above messages not working exactly like that all affiliates setting indicates, because when visiting those nodes from a different domain than One you get to an access deny page.
-----------------
So it seems, but I don't know how, in some moment the problem dissapears. So it can be only experimented in a recent installation.
Comment #16
manfer commentedAnd maybe finally I found a possible reason.
When you first install the module, when you start configuring it, if you visit the node settings, the domain node types appear all unchecked, what looks correct. But it seems though they appear unchecked they are working as if they where checked on a fresh installation. Could this be possible?
I checked domain node types and saved, then I unchecked them again and saved, after that it appears to work correctly. (I don't know if it would be enough to just click save when they first where unchecked, I decided to first check them to be sure)
Hope this help.
Comment #17
agentrickardThat last bit does make sense and needs more testing. Thanks.
Comment #18
manfer commentedThis time, as it looks at least I found something that could be the problem I did an easy test.
I disabled and uninstalled domain access. Then enabled it again and start adding domains, adding the permission to the role, assigning domains to user, and configuring domain access with "show only selected domains" and going to node types. Node types again looks correct with no domain node types selected, so I do nothing there.
That way again I can confirm it does not work correctly.
Then I go again into node settings and this time directly I click "Save configuration". (no need to first check them, save the configuration, and uncheck them and save configuration again). And that solves the problem again.
So it is clear that even on fresh install of the module no domain node types appear checked in node settings, they are working as if they where. And until you save that configuration the module does not work as expected.
Maybe now it is easy to track on code why this happens, looking at how those configuration node settings are stored.
Most probable if they are not present at all in database, the node settings configuration form show them as unchecked, but the rest of the module logic works as if they were checked if those settings are not present on database. If so, on install those settings should get default values to prevent this issue. But I haven´t looked to code to confirm if it is exactly what it is happening.
Comment #19
manfer commentedThe first time when the module has just been installed those checkboxes get a value of TRUE, FALSE, 1 or 2 depending on the value of constant DOMAIN_INSTALL_RULE and depending on domain_behaviour having a value or not.
TRUE is not interpreted as checked, 2 is not interpreted as checked either, neither FALSE. So the domain node types form show those checkboxes unchecked if they have no value yet unless Domain behaviour had been configured before and with value "Show on all affiliates sites" (value 1).
The issue comes from:
That $default variable is going to get as value DOMAIN_INSTALL_RULE (TRUE or FALSE) if domain_behavior is still not set. If domain_behaviour is set, that $default variable is going to get value 1 (if "Show on all affiliate sites" is selected on radios) or 2 (if "Only show on selected sites" is selected on radios).
I don't know exactly what is your intention exactly, so I'm not sure which is the best solution. But as you can see, when 'domain_node_' . $key has not value yet, '#default_value' can have four posible totally different values (TRUE, FALSE, 1 or 2) because it get the value of $default variable. I would need to know which is the correct logic pretended to know the correct solution.
What I can see is that if those values ('domain_node_' .$key) are not set the module is working as if they were checked. So they should be presented checked them. And maybe, I'm not sure that does not depend on domain_behaviour having a value or not (domain_behaviour could have been configured before node settings), but only on the value of DOMAIN_INSTALL_RULE. Maybe line 592 could be just:
but I don't know, maybe there is more to look somewhere else and not only to this form generation part of domain_access code. Anyway, at least this part must be reviewed.
-------------------------------------------------
On line 176 there is similar code too that applies a default value based on that constant.
I don't know there which is again the intended logic. But if I look to $options I see those radios can have value 1 or 2. If the intended logic is to set "Show on all affiliate sites" when DOMAIN_INSTALL_RULE is TRUE and set "Show only on selected sites" when DOMAIN_INSTALL_RULE is FALSE, when domain_behaviour still has not a value, I think the correct code would be:
-------------------------------------------------
Comment #20
manfer commentedWell, not exactly. TRUE is valid for checkbox as well as 1, so the problem appears when you configure first the Domain behaviour to "Only show on selected sites" (value 2). It is when, if 'domain_node_' .$key hasn't still a value, it gets the value of $default variable that is going to be 2 (the value of domain_behaviour). That time is when the form shows the checkboxes unchecked, but internally for the module logic it is treating those as checked.
It doesn't change anyway what I comment, I wonder if it would be correct the suggestion of:
being possibly the alternative correct code, because I don't think the default value to be assigned to 'domain_node' .$key when it has not value yet on database, should depend on the value of domain_behaviour variable.
Comment #21
agentrickardI see it now.
A _much_ easier way to report the problem is:
If you set the Domain Behaviors to 'Only show on selected sites' before editing the node-specific settings per node type, then the form for setting those values is given the wrong default and does not work properly.
I see the problem. This likely always existed and I am surprised no one ever caught it.
Comment #22
manfer commentedYes maybe it is time to change the issue title I really don't know exactly what to write. What you suggest looks a little long I think. :)
Lots of tests to understand what was happening or I would have put that title the first time. :)
Please, have a look too to what I mention at the end of #19. I don't understand that default value for domain_behaviour either. The radios posible values are 1 or 2. But the default value that is going to be applyed when domain_behaviour still has no value is TRUE or FALSE. I think TRUE is going to select the first radio "Show on all affiliate sites" but FALSE makes no sense in my opinion, probably in that case it is going to show none of the radios selected.
So if the pretended logic is what I describe in #19, I suggest in that comment what I think would be the correct code.
Hope it helps and sorry for such a large issue, and some of the comments maybe wrong but I was totally confused about what could be happening. :)
Comment #23
manfer commentedI was trying to understand the logic so I looked into domain.module and found this on line 1534:
It seems $node->domain_site is pretended to have one of two values if I'm not wrong, TRUE or FALSE. (Though a little later on the code the check done on that variable is a !empty ???)
I don't understand and as I don't know what is pretended, which is the logic behind, I can't understand it better.
The only think that came to my mind looking to that code is this. Wow, but that really seems to only consider domain node types settings when they are configured. It does not seems to matter at all the domain behoviour when domain node types settings are configured.
So I did a test. With the domain node types unchecked and domain behaviour as "Show on all affiliate sites" what happens? And what happens is that only node type setting is taken into account and when you publish to only one domain it is published in only one domain and won't show on all affiliates.
And to try to understand if that was something that would only happen to a user with the "to assigned domains" permission, I decided to test with a user with only the permission "from default domain". What happens? The article this user publish from default domain is only shown on the default domain, again "Show on all affiliate sites" seems to mean nothing at all for that user when the domain node type is unchecked.
And finally a last test with a user with no domain access permissions and only permissions to publish articles. This user can publish articles from whatever site and they are published to that specific site.
So now what I don't understand at all is what Domain Behaviour is for and when it is taken into account. I was understanding it was a setting that had preference over node type settings but it seem not so. Maybe it is for something totally diferent.
Comment #24
DynamicFred commentedunsubscribe please.
Comment #25
agentrickardPatch? Please? No more talk.
Comment #26
agentrickardInteresting. This doesn't affect D6 or D5. Looks like stricter type handling for checkboxes in D7.
Comment #27
agentrickardThe attached should address (albeit in an ugly way) all the issues raised here.
Comment #28
agentrickardLast patch has a logic flaw.
Comment #29
manfer commentedI would try to get a deeper look on the code if posible. Now I have read carefully all the documentation.
Only by now what I'm thinking is why the domain_behaviour radios have values 1 or 2, why not, 1 or 0 (in that order because I'm looking you maybe want 1 to mean, show on all affiliates, and 0 the other option). Radios accept perfectly 0 as one of its options. Even that input could be just a checkbox (checked meaning show on all affiliates, unchecked the other option, only needing a little change on the description).
Comment #30
agentrickardI don't want to retroactively fix that now. I just want to know if the patch fixes the problem.
Essentially, this only surfaced in D7 because it doesn't show "2" as a checked settings option on the node settings page. In D5 and D6, these appeared as checked, so users unchecked them and saved the settings.
Your issue came about because they appeared unchecked, so you don't think you needed to save the form, so the default (wrong) value was applied.
Comment #31
manfer commentedOk, then i try the patch on head and tell you or on beta-1?
Comment #32
agentrickardHEAD. Though it should apply pretty cleanly to beta-1.
Thanks.
Comment #33
manfer commentedTested with patched HEAD.
Yes that patch solves the problem with the defaults when domain node type settings are not configured.
Now on fresh install and when you don't configure domain node type settings at all, if "New content settings" is set to "Show on all affiliates" if you visit node settings (just visiting those settings to look at them not saving) they appear checked and if you start publishing works like that, on the other hand if "New content settings" is set to "Only show on selected sites" and you visit node settings they appear unchecked (as before the patch) and now if you start publishing works as expected too (before the patch this case was not working properly).
But that was not the only issue I was experimenting here. There is other one and it is still present.
As soon as you configure domain node type settings, that is the only configuration taken into account and "New content settings" is not taken into account any more. Reading the documentation very carefully and reading the description of "New content settings" field, it all indicates "New content settings" should be taken into account first. I mean if "Show on all affiliates" is what is configured on "New content settings" it should no matter what is configured on domain node types, the published content should appear on all sites (that's what I understand). But that's not so. If you configure "New content settings" as "Show on all affiliates" but you configure domain node type as unchecked, the content is not published or shown on all affiliates (only node type is being taken into account, "New content settings" is not taken into account at all).
I'm sorry if this is confusing and maybe should be published as different issues. Maybe they can be considered only one with a title like "Domain behaviour and domain node types not working always as expected".
And I'm sorry if I'm wrong about this but that is what I understand reading carefully and some times both the documentation:
and the "New content settings" description:
Comment #34
agentrickardNo, that makes sense. The global override should take precedence.
Comment #35
agentrickardTry this one.
Comment #36
manfer commentedYes it works. Tested again defaults and works fine. And this one solves too the problem with the precedence of "New content settings" when domain node type settings are saved.
Comment #37
agentrickardNice. This is a legacy of some old code that worked in D6. The stricter form handling in D7 breaks it. When we move to 7.x.3 and do API changes, we should clean this up a bit.
Thanks for hanging in on this one!
Committed to HEAD.
Comment #39
mikeytown2 commentedSame notices in 6.x
Notice: Undefined property: stdClass::$nid in domain_form_alter() (line 1898 of sites/all/modules/domain/domain.module).
Notice: Undefined property: stdClass::$domain_site in domain_form_alter() (line 1921 of sites/all/modules/domain/domain.module).
Comment #40
agentrickardWe don't enforce strict error handling in the 6.x branch.
Comment #41
agentrickardisset() is not correct. New nodes have that value set, but it is empty. Use !empty(). Same for domain_site. This could would accidentally send things to all affiliates.
Comment #42
mikeytown2 commentedThanks for the pointer; leaving this file here in case anyone else wishes to patch.
Comment #43
agentrickardSince you went to the trouble to write the patch, I'll commit it and roll into the next maintenance release.
Comment #44
mikeytown2 commentedOver the weekend with #42 applied I still get notices like this one
Notice: Undefined variable: raw_options in domain_form_alter() (line 1899 of sites/all/modules/domain/domain.module).
isset check on $raw_options, or should I look elsewhere?
Comment #45
agentrickardA little higher up. We need to define that array before using it:
Comment #46
mikeytown2 commentedComment #47
agentrickardUpdated slightly for new commits.