--- profile.module	2008-04-28 11:13:46.000000000 +0200
+++ profile.module.mod	2008-12-04 16:29:28.000000000 +0100
@@ -38,6 +38,7 @@ function profile_help($path, $arg) {
       $output .= '<li>'. t('multi-line textfield') .'</li>';
       $output .= '<li>'. t('checkbox') .'</li>';
       $output .= '<li>'. t('list selection') .'</li>';
+      $output .= '<li>'. t('multiple selection list') .'</li>';
       $output .= '<li>'. t('freeform list') .'</li>';
       $output .= '<li>'. t('URL') .'</li>';
       $output .= '<li>'. t('date') .'</li></ul>';
@@ -240,10 +241,12 @@ function profile_save_profile(&$edit, &$
     if (_profile_field_serialize($field->type)) {
       $edit[$field->name] = serialize($edit[$field->name]);
     }
+    $value = ($field->type == 'multiselect') ? implode("\n\r",$edit[$field->name]) : $edit[$field->name];
     db_query("DELETE FROM {profile_values} WHERE fid = %d AND uid = %d", $field->fid, $user->uid);
-    db_query("INSERT INTO {profile_values} (fid, uid, value) VALUES (%d, %d, '%s')", $field->fid, $user->uid, $edit[$field->name]);
+    db_query("INSERT INTO {profile_values} (fid, uid, value) VALUES (%d, %d, '%s')", $field->fid, $user->uid, $value);
     // Mark field as handled (prevents saving to user->data).
     $edit[$field->name] = NULL;
+    $value = NULL;
   }
 }
 
@@ -262,6 +265,15 @@ function profile_view_field($user, $fiel
       case 'textfield':
       case 'selection':
         return $browse ? l($value, 'profile/'. $field->name .'/'. $value) : check_plain($value);
+      case 'multiselect':
+        $values = split("[,\n\r]", $value);
+        $fields = array();
+        foreach ($values as $value) {
+          if ($value = trim($value)) {
+            $fields[] = $browse ? l($value, 'profile/'. $field->name .'/'. $value) : check_plain($value);
+          }
+        }
+        return implode(', ', $fields);
       case 'checkbox':
         return $browse ? l($field->title, 'profile/'. $field->name) : check_plain($field->title);
       case 'url':
@@ -336,7 +348,9 @@ function _profile_form_explanation($fiel
   if ($field->type == 'list') {
     $output .= ' '. t('Put each item on a separate line or separate them by commas. No HTML allowed.');
   }
-
+  else if ($field->type == 'multiselect') {
+    $output .= ' '. t('To select multiple items, hold the Ctrl key.');
+  }
   if ($field->visibility == PROFILE_PRIVATE) {
     $output .= ' '. t('The content of this field is kept private and will not be shown publicly.');
   }
@@ -403,7 +417,27 @@ function profile_form_profile($edit, $us
           '#title' => check_plain($field->title),
           '#default_value' => isset($edit[$field->name]) ? $edit[$field->name] : '',
           '#options' => $options,
+          '#size' => 'size="'. min(12, count($options)) .'"',
+          '#description' => _profile_form_explanation($field),
+          '#required' => $field->required,
+        );
+        break;
+      case 'multiselect':
+        $options = array();
+        $lines = split("[,\n\r]", $field->options);
+        foreach ($lines as $line) {
+          if ($line = trim($line)) {
+            $options[$line] = $line;
+          }
+        }
+        $value = split("[,\n\r]", $edit[$field->name]);
+        $fields[$category][$field->name] = array('#type' => 'select',
+          '#title' => check_plain($field->title),
+          '#default_value' => $value,
+          '#options' => $options,
           '#description' => _profile_form_explanation($field),
+          '#multiple' => TRUE,
+          '#size' => 'size="'. min(12, count($options)) .'"',
           '#required' => $field->required,
         );
         break;
@@ -546,6 +580,7 @@ function _profile_field_types($type = NU
                  'textarea' => t('multi-line textfield'),
                  'checkbox' => t('checkbox'),
                  'selection' => t('list selection'),
+                 'multiselect' => t('multi-list selection'),
                  'list' => t('freeform list'),
                  'url' => t('URL'),
                  'date' => t('date'));
