You are here

function autosave_nodeapi in Autosave 5.3

Same name and namespace in other branches
  1. 6.2 autosave.module \autosave_nodeapi()
  2. 6 autosave.module \autosave_nodeapi()

Implementation of hook_nodeapi().

Delete autosave table entry on successful submit (add or update) of node

File

./autosave.module, line 184
Automatically saves a node after a period of time.

Code

function autosave_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  if ($op == 'submit') {

    // we remove ALL edits for that page (not just the users) to avoid:
    //  - user1 asaves but doesnt submit
    //  - user2 edits same node and submits
    //  - user1 comes back to edit -> user1 SHOULD lose edits since user2 has precedence
    db_query("DELETE FROM {autosaved_forms} WHERE form_id = '%s' AND path = '%s'", $node->form_id, $_GET['q']);
  }
}