diff --git a/pathauto.module b/pathauto.module index 7c83068..0a424b9 100644 --- a/pathauto.module +++ b/pathauto.module @@ -590,13 +590,43 @@ 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; + $not_automatic = 0; + $patternless = 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); + pathauto_create_alias('node', $op, $uri['path'], array('node' => $node), $node->type, $options['language']); + $updated++; } + dpm($not_automatic); + 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, 'Updated URL alias for 1 node.', 'Updated URL aliases for @count nodes.')); + } + if ($not_automatic > 0) { + drupal_set_message(format_plural($not_automatic, 'Skipped 1 node because its alias was not automaticly generated.', 'Skipped @count nodes because their aliases were not automaticly generated.')); + } + if ($patternless > 0) { + drupal_set_message(format_plural($patternless, 'Skipped 1 node because it did not have an alias pattern.', 'Skipped @count nodes because they did not have an alias pattern.')); + } } }