diff --git a/pathauto.module b/pathauto.module index 5027dec..c60da90 100644 --- a/pathauto.module +++ b/pathauto.module @@ -771,13 +771,55 @@ function pathauto_node_update_alias(stdClass $node, $op, array $options = array( function pathauto_node_update_alias_multiple(array $nids, $op, array $options = array()) { $options += array('message' => FALSE); + $updated = 0; + $patternless = 0; + $not_automatic = 0; + $action_do_nothing = 0; $nodes = node_load_multiple($nids); foreach ($nodes as $node) { - pathauto_node_update_alias($node, $op, $options); + // Skip processing if the user has disabled pathauto for the node. + if (isset($node->path['pathauto']) && empty($node->path['pathauto']) && empty($options['force'])) { + $not_automatic++; + continue; + } + + $options += array('language' => pathauto_entity_language('node', $node)); + + // Skip processing if the node has no pattern. + if (!pathauto_pattern_load_by_entity('node', $node->type, $options['language'])) { + $patternless++; + continue; + } + + module_load_include('inc', 'pathauto'); + $uri = entity_uri('node', $node); + + // Special handling when updating an item which is already aliased. + $existing_alias = NULL; + if ($existing_alias = _pathauto_existing_alias_data($uri['path'], $options['language'])) { + if (variable_get('pathauto_update_action', PATHAUTO_UPDATE_ACTION_DELETE) == PATHAUTO_UPDATE_ACTION_NO_NEW){ + $action_do_nothing++; + continue; + } + } + + pathauto_create_alias('node', $op, $uri['path'], array('node' => $node), $node->type, $options['language']); + $updated++; } if (!empty($options['message'])) { - drupal_set_message(format_plural(count($nids), 'Updated URL alias for 1 node.', 'Updated URL aliases for @count nodes.')); + if ($updated > 0) { + drupal_set_message(format_plural($updated, t('Updated URL alias for 1 node.'), t('Updated URL aliases for @count nodes.'))); + } + if ($not_automatic > 0) { + drupal_set_message(format_plural($not_automatic, t('Skipped 1 node because its alias was not automaticly generated.'), t('Skipped @count nodes because their aliases were not automaticly generated.'))); + } + if ($patternless > 0) { + drupal_set_message(format_plural($patternless, t('Skipped 1 node because it did not have an alias pattern.'), t('Skipped @count nodes because they did not have an alias pattern.'))); + } + if ($action_do_nothing > 0) { + drupal_set_message(format_plural($action_do_nothing, t('Skipped 1 node because update action is set to Do nothing.'), t('Skipped @count nodes because update action is set to Do nothing.'))); + } } }