You are here

function user_revision_load in User Revision 7.2

Same name and namespace in other branches
  1. 7 user_revision.module \user_revision_load()

Load a revision.

Loads a user object with revision support.

5 calls to user_revision_load()
user_revision_show in ./user_revision.module
Show a revision.
user_revision_user_delete in ./user_revision.module
Implements hook_user_delete().
user_rev_diff_block_view in diff/user_rev_diff.module
Implements hook_block_view().
user_rev_diff_diffs_show in diff/user_rev_diff.pages.inc
Create output string for a comparison of 'user' between versions 'old_vid' and 'new_vid'.
user_rev_diff_inline_show in diff/user_rev_diff.pages.inc
Show the inline diff of a given user object v. the user with $old_vid. If $old_vid = 0 returns the normally rendered content of the user object. If metadata is TRUE a header will be added with a legend explaining the color code. This function returns…

File

./user_revision.module, line 391
Enables user revision.

Code

function user_revision_load($uid, $vid = NULL, $reset = FALSE) {
  if (isset($vid)) {
    $user = entity_revision_load('user', $vid);

    // Add the revision roles to user object.
    $query = db_select('user_revision_roles', 'revision')
      ->fields('role', array(
      'rid',
      'name',
    ));
    $query
      ->join('role', 'role', 'role.rid = revision.rid');
    $roles = $query
      ->condition('revision.vid', $vid)
      ->condition('revision.uid', $uid)
      ->execute()
      ->fetchAllKeyed();
    $user->roles = $roles;
    $fid = db_select('user_revision', 'ur')
      ->condition('ur.vid', $vid)
      ->fields('ur', array(
      'picture',
    ))
      ->execute()
      ->fetchField();
    if ($fid) {
      $user->picture = file_load($fid);
    }
    return $user;
  }
}