You are here

function user_relationships_translate_user_info in User Relationships 7

Used when the "include_user_info" option is set on user_relationships_load to translate the retrieved user fields into actual user objects. This allows us to pull the basic user data without having to run user_load

Parameters

$relationship: The relationship object with pulled user info

1 call to user_relationships_translate_user_info()
user_relationships_load in ./user_relationships.module
Load relationship objects from the database.

File

./user_relationships.module, line 847
User Relationships API. Module shell.

Code

function user_relationships_translate_user_info(&$relationship) {
  if ($relationship->requester_name) {
    foreach (array(
      'requester',
      'requestee',
    ) as $user_type) {
      $relationship->{$user_type} = new stdClass();
      foreach (array(
        'name',
        'mail',
        'data',
        'picture',
      ) as $field) {
        $db_field = "{$user_type}_{$field}";
        $relationship->{$user_type}->{$field} = $relationship->{$db_field};
        unset($relationship->{$db_field});
      }
      $user_type_id = "{$user_type}_id";
      $relationship->{$user_type}->uid = $relationship->{$user_type_id};
      $relationship->{$user_type}->data = unserialize($relationship->{$user_type}->data);
    }
  }
}