You are here

function webform_client_form_validate in Webform 5.2

Same name and namespace in other branches
  1. 5 webform.module \webform_client_form_validate()
  2. 6.3 webform.module \webform_client_form_validate()
  3. 6.2 webform.module \webform_client_form_validate()
  4. 7.4 webform.module \webform_client_form_validate()
  5. 7.3 webform.module \webform_client_form_validate()

File

./webform.module, line 1454

Code

function webform_client_form_validate($form_id, &$form_values) {
  $node = node_load(array(
    'nid' => $form_values['details']['nid'],
  ));
  $sid = $form_values['details']['sid'];

  // Check that the user has not exceeded the submission limit.
  // This usually will only apply to anonymous users when the page cache is
  // enabled, because they may submit the form even if they do not have access.
  if ($node->webform['submit_limit'] != -1) {

    // -1: Submissions are never throttled.
    include_once drupal_get_path('module', 'webform') . '/webform_submissions.inc';
    if (empty($sid) && ($limit_exceeded = _webform_submission_limit_check($node))) {
      $error = theme('webform_view_messages', $node, 0, 1, 0, $limit_exceeded, array_keys(user_roles()));
      form_set_error('', $error);
      return;
    }
  }

  // Flatten trees within the submission.
  $form_values['submitted_tree'] = $form_values['submitted'];
  $form_values['submitted'] = _webform_client_form_submit_flatten($node, $form_values['submitted']);
  if (trim($node->webform['additional_validate'])) {

    // We use eval here (rather than drupal_eval) because the user needs access to local variables.
    eval('?>' . $node->webform['additional_validate']);
  }
}