You are here

function node_pathauto_bulkupdate in Pathauto 5

Same name and namespace in other branches
  1. 5.2 pathauto_node.inc \node_pathauto_bulkupdate()
  2. 6 pathauto_node.inc \node_pathauto_bulkupdate()

File

./pathauto_node.inc, line 252

Code

function node_pathauto_bulkupdate() {
  $query = "SELECT nid, type, title, uid, created, src, dst, vid FROM {node} LEFT JOIN {url_alias} ON CONCAT('node/', nid) = src";
  $result = db_query($query);
  $node_ref = db_fetch_object($result);
  $count = 0;
  $placeholders = array();
  while ($node_ref) {
    $node = node_load($node_ref->nid, NULL, TRUE);
    $node->src = $node_ref->src;
    $node->dst = $node_ref->dst;
    if (module_exists('taxonomy')) {

      // Must populate the terms for the node here for the category
      // placeholders to work
      $node->taxonomy = array_keys(taxonomy_node_get_terms($node->nid));
    }
    $placeholders = node_get_placeholders($node);
    $src = "node/{$node->nid}";
    if ($alias = pathauto_create_alias('node', 'bulkupdate', $placeholders, $src, $node->type)) {
      $count++;
    }
    $node_ref = db_fetch_object($result);
  }
  drupal_set_message(format_plural($count, "Bulk update of nodes completed, one alias generated.", "Bulk update of nodes completed, @count aliases generated."));
}