Index: webform.module =================================================================== --- webform.module (revision 55) +++ webform.module (revision 59) @@ -103,6 +103,14 @@ 'access' => true, 'type' => MENU_CALLBACK, ); + $items[]= array( + 'path' => 'node/'. $node->nid .'/draft_saved', + 'title' => t('webform'), + 'callback' => '_webform_draft_confirmation', + 'callback arguments' => array(arg(1)), + 'access' => true, + 'type' => MENU_CALLBACK, + ); $items[] = array( 'path' => 'node/'. $node->nid .'/results', 'title' => t('Results'), @@ -226,7 +234,7 @@ } // Insert the Webform. - db_query("INSERT INTO {webform} (nid, confirmation, redirect_post, submit_limit, submit_interval, email, email_from_name, email_from_address, email_subject, additional_validate, additional_submit) VALUES (%d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s')", $node->nid, $node->confirmation, $node->redirect_post, $node->submit_limit, $node->submit_interval, $node->email, $node->email_from_name, $node->email_from_address, $node->email_subject, $node->additional_validate, $node->additional_submit); + db_query("INSERT INTO {webform} (nid, confirmation, redirect_post, submit_limit, submit_interval, email, email_from_name, email_from_address, email_subject, additional_validate, additional_submit, allow_draft) VALUES (%d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', %d)", $node->nid, $node->confirmation, $node->redirect_post, $node->submit_limit, $node->submit_interval, $node->email, $node->email_from_name, $node->email_from_address, $node->email_subject, $node->additional_validate, $node->additional_submit, $node->allow_draft); // Insert the components into the database. if (is_array($node->webformcomponents) && !empty($node->webformcomponents)) { @@ -795,6 +803,13 @@ ), ); + // Allow save draft + $form['advanced']['allow_draft'] = array( + '#type' => 'checkbox', + '#title' => t('Allow Users to Save a Draft'), + '#default_value' => $node->allow_draft, + ); + if (user_access('use PHP for additional processing')) { $form['advanced']['additional_validate'] = array( '#type' => 'textarea', @@ -1179,7 +1194,23 @@ } } - $output = drupal_get_form('webform_client_form_'. $node->nid, $node, $submission, $enabled); + // Check if this user has a draft for this webform + $is_draft = false; + if ($node->allow_draft && $user->uid != 0) + { + // Draft found - display form w/ draft data for further submission editing + if ($_draft_sid = _webform_fetch_draft_sid($node->nid, $user->uid)) + { + $submission = _webform_fetch_submission($_draft_sid, $node->nid); + $enabled = true; + $is_draft = true; + if (empty($_POST)) + { + drupal_set_message('Your previous draft was found. You may continue with your submission.', 'status'); + } + } + } + $output = drupal_get_form('webform_client_form_'. $node->nid, $node, $submission, $enabled, $is_draft); // Remove the surrounding