You are here

function autosave_save in Autosave 5

Same name and namespace in other branches
  1. 5.3 autosave.module \autosave_save()
  2. 5.2 autosave.module \autosave_save()
  3. 6.2 autosave.module \autosave_save()
  4. 6 autosave.module \autosave_save()
  5. 7.2 autosave.module \autosave_save()
  6. 7 autosave.module \autosave_save()

Menu callback; autosaves the node.

1 string reference to 'autosave_save'
autosave_menu in ./autosave.module
Implementation of hook_menu().

File

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

Code

function autosave_save() {
  global $user;
  $path = $_POST['q'];
  $form_id = $_POST['form_id'];

  // Not all variables need to be serialized.
  unset($_POST['form_id'], $_POST['form_token'], $_POST['q']);
  $serialized = serialize($_POST);

  // Currently, each user can have only one autosave form at a particular path.
  db_query("DELETE FROM {autosaved_forms} WHERE form_id = '%s' AND path = '%s' AND uid = %d", $form_id, $path, $user->uid);
  db_query("INSERT INTO {autosaved_forms} (form_id, path, uid, timestamp, serialized) VALUES ('%s', '%s', %d, %d, '%s')", $form_id, $path, $user->uid, time(), $serialized);
  exit;
}