Redirect nodes when inactive domain selected as source
BWPanda - August 31, 2009 - 02:35
| Project: | Domain Access |
| Version: | 6.x-2.x-dev |
| Component: | - Domain Source |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
Here's a scenario:
You create a node and assign it to domain_1 and domain_2. Domain_1 is active, while domain_2 is inactive. When you try to view the node, it attempts to take you to domain_2's site to view it, but as it's inactive, it just takes you to the primary domain's homepage.
Because this node is also available on domain_1, which is active, I think it'd be nice if it took you to domain_1 to view the node, until domain_2 becomes active...
The pseudo-code might be something like this:
get source_domain
if source_domain inactive
get array of other assigned_domains
foreach assigned_domains
if assigned_domain active
domain = assigned_domain
end if
end foreach
else
domain = source_domain
end if
view node at domainThoughts?

#1
Well, this is avoidable now, using Domain Source, but you're asking for a fallback protection as well? We typically don't do such redirects for individual nodes.
#2
In that case, how about limiting the Domain Source selection to only active domains...?
#3
That seems reasonable to me, except that active/inactive can change, so the first option may be better.
Other opinions.
#4
Hm. This is a sticky problem. The issues are:
1) Sometimes we want to assign nodes to inactive domains (for staging purposes).
2) The function that changes the link path is in custom_url_rewrite_outbound(), and hard to change.
3) The custom_url_rewrite_outbound() output would be cached, so having a permission-based change here really won't work.
4) It is also too late to handle this in hook_nodeapi().
The only options seem to be:
a) Do nothing
b) Restrict source to valid only (which I don't like)
c) Try to intercept things in hook_boot() or hook_init() to prevent the redirect to the primary domain.
I don't like any of these options. c) would introduce overhead.
#5
Hm. Well, we really can't have Domain Source pointing to an invalid domain. Two patches here.
1) Simply remove the invalid nodes from Domain Source. This will require #540684: Set active domain as source to be valid.
Test this in 564070-source.patch
2) A larger fix for accessing invalid domains, which will likely go in. It passes the invalid request to the best natural matching domain.
Test this in big.redirect.patch.
#6
#7
The smaller patch has been committed.
#8
And the larger as well.
#9
I was testing HEAD without Domain Source enabled and gave a user 'access inactive domains permission'. Even though the user can browse content on this domain he is not able to publish to it despite of having set domain access permission. I'm a bit out of loop re latest fixes but it seems to contradict with the purpose of set domain access permission. Am I wrong or should I be looking for a bug?
#10
Looks like I missed two cases of the new permission.
#11
I just committed the above patch for testing.
#12
Patch applies and is correct.
This brings up another pet peeve of mine - there is no indication that the domain is inactive in the domain list. Perhaps we should have a theme fuction so that one could theme the displayed site name as they wish? I've altered it in the past in a custom module (sometimes sitename means less than its url for example).
#13
Huh? Status is a column in the domain list.
#14
A patch for theming the domain name would be separate. I would do something like:
theme('domain_name', $domain, $context);Where $context might indicate various display uses (like Domain Nav vs. the Domain List).
#15
#16
Let me clarify - when I mentioned domain list in #12 I meant the domain check boxes on node forms.
#17
We should do that in D7 and backport. We need a function that generates that list for you, since we use it in about 8 places right now.
#18
Automatically closed -- issue fixed for 2 weeks with no activity.