function content_profile_tokens_token_values in Content Profile 6
Implementation of hook_token_values().
File
- modules/
content_profile_tokens.module, line 13 - Implementations of token module hooks for the content profile module.
Code
function content_profile_tokens_token_values($type, $object = NULL, $options = array()) {
$values = array();
$types = content_profile_get_types('types');
switch ($type) {
case 'user':
foreach ($types as $type_name => $type) {
if (isset($object)) {
$profile = content_profile_load($type_name, $object->uid);
}
else {
global $user;
$profile = content_profile_load($type_name, $user->uid);
}
$fields = content_types($type_name);
foreach ($fields['fields'] as $field_name => $field) {
if (!$field['multiple'] && ($field['widget']['type'] == 'text_textfield' || $field['widget']['type'] == 'number')) {
$values['content-profile-' . $type_name . '-' . substr($field_name, 6)] = check_plain($profile->{$field_name}[0]['value']);
$values['content-profile-' . $type_name . '-' . substr($field_name, 6) . '-raw'] = $profile->{$field_name}[0]['value'];
}
}
}
break;
case 'flag_friend':
if (!empty($object)) {
foreach ($types as $type_name => $type) {
$profile_requestor = content_profile_load($type_name, $object->friend->uid);
$profile_requestee = content_profile_load($type_name, $object->uid);
$fields = content_types($type_name);
foreach ($fields['fields'] as $field_name => $field) {
if (!$field['multiple'] && ($field['widget']['type'] == 'text_textfield' || $field['widget']['type'] == 'number')) {
$values['requestor-' . $type_name . '-' . substr($field_name, 6)] = check_plain($profile_requestor->{$field_name}[0]['value']);
$values['requestor-' . $type_name . '-' . substr($field_name, 6) . '-raw'] = $profile_requestor->{$field_name}[0]['value'];
$values['requestee-' . $type_name . '-' . substr($field_name, 6)] = check_plain($profile_requestee->{$field_name}[0]['value']);
$values['requestee-' . $type_name . '-' . substr($field_name, 6) . '-raw'] = $profile_requestee->{$field_name}[0]['value'];
}
}
}
}
break;
}
return $values;
}