0

I am using the Revisioning module and it has an option when saving nodes: 'Modify current revision, no moderation'.

When selecting that option I want to retain the node revision author.

So far I think I need to do this:

Create my own submit callback for node_form and replace the submit button with my own so that the default submit handler is not called.

Copy the code out of the default submit handler into my new hander. Then before node_save is called I must impersonate revision author if my condition is met.

Is this right, or is there a better way to achieve this?

0

You definitely don't need to copy, replace, override, etc.

Node revision information is handled here. As you can see, the revision author is maintained, but most use-cases will call to show the original author.

Depending on your situation, there's many ways to show the revision author instead. For example, I see that the revisioning module you're using provides a revision-author token in revisioning_tokens.inc.

Other possibilities: hook_node_view in a module, template_preprocess_node in a theme's template.php, node--NODE-TYPE.tpl.php, etc.

Edit: BTW, if you went about updating the author ID like you mentioned, you would effectively change the ownership of the node to another user, which probably isn't a good idea!

  • There is a difference between the author uid and the revision author uid. There is a revision_uid member field attached to $node. It is the revision_uid that I need to retain as it seems that is what is being used for revision uid when a node is saved. – J. Reynolds Sep 11 '14 at 10:23
0

The solution turned out to be quite simple:

function MYMODULE_revisionapi($op, $node_revision) {
  switch ($op) {
    case 'post update':
        if (isset($node_revision->revision_operation)){
          switch($node_revision->revision_operation) {
            case 0:
              db_update('node_revision')
                ->fields(array('uid' => $node_revision->revision_uid))
                ->condition('vid', $node_revision->vid)
                ->execute();
              break;
            case 1:
              break;
            case 2:
              break;
          }
        }
      }
      break;
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.