? 690894_webform_start_end_date.patch
? 690894_webform_start_end_date_2.patch
? 690894_webform_start_end_status.patch
Index: webform.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/webform.install,v
retrieving revision 1.40.2.22
diff -u -p -r1.40.2.22 webform.install
--- webform.install	18 Oct 2010 08:08:59 -0000	1.40.2.22
+++ webform.install	3 Jan 2011 15:50:30 -0000
@@ -85,6 +85,22 @@ function webform_schema() {
         'not null' => TRUE,
         'default' => -1,
       ),
+      'start_date' => array(
+        'description' => 'Start date for form submissions.',
+        'type' => 'int',
+        'default' => NULL,
+      ),
+      'end_date' => array(
+        'description' => 'End date for form submissions.',
+        'type' => 'int',
+        'default' => NULL,
+      ),
+      'status' => array(
+        'description' => 'Status of a webform.',
+        'type' => 'int',
+        'size' => 'tiny',
+        'default' => 1,
+      ),
     ),
     'primary key' => array('nid'),
   );
@@ -1259,6 +1275,32 @@ function webform_update_6322() {
 }
 
 /**
+ * Add fields for scheduling open/close of form submissions and form status (published/unpublished).
+ */
+function webform_update_6323() {
+  $ret = array();
+
+  // Safety checks to prevent re-adding existing columns.
+  if (db_column_exists('webform', 'start_date')) {
+    return $ret;
+  }
+  if (db_column_exists('webform', 'end_date')) {
+    return $ret;
+  }
+  if (db_column_exists('webform', 'status')) {
+    return $ret;
+  }
+
+  // Add the new start & end date and status columns.
+  db_add_field($ret, 'webform', 'start_date', array('type' => 'int', 'length' => 11));
+  db_add_field($ret, 'webform', 'end_date', array('type' => 'int', 'length' => 11));
+  db_add_field($ret, 'webform', 'status', array('type' => 'int', 'size' => 'tiny', 'default' => 1));
+
+  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.196.2.72
diff -u -p -r1.196.2.72 webform.module
--- webform.module	29 Dec 2010 23:56:56 -0000	1.196.2.72
+++ webform.module	3 Jan 2011 15:50:32 -0000
@@ -495,7 +495,7 @@ function webform_theme() {
       'arguments' => array('node' => NULL, 'teaser' => NULL, 'page' => NULL, 'form' => NULL, 'enabled' => NULL),
     ),
     'webform_view_messages' => array(
-      'arguments' => array('node' => NULL, 'teaser' => NULL, 'page' => NULL, 'submission_count' => NULL, 'limit_exceeded' => NULL, 'allowed_roles' => NULL),
+      'arguments' => array('node' => NULL, 'teaser' => NULL, 'page' => NULL, 'submission_count' => NULL, 'limit_exceeded' => NULL, 'allowed_roles' => NULL, 'unpublished' => NULL),
     ),
     'webform_form' => array(
       'arguments' => array('form' => NULL),
@@ -1014,6 +1014,9 @@ function webform_node_defaults() {
     'submit_text' => '',
     'submit_limit' => -1,
     'submit_interval' => -1,
+    'start_date' => '',
+    'end_date' => '',
+    'status' => 1,
     'roles' => array(1, 2),
     'emails' => array(),
     'components' => array(),
@@ -1173,6 +1176,8 @@ function webform_node_view(&$node, $teas
   $enabled = TRUE;
   $logging_in = FALSE;
   $limit_exceeded = FALSE;
+  $unpublished = FALSE;
+  $allowed_roles = array();
 
   // When logging in using a form on the same page as a webform node, surpress
   // output messages so that they don't show up after the user has logged in.
@@ -1181,19 +1186,29 @@ function webform_node_view(&$node, $teas
     $logging_in = TRUE;
   }
 
-  // Check if the user's role can submit this webform.
-  if (variable_get('webform_submission_access_control', 1)) {
-    $allowed_roles = array();
-    foreach ($node->webform['roles'] as $rid) {
-      $allowed_roles[$rid] = isset($user->roles[$rid]) ? TRUE : FALSE;
-    }
-    if (array_search(TRUE, $allowed_roles) === FALSE && $user->uid != 1) {
-      $enabled = FALSE;
-    }
+  // Make sure that the form isn't expired (having an end date previous to today),
+  // not yet active (begin date after today), or is unpublished by the user.
+  $start = $node->webform['start_date']; // 0 if unset.
+  $end = $node->webform['end_date'];
+  $now = time();
+  if (($start && $start > $now) || ($end && $end < $now) || $node->webform['status'] == 0) {
+    $unpublished = TRUE;
+    $enabled = FALSE;
   }
   else {
-    // If not using Webform submission access control, allow for all roles.
-    $allowed_roles = array_keys(user_roles());
+    // Check if the user's role can submit this webform.
+    if (variable_get('webform_submission_access_control', 1)) {
+      foreach ($node->webform['roles'] as $rid) {
+        $allowed_roles[$rid] = isset($user->roles[$rid]) ? TRUE : FALSE;
+      }
+      if (array_search(TRUE, $allowed_roles) === FALSE && $user->uid != 1) {
+        $enabled = FALSE;
+      }
+    }
+    else {
+      // If not using Webform submission access control, allow for all roles.
+      $allowed_roles = array_keys(user_roles());
+    }
   }
 
   // Check if the user can add another submission.
@@ -1235,7 +1250,7 @@ function webform_node_view(&$node, $teas
 
   // Print out messages for the webform.
   if ($node->build_mode != NODE_BUILD_PREVIEW && !isset($node->webform_block) && !$logging_in) {
-    theme('webform_view_messages', $node, $teaser, $page, $submission_count, $limit_exceeded, $allowed_roles);
+    theme('webform_view_messages', $node, $teaser, $page, $submission_count, $limit_exceeded, $allowed_roles, $unpublished);
   }
 
   if (isset($output)) {
@@ -1283,8 +1298,10 @@ function theme_webform_view($node, $teas
  *   Boolean value if the submission limit for this user has been exceeded.
  * @param $allowed_roles
  *   A list of user roles that are allowed to submit this webform.
+ * @param $unpublished
+ *   Boolean value if submissions are unpublished.
  */
-function theme_webform_view_messages($node, $teaser, $page, $submission_count, $limit_exceeded, $allowed_roles) {
+function theme_webform_view_messages($node, $teaser, $page, $submission_count, $limit_exceeded, $allowed_roles, $unpublished) {
   global $user;
 
   $type = 'notice';
@@ -1312,6 +1329,10 @@ function theme_webform_view_messages($no
       $message = t('You do not have permission to view this form.');
     }
   }
+  // Form submission disabled by date or user setting.
+  elseif ($unpublished) {
+    $message = t('Submissions for this form are currently closed.');
+  }
 
   // If the user has exceeded the limit of submissions, explain the limit.
   elseif ($limit_exceeded && !$cached) {
@@ -1827,7 +1848,7 @@ function webform_client_form_validate($f
     module_load_include('inc', 'webform', 'includes/webform.submissions');
 
     if (!$finished && $limit_exceeded = _webform_submission_limit_check($node)) {
-      $error = theme('webform_view_messages', $node, 0, 1, 0, $limit_exceeded, array_keys(user_roles()));
+      $error = theme('webform_view_messages', $node, 0, 1, 0, $limit_exceeded, array_keys(user_roles()), FALSE);
       form_set_error('', $error);
       return;
     }
@@ -3068,6 +3089,183 @@ function webform_component_invoke($type,
 }
 
 /**
+ * Webform date & time functions. Used in date.inc, time.inc and others.
+ */
+
+/**
+ * Convert an ISO 8601 date or time into an array.
+ *
+ * This converst full format dates or times. Either a date or time may be
+ * provided, in which case only those portions will be returned. Dashes and
+ * colons must be used, never implied.
+ *
+ * Formats:
+ * Dates: YYYY-MM-DD
+ * Times: HH:MM:SS
+ * Datetimes: YYYY-MM-DDTHH:MM:SS
+ *
+ * @param $string
+ *   An ISO 8601 date, time, or datetime.
+ * @param $type
+ *   If wanting only specific fields back, specify either "date" or "time".
+ *   Leaving empty will return an array with both date and time keys, even if
+ *   some are empty. Returns an array with the following keys:
+ *   - year
+ *   - month
+ *   - day
+ *   - hour (in 24hr notation)
+ *   - minute
+ *   - second
+ */
+function webform_date_array($string, $type = NULL) {
+  $pattern = '/((\d{4}?)-(\d{2}?)-(\d{2}?))?(T?(\d{2}?):(\d{2}?):(\d{2}?))?/';
+  $matches = array();
+  preg_match($pattern, $string, $matches);
+  $matches += array_fill(0, 9, '');
+
+  $return = array();
+
+  // Check for a date string.
+  if ($type == 'date' || !isset($type)) {
+    $return['year'] = $matches[2] !== '' ? (int) $matches[2] : '';
+    $return['month'] = $matches[3] !== '' ? (int) $matches[3] : '';
+    $return['day'] = $matches[4] !== '' ? (int) $matches[4] : '';
+  }
+
+  // Check for a time string.
+  if ($type == 'time' || !isset($type)) {
+    $return['hour'] = $matches[6] !== '' ? (int) $matches[6] : '';
+    $return['minute'] = $matches[7] !== '' ? (int) $matches[7] : '';
+    $return['second'] = $matches[8] !== '' ? (int) $matches[8] : '';
+  }
+
+  return $return;
+}
+
+/**
+ * Convert an array of a date or time into an ISO 8601 compatible string.
+ *
+ * @param $array
+ *   The array to convert to a date or time string.
+ * @param $type
+ *   If wanting a specific string format back specify either "date" or "time".
+ *   Otherwise a full ISO 8601 date and time string will be returned.
+ */
+function webform_date_string($array, $type = NULL) {
+  $string = '';
+
+  if ($type == 'date' || !isset($type)) {
+    $string .= empty($array['year']) ? '0000' : sprintf('%04d', $array['year']);
+    $string .= '-';
+    $string .= empty($array['month']) ? '00' : sprintf('%02d', $array['month']);
+    $string .= '-';
+    $string .= empty($array['day']) ? '00' : sprintf('%02d', $array['day']);
+  }
+
+  if (!isset($type)) {
+    $string .= 'T';
+  }
+
+  if ($type == 'time' || !isset($type)) {
+    $string .= empty($array['hour']) ? '00' :  sprintf('%02d', $array['hour']);
+    $string .= ':';
+    $string .= empty($array['minute']) ? '00' :  sprintf('%02d', $array['minute']);
+    $string .= ':';
+    $string .= empty($array['second']) ? '00' :  sprintf('%02d', $array['second']);
+  }
+
+  return $string;
+}
+
+/**
+ * Get a date format according to the site settings.
+ *
+ * @param $size
+ *   A choice of 'short', 'medium', or 'long' date formats.
+ */
+function webform_date_format($size = 'medium') {
+    // Format date according to site's given format.
+    $format = variable_get('date_format_' . $size, 'D, m/d/Y - H:i');
+    $time = 'aABgGhHisueIOPTZ';
+    $day_of_week = 'Dlw';
+    $special = ',-: ';
+    $date_format = trim($format, $time . $day_of_week . $special);
+
+    // Ensure that a day, month, and year value are present. Use a default
+    // format if all the values are not found.
+    if (!preg_match('/[dj]/', $date_format) || !preg_match('/[FmMn]/', $date_format) || !preg_match('/[oYy]/', $date_format)) {
+      $date_format = 'm/d/Y';
+    }
+
+    return $date_format;
+}
+
+/**
+ * Return a date in the format specied taking into consideration user timezones.
+ */
+function webform_strtodate($format, $string, $timezone_name = NULL) {
+  // Adjust the time based on the user or site timezone.
+  // The "timezone_name" variable is provided by DateAPI in Drupal 6.
+  if (variable_get('configurable_timezones', 1) && $timezone_name == 'user') {
+    $timezone_name = isset($GLOBALS['user']->timezone_name) ? $GLOBALS['user']->timezone_name : NULL;
+  }
+  elseif (empty($timezone_name) || $timezone_name == 'user') {
+    $timezone_name = variable_get('date_default_timezone_name', NULL);
+  }
+
+  if (!empty($timezone_name) && class_exists('DateTimeZone')) {
+    $timezone = new DateTimeZone($timezone_name);
+    $datetime = new DateTime($string, $timezone);
+    return $datetime->format($format);
+  }
+  else {
+    return date($format, strtotime($string));
+  }
+}
+
+/**
+ * Get a timestamp in GMT time, ensuring timezone accuracy.
+ */
+function webform_strtotime($date) {
+  $current_tz = date_default_timezone_get();
+  date_default_timezone_set('UTC');
+  $timestamp = strtotime($date);
+  date_default_timezone_set($current_tz);
+  return $timestamp;
+}
+
+/**
+ * Convert a time between a 24-hour and a 12-hour value.
+ *
+ * @param $array
+ *   An array of hour, minute, second, and optionally ampm.
+ * @param $format
+ *   Either 12-hour or 24-hour.
+ * @return
+ *   An array with hour, minute, second, and ampm (if using "12-hour").
+ */
+function webform_time_convert($array, $format) {
+  if ($array['hour'] !== '') {
+    if ($format == '12-hour') {
+      $array['ampm'] = ($array['hour'] >= 12 && $array['hour'] < 24) ? 'pm' : 'am';
+      $array['hour'] = ($array['hour'] > 12 || $array['hour'] == 0) ? abs($array['hour'] - 12) : (int) $array['hour'];
+    }
+    elseif ($format == '24-hour' && isset($array['ampm'])) {
+      $array['hour'] = ($array['hour'] < 12 && $array['ampm'] == 'pm') ? $array['hour'] + 12 : (int) $array['hour'];
+    }
+  }
+
+  if ($format == '12-hour' && !isset($array['ampm'])) {
+    $array['ampm'] = '';
+  }
+  elseif ($format == '24-hour' && isset($array['ampm'])) {
+    unset($array['ampm']);
+  }
+
+  return $array;
+}
+
+/**
  * Disable the Drupal page cache.
  */
 function webform_disable_page_cache() {
Index: components/date.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/date.inc,v
retrieving revision 1.29.2.16
diff -u -p -r1.29.2.16 date.inc
--- components/date.inc	18 Oct 2010 07:20:54 -0000	1.29.2.16
+++ components/date.inc	3 Jan 2011 15:50:32 -0000
@@ -405,145 +405,3 @@ function _webform_csv_data_date($compone
     return '';
   }
 }
-
-/**
- * Convert an ISO 8601 date or time into an array.
- *
- * This converst full format dates or times. Either a date or time may be
- * provided, in which case only those portions will be returned. Dashes and
- * colons must be used, never implied.
- *
- * Formats:
- * Dates: YYYY-MM-DD
- * Times: HH:MM:SS
- * Datetimes: YYYY-MM-DDTHH:MM:SS
- *
- * @param $string
- *   An ISO 8601 date, time, or datetime.
- * @param $type
- *   If wanting only specific fields back, specify either "date" or "time".
- *   Leaving empty will return an array with both date and time keys, even if
- *   some are empty. Returns an array with the following keys:
- *   - year
- *   - month
- *   - day
- *   - hour (in 24hr notation)
- *   - minute
- *   - second
- */
-function webform_date_array($string, $type = NULL) {
-  $pattern = '/((\d{4}?)-(\d{2}?)-(\d{2}?))?(T?(\d{2}?):(\d{2}?):(\d{2}?))?/';
-  $matches = array();
-  preg_match($pattern, $string, $matches);
-  $matches += array_fill(0, 9, '');
-
-  $return = array();
-
-  // Check for a date string.
-  if ($type == 'date' || !isset($type)) {
-    $return['year'] = $matches[2] !== '' ? (int) $matches[2] : '';
-    $return['month'] = $matches[3] !== '' ? (int) $matches[3] : '';
-    $return['day'] = $matches[4] !== '' ? (int) $matches[4] : '';
-  }
-
-  // Check for a time string.
-  if ($type == 'time' || !isset($type)) {
-    $return['hour'] = $matches[6] !== '' ? (int) $matches[6] : '';
-    $return['minute'] = $matches[7] !== '' ? (int) $matches[7] : '';
-    $return['second'] = $matches[8] !== '' ? (int) $matches[8] : '';
-  }
-
-  return $return;
-}
-
-/**
- * Convert an array of a date or time into an ISO 8601 compatible string.
- *
- * @param $array
- *   The array to convert to a date or time string.
- * @param $type
- *   If wanting a specific string format back specify either "date" or "time".
- *   Otherwise a full ISO 8601 date and time string will be returned.
- */
-function webform_date_string($array, $type = NULL) {
-  $string = '';
-
-  if ($type == 'date' || !isset($type)) {
-    $string .= empty($array['year']) ? '0000' : sprintf('%04d', $array['year']);
-    $string .= '-';
-    $string .= empty($array['month']) ? '00' : sprintf('%02d', $array['month']);
-    $string .= '-';
-    $string .= empty($array['day']) ? '00' : sprintf('%02d', $array['day']);
-  }
-
-  if (!isset($type)) {
-    $string .= 'T';
-  }
-
-  if ($type == 'time' || !isset($type)) {
-    $string .= empty($array['hour']) ? '00' :  sprintf('%02d', $array['hour']);
-    $string .= ':';
-    $string .= empty($array['minute']) ? '00' :  sprintf('%02d', $array['minute']);
-    $string .= ':';
-    $string .= empty($array['second']) ? '00' :  sprintf('%02d', $array['second']);
-  }
-
-  return $string;
-}
-
-/**
- * Get a date format according to the site settings.
- *
- * @param $size
- *   A choice of 'short', 'medium', or 'long' date formats.
- */
-function webform_date_format($size = 'medium') {
-    // Format date according to site's given format.
-    $format = variable_get('date_format_' . $size, 'D, m/d/Y - H:i');
-    $time = 'aABgGhHisueIOPTZ';
-    $day_of_week = 'Dlw';
-    $special = ',-: ';
-    $date_format = trim($format, $time . $day_of_week . $special);
-
-    // Ensure that a day, month, and year value are present. Use a default
-    // format if all the values are not found.
-    if (!preg_match('/[dj]/', $date_format) || !preg_match('/[FmMn]/', $date_format) || !preg_match('/[oYy]/', $date_format)) {
-      $date_format = 'm/d/Y';
-    }
-
-    return $date_format;
-}
-
-/**
- * Return a date in the format specied taking into consideration user timezones.
- */
-function webform_strtodate($format, $string, $timezone_name = NULL) {
-  // Adjust the time based on the user or site timezone.
-  // The "timezone_name" variable is provided by DateAPI in Drupal 6.
-  if (variable_get('configurable_timezones', 1) && $timezone_name == 'user') {
-    $timezone_name = isset($GLOBALS['user']->timezone_name) ? $GLOBALS['user']->timezone_name : NULL;
-  }
-  elseif (empty($timezone_name) || $timezone_name == 'user') {
-    $timezone_name = variable_get('date_default_timezone_name', NULL);
-  }
-
-  if (!empty($timezone_name) && class_exists('DateTimeZone')) {
-    $timezone = new DateTimeZone($timezone_name);
-    $datetime = new DateTime($string, $timezone);
-    return $datetime->format($format);
-  }
-  else {
-    return date($format, strtotime($string));
-  }
-}
-
-/**
- * Get a timestamp in GMT time, ensuring timezone accuracy.
- */
-function webform_strtotime($date) {
-  $current_tz = date_default_timezone_get();
-  date_default_timezone_set('UTC');
-  $timestamp = strtotime($date);
-  date_default_timezone_set($current_tz);
-  return $timestamp;
-}
Index: components/time.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/time.inc,v
retrieving revision 1.24.2.14
diff -u -p -r1.24.2.14 time.inc
--- components/time.inc	18 Oct 2010 07:20:54 -0000	1.24.2.14
+++ components/time.inc	3 Jan 2011 15:50:33 -0000
@@ -343,34 +343,3 @@ function _webform_csv_data_time($compone
     return '';
   }
 }
-
-/**
- * Convert a time between a 24-hour and a 12-hour value.
- *
- * @param $array
- *   An array of hour, minute, second, and optionally ampm.
- * @param $format
- *   Either 12-hour or 24-hour.
- * @return
- *   An array with hour, minute, second, and ampm (if using "12-hour").
- */
-function webform_time_convert($array, $format) {
-  if ($array['hour'] !== '') {
-    if ($format == '12-hour') {
-      $array['ampm'] = ($array['hour'] >= 12 && $array['hour'] < 24) ? 'pm' : 'am';
-      $array['hour'] = ($array['hour'] > 12 || $array['hour'] == 0) ? abs($array['hour'] - 12) : (int) $array['hour'];
-    }
-    elseif ($format == '24-hour' && isset($array['ampm'])) {
-      $array['hour'] = ($array['hour'] < 12 && $array['ampm'] == 'pm') ? $array['hour'] + 12 : (int) $array['hour'];
-    }
-  }
-
-  if ($format == '12-hour' && !isset($array['ampm'])) {
-    $array['ampm'] = '';
-  }
-  elseif ($format == '24-hour' && isset($array['ampm'])) {
-    unset($array['ampm']);
-  }
-
-  return $array;
-}
Index: includes/webform.pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/includes/webform.pages.inc,v
retrieving revision 1.10.2.4
diff -u -p -r1.10.2.4 webform.pages.inc
--- includes/webform.pages.inc	17 Oct 2010 18:53:09 -0000	1.10.2.4
+++ includes/webform.pages.inc	3 Jan 2011 15:50:33 -0000
@@ -113,6 +113,36 @@ function webform_configure_form(&$form_s
     '#parents' => array('submit_interval'),
   );
 
+  $format = webform_date_format('short');
+
+  $form['submission']['start_date'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Submission start date'),
+    '#default_value' => $node->webform['start_date'] != 0 ? date($format, $node->webform['start_date']) : '',
+    '#description' => t('Start date for submissions - the form will display "Submissions for this form are currently closed." prior to the date entered. Leaving this field blank will activate the form immediately.'). '<br />' . t('Accepts any date in any <a href="http://www.gnu.org/software/tar/manual/html_chapter/Date-input-formats.html">GNU Date Input Format</a>. Strings such as today, +2 months, and Dec 9 2004 are all valid.'),
+    '#parents' => array('start_date'),
+    '#size' => 60,
+    '#maxlength' => 127,
+  );
+
+  $form['submission']['end_date'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Submission end date'),
+    '#default_value' => $node->webform['end_date'] != 0 ? date($format, $node->webform['end_date']) : '',
+    '#description' => t('End date for submissions - the form will display "Submissions for this form are currently closed." after the date entered. Leave this field blank for no expiration.'). '<br />' . t('Accepts any date in any <a href="http://www.gnu.org/software/tar/manual/html_chapter/Date-input-formats.html">GNU Date Input Format</a>. Strings such as today, +2 months, and Dec 9 2004 are all valid.'),
+    '#parents' => array('end_date'),
+    '#size' => 60,
+    '#maxlength' => 127,
+  );
+
+  $form['submission']['status'] = array(
+    '#type' => 'radios',
+    '#title' => t('Status of this form'),
+    '#default_value' => $node->webform['status'] == 0 ? 0 : 1,
+    '#description' => t('This setting allows you to set this form to be published or unpublished, i.e to allow users to submit the form or not.'),
+    '#parents' => array('status'),
+    '#options' => array(0 => t('Unpublished'), 1 => t('Published')),
+  );
   /* End Edit Form */
 
   /* Start per-role submission control */
@@ -225,12 +255,26 @@ function webform_configure_form_validate
   else {
     form_set_value($form['submission']['redirection']['redirect_url'], '<none>', $form_state);
   }
+
+  if (!empty($form_state['values']['start_date']) && strtotime($form_state['values']['start_date']) === false) {
+    form_error($form['submission']['start_date'], t('Please enter a valid start date.'));
+  }
+
+  if (!empty($form_state['values']['end_date']) && strtotime($form_state['values']['end_date']) === false) {
+    form_error($form['submission']['end_date'], t('Please enter a valid end date.'));
+  }
+
+  if (!empty($form_state['values']['start_date']) && !empty($form_state['values']['end_date']) && (strtotime($form_state['values']['end_date']) < strtotime($form_state['values']['start_date']))) {
+    form_error($form['submission']['start_date'], t('Start date cannot be after end date. Please adjust one or the other.'));
+  }
 }
 
 /**
  * Submit handler for webform_configure_form().
  */
 function webform_configure_form_submit($form, &$form_state) {
+  $current_tz = date_default_timezone_get();
+  date_default_timezone_set('UTC');
   $node = node_load($form_state['values']['nid']);
 
   // Save the confirmation.
@@ -262,6 +306,23 @@ function webform_configure_form_submit($
     $node->webform['submit_interval'] = $form_state['values']['submit_interval'];
   }
 
+  // Save date fields.
+  if (!empty($form_state['values']['start_date'])) {
+    $node->webform['start_date'] = strtotime($form_state['values']['start_date']);
+  }
+  else {
+    $node->webform['start_date'] = '';
+  }
+
+  if (!empty($form_state['values']['end_date'])) {
+    $node->webform['end_date'] = strtotime($form_state['values']['end_date']);
+  }
+  else {
+    $node->webform['end_date'] = '';
+  }
+
+  $node->webform['status'] = $form_state['values']['status'];
+
   // Set submit notice.
   $node->webform['submit_notice'] = $form_state['values']['submit_notice'];
 
