Hi,
the access rules for Domain Access are not working in panels.
Szenario 1:
- Main Access restricted to certain domains.
- Result: Access denied on all domains.
Szenario 2:
- Main access open to all domains
- Panel 1 access restricted to a certain domain.
- Panel 2 access restricted to a different domain
- Panel 3 ....
- Result: Panel 1 visible on all domains
This behaviour can be reproduced on different new drupal installations.
Tested with:
- Panels 7.x-3.0-alpha3
- Domain Access 7.x-3.0-rc4
- Domain Ctools 7.x-1.2
AND
- Panels 7.x-3.0-alpha3
- Domain Access 7.x-3.0-rc2 (which was actual release while Domain Ctools 1.2 was released)
- Domain Ctools 7.x-1.2
Works as expected only with:
- Panels 7.x-3.0-alpha3
- Domain Access 7.x-2.15
- Domain CTools 1.1
Hope this helps.
Kind regards
Jan
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | 1322100-ctools-access.patch | 1.92 KB | agentrickard |
| #14 | 1322100-ctolls-access.patch | 1.92 KB | agentrickard |
| #13 | 1322100-ctolls-access.patch | 1.78 KB | agentrickard |
| #10 | panelexport.txt | 5.61 KB | jan.s |
Comments
Comment #1
jan.s commenteddomain.inc line 102:
if ($key == $_domain['machine_name']) {must be
if ($value == $_domain['machine_name']) {Can anybody confirm please.
Comment #2
agentrickardPlease keep a meaningful title.
Comment #3
agentrickardWhen did you configure this code? That is, is this an exported Panel rule set?
The error has to do with trying to use machine_name key settings (7.x.3) vs. numeric keys (7.x.2).
Can you please post the export of this access rule. (Or the entire panel.)
Comment #4
jan.s commentedI first postetd it has to be
if ($value == $_domain['machine_name']) {but it must be:
if ($value === $_domain['machine_name']) {(Don't know exactly why, but the first code gives me a (0 == "domain_1") is true. I'm confused, but with type checking (===) it works fine.)
I will write more in a few minutes.
Comment #5
jan.s commentedThank you for your quick reply and changing the title back (thought it was the title for the comment).
Let me explain without the panels export (it is ok), that might be more helpful:
Look at function domain_ctools_domain_access_check($conf, $context, $plugin) in domain.inc.
If you var_dump the $conf variable you get something like this, if the second domain is selected:
While looping through the conf['domains'] you get the $key and $values, but for 7.x.3 support you can see the code:
Lets assume you load this page from "domain 1" but the first panel is configured to appear on "domain 2".
So this function is called for the first panel. Now the loop runs and will get a TRUE when the loop reaches the first domain, because the $key is definitly the domain machine name (see the array dump above). -> Panel 1 is displayed, but thats not correct.
You must check for the $value to be the domain machine name (and not 0). In this example "domain_1" is not existent in any $value, so the panel is not displayed.
If you load this page on "domain 2", the loop checks for the $value "domain_2" and it gets a true in the second loop. -> Panel will be displayed.
If you want to get my panel export anyway let me know.
Comment #6
agentrickardWhat I am saying is that with 7.x.3, I expect $key to be a string, not an integer. But the === is likely necessary.
Comment #7
jan.s commentedYes, with 7.x.3 $key is a string.
Nevertheless in the 7.x.3 loop the $value must be compared to the domain machine name, not the $key. The problem itself is caused by that, not by the format of the $key index.
Comment #8
jan.s commentedDon't know the $conf array of 7.x.2, maybe it is neccessary to check still for $key to be string, so that the right code for 7.x.3 is used.
So I think it should be
Comment #9
agentrickardI think you are correct about the ===, I'm just looking for information so I can duplicate the problem. An export of the access rule would be very helpful in that regard.
Comment #10
jan.s commentedThe panel export is attached, I renamed the domains to "domain1_de", "domain2_de" and "domain3_de".
Here an excerpt of the rule for the first panel (for domain1).
Comment #11
agentrickardThanks. I think your original patch is likely correct.
Comment #12
jan.s commentedI think #8 would be a better solution to respect Domain Access 7.x.2. But I didn't test it.
Comment #13
agentrickardI refactored the code to be a little more clear. array_filter() can rip out the 0 records, and we explicitly check the expected version of the key,
Comment #14
agentrickardThat last patch isn't quite right, because it doesn't account for cases where access rules were exported in 7.x.2 and applied in 7.x.3.
Comment #15
jan.s commentedSeems to work.
Testet with:
- Domain Ctools 7.x-1.2
- Domain Access 7.x-2.15
AND
- Domain Ctools 7.x-1.2
- Domain Access 7.x-3.0-rc4
Comment #16
agentrickardMinor re-roll for better comments. Committed and new release rolled.
Comment #17
agentrickardComment #18
jan.s commentedNew release tested. Seems to work.
Thank you!
Comment #18.0
jan.s commentededit