--- ../sites/all/modules/profile_checkboxes/profile_checkboxes.module	2011-02-25 02:11:52.000000000 +0000
+++ ../sites/all/modules/profile_checkboxes/profile_checkboxes.module.patched	2011-04-04 16:10:32.000000000 +0000
@@ -68,11 +68,11 @@
             if (!empty($form[$field->category][$field->name]['#options'])) {
               reset($form[$field->category][$field->name]['#options']);
               unset($form[$field->category][$field->name]['#options'][key($form[$field->category][$field->name]['#options'])]);
             }
           }
-          $value = unserialize($field->value) ? unserialize($field->value) : array();
+          $value = unserialize($field->value) ? unserialize($field->value) : array($field->value);
           switch ($field->type) {
             case 'checkboxes':
               // change list selection field type from 'select' to 'checkboxes'
               $form[$field->category][$field->name]['#type'] = 'checkboxes';
               $form[$field->category][$field->name]['#default_value'] = $value;
@@ -135,11 +135,11 @@
       }
       break;
     case 'validate':
       $fields = profile_checkboxes_selection_fields($account->uid);
       while ($field = db_fetch_object($fields)) {
-        if (isset($edit[$field->name])) {
+        if (is_array($edit[$field->name])) {
           $value = array_filter($edit[$field->name]);
           // convert non-empty field array to serialize array
           $edit[$field->name] = count($value) ? serialize($value) : NULL;
         }
       }
@@ -157,11 +157,11 @@
     if (!empty($field->page)) {
       if ($items = unserialize($field->value)) {
         $links = array();
         foreach ($items as $item) {
           // create individual links to mimic default behavior
-          $links[] = l($item, 'profile/'. $field->name .'/'. $item);
+          $links[] = l($item, 'multiprofile/'. $field->name .'/'. $item);
         }
         // replace single value link with multiple value links
         $account->content[$field->category][$field->name]['#value'] = implode($field->delimiter, $links);
       }
     }
@@ -210,5 +210,72 @@
   return array(
     'api' => 2.0,
     'path' => drupal_get_path('module', 'profile_checkboxes') .'/views',
   );
 }
+
+/**
+ * Implementation of hook_menu().
+ */
+function profile_checkboxes_menu() {
+  $items['multiprofile/%/%'] = array(
+    'title' => 'User list',
+    'page callback' => 'profile_checkboxes_browse',
+    'page arguments' => array(1,2),
+    'access arguments' => array('access user profiles'),
+    'type' => MENU_SUGGESTED_ITEM,
+  );
+  return $items;
+}
+
+/**
+ * Menu callback; display a list of user information.
+ */
+function profile_checkboxes_browse($name,$value) {
+
+  $field = db_fetch_object(db_query("SELECT DISTINCT(fid), type, title, page, visibility FROM {profile_fields} WHERE name = '%s'", $name));
+
+  if ($name && $field->fid) {
+    // Only allow browsing of fields that have a page title set.
+    if (empty($field->page)) {
+      drupal_not_found();
+      return;
+    }
+    // Do not allow browsing of private and hidden fields by non-admins.
+    if (!user_access('administer users') && ($field->visibility == PROFILE_PRIVATE || $field->visibility == PROFILE_HIDDEN)) {
+      drupal_access_denied();
+      return;
+    }
+
+    // Compile a list of fields to show.
+    $fields = array();
+    $result = db_query('SELECT name, title, type, weight, page FROM {profile_fields} WHERE fid != %d AND visibility = %d ORDER BY weight', $field->fid, PROFILE_PUBLIC_LISTINGS);
+    while ($record = db_fetch_object($result)) {
+      $fields[] = $record;
+    }
+
+    // Determine what query to use:
+    $arguments = array($field->fid);
+    $query = "v.value like '%%%s%%'";
+    $arguments[] = $value;
+
+    // Extract the affected users:
+    $result = pager_query("SELECT u.uid, u.access FROM {users} u INNER JOIN {profile_values} v ON u.uid = v.uid WHERE v.fid = %d AND $query AND u.access != 0 AND u.status != 0 ORDER BY u.access DESC", 20, 0, NULL, $arguments);
+
+    $content = '';
+    while ($account = db_fetch_object($result)) {
+      $account = user_load(array('uid' => $account->uid));
+      $profile = _profile_update_user_fields($fields, $account);
+      $content .= theme('profile_listing', $account, $profile);
+    }
+    $output = theme('profile_wrapper', $content);
+    $output .= theme('pager', NULL, 20);
+
+    $title = strtr(check_plain($field->page), array('%value' => theme('placeholder', $value)));
+
+    drupal_set_title($title);
+    return $output;
+  }
+  else {
+    drupal_not_found();
+  }
+}
