Index: finduser.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/finduser/finduser.module,v
retrieving revision 1.1.2.6
diff -u -r1.1.2.6 finduser.module
--- finduser.module	29 Oct 2008 16:40:40 -0000	1.1.2.6
+++ finduser.module	7 Jan 2009 04:49:22 -0000
@@ -79,6 +79,26 @@
       $form['#validate'] = array('finduser_validate_usertype' => array());
     }
   }
+
+  // If Profile module is enabled, provide option for searching profiles.
+  if (module_exists('profile')) {
+    $form['finduser_profile'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Profile Module'),
+    );
+    $categories = profile_categories();
+    foreach ($categories as $category) {
+      $res = _profile_get_fields($category['name']);
+      while ($field = db_fetch_object($res)) {
+        $form['finduser_profile']['finduser_profile_'. $field->fid] = array(
+          '#type' => 'checkbox',
+          '#title' => t('Enable @field_name search.', array('@field_name' => $field->title)),
+          '#default_value' => variable_get('finduser_profile_'. $field->fid, TRUE),
+        );
+      }
+    }
+  }
+
   $form['finduser_pagetitle'] = array(
     '#type' => 'textfield',
     '#title' => t('Title of page and form'),
@@ -133,6 +153,19 @@
   if (variable_get('finduser_email', TRUE)) {
     $search_by_options['email'] = t('Email address');
   }
+  
+  // If Profile module is enabled, show the enabled fields.
+  if (module_exists('profile')) {
+    $categories = profile_categories();
+    foreach ($categories as $category) {
+      $res = _profile_get_fields($category['name']);
+      while ($field = db_fetch_object($res)) {
+        if (variable_get('finduser_profile_'. $field->fid, TRUE)) {
+          $search_by_options['profile_'. $field->fid] = $field->title;
+        }
+      }
+    }
+  }
 
   $form['search_by'] = array(
     '#type' => 'radios',
@@ -212,7 +245,17 @@
     break;
 
     default:
-      if (module_exists('content')) {
+      if (substr($type, 0, 7) == 'profile') {
+        if (module_exists('profile') && strlen($query) >= variable_get('finduser_minimum_characters', 3)) {
+          $field_id = substr($type, -1);
+          $result = pager_query("SELECT uid AS id FROM {profile_values} WHERE fid = %d AND value = '%s'", $limit, 0, NULL, $field_id, $query);
+          while ($row = db_fetch_object($result)) {
+            $row->theme = 'finduser_user';
+            $results[] = $row;
+          }
+        }
+      }
+      elseif (module_exists('content')) {
         if (strlen($query) >= variable_get('finduser_minimum_characters', 3)) {
           $info = content_fields($type);
           $db_info = content_database_info($info);
