--- profile.module.old	2005-09-17 20:21:17.000000000 -0500
+++ profile.module	2005-10-05 12:38:35.000000000 -0500
@@ -29,6 +29,7 @@ function profile_help($section) {
        <li>single-line textfield</li>
        <li>multi-line textfield</li>
        <li>checkbox</li>
+       <li>checkbox group</li>
        <li>list selection</li>
        <li>freeform list</li>
        <li>URL</li>
@@ -80,7 +81,6 @@ function profile_menu($may_cache) {
  * Menu callback; display a list of user information.
  */
 function profile_browse() {
-
   $name = arg(1);
   $value = arg(2);
 
@@ -111,6 +111,9 @@ function profile_browse() {
       case 'list':
         $query = "v.value LIKE '%%". db_escape_string($value) ."%%'";
         break;
+      case 'checkboxes':
+        $query = "v.value LIKE '%%". db_escape_string($value) ."%%'";
+        break;
       default:
         drupal_not_found();
         return;
@@ -125,7 +128,7 @@ function profile_browse() {
     }
     $output .= theme('pager', NULL, 20);
 
-    if ($field->type == 'selection' || $field->type == 'list') {
+    if ($field->type == 'selection' || $field->type == 'list' || $field->type == 'checkboxes') {
       $title = strtr($field->page, array('%value' => theme('placeholder', $value)));
     }
     else {
@@ -142,7 +145,7 @@ function profile_browse() {
   else {
     // Compile a list of fields to show
     $fields = array();
-    $result = db_query('SELECT name, title, type FROM {profile_fields} WHERE visibility = %d', PROFILE_PUBLIC_LISTINGS);
+    $result = db_query('SELECT name, title, type FROM {profile_fields} WHERE visibility = %d ORDER BY category, weight', PROFILE_PUBLIC_LISTINGS);
     while ($record = db_fetch_object($result)) {
       $fields[] = $record;
     }
@@ -207,7 +210,7 @@ function profile_view_field($user, $fiel
       case 'url':
         return '<a href="'. check_url($value) .'">'. check_plain($value) .'</a>';
       case 'date':
-        list($format) = explode(' - ', variable_get('date_format_short', 'm/d/Y - H:i'), 2);
+		$format = 'm/d/Y';
         // Note: we avoid PHP's date() because it does not handle dates before
         // 1970 on Windows. This would make the date field useless for e.g.
         // birthdays.
@@ -226,6 +229,13 @@ function profile_view_field($user, $fiel
           }
         }
         return implode(', ', $fields);
+      case 'checkboxes':
+        foreach ($value as $val) {
+          if ($val = trim($val)) {
+            $fields[] = $browse ? l($val, "profile/". urlencode($field->name) ."/". urlencode($val)) : check_plain($val);
+          }
+        }
+        return implode(', ', $fields);
     }
   }
 }
@@ -294,6 +304,17 @@ function profile_form_profile($edit, $us
       case 'checkbox':
         $fields[$category] .= form_checkbox(check_plain($field->title), $field->name, 1, $edit[$field->name], _profile_form_explanation($field), NULL, $field->required);
         break;
+      case 'checkboxes':
+	    $options = array();
+		$values = array();
+        $lines = split("[,\n\r]", $field->options);
+        foreach ($lines as $line) {
+          if ($line = trim($line)) {
+            $options[$line] = $line;
+          }
+        }
+        $fields[$category] .= form_checkboxes(check_plain($field->title), $field->name, $edit[$field->name], $options, _profile_form_explanation($field), NULL, $field->required);
+        break;
       case 'selection':
         $options = array('--');
         $lines = split("[,\n\r]", $field->options);
@@ -533,9 +554,12 @@ function _profile_field_form($type, $edi
   if ($type == 'selection') {
     $group .= form_textarea(t('Selection options'), 'options', $edit['options'], 70, 8, t('A list of all options.  Put each option on a separate line.  Example options are "red", "blue", "green", etc.'));
   }
+  if ($type == 'checkboxes') {
+    $group .= form_textarea(t('Checkboxes'), 'options', $edit['options'], 70, 8, t('A list of all checkboxes.  Put each checkbox on a separate line.  Examples are "men", "women", "mixed", etc.'));
+  }
   $group .= form_weight(t('Weight'), 'weight', $edit['weight'], 5, t('The weights define the order in which the form fields are shown.  Lighter fields "float up" towards the top of the category.'));
   $group .= form_radios(t('Visibility'), 'visibility', $edit['visibility'], array(PROFILE_PRIVATE => t('Private field, content only available to privileged users.'), PROFILE_PUBLIC => t('Public field, content shown on profile page but not used on member list pages.'), PROFILE_PUBLIC_LISTINGS => t('Public field, content shown on profile page and on member list pages.')));
-  if ($type == 'selection' || $type == 'list') {
+  if ($type == 'selection' || $type == 'list' || $type == 'checkboxes') {
     $group .= form_textfield(t('Page title'), 'page', $edit['page'], 70, 128, t('The title of the page showing all users with the specified field.  The word <code>%value</code> will be substituted with the corresponding value.  An example page title is "People whose favorite color is %value".  Only applicable if the field is configured to be shown on member list pages.'));
   }
   else {
@@ -585,7 +609,7 @@ function theme_profile_profile($user, $f
 
   foreach ($fields as $field) {
     if ($value = profile_view_field($user, $field)) {
-      $output .= " <div class=\"field\">$value</div>\n";
+      $output .= " <div class=\"field\">$field->title: $value</div>\n";
     }
   }
 
@@ -598,6 +622,7 @@ function _profile_field_types($type = NU
   $types = array('textfield' => t('single-line textfield'),
                  'textarea' => t('multi-line textfield'),
                  'checkbox' => t('checkbox'),
+                 'checkboxes' => t('checkbox group'),
                  'selection' => t('list selection'),
                  'list' => t('freeform list'),
                  'url' => t('URL'),
@@ -606,7 +631,7 @@ function _profile_field_types($type = NU
 }
 
 function _profile_field_serialize($type = NULL) {
-  return $type == 'date';
+  return $type == 'date' || $type == 'checkboxes';
 }
 
 ?>
