You are here

function revisioning_token_values in Revisioning 6.3

Same name and namespace in other branches
  1. 6.4 revisioning_tokens.inc \revisioning_token_values()

Implementation of hook_token_values().

File

./revisioning_tokens.inc, line 42
Add tokens pertaining to the Revisioning module.

Code

function revisioning_token_values($type, $object = NULL, $options = array()) {
  $values = array();
  switch ($type) {
    case 'node':
      $values['vid'] = $object->vid;
      $values['revision-title'] = $object->title;
      $values['revision-log'] = isset($object->log) ? $object->log : '';
      if (empty($object->revision_uid)) {

        // Can happen in Rules context
        $object->revision_uid = revisioning_get_revision_uid($object->vid);
      }
      _set_revision_author_values($object->revision_uid, $values);
      break;
    case 'op':
      switch ($object) {
        case 'publish':
        case 'revert':
        case 'unpublish':
          $nid = arg(1);
          $revision = node_load($nid, node_tools_get_current_node_revision_id($nid));
          $values['vid'] = $revision->vid;
          $values['revision-title'] = $revision->title;
          $values['revision-log'] = isset($revision->log) ? $revision->log : '';
          _set_revision_author_values($revision->revision_uid, $values);
      }
      break;
  }
  return $values;
}