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 == 'user' || $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); } }