You are here

function webform_client_form_validate in Webform 5

Same name and namespace in other branches
  1. 5.2 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 1421

Code

function webform_client_form_validate($form_id, $form_values) {
  global $user, $base_url;
  include_once drupal_get_path('module', 'webform') . "/webform.inc";
  $node = node_load(array(
    'nid' => $form_values['details']['nid'],
  ));

  // Flatten trees within the submission.
  $form_values['submitted_tree'] = $form_values['submitted'];
  _webform_client_form_submit_flatten($node, $form_values['submitted'], $form_values['submitted']);

  // Verify that this submission is within the submission limits on this form.
  if ($violation_count = _webform_submission_limit_check($node, $form_values) && !$form_values['details']['sid']) {

    // If the webform is being swamped by repeated entries, limit the messages in watchdog.
    if ($violation_count < 21) {
      if ($user->uid > 0) {
        watchdog('webform', t('The authenticated user <a href="%user_url">%username</a> attempted to submit more entries than allowed on the <a href="%webform_url">%webform_title</a> webform', array(
          '%user_url' => url('user/' . $user->uid),
          '%username' => $user->name,
          '%webform_url' => url('node/' . $node->nid),
          '%webform_title' => $node->title,
        )), WATCHDOG_WARNING);
      }
      else {
        watchdog('webform', t('An anonymous user with IP address %ip attempted to submit more entries than allowed on the <a href="%webform_url">%webform_title</a> webform', array(
          '%ip' => $_SERVER['REMOTE_ADDR'],
          '%webform_url' => url('node/' . $node->nid),
          '%webform_title' => $node->title,
        )), WATCHDOG_WARNING);
      }
    }
    form_set_error('', t("You have submitted the maximum number of entries. Check submission guidelines."));
  }
  if (trim($node->additional_validate)) {

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