path_form_validate

Versions
4.7
path_form_validate($form_id, $edit)
5
path_form_validate($form_id, $form_values)

Verify that URL alias is valid.

Code

modules/path.module, line 323

<?php
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
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.