Index: pathauto_taxonomy.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/pathauto/pathauto_taxonomy.inc,v
retrieving revision 1.20.2.2
diff -u -p -r1.20.2.2 pathauto_taxonomy.inc
--- pathauto_taxonomy.inc	17 Jan 2007 16:53:41 -0000	1.20.2.2
+++ pathauto_taxonomy.inc	11 Apr 2007 19:48:35 -0000
@@ -17,7 +17,7 @@ function taxonomy_pathauto($op) {
         t('[vocab]') => t("The vocabulary that the page's first category belongs to."),
         t('[cat]') => t('The name of the category.'),
         t('[catpath]') => t('As [cat], but including its supercategories.'),
-        t('[tid]') => t('The id number of the category.')
+        t('[tid]') => t('The id number of the category.'),
       );
       // Look for extensions from other modules
       $placeholders = module_invoke_all('pathauto_taxonomy', 'placeholders');
@@ -67,7 +67,7 @@ function pathauto_taxonomy($op, $type, $
             $catpath = ''; 
             $parents = taxonomy_get_parents_all($category->tid);
             foreach ($parents as $parent) {
-              $catpath = pathauto_cleanstring($parent->name).'/'.$catpath;
+              $catpath = pathauto_cleanstring($parent->name) .'/'. $catpath;
             }
             $placeholders[t('[catpath]')] = $catpath;
             
@@ -76,8 +76,7 @@ function pathauto_taxonomy($op, $type, $
             $placeholders = array_merge($placeholders, $extplaceholders);
             
             $src = taxonomy_term_path($category);
-            $alias = pathauto_create_alias('taxonomy', $op, $placeholders,
-              $src, $vid);
+            $alias = pathauto_create_alias('taxonomy', $op, $placeholders, $src, $vid);
           }
           break;
         case 'delete':
@@ -97,52 +96,120 @@ function pathauto_taxonomy($op, $type, $
 
 // Generate aliases for all categories without aliases
 function taxonomy_pathauto_bulkupdate() {
-  $query = "SELECT tid,vid,name,src,dst FROM {term_data} LEFT JOIN {url_alias} ON CONCAT('taxonomy/term/', tid) = src OR CONCAT('forum/', tid) = src";
+  $query = "SELECT tid,vid,name,src,dst FROM {term_data} LEFT JOIN {url_alias} ON CONCAT('taxonomy/term/', tid) = src";
   $result = db_query($query);
   $category = db_fetch_object($result);
+  if (module_exists('forum')) {
+    $forumvid = variable_get('forum_nav_vocabulary', '');  
+  }
   
   $count = 0;
   $placeholders = array();
   while ($category) {
     $vid = $category->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;
-  
-    if ($category->parent) {
-      $catpath = pathauto_cleanstring($category->name);
-      $parents = taxonomy_get_parents_all($category->parent);
-    } 
-    else {
-      $catpath = '';
-      $parents = taxonomy_get_parents_all($category->tid);
-    }
+    if (!module_exists($forum) || (module_exists($forum) && $forumvid != $vid)) {
+      print '<pre>processing term with tid'. $forum->tid .', with vid: '. $vid . '</pre>';
+      $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);
     
-    foreach ($parents as $parent) {
-      $catpath = pathauto_cleanstring($parent->name).'/'.$catpath;
+      // Append any additional extensions
+      $extplaceholders = module_invoke_all('pathauto_taxonomy', 'values', $category);
+      $placeholders = array_merge($placeholders, $extplaceholders);
+
+      $src = 'taxonomy/term/'. $category->tid;
+      if ($alias = pathauto_create_alias('taxonomy', 'bulkupdate', $placeholders, $src, $vid)) {
+        print '<pre>TAXONOMY: created alias: '. $alias .'</pre>';
+        $count++;
+      }
     }
-    $placeholders['[catpath]'] = $catpath;
+    $category = db_fetch_object($result);
+  }
+  
+  drupal_set_message(format_plural($count,
+    "Bulk update of terms completed, one alias generated.",
+    "Bulk update of terms completed, @count aliases generated."));
+}
+
+
+/**
+ * Implementation of hook_pathauto() for forum topics.
+ */
+function forum_pathauto($op) {
+  switch ($op) {
+    case 'settings':
+      $settings = array();
+      $settings['module'] = 'forum';
+      $settings['groupheader'] = t('Forum path settings');
+      $settings['patterndescr'] = t('Pattern for forums and forum containers');
+      $settings['patterndefault'] = t('[vocab]/[catpath]');
+      $settings['placeholders'] = array(
+        t('[vocab]') => t("The vocabulary that the page's first category belongs to."),
+        t('[cat]') => t('The name of the category.'),
+        t('[catpath]') => t('As [cat], but including its supercategories.'),
+        t('[tid]') => t('The id number of the category.'),
+      );
+      $settings['supportsfeeds'] = '0/feed';
+      $settings['bulkname'] = t('Bulk update forum paths');
+      $settings['bulkdescr'] = t('Generate aliases for all existing forums and forum containers which do not already have aliases.');
+      return (object) $settings;
+    default:
+      break;
+  }
+}
+
+// Generate aliases for all forums and forum containers without aliases
+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);
+  $forumvid = variable_get('forum_nav_vocabulary', '');  
+print '<pre>forumvid: '. $categoryvid . '</pre>';
+  $count = 0;
+  $placeholders = array();
+  while ($category) {
+    $vid = $category->vid;
+    if ($forumvid == $vid) {
+      print '<pre>processing term with tid'. $category->tid .', with vid: '. $vid . '</pre>';
+      $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);
+      // Append any additional extensions
+      $extplaceholders = module_invoke_all('pathauto_taxonomy', 'values', $category);
+      $placeholders = array_merge($placeholders, $extplaceholders);
     
-    $forumvid = variable_get('forum_nav_vocabulary', '');
-    if ($forumvid == $vid) {
-      $src = 'forum/'.$category->tid;
-      if ($forumalias = pathauto_create_alias('taxonomy', 'bulkupdate', $placeholders, $src, $forumvid)) {
+      $src = 'forum/'. $category->tid;
+      if ($alias = pathauto_create_alias('forum', 'bulkupdate', $placeholders, $src, $vid)) {
+        print '<pre>FORUM: created alias: '. $alias .'</pre>';
         $count++;
       }
     }
-    $src = 'taxonomy/term/'.$category->tid;
-    if ($alias = pathauto_create_alias('taxonomy', 'bulkupdate', $placeholders, $src, $vid)) {
-      $count++;
-    }
     $category = db_fetch_object($result);
   }
   
   drupal_set_message(format_plural($count,
-    "Bulk update of terms completed, one alias generated.",
-    "Bulk update of terms completed, @count aliases generated."));
+    "Bulk update of forums and forum containers completed, one alias generated.",
+    "Bulk update of forums and forum containers completed, @count aliases generated."));
 }
+
+
+// Helper function for the [catpath] placeholder.
+function _pathauto_taxonomy_catpath($category) {
+  if ($category->parent) {
+    $catpath = pathauto_cleanstring($category->name);
+    $parents = taxonomy_get_parents_all($category->parent);
+  } 
+  else {
+    $catpath = '';
+    $parents = taxonomy_get_parents_all($category->tid);
+  }
+  foreach ($parents as $parent) {
+    $catpath = pathauto_cleanstring($parent->name) .'/'. $catpath;
+  }
+  return $catpath;
+}
\ No newline at end of file
