You are here

function sheetnode_update in Sheetnode 6

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

Implementation of hook_update().

File

./sheetnode.module, line 286

Code

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

      // reverting a revision
      db_query("INSERT INTO {sheetnode} (nid, vid, value) \n              SELECT old.nid, %d, old.value \n              FROM sheetnode AS old WHERE old.vid=%d", array(
        $node->vid,
        $node->old_vid,
      ));
    }
  }
  if (!empty($node->sheetnode['template']) && user_access('create sheetnode template')) {
    _sheetnode_template_save($node->vid, $node->sheetnode['template'], $node->sheetnode['value']);
  }
}