﻿Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.973
diff -u -r1.973 user.module
--- modules/user/user.module	1 Apr 2009 20:00:47 -0000	1.973
+++ modules/user/user.module	3 Apr 2009 16:21:35 -0000
@@ -2413,8 +2413,9 @@
     $function = $module . '_perm';
     if ($permissions = $function('perm')) {
       asort($permissions);
+      $options[t('@module module', array('@module' => $module))] = array('#options' => array());
       foreach ($permissions as $permission => $description) {
-        $options[t('@module module', array('@module' => $module))][$permission] = t($permission);
+        $options[t('@module module', array('@module' => $module))]['#options'][$permission] = t($permission);
       }
     }
   }
Index: modules/user/user.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.admin.inc,v
retrieving revision 1.40
diff -u -r1.40 user.admin.inc
--- modules/user/user.admin.inc	26 Feb 2009 07:30:28 -0000	1.40
+++ modules/user/user.admin.inc	3 Apr 2009 16:21:31 -0000
@@ -48,7 +48,13 @@
   foreach ($session as $filter) {
     list($type, $value) = $filter;
     // Merge an array of arrays into one if necessary.
-    $options = $type == 'permission' ? call_user_func_array('array_merge', $filters[$type]['options']) : $filters[$type]['options'];
+    $options = $filters[$type]['options'];
+    if ($type == 'permission') {
+      $options = array();
+      foreach ($filters[$type]['options'] as $filtermodule) {
+        $options += $filtermodule['#options'];
+      }
+    }
     $params = array('%property' => $filters[$type]['title'] , '%value' => $options[$value]);
     if ($i++ > 0) {
       $form['filters']['current'][] = array('#markup' => t('<em>and</em> where <strong>%property</strong> is <strong>%value</strong>', $params));
@@ -101,7 +107,13 @@
       if (isset($form_state['values']['filter'])) {
         $filter = $form_state['values']['filter'];
         // Merge an array of arrays into one if necessary.
-        $options = $filter == 'permission' ? call_user_func_array('array_merge', $filters[$filter]['options']) : $filters[$filter]['options'];
+        $options = $filters[$filter]['options'];
+        if ($filter == 'permission') {
+          $options = array();
+          foreach ($filters[$filter]['options'] as $filtermodule) {
+            $options += $filtermodule['#options'];
+          }
+        }
         if (isset($options[$form_state['values'][$filter]])) {
           if (!isset($_SESSION['user_overview_filter'])) {
             drupal_set_session('user_overview_filter', array());
Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.326
diff -u -r1.326 form.inc
--- includes/form.inc	30 Mar 2009 03:15:40 -0000	1.326
+++ includes/form.inc	3 Apr 2009 16:21:25 -0000
@@ -1458,7 +1458,12 @@
       form_options_flatten($value->option, FALSE);
     }
     elseif (is_array($value)) {
-      form_options_flatten($value, FALSE);
+      if (isset($value['#value']) && isset($value['#return_value'])) {
+        $return[$value['#return_value']] = 1;
+      }
+      else {
+        form_options_flatten($value, FALSE);
+      }
     }
     else {
       $return[$key] = 1;
@@ -1501,23 +1506,43 @@
   $value_is_array = is_array($element['#value']);
   $options = '';
   foreach ($choices as $key => $choice) {
-    if (is_array($choice)) {
-      $options .= '<optgroup label="' . $key . '">';
-      $options .= form_select_options($element, $choice);
-      $options .= '</optgroup>';
+    if (is_object($choice)) {
+      $optioncontent = each($choice->option);
+      $choice = array(
+        '#value' => $optioncontent['value'],
+        '#return_value' => $optioncontent['key'],
+      );
     }
-    elseif (is_object($choice)) {
-      $options .= form_select_options($element, $choice->option);
+    if (!is_array($choice)) {
+      $choice = array('#value' => $choice);
+    }
+    elseif (!isset($choice['#value']) && !isset($choice['#options'])) {
+      $choice = array('#value' => array_shift($choice));
+    }
+    elseif (!isset($choice['#value']) && isset($choice['#options'])) {
+      $choice['#value'] = (string)$key;
+    }
+    if (!isset($choice['#return_value'])) {
+      $choice['#return_value'] = (string)$key;
+    }
+
+    if (isset($choice['#options']) && is_array($choice['#options'])) {
+      $options .= '<optgroup label="' . $choice['#value'] . '">';
+      $options .= form_select_options($element, $choice['#options']);
+      $options .= '</optgroup>';
     }
     else {
-      $key = (string)$key;
-      if ($value_valid && (!$value_is_array && (string)$element['#value'] === $key || ($value_is_array && in_array($key, $element['#value'])))) {
+      if ($value_valid && (!$value_is_array && (string)$element['#value'] === $choice['#return_value'] 
+          || ($value_is_array && in_array($choice['#return_value'], $element['#value'])))) {
         $selected = ' selected="selected"';
       }
       else {
         $selected = '';
       }
-      $options .= '<option value="' . check_plain($key) . '"' . $selected . '>' . check_plain($choice) . '</option>';
+      if (!isset($choice['#attributes'])) {
+      	$choice['#attributes'] = array();
+      }
+      $options .= '<option value="' . check_plain($choice['#return_value']) . '"' . drupal_attributes($choice['#attributes']) . $selected . '>' . check_plain($choice['#value']) . '</option>';
     }
   }
   return $options;
@@ -1846,15 +1871,22 @@
   if (count($element['#options']) > 0) {
     foreach ($element['#options'] as $key => $choice) {
       if (!isset($element[$key])) {
+        if (!is_array($choice)) {
+          $choice = array(
+            '#return_value' => $key,
+            '#value' => $choice,
+            '#attributes' => $element['#attributes'],
+          );
+        }
         // Generate the parents as the autogenerator does, so we will have a
         // unique id for each radio button.
         $parents_for_id = array_merge($element['#parents'], array($key));
         $element[$key] = array(
           '#type' => 'radio',
-          '#title' => $choice,
-          '#return_value' => check_plain($key),
+          '#title' => $choice['#value'],
+          '#return_value' => check_plain($choice['#return_value']),
           '#default_value' => isset($element['#default_value']) ? $element['#default_value'] : NULL,
-          '#attributes' => $element['#attributes'],
+          '#attributes' => $choice['#attributes'],
           '#parents' => $element['#parents'],
           '#id' => form_clean_id('edit-' . implode('-', $parents_for_id)),
           '#ahah' => isset($element['#ahah']) ? $element['#ahah'] : NULL,
@@ -2120,13 +2152,20 @@
       $element['#default_value'] = array();
     }
     foreach ($element['#options'] as $key => $choice) {
+      if (!is_array($choice)) {
+          $choice = array(
+            '#return_value' => $key,
+            '#value' => $choice,
+            '#attributes' => $element['#attributes'],
+          );
+        }
       if (!isset($element[$key])) {
         $element[$key] = array(
           '#type' => 'checkbox',
           '#processed' => TRUE,
-          '#title' => $choice,
-          '#return_value' => $key,
-          '#default_value' => isset($value[$key]),
+          '#title' => $choice['#value'],
+          '#return_value' => $choice['#return_value'],
+          '#default_value' => isset($value[$choice['#return_value']]),
           '#attributes' => $element['#attributes'],
           '#ahah' => isset($element['#ahah']) ? $element['#ahah'] : NULL,
         );
Index: includes/locale.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/locale.inc,v
retrieving revision 1.210
diff -u -r1.210 locale.inc
--- includes/locale.inc	2 Apr 2009 20:39:44 -0000	1.210
+++ includes/locale.inc	3 Apr 2009 16:21:31 -0000
@@ -712,8 +712,14 @@
   }
   else {
     $languages = array(
-      t('Already added languages') => $names,
-      t('Languages not yet added') => _locale_prepare_predefined_list()
+      array(
+        '#value' => t('Already added languages'), 
+        '#options' => $names,
+      ),
+      array(
+        '#value' => t('Languages not yet added'),
+        '#options' => _locale_prepare_predefined_list(),
+      ),
     );
     $default = key($names);
   }
Index: install.php
===================================================================
RCS file: /cvs/drupal/drupal/install.php,v
retrieving revision 1.162
diff -u -r1.162 install.php
--- install.php	2 Apr 2009 20:39:44 -0000	1.162
+++ install.php	3 Apr 2009 16:21:18 -0000
@@ -1021,7 +1021,13 @@
   );
 
   $countries = country_get_list();
-  $countries = array_merge(array('' => st('No default country')), $countries);
+  $countries = array_merge(
+    array(array(
+      '#return_value' => '', 
+      '#value' => st('No default country'), 
+      '#attributes' => array(),
+    )), 
+    $countries);
   $form['server_settings']['site_default_country'] = array(
     '#type' => 'select',
     '#title' => t('Default country'),
Index: modules/trigger/trigger.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/trigger/trigger.admin.inc,v
retrieving revision 1.9
diff -u -r1.9 trigger.admin.inc
--- modules/trigger/trigger.admin.inc	8 Mar 2009 04:25:07 -0000	1.9
+++ modules/trigger/trigger.admin.inc	3 Apr 2009 16:21:31 -0000
@@ -132,7 +132,10 @@
   }
   foreach (actions_actions_map(actions_get_all_actions()) as $aid => $action) {
     if (in_array($action['callback'], $functions)) {
-      $options[$action['type']][$aid] = $action['description'];
+      $options[$action['type']]['#options'][] = array(
+        '#value' => $action['description'],
+        '#return_value' => $aid,
+      );
     }
   }
 
