function domain_content_update_nodes in Domain Access 7.3
Same name and namespace in other branches
- 5 domain_content/domain_content.module \domain_content_update_nodes()
- 6.2 domain_content/domain_content.module \domain_content_update_nodes()
- 7.2 domain_content/domain_content.module \domain_content_update_nodes()
Abstraction function that lets us update access rules.
1 call to domain_content_update_nodes()
- domain_content_process_nodes in domain_content/
domain_content.module - Process the form submission.
File
- domain_content/
domain_content.module, line 268 - Editorial overview module.
Code
function domain_content_update_nodes($nids, $options) {
// If our operation is run, then we have to manually change the
// {node_access} table. The rest of the process will clear the cache,
// so this should be a safe operation.
$domain_site = $options['domain_site'];
$behavior = $options['behavior'];
foreach ($nids as $nid) {
$domains = $options['domain_id'];
// Other modules need to respond, we have to load the full node.
$node = node_load($nid);
// Make sure the node is valid.
if ($node->nid > 0) {
// If modifying values, do so here.
if (!empty($behavior)) {
$current = domain_get_node_domains($node->nid);
// Add values to the current set.
if ($behavior == 1) {
if (!empty($current['domain_site'])) {
$domain_site = TRUE;
}
$domains += $current['domain_id'];
}
else {
foreach ($domains as $domain_id) {
if (isset($current['domain_id'][$domain_id])) {
unset($current['domain_id'][$domain_id]);
}
}
$domains = $current['domain_id'];
// If all affiliates is selected, remove it.
if ($domain_site) {
$domain_site = FALSE;
}
}
}
// Use our new options, as set above.
$node->domain_site = $domain_site;
$node->domains = $domains;
// Delete our grants and rebuild.
node_access_acquire_grants($node);
}
}
// Clear the cache.
cache_clear_all();
}