4 * @defgroup pathauto Pathauto: Automatically generates aliases for content
6 * The Pathauto module automatically generates path aliases for various kinds of
7 * content (nodes, categories, users) without requiring the user to manually
8 * specify the path alias. This allows you to get aliases like
9 * /category/my-node-title.html instead of /node/123. The aliases are based upon
10 * a "pattern" system which the administrator can control.
15 * Main file for the Pathauto module, which automatically generates aliases for content.
21 * The default ignore word list.
23 define('PATHAUTO_IGNORE_WORDS', 'a, an, as, at, before, but, by, for, from, is, in, into, like, of, off, on, onto, per, since, than, the, this, that, to, up, via, with');
26 * Implements hook_hook_info().
28 function pathauto_hook_info() {
32 'pathauto_pattern_alter',
33 'pathauto_alias_alter',
34 'pathauto_is_alias_reserved',
36 return array_fill_keys($hooks, array('group' => 'pathauto'));
40 * Implements hook_module_implements_alter().
42 * Adds pathauto support for core modules.
44 function pathauto_module_implements_alter(&$implementations, $hook) {
45 if (in_array($hook, array('pathauto', 'path_alias_types'))) {
46 $modules = array('node', 'taxonomy', 'user', 'forum', 'blog');
47 foreach ($modules as
$module) {
48 if (module_exists($module)) {
49 $implementations[$module] = TRUE
;
52 // Move pathauto.module to get included first since it is responsible for
54 unset($implementations['pathauto']);
55 $implementations = array_merge(array('pathauto' => 'pathauto'), $implementations);
60 * Implements hook_help().
62 function pathauto_help($path, $arg) {
64 case
'admin/help#pathauto':
65 module_load_include('inc', 'pathauto');
66 $output = '<h3>' .
t('About') .
'</h3>';
67 $output .
= '<p>' .
t('Provides a mechanism for modules to automatically generate aliases for the content they manage.') .
'</p>';
68 $output .
= '<h3>' .
t('Settings') .
'</h3>';
70 $output .
= '<dt>' .
t('Maximum alias and component length') .
'</dt>';
71 $output .
= '<dd>' .
t('The <strong>maximum alias length</strong> and <strong>maximum component length</strong> values default to 100 and have a limit of @max from Pathauto. This length is limited by the length of the "alias" column of the url_alias database table. The default database schema for this column is @max. If you set a length that is equal to that of the one set in the "alias" column it will cause problems in situations where the system needs to append additional words to the aliased URL. You should enter a value that is the length of the "alias" column minus the length of any strings that might get added to the end of the URL. The length of strings that might get added to the end of your URLs depends on which modules you have enabled and on your Pathauto settings. The recommended and default value is 100.', array('@max' => _pathauto_get_schema_alias_maxlength())) .
'</dd>';
74 case
'admin/config/search/path/update_bulk':
75 $output = '<p>' .
t('Bulk generation will only generate URL aliases for items that currently have no aliases. This is typically used when installing Pathauto on a site that has existing un-aliased content that needs to be aliased in bulk.') .
'</p>';
81 * Implements hook_permission().
83 function pathauto_permission() {
85 'administer pathauto' => array(
86 'title' => t('Administer pathauto'),
87 'description' => t('Allows a user to configure patterns for automated aliases and bulk delete URL-aliases.'),
89 'notify of path changes' => array(
90 'title' => t('Notify of Path Changes'),
91 'description' => t('Determines whether or not users are notified.'),
97 * Implements hook_menu().
99 function pathauto_menu() {
100 $items['admin/config/search/path/patterns'] = array(
101 'title' => 'Patterns',
102 'page callback' => 'drupal_get_form',
103 'page arguments' => array('pathauto_patterns_form'),
104 'access arguments' => array('administer pathauto'),
105 'type' => MENU_LOCAL_TASK
,
107 'file' => 'pathauto.admin.inc',
109 $items['admin/config/search/path/settings'] = array(
110 'title' => 'Settings',
111 'page callback' => 'drupal_get_form',
112 'page arguments' => array('pathauto_settings_form'),
113 'access arguments' => array('administer pathauto'),
114 'type' => MENU_LOCAL_TASK
,
116 'file' => 'pathauto.admin.inc',
118 $items['admin/config/search/path/update_bulk'] = array(
119 'title' => 'Bulk generate',
120 'page callback' => 'drupal_get_form',
121 'page arguments' => array('pathauto_bulk_update_form'),
122 'access arguments' => array('administer url aliases'),
123 'type' => MENU_LOCAL_TASK
,
125 'file' => 'pathauto.admin.inc',
127 $items['admin/config/search/path/delete_bulk'] = array(
128 'title' => 'Delete aliases',
129 'page callback' => 'drupal_get_form',
130 'page arguments' => array('pathauto_admin_delete'),
131 'access arguments' => array('administer url aliases'),
132 'type' => MENU_LOCAL_TASK
,
134 'file' => 'pathauto.admin.inc',
141 * Load an URL alias pattern by entity, bundle, and language.
144 * An entity (e.g. node, taxonomy, user, etc.)
146 * A bundle (e.g. content type, vocabulary ID, etc.)
148 * A language code, defaults to the LANGUAGE_NONE constant.
150 function pathauto_pattern_load_by_entity($entity, $bundle = '', $language = LANGUAGE_NONE
) {
151 $patterns = &drupal_static(__FUNCTION__
, array());
153 $pattern_id = "$entity:$bundle:$language";
154 if (!isset($patterns[$pattern_id])) {
155 $variables = array();
156 if ($language != LANGUAGE_NONE
) {
157 $variables[] = "pathauto_{$entity}_{$bundle}_{$language}_pattern";
160 $variables[] = "pathauto_{$entity}_{$bundle}_pattern";
162 $variables[] = "pathauto_{$entity}_pattern";
164 foreach ($variables as
$variable) {
165 if ($pattern = trim(variable_get($variable, ''))) {
170 $patterns[$pattern_id] = $pattern;
173 return $patterns[$pattern_id];
177 * Delete multiple URL aliases.
179 * Intent of this is to abstract a potential path_delete_multiple() function
183 * An array of path IDs to delete.
185 function pathauto_path_delete_multiple($pids) {
186 foreach ($pids as
$pid) {
187 path_delete(array('pid' => $pid));
192 * Delete an URL alias and any of its sub-paths.
194 * Given a source like 'node/1' this function will delete any alias that have
195 * that specific source or any sources that match 'node/1/%'.
198 * An string with a source URL path.
200 function pathauto_path_delete_all($source) {
201 $sql = "SELECT pid FROM {url_alias} WHERE source = :source OR source LIKE :source_wildcard";
202 $pids = db_query($sql, array(':source' => $source, ':source_wildcard' => $source .
'/%'))->fetchCol();
204 pathauto_path_delete_multiple($pids);
209 * Delete an entity URL alias and any of its sub-paths.
211 * This function also checks to see if the default entity URI is different from
212 * the current entity URI and will delete any of the default aliases.
214 * @param $entity_type
215 * A string with the entity type.
218 * @param $default_uri
219 * The optional default uri path for the entity.
221 function pathauto_entity_path_delete_all($entity_type, $entity, $default_uri = NULL
) {
222 $uri = entity_uri($entity_type, $entity);
223 pathauto_path_delete_all($uri['path']);
224 if (isset($default_uri) && $uri['path'] != $default_uri) {
225 pathauto_path_delete_all($default_uri);
230 * Implements hook_field_attach_rename_bundle().
232 * Respond to machine name changes for pattern variables.
234 function pathauto_field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new) {
235 $variables = db_select('variable', 'v')
236 ->fields('v', array('name'))
237 ->condition('name', db_like("pathauto_{$entity_type}_{$bundle_old}_") .
'%', 'LIKE')
240 foreach ($variables as
$variable) {
241 $value = variable_get($variable, '');
242 variable_del($variable);
243 $variable = strtr($variable, array("{$entity_type}_{$bundle_old}" => "{$entity_type}_{$bundle_new}"));
244 variable_set($variable, $value);
249 * Implements hook_field_attach_delete_bundle().
251 * Respond to sub-types being deleted, their patterns can be removed.
253 function pathauto_field_attach_delete_bundle($entity_type, $bundle) {
254 $variables = db_select('variable', 'v')
255 ->fields('v', array('name'))
256 ->condition('name', db_like("pathauto_{$entity_type}_{$bundle}_") .
'%', 'LIKE')
259 foreach ($variables as
$variable) {
260 variable_del($variable);
265 * Implements hook_field_attach_form().
267 * Add the automatic alias form elements to an existing path form fieldset.
269 function pathauto_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) {
270 list($id, , $bundle) = entity_extract_ids($entity_type, $entity);
272 if (!isset($form['path'])) {
273 // This entity must be supported by core's path.module first.
274 // @todo Investigate removing this and supporting all fieldable entities.
278 // Taxonomy terms do not have an actual fieldset for path settings.
279 // Merge in the defaults.
280 $form['path'] += array(
281 '#type' => 'fieldset',
282 '#title' => t('URL path settings'),
283 '#collapsible' => TRUE
,
284 '#collapsed' => empty($form['path']['alias']),
285 '#group' => 'additional_settings',
286 '#attributes' => array(
287 'class' => array('path-form'),
289 '#access' => user_access('create url aliases') || user_access('administer url aliases'),
292 '#element_validate' => array('path_form_element_validate'),
296 $pattern = pathauto_pattern_load_by_entity($entity_type, $bundle, $langcode);
297 if (empty($pattern)) {
301 if (!isset($entity->path
['pathauto'])) {
303 module_load_include('inc', 'pathauto');
304 $uri = entity_uri($entity_type, $entity);
305 $path = drupal_get_path_alias($uri['path'], $langcode);
306 $pathauto_alias = pathauto_create_alias($entity_type, 'return', $uri['path'], array($entity_type => $entity), $bundle, $langcode);
307 $entity->path
['pathauto'] = ($path != $uri['path'] && $path == $pathauto_alias);
310 $entity->path
['pathauto'] = TRUE
;
314 // Add JavaScript that will disable the path textfield when the automatic
315 // alias checkbox is checked.
316 $form['path']['alias']['#states']['!enabled']['input[name="path[pathauto]"]'] = array('checked' => TRUE
);
318 // Override path.module's vertical tabs summary.
319 $form['path']['#attached']['js'] = array(
320 'vertical-tabs' => drupal_get_path('module', 'pathauto') .
'/pathauto.js'
323 $form['path']['pathauto'] = array(
324 '#type' => 'checkbox',
325 '#title' => t('Generate automatic URL alias'),
326 '#default_value' => $entity->path
['pathauto'],
327 '#description' => t('Uncheck this to create a custom alias below.'),
331 // Add a shortcut link to configure URL alias patterns.
332 if (drupal_valid_path('admin/config/search/path/patterns')) {
333 $form['path']['pathauto']['#description'] .
= ' ' .
l(t('Configure URL alias patterns.'), 'admin/config/search/path/patterns');
336 if ($entity->path
['pathauto'] && !empty($entity->old_alias
) && empty($entity->path
['alias'])) {
337 $form['path']['alias']['#default_value'] = $entity->old_alias
;
338 $entity->path
['alias'] = $entity->old_alias
;
341 // For Pathauto to remember the old alias and prevent the Path module from
342 // deleting it when Pathauto wants to preserve it.
343 if (!empty($entity->path
['alias'])) {
344 $form['path']['old_alias'] = array(
346 '#value' => $entity->path
['alias'],
352 * Implements hook_entity_presave().
354 function pathauto_entity_presave($entity, $type) {
355 // About to be saved (before insert/update)
356 if (!empty($entity->path
['pathauto']) && isset($entity->path
['old_alias'])
357 && $entity->path
['alias'] == '' && $entity->path
['old_alias'] != '') {
359 * There was an old alias, but when pathauto_perform_alias was checked
360 * the javascript disabled the textbox which led to an empty value being
361 * submitted. Restoring the old path-value here prevents the Path module
362 * from deleting any old alias before Pathauto gets control.
364 $entity->path
['alias'] = $entity->path
['old_alias'];
367 // Help prevent errors with progromatically creating entities by defining
368 // path['alias'] as an empty string.
369 // @see http://drupal.org/node/1328180
370 // @see http://drupal.org/node/1576552
371 if (isset($entity->path
['pathauto']) && !isset($entity->path
['alias'])) {
372 $entity->path
['alias'] = '';
377 * Implements hook_action_info().
379 function pathauto_action_info() {
380 $info['pathauto_node_update_action'] = array(
382 'label' => t('Update node alias'),
383 'configurable' => FALSE
,
384 'triggers' => array(),
386 $info['pathauto_taxonomy_term_update_action'] = array(
387 'type' => 'taxonomy_term',
388 'label' => t('Update taxonomy term alias'),
389 'configurable' => FALSE
,
390 'triggers' => array(),
392 $info['pathauto_user_update_action'] = array(
394 'label' => t('Update user alias'),
395 'configurable' => FALSE
,
396 'triggers' => array(),
403 * Returns the language code of the given entity.
405 * Backward compatibility layer to ensure that installations running an older
406 * version of core where entity_language() is not avilable do not break.
408 * @param string $entity_type
410 * @param object $entity
412 * @param bool $check_language_property
413 * A boolean if TRUE, will attempt to fetch the language code from
414 * $entity->language if the entity_language() function failed or does not
415 * exist. Default is TRUE.
417 function pathauto_entity_language($entity_type, $entity, $check_language_property = TRUE
) {
420 if (function_exists('entity_language')) {
421 $langcode = entity_language($entity_type, $entity);
423 elseif ($check_language_property && !empty($entity->language
)) {
424 $langcode = $entity->language
;
427 return !empty($langcode) ?
$langcode : LANGUAGE_NONE
;
430 function pathauto_is_alias_reserved($alias, $source, $langcode = LANGUAGE_NONE
) {
431 foreach (module_implements('pathauto_is_alias_reserved') as
$module) {
432 $result = module_invoke($module, 'pathauto_is_alias_reserved', $alias, $source, $langcode);
433 if (!empty($result)) {
434 // As soon as the first module says that an alias is in fact reserved,
435 // then there is no point in checking the rest of the modules.
444 * Implements hook_pathauto_is_alias_reserved() on behalf of path.module.
446 function path_pathauto_is_alias_reserved($alias, $source, $langcode) {
447 return (bool
) db_query_range("SELECT pid FROM {url_alias} WHERE source <> :source AND alias = :alias AND language IN (:language, :language_none) ORDER BY language DESC, pid DESC", 0, 1, array(
448 ':source' => $source,
450 ':language' => $langcode,
451 ':language_none' => LANGUAGE_NONE
,
456 * Implements hook_pathauto_is_alias_reserved().
458 function pathauto_pathauto_is_alias_reserved($alias, $source, $langcode) {
459 module_load_include('inc', 'pathauto');
460 return _pathauto_path_is_callback($alias);
463 if (!function_exists('path_field_extra_fields')) {
465 * Implements hook_field_extra_fields() on behalf of path.module.
467 * Add support for the 'URL path settings' to be re-ordered by the user on the
468 * 'Manage Fields' tab of content types and vocabularies.
470 function path_field_extra_fields() {
473 foreach (node_type_get_types() as
$node_type) {
474 if (!isset($info['node'][$node_type->type
]['form']['path'])) {
475 $info['node'][$node_type->type
]['form']['path'] = array(
476 'label' => t('URL path settings'),
477 'description' => t('Path module form elements'),
483 if (module_exists('taxonomy')) {
484 $vocabularies = taxonomy_get_vocabularies();
485 foreach ($vocabularies as
$vocabulary) {
486 if (!isset($info['taxonomy_term'][$vocabulary->machine_name
]['form']['path'])) {
487 $info['taxonomy_term'][$vocabulary->machine_name
]['form']['path'] = array(
488 'label' => t('URL path settings'),
489 'description' => t('Path module form elements'),
501 * @name pathauto_node Pathauto integration for the core node module.
506 * Implements hook_node_insert().
508 function pathauto_node_insert($node) {
509 // @todo Remove the next line when http://drupal.org/node/1025870 is fixed.
511 pathauto_node_update_alias($node, 'insert');
515 * Implements hook_node_update().
517 function pathauto_node_update($node) {
518 pathauto_node_update_alias($node, 'update');
522 * Implements hook_node_delete().
524 function pathauto_node_delete($node) {
525 pathauto_entity_path_delete_all('node', $node, "node/{$node->nid}");
529 * Implements hook_form_BASE_FORM_ID_alter().
531 * Add the Pathauto settings to the node form.
533 function pathauto_form_node_form_alter(&$form, &$form_state) {
534 $node = $form_state['node'];
535 $langcode = pathauto_entity_language('node', $node);
536 pathauto_field_attach_form('node', $node, $form, $form_state, $langcode);
540 * Implements hook_node_operations().
542 function pathauto_node_operations() {
543 $operations['pathauto_update_alias'] = array(
544 'label' => t('Update URL alias'),
545 'callback' => 'pathauto_node_update_alias_multiple',
546 'callback arguments' => array('bulkupdate', array('message' => TRUE
)),
552 * Update the URL aliases for an individual node.
557 * Operation being performed on the node ('insert', 'update' or 'bulkupdate').
559 * An optional array of additional options.
561 function pathauto_node_update_alias(stdClass
$node, $op, array $options = array()) {
562 // Skip processing if the user has disabled pathauto for the node.
563 if (isset($node->path
['pathauto']) && empty($node->path
['pathauto'])) {
567 $options += array('language' => pathauto_entity_language('node', $node));
569 // Skip processing if the node has no pattern.
570 if (!pathauto_pattern_load_by_entity('node', $node->type
, $options['language'])) {
574 module_load_include('inc', 'pathauto');
575 $uri = entity_uri('node', $node);
576 return pathauto_create_alias('node', $op, $uri['path'], array('node' => $node), $node->type
, $options['language']);
580 * Update the URL aliases for multiple nodes.
583 * An array of node IDs.
585 * Operation being performed on the nodes ('insert', 'update' or
588 * An optional array of additional options.
590 function pathauto_node_update_alias_multiple(array $nids, $op, array $options = array()) {
591 $options += array('message' => FALSE
);
593 $nodes = node_load_multiple($nids);
594 foreach ($nodes as
$node) {
595 pathauto_node_update_alias($node, $op, $options);
598 if (!empty($options['message'])) {
599 drupal_set_message(format_plural(count($nids), 'Updated URL alias for 1 node.', 'Updated URL aliases for @count nodes.'));
604 * Update action wrapper for pathauto_node_update_alias().
606 function pathauto_node_update_action($node, $context = array()) {
607 pathauto_node_update_alias($node, 'bulkupdate', array('message' => TRUE
));
611 * @} End of "name pathauto_node".
615 * @name pathauto_taxonomy Pathauto integration for the core taxonomy module.
620 * Implements hook_taxonomy_term_insert().
622 function pathauto_taxonomy_term_insert($term) {
623 pathauto_taxonomy_term_update_alias($term, 'insert');
627 * Implements hook_taxonomy_term_update().
629 function pathauto_taxonomy_term_update($term) {
630 pathauto_taxonomy_term_update_alias($term, 'update', array('alias children' => TRUE
));
634 * Implements hook_taxonomy_term_delete().
636 function pathauto_taxonomy_term_delete($term) {
637 pathauto_entity_path_delete_all('taxonomy_term', $term, "taxonomy/term/{$term->tid}");
641 * Implements hook_form_FORM_ID_alter().
643 * Add the Pathauto settings to the taxonomy term form.
645 function pathauto_form_taxonomy_form_term_alter(&$form, $form_state) {
646 $term = $form_state['term'];
647 $langcode = pathauto_entity_language('taxonomy_term', $term);
648 pathauto_field_attach_form('taxonomy_term', $term, $form, $form_state, $langcode);
652 * Update the URL aliases for an individual taxonomy term.
655 * A taxonomy term object.
657 * Operation being performed on the term ('insert', 'update' or 'bulkupdate').
659 * An optional array of additional options.
661 function pathauto_taxonomy_term_update_alias(stdClass
$term, $op, array $options = array()) {
662 // Skip processing if the user has disabled pathauto for the term.
663 if (isset($term->path
['pathauto']) && empty($term->path
['pathauto'])) {
667 $module = 'taxonomy_term';
668 if ($term->vid
== variable_get('forum_nav_vocabulary', '')) {
669 if (module_exists('forum')) {
677 // Check that the term has its bundle, which is the vocabulary's machine name.
678 if (!isset($term->vocabulary_machine_name
)) {
679 $vocabulary = taxonomy_vocabulary_load($term->vid
);
680 $term->vocabulary_machine_name
= $vocabulary->machine_name
;
684 'alias children' => FALSE
,
685 'language' => pathauto_entity_language('taxonomy_term', $term),
688 // Skip processing if the term has no pattern.
689 if (!pathauto_pattern_load_by_entity($module, $term->vocabulary_machine_name
)) {
693 module_load_include('inc', 'pathauto');
694 $uri = entity_uri('taxonomy_term', $term);
695 $result = pathauto_create_alias($module, $op, $uri['path'], array('term' => $term), $term->vocabulary_machine_name
, $options['language']);
697 if (!empty($options['alias children'])) {
698 // For all children generate new aliases.
699 $options['alias children'] = FALSE
;
700 unset($options['language']);
701 foreach (taxonomy_get_tree($term->vid
, $term->tid
) as
$subterm) {
702 pathauto_taxonomy_term_update_alias($subterm, $op, $options);
710 * Update the URL aliases for multiple taxonomy terms.
713 * An array of term IDs.
715 * Operation being performed on the nodes ('insert', 'update' or
718 * An optional array of additional options.
720 function pathauto_taxonomy_term_update_alias_multiple(array $tids, $op, array $options = array()) {
721 $options += array('message' => FALSE
);
723 $terms = taxonomy_term_load_multiple($tids);
724 foreach ($terms as
$term) {
725 pathauto_taxonomy_term_update_alias($term, $op, $options);
728 if (!empty($options['message'])) {
729 drupal_set_message(format_plural(count($tids), 'Updated URL alias for 1 term.', 'Updated URL aliases for @count terms.'));
734 * Update action wrapper for pathauto_taxonomy_term_update_alias().
736 function pathauto_taxonomy_term_update_action($term, $context = array()) {
737 pathauto_taxonomy_term_update_alias($term, 'bulkupdate', array('message' => TRUE
));
741 * @} End of "name pathauto_taxonomy".
745 * @name pathauto_user Pathauto integration for the core user and blog modules.
750 * Implements hook_user_insert().
752 function pathauto_user_insert(&$edit, $account, $category) {
753 pathauto_user_update_alias($account, 'insert');
757 * Implements hook_user_update().
759 function pathauto_user_update(&$edit, $account, $category) {
760 pathauto_user_update_alias($account, 'update');
764 * Implements hook_user_delete().
766 function pathauto_user_delete($account) {
767 pathauto_entity_path_delete_all('user', $account, "user/{$account->uid}");
768 pathauto_path_delete_all("blog/{$account->uid}");
772 * Implements hook_user_operations().
774 function pathauto_user_operations() {
775 $operations['pathauto_update_alias'] = array(
776 'label' => t('Update URL alias'),
777 'callback' => 'pathauto_user_update_alias_multiple',
778 'callback arguments' => array('bulkupdate', array('message' => TRUE
)),
784 * Update the URL aliases for an individual user account.
787 * A user account object.
789 * Operation being performed on the account ('insert', 'update' or
792 * An optional array of additional options.
794 function pathauto_user_update_alias(stdClass
$account, $op, array $options = array()) {
795 // Skip processing if the user has disabled pathauto for the account.
796 if (isset($account->path
['pathauto']) && empty($account->path
['pathauto'])) {
801 'alias blog' => module_exists('blog'),
802 // $user->language is not the user entity language, thus we need to skip
803 // the property fallback check.
804 'language' => pathauto_entity_language('user', $account, FALSE
),
807 // Skip processing if the account has no pattern.
808 if (!pathauto_pattern_load_by_entity('user', '', $options['language'])) {
812 module_load_include('inc', 'pathauto');
813 $uri = entity_uri('user', $account);
814 $return = pathauto_create_alias('user', $op, $uri['path'], array('user' => $account), NULL
, $options['language']);
816 // Because blogs are also associated with users, also generate the blog paths.
817 if (!empty($options['alias blog'])) {
818 pathauto_blog_update_alias($account, $op, $options);
825 * Update the URL aliases for multiple user accounts.
828 * An array of user account IDs.
830 * Operation being performed on the accounts ('insert', 'update' or
833 * An optional array of additional options.
835 function pathauto_user_update_alias_multiple(array $uids, $op, array $options = array()) {
836 $options += array('message' => FALSE
);
838 $accounts = user_load_multiple($uids);
839 foreach ($accounts as
$account) {
840 pathauto_user_update_alias($account, $op, $options);
843 if (!empty($options['message'])) {
844 drupal_set_message(format_plural(count($uids), 'Updated URL alias for 1 user account.', 'Updated URL aliases for @count user accounts.'));
849 * Update action wrapper for pathauto_user_update_alias().
851 function pathauto_user_update_action($account, $context = array()) {
852 pathauto_user_update_alias($account, 'bulkupdate', array('message' => TRUE
));
856 * Update the blog URL aliases for an individual user account.
859 * A user account object.
861 * Operation being performed on the blog ('insert', 'update' or
864 * An optional array of additional options.
866 function pathauto_blog_update_alias(stdClass
$account, $op, array $options = array()) {
867 // Skip processing if the blog has no pattern.
868 if (!pathauto_pattern_load_by_entity('blog')) {
873 'language' => LANGUAGE_NONE
,
876 module_load_include('inc', 'pathauto');
877 if (node_access('create', 'blog', $account)) {
878 return pathauto_create_alias('blog', $op, "blog/{$account->uid}", array('user' => $account), NULL
, $options['language']);
881 pathauto_path_delete_all("blog/{$account->uid}");
886 * @} End of "name pathauto_user".