You are here

function sheetnode_update in Sheetnode 7.2

Same name and namespace in other branches
  1. 5 sheetnode.module \sheetnode_update()
  2. 6 sheetnode.module \sheetnode_update()
  3. 7 sheetnode.module \sheetnode_update()

Implements hook_update().

File

./sheetnode.module, line 271
Module file for the sheetnode module.

Code

function sheetnode_update($node) {
  if (!empty($node->sheetnode['value'])) {
    _sheetnode_save($node->nid, $node->vid, $node->sheetnode['value']);
  }
  elseif (!empty($node->revision)) {

    // Reverting a revision.
    $value = db_query("SELECT value FROM {sheetnode} WHERE vid = :old", array(
      ':old' => $node->old_vid,
    ))
      ->fetchField();
    db_insert('sheetnode')
      ->fields(array(
      'vid' => $node->vid,
      'nid' => $node->nid,
      'value' => $value,
    ))
      ->execute();
  }
  if (!empty($node->sheetnode['template']) && user_access('create sheetnode template')) {
    _sheetnode_template_save($node->vid, $node->sheetnode['template'], $node->sheetnode['value']);
  }
}