Index: openid_cp_field.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/openid_cp_field/openid_cp_field.module,v retrieving revision 1.1.2.14 diff -u -p -r1.1.2.14 openid_cp_field.module --- openid_cp_field.module 29 Jun 2009 13:02:14 -0000 1.1.2.14 +++ openid_cp_field.module 29 Jun 2009 15:21:02 -0000 @@ -384,6 +384,31 @@ function openid_cp_field_get_mapping(&$m } /** + * Assigns a profile node to the user + * + * @param $uid + * User id + * @return + * Node object of the profile + */ +function openid_cp_field_assign_profile($uid) { + static $user_type = array(); + if (isset($user_type[$uid])) { + return $user_type[$uid]; + } + $types = array_keys(content_profile_get_types('names')); + foreach ($types as $type) { + $profile = content_profile_load($type, $uid); + if ($profile !== FALSE) { + $user_type[$uid] = $profile; + break; + } + } + $user_type[$uid] = isset($user_type[$uid]) ? $user_type[$uid] : FALSE; + return $user_type[$uid]; +} + +/** * Utility function to retrieve the value for the field if all permissions checks pass * * @param $field @@ -392,25 +417,11 @@ function openid_cp_field_get_mapping(&$m */ function _openid_cp_field_get_value($field) { global $user; - static $user_type = array(); static $mapping = array(); $appendix = strstr($field, '.sreg.') && !strstr($field, 'axschema.org') ? '_sreg' : ''; - - if (!isset($user_type[$user->uid])) { - $types = array_keys(content_profile_get_types('names')); - foreach ($types as $type) { - $profile = content_profile_load($type, $user->uid); - if ($profile !== FALSE) { - $user_type[$user->uid] = $profile; - break; - } - } - } - else { - $profile = $user_type[$user->uid]; - $type = $profile->type; - } + $profile = openid_cp_field_assign_profile($user->uid); + $type = $profile->type; $type .= $appendix; if (count($mapping) == 0) {