Index: README.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/content_profile/README.txt,v retrieving revision 1.1.2.8 diff -u -r1.1.2.8 README.txt --- README.txt 11 Jun 2009 15:07:15 -0000 1.1.2.8 +++ README.txt 16 Sep 2009 11:49:22 -0000 @@ -136,14 +136,6 @@ - - - - - - - - --------------------------------------------- Content Profile User Registration Integration ---------------------------------------------- @@ -213,3 +205,21 @@ * Putting file uploads on the registration form is not supported and probably won't work right. + +----------------------- +Content Profile Tokens +----------------------- + +Original author: @author Ádám Lippai - Oghma ltd. (lippai.adam@oghma.hu) + + +This is a small module that adds content profile tokens for textfields and number CCK fields for +a user as well as to the 'flag friend' modules' requester and requestee. + +Warning: This module slows down the generation of users tokens, thus it might have some performance + implications for your site. Use it with caution. + +Installation +------------ + * Activiate the module. + \ No newline at end of file Index: modules/content_profile_tokens.info =================================================================== RCS file: modules/content_profile_tokens.info diff -N modules/content_profile_tokens.info --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/content_profile_tokens.info 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,8 @@ +; $Id: $ +name = Content Profile Tokens +description = Add user tokens for content profiles. +package = "Content Profile" +dependencies[] = content_profile +dependencies[] = token +dependencies[] = content +core = 6.x Index: modules/content_profile_tokens.module =================================================================== RCS file: modules/content_profile_tokens.module diff -N modules/content_profile_tokens.module --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/content_profile_tokens.module 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,94 @@ + $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; +} + +/** + * Implementation of hook_token_list(). + */ +function content_profile_tokens_token_list($type = 'all') { + $tokens = array(); + if ($type == 'user' || $type == 'all') { + $types = content_profile_get_types('types'); + foreach ($types as $type_name => $type) { + + $fields = content_types($type_name); + foreach ($fields['fields'] as $field_name => $field) { + if (!$field['multiple'] && ($field['widget']['type'] == 'text_textfield' || $field['widget']['type'] == 'number')) { + $tokens['user']['content-profile-'. $type_name .'-'. substr($field_name, 6)] = t($fields['description']) .'-'. t($field['widget']['label']); + $tokens['user']['content-profile-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = t($fields['description']) .'-'. t($field['widget']['label']) .' '. t('WARNING - raw user input'); + } + } + } + } + + if ($type == 'flag_friend' && module_exists('flag_friend')) { + foreach($types as $type_name => $type) { + $fields = content_types($type_name); + foreach ($fields['fields'] as $field_name => $field) { + if (!$field['multiple'] && ($field['widget']['type'] == 'text_textfield' || $field['widget']['type'] == 'number')) { + $tokens['content_profile_flag_friend']['requestor-'. $type_name .'-'. substr($field_name, 6)] = t('Requestor:') . t($fields['description']) .'-'. t($field['widget']['label']); + $tokens['content_profile_flag_friend']['requestor-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = t('Requestor:') . t($fields['description']) .'-'. t($field['widget']['label']) .' '. t('WARNING - raw user input'); + + $tokens['content_profile_flag_friend']['requestee-'. $type_name .'-'. substr($field_name, 6)] = t('Requestee:') . t($fields['description']) .'-'. t($field['widget']['label']); + $tokens['content_profile_flag_friend']['requestee-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = t('Requestee:') .t($fields['description']) .'-'. t($field['widget']['label']) .' '. t('WARNING - raw user input'); + } + } + } + } + return $tokens; +}