function _pathauto_set_alias in Pathauto 5.2
Same name and namespace in other branches
- 5 pathauto.module \_pathauto_set_alias()
- 6.2 pathauto.inc \_pathauto_set_alias()
- 6 pathauto.inc \_pathauto_set_alias()
- 7 pathauto.inc \_pathauto_set_alias()
Private function for Pathauto to create an alias.
Parameters
$src: The internal path.
$dst: The visible externally used path.
$pid: If the item is currently aliased, the pid for that item.
$verbose: If the admin has enabled verbose, should be TRUE. Else FALSE or NULL.
$old_alias: If the item is currently aliased, the existing alias for that item.
1 call to _pathauto_set_alias()
- pathauto_create_alias in ./
pathauto.inc - Apply patterns to create an alias.
File
- ./
pathauto.inc, line 369 - Miscellaneous functions for Pathauto.
Code
function _pathauto_set_alias($src, $dst, $entity_type, $entity_id, $pid = NULL, $verbose = FALSE, $old_alias = NULL) {
// Alert users that an existing callback cannot be overridden automatically
if (_pathauto_path_is_callback($dst)) {
if ($verbose && user_access('notify of path changes')) {
drupal_set_message(t('Ignoring alias %dst due to existing path conflict.', array(
'%dst' => $dst,
)));
}
return;
}
// Alert users if they are trying to create an alias that is the same as the internal path
if ($src == $dst) {
if ($verbose && user_access('notify of path changes')) {
drupal_set_message(t('Ignoring alias %dst because it is the same as the internal path.', array(
'%dst' => $dst,
)));
}
return;
}
// Skip replacing the current alias with an identical alias
if ($old_alias != $dst) {
path_set_alias($src, $dst, $pid);
if (variable_get('pathauto_update_action', 2) == 3 && function_exists('path_redirect_save')) {
if (!empty($old_alias)) {
$save['path'] = $old_alias;
$save['redirect'] = $src;
$save['type'] = 301;
//moved permanently
path_redirect_save($save);
$redirect = TRUE;
}
}
if ($verbose && user_access('notify of path changes')) {
if (!empty($redirect)) {
drupal_set_message(t('Created new alias %dst for %src, replacing %old_alias. %old_alias now redirects to %dst', array(
'%dst' => $dst,
'%src' => $src,
'%old_alias' => $old_alias,
)));
}
elseif ($pid) {
drupal_set_message(t('Created new alias %dst for %src, replacing %old_alias', array(
'%dst' => $dst,
'%src' => $src,
'%old_alias' => $old_alias,
)));
}
else {
drupal_set_message(t('Created new alias %dst for %src', array(
'%dst' => $dst,
'%src' => $src,
)));
}
}
}
}