Content for all affiliate sites filtering problem
ariflukito - September 10, 2008 - 04:46
| Project: | Domain Access |
| Version: | 6.x-1.2 |
| Component: | - Domain Content |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
Running filter on this page "Content for all affiliate sites" showing nodes from primary domain
For example
content for all affiliate sites:
- node A
contents for primary domain
- node B
- node C
Step to reproduce:
- Go to content for all affiliate sites -> showing only node A
- click on filter -> node B and C are showed now
Also I think content for primary domain page should not show nodes for all affiliates

#1
This doesn't make any sense to me. Can you try describing it more clearly, please.
#2
Here I provide screenshots
- first one is not filtered
- second one is filtered (first and third in the list shoudn't be there)
#3
Can you list the steps to replicate? I tried earlier and could not.
Do you have any special permissions (administer nodes)?
#4
That's weird, I can reproduce it reliably.
Just need to do the 2 simple steps I listed above. Make sure you have nodes assigned to primary domain only.
Special permission? The user has edit domain nodes permission and use access controls for editor is turned on.
Otherwise I cannot open the page.
edit:
if you log in as user with restricted permission, you need to be in primary domain to reproduce it
if you log in as admin, you can reproduce it regardless what domain you are in
#5
ok I found out what the problem was, see the attached patch for fix.
now I'm thinking on the second problem I mentioned above
ie: the content for primary domain page listing all affiliates content nodes (see attached pic)
The 2nd row should not be there. Here is the problem, if you look at the node_access table we have this
nid | gid | realm-------------------------------
1 | 0 | domain_id
2 | 0 | domain_id
2 | 0 | domain_site
3 | 0 | domain_id
and the sql where clause is "WHERE nac.realm = 'domain_id' AND nac.gid = 0"
but we are not interested on node 2
my suggestion is change the query to the following:
select count(*) as cnt, * from {from clause}where nac.gid = 0
group by nac.nid
having cnt = 1 and nac.realm = 'domain_id'
so that the above query only return node 1 and node 2
#6
@ariflukito.
Replying to your first post...
did u see whether the particular content type you filtered is enabled in tyour domain access -->node settings.
If its enabled as what is said'Check the content types that should be published to all affiliates when new content is created. 'i think, the content will be naturally shown in the filter results.
#7
I think the page is behaving as expected. The question is why do you have a node assigned to domain_site (or domain_id) when you do not want them to be?
#8
@nirvanajyothi
thx, but that's not the problem, the problem was contents NOT for all affiliates site showing on Content for all affiliate sites page (after you do filtering).
but I managed to fix it already, the patch is on #5
here is the original code
<?phpif (empty($filter['where'])) {
$filter['where'] = " WHERE nac.realm = 'domain_site' AND nac.gid = 0 ";
}
else {
$filter['where'] .= " AND nac.realm = 'domain_id' AND nac.gid = 0 ";
}
?>
the nac.realm on else block should be 'domain_site'
@agentrickard
Are you referring to my 2nd issue?
The problem is if a node is set up like this:
Publishing options:
[x] Send to all affiliates
Select if this content can be shown to all affiliates. This setting will override the options below.
Publish to: *
[x] Drupal
[ ] Drupal A
[ ] Drupal B
The node access table will have 2 rows for the same nid and gid (0), one with realm = 'domain_id' and the other with realm = 'domain_site'.
So if you select "WHERE nac.realm = 'domain_id' AND nac.gid = 0", this node will get selected.
What we want is nodes that are assigned to domain_id 0 only, without having domain_site entry.
Based on my example on #5.
The current situation is if you go to primary domain content page, node 1, 2 and 3 will be listed (as seen in the screenshot).
And what I think it should be is only node 1 and node 3 should be listed there.
I hope I explain it clearly.
#9
"What we want is nodes that are assigned to domain_id 0 only, without having domain_site entry. "
No. This is where I think you are wrong. The node shows up and is marked that it belongs to both, but it doesn't show up under domain 1 or domain 2, which would be wrong. The behavior would be wrong if the node were marked "All affiliates" and appearing on a domain_id that it was not assigned to.
Nodes are always assigned to a domain_id and they _may_ also be assigned to 'all affiliates.' The 'All affiliates' flag in this case is just a marker to remind you that the content is assigned to both. It does not, in fact, affect the query.
Remember that it is the domain_id that allows editing privileges, so that is why the query is written that way. Any other information is just there as a guide to help the editor.
Take a look at the attachments below. domain_0.png is perfectly correct. There is only an issue if nodes assigned to domain_0 also appear under domain_1.
Try assigning a node to two domains, and you will see why this behavior is the way it is. (As shown in two_domains.png). To remove a node from one list just because it belonged also in another list would be very wrong.
#10
I was also confused by the use of 'fliter' here -- you mean "Change to an affiliate domain" and not "use the node filter form at the top of the page." Right?
#11
#12
@#10
no the later one "node filter at the top of the page"
<?phpif (empty($filter['where'])) {
$filter['where'] = " WHERE nac.realm = 'domain_site' AND nac.gid = 0 ";
}
else {
$filter['where'] .= " AND nac.realm = 'domain_id' AND nac.gid = 0 ";
}
?>
see that above if you use the filter the nac.realm changed to 'domain_id'
#13
@#9
ah ok forget everything that I said before, the thing I want to question is domain_0.png. If nodes for affiliate sites showing up on domain_0, why they are not showing up on domain_1 and domain_2.
All affiliates option should override any other option right, so I think domain content should respect that by not showing nodes for all affiliate sites on domain_id page (domain_0, domain_1, domain_2).
#14
change status back to active because I think #12 is a real bug
#15
This is the clearest statement I can make:
"Remember that it is the domain_id that allows editing privileges, so that is why the query is written that way. Any other information is just there as a guide to help the editor."
THe purpose of Domain Content is to let editors with limited access -- that is, people without 'administer nodes' -- quickly find the content that is assigned to them. The obvious way to do this is by domain_id. If we showed content assigned to 'all affiliates' on all pages, then editors would (in most cases) be overwhelmed by content that they _cannot_ edit, which would defeat the purpose.
Now I see the error in the node filter -- it applies only to the 'All affiliates' page, and should be (as stated in #8):
// Or check the domain_site grant.if (empty($filter['where'])) {
$filter['where'] = " WHERE nac.realm = 'domain_site' AND nac.gid = 0 ";
}
else {
$filter['where'] .= " AND nac.realm = 'domain_site' AND nac.gid = 0 ";
}
(This is a copy/paste error that I failed to correct.)
#16
Fix committed to HEAD.
#17
Committed to 5.x
#18
thx for the fix.
As for the other one I think I understand now. Not all editors can edit contents for all affiliates. Only if the content is assigned to the domain where the editor has editing grant on that domain.
Sorry for the confusion.
#19
Right. And the real patch got lost in the confusion....
Nice catch, though!
#20
Automatically closed -- issue fixed for two weeks with no activity.