Index: components/date.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/date.inc,v
retrieving revision 1.46
diff -u -r1.46 date.inc
--- components/date.inc	18 Oct 2010 07:21:10 -0000	1.46
+++ components/date.inc	6 Jan 2011 04:19:17 -0000
@@ -408,144 +408,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.
-  if (variable_get('configurable_timezones', 1) && $timezone_name == 'user') {
-    $timezone_name = isset($GLOBALS['user']->timezone) ? $GLOBALS['user']->timezone : 'UTC';
-  }
-  elseif (empty($timezone_name) || $timezone_name == 'user') {
-    $timezone_name = variable_get('date_default_timezone', 'UTC');
-  }
-
-  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.18
diff -u -r1.18 webform.pages.inc
--- includes/webform.pages.inc	17 Oct 2010 18:53:13 -0000	1.18
+++ includes/webform.pages.inc	6 Jan 2011 04:19:18 -0000
@@ -115,6 +115,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 */
@@ -139,7 +147,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 */
 
@@ -242,6 +250,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.61
diff -u -r1.61 webform.install
--- webform.install	30 Dec 2010 01:25:04 -0000	1.61
+++ webform.install	6 Jan 2011 04:19:15 -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',
@@ -458,3 +465,12 @@
     db_change_field('webform', 'additional_submit', 'additional_submit', array('type' => 'text', 'not null' => FALSE));
   }
 }
+
+/**
+ * Add column for webform status (open or closed).
+ */
+function webform_update_7306() {
+  if (!db_field_exists('webform', 'status')) {
+    db_add_field('webform', 'status', array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 1));
+  }
+}
Index: webform.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/webform.module,v
retrieving revision 1.274
diff -u -r1.274 webform.module
--- webform.module	3 Jan 2011 16:25:14 -0000	1.274
+++ webform.module	6 Jan 2011 04:19:17 -0000
@@ -511,7 +511,7 @@
       'render element' => 'webform',
     ),
     'webform_view_messages' => array(
-      'variables' => array('node' => NULL, 'teaser' => NULL, 'page' => NULL, 'submission_count' => NULL, 'limit_exceeded' => NULL, 'allowed_roles' => NULL),
+      'variables' => array('node' => NULL, 'teaser' => NULL, 'page' => NULL, 'submission_count' => NULL, 'limit_exceeded' => NULL, 'allowed_roles' => NULL, 'closed' => NULL),
     ),
     'webform_form' => array(
       'render element' => 'form',
@@ -1021,6 +1021,7 @@
     'submit_text' => '',
     'submit_limit' => -1,
     'submit_interval' => -1,
+    'status' => 1,
     'roles' => array(1, 2),
     'emails' => array(),
     'components' => array(),
@@ -1205,6 +1206,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.
@@ -1213,19 +1216,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.
@@ -1266,7 +1274,7 @@
 
   // Print out messages for the webform.
   if (empty($node->in_preview) && !isset($node->webform_block) && !$logging_in) {
-    theme('webform_view_messages', array('node' => $node, 'teaser' => $teaser, 'page' => $page, 'submission_count' => $submission_count, 'limit_exceeded' => $limit_exceeded, 'allowed_roles' => $allowed_roles));
+    theme('webform_view_messages', array('node' => $node, 'teaser' => $teaser, 'page' => $page, 'submission_count' => $submission_count, 'limit_exceeded' => $limit_exceeded, 'allowed_roles' => $allowed_roles, 'closed' => $closed));
   }
 
   // Add the output to the node.
@@ -1320,6 +1328,8 @@
  *   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($variables) {
   global $user;
@@ -1330,12 +1340,16 @@
   $submission_count = $variables['submission_count'];
   $limit_exceeded = $variables['limit_exceeded'];
   $allowed_roles = $variables['allowed_roles'];
+  $closed = $variables['closed'];
 
   $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.');
@@ -1855,7 +1869,7 @@
     module_load_include('inc', 'webform', 'includes/webform.submissions');
 
     if (!$finished && $limit_exceeded = _webform_submission_limit_check($node)) {
-      $error = theme('webform_view_messages', array('node' => $node, 'teaser' => 0, 'pager' => 1, 'submission_count' => 0, 'limit_exceeded' => $limit_exceeded, 'allowed_roles' => array_keys(user_roles())));
+      $error = theme('webform_view_messages', array('node' => $node, 'teaser' => 0, 'pager' => 1, 'submission_count' => 0, 'limit_exceeded' => $limit_exceeded, 'allowed_roles' => array_keys(user_roles()), 'closed' => FALSE));
       form_set_error('', $error);
       return;
     }
@@ -3166,6 +3180,147 @@
 }
 
 /**
+ * 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.
+  if (variable_get('configurable_timezones', 1) && $timezone_name == 'user') {
+    $timezone_name = isset($GLOBALS['user']->timezone) ? $GLOBALS['user']->timezone : 'UTC';
+  }
+  elseif (empty($timezone_name) || $timezone_name == 'user') {
+    $timezone_name = variable_get('date_default_timezone', 'UTC');
+  }
+
+  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) {
