--- exhibit_core.pages.inc	2008-05-18 15:04:10.000000000 -0500
+++ /Users/josh/Desktop/exhibit_core.pages.inc.new	2008-05-18 15:05:09.000000000 -0500
@@ -12,7 +12,7 @@
 //////////////////////////////////////////////////////////////////////////////
 // Exhibit data feeds
 
-function exhibit_core_get_users($options = array()) {
+function exhibit_core_get_users($role = NULL, $options = array()) {
   $types  = array('user' => array('label' => t('User'), 'pluralLabel' => t('Users')));
   $fields = array(
     'created'    => array('valueType' => 'date'),
@@ -24,13 +24,20 @@ function exhibit_core_get_users($options
   // Make sure the current user is allowed to see user profile information.
   if (!user_access('access user profiles'))
     return exhibit_json(array(), $types, $fields);
+    
+  // Check for role limitation in URL parameters
+  if ($role) {
+    $result = db_query("SELECT u.* FROM {users} u, {users_roles} ur, {role} r where r.name='%s' AND r.rid=ur.rid AND u.uid = ur.uid", $role);
+  } 
+  else {
+    $result = db_query('SELECT u.uid FROM {users} u WHERE u.status = 1 ORDER BY u.name');
+  }
 
-  $result = db_query('SELECT u.uid FROM {users} u WHERE u.status = 1 ORDER BY u.name');
   $items = array();
   while ($user = db_fetch_object($result)) {
     $user = user_load($user->uid);
 
-    $items[] = exhibit_compact_item(array(
+    $userdata = array(
       'type'        => 'user',
       'id'          => 'user/' . $user->uid,
       'label'       => $user->name, // TODO: use profile fields if possible
@@ -42,7 +49,20 @@ function exhibit_core_get_users($options
       'language'    => $user->language, // TODO: should probably be language label, not ID
       'roles'       => array_values($user->roles),
       'url'         => url('user/' . $user->uid, array('absolute' => TRUE)),
-    ));
+    );
+    
+    // Add profile fields if the module is enabled
+    if (module_exists('profile')) {
+      $result2 = db_query('SELECT f.title title, v.value value FROM {profile_values} v, {profile_fields} f WHERE v.fid = f.fid AND v.uid = %d AND f.visibility = 3', $user->uid);
+
+      while ($row = db_fetch_array($result2)) {
+        if($row['title'] != null && $row['value'] != null) {
+          $userdata[$row['title']] = $row['value'];
+        }
+      }
+    }
+    
+    $items[] = exhibit_compact_item($userdata);
   }
 
   return exhibit_json($items, $types, $fields);
