You are here

function user_relationships_api_translate_user_info in User Relationships 6

Same name and namespace in other branches
  1. 5.3 user_relationships_api/user_relationships_api.api.inc \user_relationships_api_translate_user_info()

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

3 calls to user_relationships_api_translate_user_info()
template_preprocess_user_relationships in user_relationships_ui/user_relationships_ui.module
Pre processor for user_relationships page
template_preprocess_user_relationships_pending_requests in user_relationships_ui/user_relationships_ui.module
Pre processor page for user_relationships_pending_requests page
user_relationships_load in user_relationships_api/user_relationships_api.api.inc
Load relationship objects from the database.

File

user_relationships_api/user_relationships_api.api.inc, line 408
User Relationships API. Data abstraction layer @author Jeff Smick (creator) @author Alex Karshakevich (maintainer) http://drupal.org/user/183217

Code

function user_relationships_api_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);
    }
  }
}