Index: components/date.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/date.inc,v
retrieving revision 1.29.2.16
diff -u -r1.29.2.16 date.inc
--- components/date.inc	18 Oct 2010 07:20:54 -0000	1.29.2.16
+++ components/date.inc	6 Jan 2011 04:22:22 -0000
@@ -405,145 +405,3 @@
     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: 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 -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	6 Jan 2011 04:22:22 -0000
@@ -113,6 +113,14 @@
     '#parents' => array('submit_interval'),
   );
 
+  $form['submission']['status'] = array(
+    '#type' => 'radios',
+    '#title' => t('Status of this form'),
+    '#default_value' => $node->webform['status'] == 0 ? 0 : 1,
+    '#description' => t('Closing a form prevents any further submissions by any users.'),
+    '#parents' => array('status'),
+    '#options' => array(1 => t('Open'), 0 => t('Closed')),
+  );
   /* End Edit Form */
 
   /* Start per-role submission control */
@@ -137,7 +145,7 @@
     '#options' => $user_roles,
     '#type' => 'checkboxes',
     '#title' => t('Roles that can submit this webform'),
-    '#description' => t('Uncheck all roles to prevent new submissions. The %authenticated role applies to any user signed into the site, regardless of other assigned roles.', array('%authenticated' => $user_roles[2])),
+    '#description' => t('The %authenticated role applies to any user signed into the site, regardless of other assigned roles.', array('%authenticated' => $user_roles[2])),
   );
   /* End per-role submission control */
 
@@ -240,6 +248,9 @@
   // Save the redirect URL
   $node->webform['redirect_url'] = $form_state['values']['redirect_url'];
 
+  // Overall form status.
+  $node->webform['status'] = $form_state['values']['status'];
+
   // Save roles.
   $node->webform['roles'] = array_keys(array_filter($form_state['values']['roles']));
 
Index: webform.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/webform.install,v
retrieving revision 1.40.2.22
diff -u -r1.40.2.22 webform.install
--- webform.install	18 Oct 2010 08:08:59 -0000	1.40.2.22
+++ webform.install	6 Jan 2011 04:22:20 -0000
@@ -39,6 +39,13 @@
         'length' => 255,
         'default' => '<confirmation>',
       ),
+      'status' => array(
+        'description' => 'Boolean value of a webform for open (1) or closed (0).',
+        'type' => 'int',
+        'size' => 'tiny',
+        'not null' => TRUE,
+        'default' => 1,
+      ),
       'block' => array(
          'description' => 'Boolean value for whether this form be available as a block.',
          'type' => 'int',
@@ -1259,6 +1266,17 @@
 }
 
 /**
+ * Add column for webform status (open or closed).
+ */
+function webform_update_6323() {
+  $ret = array();
+  if (!db_column_exists('webform', 'status')) {
+    db_add_field($ret, 'webform', 'status', array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, '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.73
diff -u -r1.196.2.73 webform.module
--- webform.module	3 Jan 2011 16:25:18 -0000	1.196.2.73
+++ webform.module	6 Jan 2011 04:22:22 -0000
@@ -495,7 +495,7 @@
       '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, 'closed' => NULL),
     ),
     'webform_form' => array(
       'arguments' => array('form' => NULL),
@@ -1014,6 +1014,7 @@
     'submit_text' => '',
     'submit_limit' => -1,
     'submit_interval' => -1,
+    'status' => 1,
     'roles' => array(1, 2),
     'emails' => array(),
     'components' => array(),
@@ -1173,6 +1174,8 @@
   $enabled = TRUE;
   $logging_in = FALSE;
   $limit_exceeded = FALSE;
+  $closed = 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 +1184,24 @@
     $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;
-    }
+  if ($node->webform['status'] == 0) {
+    $closed = 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 +1243,7 @@
 
   // 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, $closed);
   }
 
   if (isset($output)) {
@@ -1283,15 +1291,20 @@
  *   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 $closed
+ *   Boolean value if submissions are closed.
  */
-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, $closed) {
   global $user;
 
   $type = 'notice';
   $cached = $user->uid == 0 && variable_get('cache', 0);
 
-  // If not allowed to submit the form, give an explanation.
-  if (array_search(TRUE, $allowed_roles) === FALSE && $user->uid != 1) {
+  if ($closed) {
+    $message = t('Submissions for this form are closed.');
+  }
+  // If open and not allowed to submit the form, give an explanation.
+  elseif (array_search(TRUE, $allowed_roles) === FALSE && $user->uid != 1) {
     if (empty($allowed_roles)) {
       // No roles are allowed to submit the form.
       $message = t('Submissions for this form are closed.');
@@ -1827,7 +1840,7 @@
     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;
     }
@@ -3105,6 +3118,148 @@
 }
 
 /**
+ * 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;
+}
+
+/**
  * Wrapper function for tt() if i18nstrings enabled.
  */
 function webform_tt($name, $string, $langcode = NULL, $update = FALSE) {
