You are here

function login_destination_edit_form_validate in Login Destination 7

Validate the contact category edit page form submission.

File

./login_destination.admin.inc, line 509
Admin page callback file for the Login Destination module.

Code

function login_destination_edit_form_validate($form, &$form_state) {
  $destination = $form_state['values']['destination'];
  $destination_type = $form_state['values']['destination_type'];

  // Check user has enter any path.
  $available_urls = array(
    '<current>',
    '<front>',
  );
  if (empty($destination) || $destination_type != 0 || in_array($destination, $available_urls)) {
    return;
  }
  $destination = preg_replace("/\\?.+/", "", $destination);
  if (url_is_external($destination)) {
    return;
  }

  // Replace tokens.
  if (module_exists('token')) {
    $destination = token_replace($destination);
  }

  // Get source path if an alias entered.
  $source_path = drupal_lookup_path('source', $destination);
  if (!empty($source_path)) {
    $destination = $source_path;
  }
  if (!drupal_valid_path($destination)) {
    form_set_error('destination', t('Incorrect path, please enter a valid path.'));
  }
}