You are here

function domain_source_node_validate in Domain Access 7.3

Same name and namespace in other branches
  1. 7.2 domain_source/domain_source.module \domain_source_node_validate()

Implements hook_node_validate().

File

domain_source/domain_source.module, line 162
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;
  }
  $key = $node->domain_source;
  $default = domain_default_id();

  // 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) {

    // Any assignment is acceptable if sent to all affiliates.
    // 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.'));
  }
}