function domain_source_validate in Domain Access 7.3
Same name and namespace in other branches
- 5 domain_source/domain_source.module \domain_source_validate()
- 6.2 domain_source/domain_source.module \domain_source_validate()
- 7.2 domain_source/domain_source.module \domain_source_validate()
Form validation step
1 string reference to 'domain_source_validate'
- domain_source_form_domain_content_admin_alter in domain_source/
domain_source.module - Integrate with Domain Content.
File
- domain_source/
domain_source.module, line 310 - Creates a source domain for linking to content from other domains.
Code
function domain_source_validate($form, &$form_state) {
if ($form_state['values']['operation'] == 'domain') {
$default = domain_default_id();
$key = $form_state['values']['domain_source'];
if (!empty($form_state['values']['domain_site']) || $key == DOMAIN_SOURCE_USE_ACTIVE) {
// These cases are acceptable, so we let them pass.
// I find this code easier to read than a compound negative IF statement.
}
elseif ($key == DOMAIN_SOURCE_IGNORE) {
// In this case, we need to check all the selected nodes, which is resource intensive.
$nodes = array_filter($form_state['values']['nodes']);
foreach ($nodes as $nid) {
$key = domain_source_lookup($nid);
// Test for the first two behaviors, which add domains to the node.
$behavior = $form_state['values']['behavior'];
if ($behavior < 2) {
if (empty($form_state['values']['domains'][$key])) {
$node = node_load($nid);
form_set_error('domain_source', t('The source affiliate must be selected as a publishing option. %title is assigned to %domain.', array(
'%title' => $node->title,
'%domain' => $source['sitename'],
)));
}
}
elseif (!empty($form_state['values']['domains'][$key])) {
$node = node_load($nid);
form_set_error('domain_source', t('The source affiliate must be selected as a publishing option. %title is assigned to %domain.', array(
'%title' => $node->title,
'%domain' => $source['sitename'],
)));
}
}
}
elseif (empty($form_state['values']['domains'][$key])) {
form_set_error('domain_source', t('The source affiliate must be selected as a publishing option.'));
}
}
}