Superfish and Domain Access: (un)Sharing Fusion Links
Further research into my issue of missing menu-item links revealed that there is a problem with the Superfish jQuery flyout menu script when it comes to Domain Access and domain nodes. I brought this up with the maintainer a while back, but I've been using these menus more and more so I had to come up with my own solution.
Essentially, the problem is that Superfish is creating links before checking the domain_access table to see if the resulting node is visible to any given domain. With the menu_item_link theme hook, I created my own query as an extra check before rendering the links.
$domain_id = domain_get_domain();
// Find the nodes visible to this domain or all affiliates
$link_query = 'SELECT a.gid, a.nid FROM node n JOIN domain_access a WHERE n.nid = a.nid AND ((a.gid = ' . $domain_id['domain_id'] . ' AND realm = "domain_id") OR gid = 0)';
$link_result = db_query($link_query);
$xlinks = db_result($link_result);
// Build an array of all possible valid links
while ($row=db_fetch_array($link_result)) {
$nids[] = $row['nid'];
}
At this point we have a handy array of valid node ID's that we can use to verify each link.
if ($link['type'] & MENU_IS_LOCAL_TASK) {
$link['title'] = '' . check_plain($link['title']) . '';
$link['localized_options']['html'] = TRUE;
return l($link['title'], $link['href'], $link['localized_options']);
}
// Add an extra domain visibility check to hide erronous superfish links
elseif (in_array(str_replace("node/", "", $link['href']), $nids)) {
return l($link['title'], $link['href'], $link['localized_options']);
}
// If the link isn't found in the array, unset
else {
unset($link);
}
This is an imperfect solution as some shared Superfish flyouts sometimes inherit blank space for the nodes, even though the link is not rendered. Clear cache if in doubt. I may improve upon this later, or perhaps the module maintainer will address the issue in an upcoming release, but it's doing the job for me right now.