You are here

function autosave_remove in Autosave 7.2

Menu callback to remove autosaved form from database.

Gets its data from $_POST.

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

File

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

Code

function autosave_remove() {
  if (!empty($_POST['form_id']) && !empty($_POST['form_token'])) {
    global $user;
    $form = array();
    $form['#form_id'] = str_replace('-', '_', $_POST['form_id']);
    if (drupal_valid_token($_POST['form_token'], $form['#form_id'])) {
      $_POST['autosave_form_path'] = $_POST['q'];
      $form_id = check_plain($_POST['form_id']);
      $path = check_plain($_POST['q']);
      $key = array(
        'form_id' => $form_id,
        'uid' => $user->uid,
        'path' => $path,
      );
      db_merge('autosaved_forms')
        ->key($key)
        ->updateFields(array(
        'timestamp' => 0,
        'serialized' => '',
      ))
        ->execute();
    }
  }
}