function domain_source_node_validate in Domain Access 7.2
Same name and namespace in other branches
- 7.3 domain_source/domain_source.module \domain_source_node_validate()
Implements hook_node_validate().
File
- domain_source/
domain_source.module, line 154 - Creates a source domain for linking to content from other domains.
Code
function domain_source_node_validate($node, $form) {
// If not set, we ignore.
if (!isset($node->domain_source)) {
return;
}
// Cast the key from zero to -1 to match the data coming from the input.
$node->domain_source == 0 ? $key = -1 : ($key = $node->domain_source);
// Check the domain and domains_raw variables to set up the allowed source list.
$allowed = array();
if (!empty($node->domains)) {
$allowed = $node->domains;
}
if (!empty($node->domains_raw)) {
$allowed = array_merge($allowed, $node->domains_raw);
}
if ($node->domain_site && $key == -1) {
// This case is acceptable, so we let it pass.
// I find this code easier to read than a compound IF statement.
}
elseif ($node->domain_source != DOMAIN_SOURCE_USE_ACTIVE && !in_array($key, $allowed)) {
form_set_error('domain_source', t('The source affiliate must be selected as a publishing option.'));
}
}