You are here

function resource_conflict_node_validate in Resource Conflict 7.3

Implements hook_node_validate().

Fire a rule event if this node is enabled for RC. If the Rule executed our action "resource_conflict_form_error" Then a session var would have been set that indicates there was a conflict and we should set a form error.

File

./resource_conflict.module, line 16
Provides general functionality for the resource conflict module.

Code

function resource_conflict_node_validate($node, $form, &$form_state) {

  // Don't validate on delete.
  if (isset($form_state['values']['op']) && $form_state['values']['op'] == t('Delete')) {
    return;
  }

  // Conflict handling is not enabled for this content type.
  if (!variable_get('rc_type_' . $node->type, FALSE)) {
    return;
  }
  rules_invoke_event('resource_conflict_node_validation', $node, $form);
  if (isset($_SESSION['resource_conflict_message'])) {

    // Find the date field that handles conflicts.
    $message = implode('<br>', $_SESSION['resource_conflict_message']);
    form_set_error('', $message);
    unset($_SESSION['resource_conflict_message']);
  }
}