1 path.admin.inc path_admin_form_validate($form, &$form_state)

Form validation handler for path_admin_form().

See also

path_admin_form_submit()

path_admin_form_delete_submit()

File

core/modules/path/path.admin.inc, line 214
Administrative page callbacks for the path module.

Code

function path_admin_form_validate($form, &$form_state) {
  $source = &$form_state['values']['source'];
  $source = backdrop_get_normal_path($source);
  $alias = $form_state['values']['alias'];
  $pid = isset($form_state['values']['pid']) ? $form_state['values']['pid'] : 0;
  // Language is only set if language.module is enabled, otherwise save for all
  // languages.
  $langcode = isset($form_state['values']['langcode']) ? $form_state['values']['langcode'] : LANGUAGE_NONE;

  $has_alias = db_query("SELECT COUNT(alias) FROM {url_alias} WHERE pid <> :pid AND alias = :alias AND langcode = :langcode", array(
    ':pid' => $pid,
    ':alias' => $alias,
    ':langcode' => $langcode,
  ))
    ->fetchField();

  if ($has_alias) {
    form_set_error('alias', t('The alias %alias is already in use in this language.', array('%alias' => $alias)));
  }
  if (!backdrop_valid_path($source)) {
    form_set_error('source', t('The path <code>@link_path</code> is either invalid or you do not have access to it.', array('@link_path' => $source)));
  }
}