Index: token.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/token/Attic/token.inc,v
retrieving revision 1.1.2.7
diff -u -r1.1.2.7 token.inc
--- token.inc	14 Apr 2007 12:39:58 -0000	1.1.2.7
+++ token.inc	20 Apr 2007 00:15:55 -0000
@@ -128,7 +128,9 @@
   if (module_exists('taxonomy')) {
     include_once("$path/token_taxonomy.inc");
   }
-
+  if (module_exists('profile')) {
+    include_once("$path/token_profile.inc");
+  }
 
   $id = _token_get_id($type, $object);
   if (isset($tokens[$type][$id])) {
Index: token.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/token/token.module,v
retrieving revision 1.5.2.6
diff -u -r1.5.2.6 token.module
--- token.module	14 Apr 2007 12:39:58 -0000	1.5.2.6
+++ token.module	20 Apr 2007 00:16:11 -0000
@@ -38,6 +38,9 @@
   if (module_exists('taxonomy')) {
     include_once("$path/token_taxonomy.inc");
   }
+  if (module_exists('profile')) {
+    include_once("$path/token_profile.inc");
+  }
   $full_list = token_get_list($type);
   
   $headers = array(t('Token'), t('Replacement value'));
--- D:/[projects]/token-DRUPAL-5/token_profile.inc
+++ D:/[projects]/token-DRUPAL-5/token_profile.inc
@@ -0,0 +1,71 @@
+<?php
+// $Id$
+
+/**
+ * Implementation of hook_token_values()
+ */
+function profile_token_values($type, $object = NULL) {
+  $values = array();
+  if ($type == 'profile') {
+    if (isset($object)) {
+      $account = $object;
+    }
+    else {
+      global $user;
+      $account = $user;
+    }
+
+    $result = db_query('SELECT f.name, f.title, f.type, v.value FROM {profile_fields} f INNER JOIN {profile_values} v ON f.fid = v.fid WHERE uid = %d', $account->uid);
+    while ($field = db_fetch_object($result)) {
+      if (_profile_field_serialize($field->type)) {
+        $field->value = unserialize($field->value);
+      }
+      $values[$field->name] = _profile_token_format_field($field);
+    }
+  }
+  return $values;
+}
+
+/**
+ * Implementation of hook_token_list()
+ */
+function profile_token_list($type = 'all') {
+  if ($type == 'profile' || $type == 'all') {
+    $result = db_query('SELECT name, title FROM {profile_fields}');
+    while ($field = db_fetch_object($result)) {
+      $tokens['profile'][$field->name] = $field->title;
+    }
+    return $tokens;
+  }
+}
+
+function _profile_token_format_field($field) {
+  switch ($field->type) {
+    case 'checkbox':
+      return check_plain($field->title);
+    case 'date':
+      $format = substr(variable_get('date_format_short', 'm/d/Y - H:i'), 0, 5);
+      // Note: Avoid PHP's date() because it does not handle dates before
+      // 1970 on Windows. This would make the date field useless for e.g.
+      // birthdays.
+      $replace = array('d' => sprintf('%02d', $field->value['day']),
+                       'j' => $field->value['day'],
+                       'm' => sprintf('%02d', $field->value['month']),
+                       'M' => map_month($field->value['month']),
+                       'Y' => $field->value['year'],
+                       'H:i' => NULL,
+                       'g:ia' => NULL);
+      return strtr($format, $replace);
+    case 'list':
+      $values = split("[,\n\r]", $field->value);
+      $fields = array();
+      foreach ($values as $value) {
+        if ($value = trim($value)) {
+          $fields[] = check_plain($value);
+        }
+      }
+      return implode(', ', $fields);
+    default:
+      return check_plain($field->value);
+  }
+}


