You are here

function user_revision_list in User Revision 7

Same name and namespace in other branches
  1. 7.2 user_revision.module \user_revision_list()

Return a list of all the existing revision numbers.

1 call to user_revision_list()
user_revision_overview in ./user_revision.pages.inc
Generate an overview table of older revisions of a user.

File

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

Code

function user_revision_list($user) {
  $revisions = array();
  $result = db_select('user_revision', 'ur')
    ->fields('ur', array(
    'vid',
    'log',
    'authorid',
    'ip',
    'timestamp',
  ));
  $user_alias = $result
    ->leftJoin('users', 'u', "%alias.vid = ur.vid");
  $user_alias2 = $result
    ->leftJoin('users', 'u2', "%alias.uid = ur.authorid");
  $result
    ->addField($user_alias, 'vid', 'current_vid');
  $result
    ->addField($user_alias2, 'name', 'current_name');
  $result
    ->fields($user_alias2, array(
    'uid',
    'name',
  ));
  $result = $result
    ->condition('ur.uid', $user->uid)
    ->orderBy('ur.vid', 'DESC')
    ->execute()
    ->fetchAll();
  foreach ($result as $revision) {
    $revisions[$revision->vid] = $revision;
  }
  return $revisions;
}