You are here

function forum_pathauto_bulkupdate in Pathauto 5

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

Generate aliases for all forums and forum containers without aliases

File

./pathauto_taxonomy.inc, line 173

Code

function forum_pathauto_bulkupdate() {
  $query = "SELECT tid,vid,name,src,dst FROM {term_data} LEFT JOIN {url_alias} ON CONCAT('forum/', tid) = src";
  $result = db_query($query);
  $category = db_fetch_object($result);
  $count = 0;
  $placeholders = array();
  while ($category) {
    $vid = $category->vid;
    if ($vid == _forum_get_vid()) {
      $vocabulary = taxonomy_get_vocabulary($vid);
      $placeholders[t('[vocab]')] = pathauto_cleanstring($vocabulary->name);
      $placeholders[t('[cat]')] = pathauto_cleanstring($category->name);
      $placeholders[t('[tid]')] = $category->tid;
      $placeholders[t('[catpath]')] = _pathauto_taxonomy_catpath($category);

      // Append any additional extensions
      $extplaceholders = module_invoke_all('pathauto_taxonomy', 'values', $category);
      $placeholders = array_merge($placeholders, $extplaceholders);
      $src = 'forum/' . $category->tid;
      if ($alias = pathauto_create_alias('forum', 'bulkupdate', $placeholders, $src, $vid)) {
        $count++;
      }
    }
    $category = db_fetch_object($result);
  }
  drupal_set_message(format_plural($count, "Bulk update of forums and forum containers completed, one alias generated.", "Bulk update of forums and forum containers completed, @count aliases generated."));
}