You are here

function revisioning_get_last_editor in Revisioning 8

Same name and namespace in other branches
  1. 6.3 revisioning_api.inc \revisioning_get_last_editor()
  2. 7 revisioning_api.inc \revisioning_get_last_editor()

Get the id of the user who last edited the supplied node.

ie. the author of the latest revision.

This is irrespective of whether this latest revision is pending or not, unless TRUE is specified for the second argument, in which case the uid of the creator of the current revision (published or not) is returned.

Parameters

int $nid: The id of the node whose most recent editor id is to be returned.

bool $current: Whether the uid of the current or very latest revision should be returned.

Return value

int A single number being the user id (uid).

1 call to revisioning_get_last_editor()
revisioning_handler_field_node_last_editor::render in views/revisioning_handler_field_node_last_editor.inc
Render data.

File

./revisioning_api.inc, line 144
API functions of Revisioning module

Code

function revisioning_get_last_editor($nid, $current = FALSE) {
  $sql = $current ? "SELECT vid FROM {node} WHERE nid = :nid" : "SELECT MAX(vid) FROM {node_revision} WHERE nid = :nid";
  $vid = db_query($sql, array(
    ':nid' => $nid,
  ))
    ->fetchField();
  $result = db_query("SELECT uid FROM {node_revision} WHERE vid = :vid", array(
    ':vid' => $vid,
  ));
  return $result
    ->fetchField();
}