? og_subgroups_482156.patch
Index: og_subgroups.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/og_subgroups/og_subgroups.module,v
retrieving revision 1.47.2.3
diff -u -p -r1.47.2.3 og_subgroups.module
--- og_subgroups.module	3 Sep 2010 21:01:24 -0000	1.47.2.3
+++ og_subgroups.module	28 Oct 2010 03:29:09 -0000
@@ -747,4 +747,46 @@ function og_subgroups_count_children($pa
   }
 
   return (int)db_result($result);
+}
+
+/**
+ * Implementation of hook_token_values().
+ */
+function og_subgroups_token_values($type, $object = NULL, $options = array()) {
+  if ($type == 'node' && og_is_group_type($object->type)) {
+    $node = $object;
+    $parent = og_subgroups_get_family($node->nid, 'up');
+    $ancestry = og_subgroups_get_all_family($node->nid, 'up');
+    $path = array();
+    $path_raw = array();
+
+    foreach ($ancestry as $ancestor) {
+      $path[] = check_plain($ancestor->title);
+      $path_raw[] = $ancestor->title;
+    }
+
+    // Set the token.
+    $tokens['subgroups-parent'] = check_plain($parent[0]->title);
+    $tokens['subgroups-parent-raw'] = $parent[0]->title;
+    $tokens['subgroups-parent-id'] = $parent[0]->gid;
+    $tokens['subgroups-path'] = !empty($options['pathauto']) ? $path : implode('/', $path);
+    $tokens['subgroups-path-raw'] = !empty($options['pathauto']) ? $path_raw : implode('/', $path_raw);
+
+    return $tokens;
+  }
+}
+
+/**
+ * Implementation of hook_token_list().
+ */
+function og_subgroups_token_list($type = 'all') {
+  if ($type == 'node' || $type == 'all') {
+    $tokens['node']['subgroups-parent'] = t('Node title of the parent group');
+    $tokens['node']['subgroups-parent-raw'] = t('Unfiltered node title of the parent group - raw user input');
+    $tokens['node']['subgroups-parent-id'] = t('Node ID of the parent group');
+    $tokens['node']['subgroups-path'] = t('Node titles of all parent groups in a path format');
+    $tokens['node']['subgroups-path-raw'] = t('Unfiltered node titles of all parent groups in a path format - raw user input');
+
+    return $tokens;
+  }
 }
\ No newline at end of file
