You are here

function autosave_save in Autosave 7.2

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

Menu callback; autosaves the form.

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

File

./autosave.module, line 387
Does background saves of node being edited.

Code

function autosave_save() {
  global $user;

  // Possibility to prevent autosaving.
  $prevent_autosave = FALSE;
  drupal_alter('autosave_prevent', $prevent_autosave);
  $path = $_POST['autosave_form_path'];
  $form_id = $_POST['form_id'];

  // Not all variables need to be serialized.
  unset($_POST['autosave_form_path'], $_POST['op'], $_POST['form_build_id']);
  $serialized = serialize($_POST);
  if (!$prevent_autosave) {

    // Currently, each user can have only one autosave form at a particular path.
    db_merge('autosaved_forms')
      ->key(array(
      'form_id' => $form_id,
      'path' => $path,
      'uid' => $user->uid,
    ))
      ->fields(array(
      'timestamp' => REQUEST_TIME,
      'serialized' => $serialized,
    ))
      ->execute();
  }
  exit;
}