? .svn ? p_219181_editown.patch ? p_226907_draft.patch ? p_239343_access.patch ? p_239751_throttle.patch ? components/.svn ? po/.svn Index: webform.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/webform.install,v retrieving revision 1.14.2.16.2.15 diff -u -p -r1.14.2.16.2.15 webform.install --- webform.install 28 Feb 2008 03:21:40 -0000 1.14.2.16.2.15 +++ webform.install 31 Mar 2008 17:10:23 -0000 @@ -15,7 +15,7 @@ function webform_install() { confirmation text, teaser tinyint not null default '0', submit_text varchar(255) default NULL, - submit_limit tinyint not null default '-1', + submit_limit tinyint not null default '-1', submit_interval int not null default '-1', email varchar(255) default NULL, email_from_name varchar(255) default NULL, @@ -23,6 +23,7 @@ function webform_install() { email_subject varchar(255) default NULL, additional_validate text default NULL, additional_submit text default NULL, + allow_draft tinyint not null default '0', PRIMARY KEY (nid) ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */" ); @@ -48,6 +49,7 @@ function webform_install() { uid int(10) unsigned NOT NULL default '0', submitted int(11) NOT NULL default '0', remote_addr varchar(128), + is_draft tinyint not null default '0', PRIMARY KEY (sid), UNIQUE KEY sid_nid (sid, nid) ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */" @@ -80,6 +82,7 @@ function webform_install() { email_subject varchar(255) NOT NULL default '', additional_validate text default NULL, additional_submit text default NULL, + allow_draft smallint NOT NULL default '0', PRIMARY KEY (nid) )" ); @@ -105,6 +108,7 @@ function webform_install() { uid integer NOT NULL default '0', submitted integer NOT NULL default '0', remote_addr varchar(128) NOT NULL default '', + is_draft smallint NOT NULL default '0', PRIMARY KEY (sid) )" ); @@ -655,6 +659,25 @@ function webform_update_20() { } /** + * Add draft capabilities. + */ +function webform_update_21() { + $ret = array(); + switch ($GLOBALS['db_type']) { + case 'mysqli': + case 'mysql': + $ret[] = update_sql("ALTER TABLE {webform_submissions} ADD is_draft tinyint not null default '0'"); + $ret[] = update_sql("ALTER TABLE {webform} ADD allow_draft tinyint not null default '0'"); + break; + case 'pgsql': + $ret[] = update_sql("ALTER TABLE {webform_submissions} ADD is_draft smallint not null default '0'"); + $ret[] = update_sql("ALTER TABLE {webform} ADD allow_draft smallint not null default '0'"); + break; + } + return $ret; +} + +/** * Recursively delete all files and folders in the specified filepath, then * delete the containing folder. * Index: webform.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/webform.module,v retrieving revision 1.113.2.70.2.33 diff -u -p -r1.113.2.70.2.33 webform.module --- webform.module 30 Mar 2008 00:32:14 -0000 1.113.2.70.2.33 +++ webform.module 31 Mar 2008 17:10:23 -0000 @@ -13,7 +13,7 @@ */ /** - * Implemenation of hook_help(). + * Implementation of hook_help(). */ function webform_help($section = "admin/help#webform") { $output = ""; @@ -114,6 +114,13 @@ function webform_menu($may_cache) { 'access' => node_access('view', $node), 'type' => MENU_CALLBACK, ); + $items[]= array( + 'path' => 'node/'. $node->nid .'/draft_saved', + 'title' => t('Draft saved'), + 'callback' => '_webform_draft_confirmation', + 'callback arguments' => array(arg(1)), + 'type' => MENU_CALLBACK, + ); $items[] = array( 'path' => 'node/'. $nid .'/done', 'title' => t('Webform confirmation'), @@ -200,7 +207,7 @@ function webform_menu($may_cache) { 'path' => 'node/'. $nid .'/submission/'. $sid, 'title' => t('Webform submission'), 'callback' => 'drupal_get_form', - 'callback arguments' => array('webform_client_form_'. $node->nid, $node, $submission, FALSE, FALSE), + 'callback arguments' => array('webform_client_form_'. $node->nid, $node, $submission, FALSE, FALSE, FALSE), 'access' => webform_submission_access($node, $submission, 'view'), 'type' => MENU_CALLBACK, ); @@ -208,7 +215,7 @@ function webform_menu($may_cache) { 'path' => 'node/'. $nid .'/submission/'. $sid .'/view', 'title' => t('View'), 'callback' => 'drupal_get_form', - 'callback arguments' => array('webform_client_form_'. $node->nid, $node, $submission, FALSE, FALSE), + 'callback arguments' => array('webform_client_form_'. $node->nid, $node, $submission, FALSE, FALSE, FALSE), 'access' => webform_submission_access($node, $submission, 'view'), 'weight' => 0, 'type' => MENU_DEFAULT_LOCAL_TASK, @@ -217,7 +224,7 @@ function webform_menu($may_cache) { 'path' => 'node/'. $nid .'/submission/'. $sid .'/edit', 'title' => t('Edit'), 'callback' => 'drupal_get_form', - 'callback arguments' => array('webform_client_form_'. $node->nid, $node, $submission, TRUE, FALSE), + 'callback arguments' => array('webform_client_form_'. $node->nid, $node, $submission, TRUE, FALSE, FALSE), 'access' => webform_submission_access($node, $submission, 'edit'), 'weight' => 1, 'type' => MENU_LOCAL_TASK, @@ -259,7 +266,7 @@ function webform_node_info() { } /** - * Implemenation of hook_access(). + * Implementation of hook_access(). */ function webform_access($op, $node) { global $user; @@ -299,13 +306,13 @@ function webform_file_download($file) { } /** - * Implemenation of hook_insert(). + * Implementation of hook_insert(). */ function webform_insert($node) { include_once(drupal_get_path('module', 'webform') .'/webform_components.inc'); // Insert the Webform. - db_query("INSERT INTO {webform} (nid, confirmation, teaser, submit_text, submit_limit, submit_interval, email, email_from_name, email_from_address, email_subject, additional_validate, additional_submit) VALUES (%d, '%s', %d, '%s', %d, %d, '%s', '%s', '%s', '%s', '%s', '%s')", $node->nid, $node->webform['confirmation'], $node->webform['teaser'], $node->webform['submit_text'], $node->webform['submit_limit'], $node->webform['submit_interval'], $node->webform['email'], $node->webform['email_from_name'], $node->webform['email_from_address'], $node->webform['email_subject'], $node->webform['additional_validate'], $node->webform['additional_submit']); + db_query("INSERT INTO {webform} (nid, confirmation, teaser, submit_text, submit_limit, submit_interval, email, email_from_name, email_from_address, email_subject, additional_validate, additional_submit, allow_draft) VALUES (%d, '%s', %d, '%s', %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', %d)", $node->nid, $node->webform['confirmation'], $node->webform['teaser'], $node->webform['submit_text'], $node->webform['submit_limit'], $node->webform['submit_interval'], $node->webform['email'], $node->webform['email_from_name'], $node->webform['email_from_address'], $node->webform['email_subject'], $node->webform['additional_validate'], $node->webform['additional_submit'], $node->webform['allow_draft']); // Insert the components into the database. if (isset($node->webform['components']) && !empty($node->webform['components'])) { @@ -318,7 +325,7 @@ function webform_insert($node) { } /** - * Implemenation of hook_update(). + * Implementation of hook_update(). */ function webform_update($node) { // Update the webform by deleting existing data and replacing with the new. @@ -328,7 +335,7 @@ function webform_update($node) { } /** - * Implemenation of hook_delete(). + * Implementation of hook_delete(). */ function webform_delete(&$node) { db_query("DELETE FROM {webform} WHERE nid = %d", $node->nid); @@ -337,7 +344,7 @@ function webform_delete(&$node) { } /** - * Implemenation of hook_load(). + * Implementation of hook_load(). */ function webform_load($node) { $additions = new stdClass(); @@ -616,6 +623,13 @@ function webform_form(&$node, &$param) { '#description' => t('By default the submit button on this form will have the label Submit. Enter a new title here to override the default.'), ); + // Allow save draft + $form['webform']['advanced']['allow_draft'] = array( + '#type' => 'checkbox', + '#title' => t('Allow users to save a draft'), + '#default_value' => $node->webform['allow_draft'], + ); + if (user_access('use PHP for additional processing')) { $form['webform']['advanced']['additional_validate'] = array( '#type' => 'textarea', @@ -821,7 +835,7 @@ function webform_view(&$node, $teaser = $preview = FALSE; if ($_POST['op'] == t('Preview')) { - $preview = true; + $preview = TRUE; $additions = webform_load($node); $node->webform['components'] = $additions->webform['components']; } @@ -839,7 +853,18 @@ function webform_view(&$node, $teaser = } } - $output = drupal_get_form('webform_client_form_'. $node->nid, $node, $submission, $enabled, $preview); + // Check if this user has a draft for this webform. + $is_draft = FALSE; + if ($node->webform['allow_draft'] && $user->uid != 0) { + // Draft found - display form with draft data for further editing. + if ($_draft_sid = _webform_fetch_draft_sid($node->nid, $user->uid)) { + include_once(drupal_get_path('module', 'webform') ."/webform_submissions.inc"); + $submission = webform_get_submission($node->nid, $_draft_sid); + $enabled = TRUE; + $is_draft = TRUE; + } + } + $output = drupal_get_form('webform_client_form_'. $node->nid, $node, $submission, $enabled, $preview, $is_draft); // Remove the surrounding