Index: includes/webform.components.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/includes/webform.components.inc,v
retrieving revision 1.25.2.10
diff -u -r1.25.2.10 webform.components.inc
--- includes/webform.components.inc	26 Mar 2010 00:50:36 -0000	1.25.2.10
+++ includes/webform.components.inc	3 Apr 2010 02:37:33 -0000
@@ -295,7 +295,7 @@
   }
   elseif (isset($_POST['op']) && $_POST['op'] == t('Add')) {
     $component = $form_state['values']['add'];
-    $form_state['redirect'] = array('node/' . $node->nid . '/webform/components/new/' . $component['type'], 'name=' . urlencode($component['name']) . ' &mandatory=' . $component['mandatory'] . '&pid=' . $component['pid'] . '&weight=' . $component['weight']);
+    $form_state['redirect'] = array('node/' . $node->nid . '/webform/components/new/' . $component['type'], 'name=' . urlencode($component['name']) . '&mandatory=' . $component['mandatory'] . '&pid=' . $component['pid'] . '&weight=' . $component['weight']);
   }
   else {
     drupal_set_message(t('The component positions and mandatory values have been updated.'));
Index: webform.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/webform.module,v
retrieving revision 1.196.2.14
diff -u -r1.196.2.14 webform.module
--- webform.module	1 Apr 2010 02:07:44 -0000	1.196.2.14
+++ webform.module	3 Apr 2010 02:37:32 -0000
@@ -2243,7 +2243,7 @@
     ),
     'unsafe' => array(
       '%cookie' => $_COOKIE,
-      '%session' => $_SESSION,
+      '%session' => isset($_SESSION) ? $_SESSION : array(),
       '%request' => $_REQUEST,
       '%server' => $_SERVER,
       '%profile' => (array) $user,
Index: tests/webform.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/tests/webform.test,v
retrieving revision 1.5.2.1
diff -u -r1.5.2.1 webform.test
--- tests/webform.test	27 Mar 2010 18:21:06 -0000	1.5.2.1
+++ tests/webform.test	3 Apr 2010 02:37:33 -0000
@@ -12,17 +12,6 @@
   public $webform_users;
 
   /**
-   * Implementation of getInfo().
-   */
-  public static function getInfo() {
-    return array(
-      'name' => t('Webform'),
-      'description' => t('Parent test suite used to setup Webform tests.'),
-      'group' => t('Webform'),
-    );
-  }
-
-  /**
    * Implementation of setUp().
    */
   function setUp() {
@@ -113,14 +102,6 @@
       return $this->_webform_components;
     }
 
-    // Time components use a lot of conversion factors, generate a list of times
-    // equal to 10:30pm (the default value used as a sample).
-    $timestamp = strtotime('10:30pm');
-    $site_hour12 = gmdate('g', $timestamp + (int)variable_get('date_default_timezone', 0));
-    $site_hour24 = gmdate('G', $timestamp + (int)variable_get('date_default_timezone', 0));
-    $site_minute = gmdate('i', $timestamp + (int)variable_get('date_default_timezone', 0));
-    $site_ampm = gmdate('a', $timestamp + (int)variable_get('date_default_timezone', 0));
-
     $this->_webform_components = array(
       // Test date components.
       'date' => array(
@@ -141,8 +122,8 @@
           'page_num' => 1,
         ),
         'sample values' => array('day' => '30', 'month' => '9', 'year' => '1982'),
-        'database values' => array('9', '30', '1982'),
-        'database default values' => array('11', '19', '1978'),
+        'database values' => array('1982-09-30'),
+        'database default values' => array('1978-11-19'),
       ),
 
       // Test grid components.
@@ -153,8 +134,8 @@
           'type' => 'grid',
           'value' => '',
           'extra' => array(
-            'questions' => "Ålphå\nıé†å\nÎé¬†å", // Left side
-            'options' => "øne\ntwö\nǼBƇ\n€Euro", // Top
+            'questions' => "0|Ålphå\n1|ıé†å\n2|Îé¬†å", // Left side
+            'options' => "0|øne\n1|twö\n2|ǼBƇ\n3|€Euro", // Top
           ),
           'mandatory' => '0',
           'email' => '1',
@@ -162,8 +143,8 @@
           'weight' => '-19',
           'page_num' => 1,
         ),
-        'sample values' => array('q1' => 'øne', 'q2' => 'twö', 'q3' => 'ǼBƇ'),
-        'database values' => array('øne', 'twö', 'ǼBƇ'),
+        'sample values' => array('0' => '0', '1' => '1', '2' => '2'),
+        'database values' => array('0' => '0', '1' => '1', '2' => '2'),
         'database default values' => array('', '', ''),
       ),
       'grid_keyed' => array(
@@ -173,7 +154,7 @@
           'type' => 'grid',
           'value' => '',
           'extra' => array(
-            'questions' => "What's your option?\nAgåin?\nOne more time!", // Left side.
+            'questions' => "one|What's your option?\ntwo|Agåin?\nthree|One more time!", // Left side.
             'options' => "one|Option one\ntwo|Option 2\nthree| Three is me", // Top
           ),
           'mandatory' => '0',
@@ -182,61 +163,9 @@
           'weight' => '-15',
           'page_num' => 1,
         ),
-        'sample values' => array(
-          'q1' => 'one',
-          'q2' => 'two',
-          'q3' => 'three',
-        ),
-        'database values' => array('one', 'two', 'three'),
-        'database default values' => array('', '', ''),
-      ),
-      'grid_mixed' => array(
-        'component' => array(
-          'form_key' => 'grid_mixed',
-          'name' => 'Grid Mixed',
-          'type' => 'grid',
-          'value' => '',
-          'extra' => array(
-            'questions' => "Ålphå\nıé†å\nÎé¬†å", // Left side
-            'options' => "øne\ntwö\nǼBƇ\n€Euro", // Top
-            'optrand' => 1,
-            'qrand' => 1,
-          ),
-          'mandatory' => '0',
-          'email' => '1',
-          'pid' => '2',
-          'weight' => '-19',
-          'page_num' => 1,
-        ),
-        'sample values' => array('q1' => 'øne', 'q2' => 'twö', 'q3' => 'ǼBƇ'),
-        'database values' => array('øne', 'twö', 'ǼBƇ'),
-        'database default values' => array('', '', ''),
-      ),
-      'grid_keyed_mixed' => array(
-        'component' => array(
-          'form_key' => 'grid_keyed_mixed',
-          'name' => 'Grid Keyed',
-          'type' => 'grid',
-          'value' => '',
-          'extra' => array(
-            'questions' => "What's your option?\nAgåin?\nOne more time!", // Left side.
-            'options' => "one|Option one\ntwo|Option 2\nthree| Three is me", // Top
-            'optrand' => 1,
-            'qrand' => 1,
-          ),
-          'mandatory' => '0',
-          'email' => '1',
-          'pid' => '0',
-          'weight' => '-15',
-          'page_num' => 1,
-        ),
-        'sample values' => array(
-          'q1' => 'one',
-          'q2' => 'two',
-          'q3' => 'three',
-        ),
-        'database values' => array('one', 'two', 'three'),
-        'database default values' => array('', '', ''),
+        'sample values' => array('one' => 'one', 'two' => 'two', 'three' => 'three'),
+        'database values' => array('one' => 'one', 'two' => 'two', 'three' => 'three'),
+        'database default values' => array('one' => '', 'two' => '', 'three' => ''),
       ),
 
       // Test select components.
@@ -247,7 +176,7 @@
           'type' => 'select',
           'value' => 'two',
           'extra' => array(
-            'items' => "one\ntwo\nthree",
+            'items' => "one|one\ntwo|two\nthree|three",
             'multiple' => 'Y',
             'email' => 0,
           ),
@@ -261,6 +190,26 @@
         'database values' => array('one', 'three'),
         'database default values' => array('two'),
       ),
+      'checkboxes_zero' => array(
+        'component' => array(
+          'form_key' => 'checkboxes_zero',
+          'name' => 'Checkboxes zero',
+          'type' => 'select',
+          'value' => '0',
+          'extra' => array(
+            'items' => "0|zero\n1|one\n2|two",
+            'email' => 0,
+          ),
+          'mandatory' => '1',
+          'email' => '1',
+          'pid' => '0',
+          'weight' => '-9',
+          'page_num' => 1,
+        ),
+        'sample values' => '0',
+        'database values' => array('0'),
+        'database default values' => array('0'),
+      ),
       'radios' => array(
         'component' => array(
           'form_key' => 'radios',
@@ -268,7 +217,7 @@
           'type' => 'select',
           'value' => 'two',
           'extra' => array(
-            'items' => "one\ntwo\nthree",
+            'items' => "one|one\ntwo|two\nthree|three",
             'email' => 0,
           ),
           'mandatory' => '1',
@@ -284,7 +233,7 @@
       'radios_zero' => array(
         'component' => array(
           'form_key' => 'radios_zero',
-          'name' => 'Radios',
+          'name' => 'Radios zero',
           'type' => 'select',
           'value' => '0',
           'extra' => array(
@@ -309,7 +258,7 @@
           'value' => 'one',
           'extra' => array(
             'description' => '<p>Description here</p>',
-            'items' => "one\ntwo\nthree\nfour\nfive\nsix",
+            'items' => "one|one\ntwo|two\nthree|three\nfour|four\nfive|five\nsix|six",
             'aslist' => 'Y',
             'email' => 0,
           ),
@@ -353,7 +302,7 @@
           'value' => 'option 1-2',
           'extra' => array(
             'description' => '<p>Tests saving zero as a value.</p>',
-            'items' => "<Group 1>\noption 1-1\noption 1-2\noption 1-3\n<Group 2>\noption 2-1\noption 2-2\noption 2-3",
+            'items' => "<Group 1>\noption 1-1|option 1-1\noption 1-2|option 1-2\noption 1-3|option 1-3\n<Group 2>\noption 2-1|option 2-1\noption 2-2|option 2-2\noption 2-3|option 2-3",
             'aslist' => 'Y',
             'email' => 0,
           ),
@@ -372,9 +321,9 @@
           'form_key' => 'select_email',
           'name' => 'Select e-mails',
           'type' => 'select',
-          'value' => 'nate@localhost',
+          'value' => 'nate@localhost.localhost',
           'extra' => array(
-            'items' => "nate@localhost|one\nadmin@localhost|two",
+            'items' => "nate@localhost.localhost|one\nadmin@localhost.localhost|two",
             'email' => 3,
           ),
           'mandatory' => '0',
@@ -383,9 +332,9 @@
           'weight' => '-17',
           'page_num' => 1,
         ),
-        'sample values' => 'admin@localhost',
-        'database values' => array('admin@localhost'),
-        'database default values' => array('nate@localhost'),
+        'sample values' => 'admin@localhost.localhost',
+        'database values' => array('admin@localhost.localhost'),
+        'database default values' => array('nate@localhost.localhost'),
       ),
       'select_multiple' => array(
         'component' => array(
@@ -394,7 +343,7 @@
           'type' => 'select',
           'value' => 'one,two',
           'extra' => array(
-            'items' => "one\ntwo\nthree",
+            'items' => "one|one\ntwo|two\nthree|three",
             'multiple' => 'Y',
             'aslist' => 'Y',
             'email' => 0,
@@ -431,8 +380,8 @@
           'page_num' => 1,
         ),
         'sample values' => array('day' => '30', 'month' => '9', 'year' => '1982'),
-        'database values' => array('9', '30', '1982'),
-        'database default values' => array('11', '19', '1978'),
+        'database values' => array('1982-09-30'),
+        'database default values' => array('1978-11-19'),
       ),
 
       // Test email components.
@@ -451,8 +400,8 @@
           'weight' => '-5',
           'page_num' => 1,
         ),
-        'sample values' => 'admin@localhost',
-        'database values' => array('admin@localhost'),
+        'sample values' => 'admin@localhost.localhost',
+        'database values' => array('admin@localhost.localhost'),
         'database default values' => array($this->webform_users['admin']->mail),
       ),
 
@@ -553,9 +502,9 @@
           'weight' => '16',
           'page_num' => 1,
         ),
-        'sample values' => array('hour' => '5', 'minute' => '00', 'ampm' => 'am'),
-        'database values' => array('5', '00', 'am'),
-        'database default values' => array($site_hour12, $site_minute, $site_ampm),
+        'sample values' => array('hour' => '5', 'minute' => '0', 'ampm' => 'am'),
+        'database values' => array('05:00:00'),
+        'database default values' => array('22:30:00'),
       ),
       'time_24h' => array(
         'component' => array(
@@ -573,9 +522,9 @@
           'weight' => '17',
           'page_num' => 1,
         ),
-        'sample values' => array('hour' => '5', 'minute' => '00'),
-        'database values' => array('5', '00'),
-        'database default values' => array($site_hour24, $site_minute),
+        'sample values' => array('hour' => '5', 'minute' => '0'),
+        'database values' => array('05:00:00'),
+        'database default values' => array('22:30:00'),
       ),
     );
 
@@ -605,6 +554,7 @@
      'webform' => array(
         'confirmation' => 'Thanks!',
         'confirmation_format' => FILTER_FORMAT_DEFAULT,
+        'redirect_url' => '',
         'teaser' => '0',
         'allow_draft' => '1',
         'submit_text' => '',
Index: tests/permissions.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/tests/permissions.test,v
retrieving revision 1.3.2.1
diff -u -r1.3.2.1 permissions.test
--- tests/permissions.test	3 Mar 2010 02:51:31 -0000	1.3.2.1
+++ tests/permissions.test	3 Apr 2010 02:37:33 -0000
@@ -57,8 +57,7 @@
     $this->drupalGet('node/' . $node->nid);
     // Note: Should be: You must <a href="!login">login</a> or <a href="!register">register</a> to view this form.
     // Something in SimpleTest isn't handling the string correctly.
-    $this->assertText(t('to view this form.', array('!login' => url('user/login'), '!register' => url('user/register'))), t('Anonymous user is not allowed to submit form.'), t('Webform'));
-    $this->drupalLogout();
+    $this->assertText('to view this form.', t('Anonymous user is not allowed to submit form.'), t('Webform'));
   }
 
   /**
Index: components/select.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/select.inc,v
retrieving revision 1.39.2.10
diff -u -r1.39.2.10 select.inc
--- components/select.inc	29 Mar 2010 03:19:49 -0000	1.39.2.10
+++ components/select.inc	3 Apr 2010 02:37:32 -0000
@@ -127,11 +127,15 @@
       '#description' => t('<strong>Key-value pairs MUST be specified as "safe_key|Some readable option"</strong>. Only alphanumeric characters and underscores are allowed as a key. One option per line. Option groups may be specified with &lt;Group Name&gt;. &lt;&gt; can be used to insert items at the root of the menu after specifying a group.') . theme('webform_token_help'),
       '#cols' => 60,
       '#rows' => 5,
-      '#weight' => -2,
+      '#weight' => 0,
       '#required' => TRUE,
-      '#attributes' => array('readonly' => !empty($component['extra']['options_source'])),
       '#element_validate' => array('_webform_edit_validate_select'),
     );
+
+    if (!empty($component['extra']['options_source'])) {
+      $form['extra']['items']['#attributes'] = array('readonly' => 'readonly');
+    }
+
     $form['extra'] = array_merge($form['extra'], $other);
     $form['value'] = array(
       '#type' => 'textfield',
@@ -423,16 +427,28 @@
  * Convert FAPI 0/1 values into something saveable.
  */
 function _webform_submit_select($component, $value) {
-  $options = drupal_map_assoc(array_flip(_webform_select_options($component)));
+  // Build a list of all valid keys expected to be submitted.
+  $options = _webform_select_options($component);
+  $keys = array();
+  foreach ($options as $option_key => $option_value) {
+    if (is_array($option_key)) {
+      foreach ($option_key as $option_subkey => $option_subvalue) {
+        $keys[$option_subkey] = $option_subkey;
+      }
+    }
+    else {
+      $keys[$option_key] = $option_key;
+    }
+  }
 
   $return = NULL;
   if (is_array($value)) {
     $return = array();
     foreach ($value as $key => $option_value) {
       // Handle options that are specified options.
-      if ($option_value !== '' && isset($options[$key])) {
+      if ($option_value !== '' && isset($keys[$key])) {
         // Checkboxes submit an *integer* value of 0 when not checked.
-        if ($option_value === 0 && $options[$key] !== '0' && !$component['extra']['aslist'] && $component['extra']['multiple']) {
+        if ($option_value === 0 && $keys[$key] !== '0' && !$component['extra']['aslist'] && $component['extra']['multiple']) {
           unset($value[$key]);
         }
         else {
