function path_admin_form_validate in Drupal 6
Same name and namespace in other branches
- 7 modules/path/path.admin.inc \path_admin_form_validate()
Verify that a new URL alias is valid
File
- modules/
path/ path.admin.inc, line 130 - Administrative page callbacks for the path module.
Code
function path_admin_form_validate($form, &$form_state) {
$src = $form_state['values']['src'];
$dst = $form_state['values']['dst'];
$pid = isset($form_state['values']['pid']) ? $form_state['values']['pid'] : 0;
// Language is only set if locale module is enabled, otherwise save for all languages.
$language = isset($form_state['values']['language']) ? $form_state['values']['language'] : '';
if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE pid != %d AND dst = '%s' AND language = '%s'", $pid, $dst, $language))) {
form_set_error('dst', t('The alias %alias is already in use in this language.', array(
'%alias' => $dst,
)));
}
$item = menu_get_item($src);
if (!$item || !$item['access']) {
form_set_error('src', t("The path '@link_path' is either invalid or you do not have access to it.", array(
'@link_path' => $src,
)));
}
}