function domain_node_load in Domain Access 7.3
Same name and namespace in other branches
- 7.2 domain.module \domain_node_load()
Implements hook_node_load().
1 call to domain_node_load()
File
- ./
domain.module, line 1721 - Core module functions for the Domain Access suite.
Code
function domain_node_load($nodes, $types) {
// Get the domain data.
$domains = domain_get_node_domains($nodes);
foreach ($nodes as $node) {
// Cannot load if the node has not been created yet.
if (!isset($node->nid)) {
continue;
}
// Get default settings.
$defaults = domain_get_node_defaults($node->type);
// Append the domain grants to the node for editing.
$nodes[$node->nid]->domains = isset($domains[$node->nid]['domain_id']) ? $domains[$node->nid]['domain_id'] : array();
// If the node is not assigned, grant to all domains to prevent errors.
$nodes[$node->nid]->domain_site = isset($domains[$node->nid]['domain_site']) ? $domains[$node->nid]['domain_site'] : $defaults['domain_site'];
$nodes[$node->nid]->subdomains = array();
if (!empty($nodes[$node->nid]->domain_site)) {
$nodes[$node->nid]->subdomains[] = t('All affiliates');
}
if (!empty($nodes[$node->nid]->domains)) {
foreach ($nodes[$node->nid]->domains as $gid) {
$domain = domain_lookup($gid);
$nodes[$node->nid]->subdomains[] = $domain['sitename'];
}
}
else {
$nodes[$node->nid]->subdomains[] = t('This node is not assigned to a domain.');
}
}
}