You are here

function path_redirect_edit_form_validate in Path redirect 6

File

./path_redirect.admin.inc, line 446
Administrative page callbacks for the path_redirect module.

Code

function path_redirect_edit_form_validate($form, &$form_state) {
  $redirect =& $form_state['values'];
  if ($existing = path_redirect_load_by_source($redirect['source'], $redirect['language'])) {
    if ($redirect['rid'] != $existing['rid'] && $redirect['language'] == $existing['language']) {

      // The "from" path should not conflict with another redirect
      form_set_error('source', t('The source path %source is already being redirected. Do you want to <a href="@edit-page">edit the existing redirect</a>?', array(
        '%source' => $redirect['source'],
        '@edit-page' => url('admin/build/path-redirect/edit/' . $existing['rid']),
      )));
    }
  }
  if (!valid_url($redirect['redirect']) && !valid_url($redirect['redirect'], TRUE) && $redirect['redirect'] != '<front>') {

    //form_set_error('redirect', t('The redirect <strong>to</strong> path does not appear valid.'));
  }

  // check that there there are no redirect loops
  if (url(drupal_strtolower($redirect['source'])) == url(drupal_strtolower($redirect['redirect']))) {
    form_set_error('redirect', t('You are attempting to redirect the page to itself. This will result in an infinite loop.'));
  }
}