Hi, I did a little coding, I'm not a programmer anymore and am verry rusty, but here is an implementation so you can include fields from Profiles and only list users with a specific role:

In exhibit_core.pages.ing:

function exhibit_core_get_users($role, $options = array()) { $types  = 
array('user' => array('label' => t('User'), 'pluralLabel' => t('Users'))); 
$fields = array( 'created'    => array('valueType' => 'date'), 'access'     => 
array('valueType' => 'date'), 'login'      => array('valueType' => 'date'), 
'url'        => array('valueType' => 'url'), );

  // Make sure the current user is allowed to see user profile information.
  if (!user_access('access user profiles'))
    return exhibit_json(array(), $types, $fields);

	// If 
	if( $role != null)
	{
		$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');
	}
	
  $items = array();
  while ($user = db_fetch_object($result)) {
    $user = user_load($user->uid);

    $userdata = array(
      'type'        => 'user',
      'id'          => 'user/' . $user->uid,
      'label'       => $user->name, // TODO: use profile fields if possible
      'name'        => $user->name,
      'mail'        => $user->mail,
      'created'     => gmstrftime(EXHIBIT_DATE_FORMAT, $user->created),
      'access'      => gmstrftime(EXHIBIT_DATE_FORMAT, $user->access),
      'login'       => gmstrftime(EXHIBIT_DATE_FORMAT, $user->login),
      'language'    => $user->language, // TODO: should probably be language label, not ID
      'roles'       => array_values($user->roles),
      'url'         => url('user/' . $user->uid, array('absolute' => TRUE)),
    );
  	// visibility = 3 : Public field, content shown on profile page and on member list pages. 
    $result2 = db_query('SELECT f.name name, 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['name'] != null && $row['value'] != null) {
        $userdata[$row['name']] = $row['value'];
    }
    }
    
    $items[] = exhibit_compact_item($userdata);
  }

  

  
  return exhibit_json($items, $types, $fields);

}

Also needed is to change in exhibit_core.module

function exhibit_core_menu() {
  return array(
    'exhibit/drupal/users' => array(
      'type' => MENU_CALLBACK,
      'access arguments' => array('access exhibits'),
      'page callback' => 'exhibit_core_callback',
      'page arguments' => array('exhibit_core_get_users', 3),
      'file' => 'exhibit_core.pages.inc',
    ),
  );
}

Hope you can make some use of it...

/Andrei

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Arto’s picture

Title: List Users by roles and list Profile fields. » Include profile fields in the users data feed
Assigned: TypQxQ » Unassigned

Thanks for the contribution, Andrei. I believe that Josh is currently looking into rolling this functionality, based on your code, into a patch against the latest development snapshot.

Arto’s picture

Josh, there are two separate feature requests here: only list users with specific roles, and include profile fields in the data feed. I think the latter is the more important feature, and has a clear-cut implementation.

As for the former (role limitations), I think that could be implemented in the form of a URL query argument, the absence of which didn't filter the users, and the presence of which would filter based on e.g. the textual role ID passed as a parameter. For example: exhibit/drupal/users?role=administrator. You can find a relevant example in the Exhibit Views submodule.

jhuckabee’s picture

Status: Patch (to be ported) » Needs review
FileSize
2.36 KB

Patch attached.

Arto’s picture

Assigned: Unassigned » Arto

Testing this patch now. The role limitation does not seem to work - looks like a bug in the JOIN. Will fix and commit shortly.

Arto’s picture

Status: Needs review » Fixed

Patch applied in changeset [119021] and included in the 6.x-1.0-alpha1 snapshot. Thanks guys.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.