path_form_validate

5 path.module path_form_validate($form_id, $form_values)

Verify that URL alias is valid.

File

modules/path.module, line 323
Enables users to rename URLs.

Code

function path_form_validate($form_id, $edit) {
  $src = $edit['src'];
  $dst = $edit['dst'];
  $pid = $edit['pid'];

  if (!valid_url($src)) {
    form_set_error('src', t('The system path %path is invalid.', array('%path' => theme('placeholder', $src))));
  }

  if (!valid_url($dst)) {
    form_set_error('dst', t('The alias %alias is invalid.', array('%alias' => theme('placeholder', $dst))));
  }

  if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE pid != %d AND dst = '%s'", $pid, $dst))) {
    form_set_error('dst', t('The alias %alias is already in use.', array('%alias' => theme('placeholder', $dst))));
  }
}
Login or register to post comments