path_save

Versions
4.6
path_save($edit)
7
path_save(&$path)

Verify that a new URL alias is valid, and save it to the database.

▾ 1 function calls path_save()

path_admin_edit in modules/path.module
Menu callback; handles pages for creating and editing URL aliases.

Code

modules/path.module, line 292

<?php
function path_save($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))));
  }

  if (form_get_errors()) {
    return path_form($edit);
  }
  else {
    path_set_alias($src, $dst, $pid);

    drupal_set_message(t('The alias has been saved.'));
    drupal_goto('admin/path');
  }
}
?>
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.