_node_save_revision

function _node_save_revision

_node_save_revision($node, $uid, $update = NULL)

Helper function to save a revision with the uid of the current user.

The resulting revision ID is available afterward in $node->vid.

Parameters

$node: A node object.

$uid: The current user's UID.

$update: (optional) An array of primary keys' field names to update.

File

modules/node/node.module, line 1215
The core that allows content to be submitted to the site. Modules and scripts may programmatically submit nodes using the usual form API pattern.

Code

function _node_save_revision($node, $uid, $update = NULL) {
  $temp_uid = $node->uid;
  $node->uid = $uid;
  if (isset($update)) {
    drupal_write_record('node_revision', $node, $update);
  }
  else {
    drupal_write_record('node_revision', $node);
  }
  // Have node object still show node owner's uid, not revision author's.
  $node->uid = $temp_uid;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!node!node.module/function/_node_save_revision/7.x

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部