You are here

function _nodesymlinks_pathauto_bulkupdate in NodeSymlinks 6

Same name and namespace in other branches
  1. 7 nodesymlinks.inc \_nodesymlinks_pathauto_bulkupdate()

Generate aliases for all nodesymlinks without aliases.

1 call to _nodesymlinks_pathauto_bulkupdate()
nodesymlinks_pathauto_bulkupdate in ./nodesymlinks.module
Implementation of hook_pathauto_bulkupdate().
1 string reference to '_nodesymlinks_pathauto_bulkupdate'
nodesymlinks_pathauto in ./nodesymlinks.module
Implementation of hook_pathauto().

File

./nodesymlinks.pathauto.inc, line 96

Code

function _nodesymlinks_pathauto_bulkupdate() {
  $count = 0;
  $query = "SELECT m.mlid, m.link_path, alias.src, alias.dst\n    FROM {menu_links} m LEFT JOIN {url_alias} alias ON m.link_path = alias.src\n    WHERE m.module = 'nodesymlinks' AND alias.src IS NULL";
  $result = db_query_range($query, 0, variable_get('pathauto_max_bulk_update', 50));
  while ($nodesymlink_ref = db_fetch_object($result)) {
    $link_path = explode('/', $nodesymlink_ref->link_path);
    $nid = $link_path[1];
    $mlid = $nodesymlink_ref->mlid;
    $node = node_load($nid, NULL, TRUE);
    $item = menu_link_load($mlid);
    $node->src = $nodesymlink_ref->src;
    $node->dst = $nodesymlink_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));
    }
    if (nodesymlinks_pathauto_create_alias($item, $node, 'bulkupdate')) {
      $count++;
    }
  }
  drupal_set_message(format_plural($count, 'Bulk generation of nodes completed, one alias generated.', 'Bulk generation of nodes completed, @count aliases generated.'));
}