You are here

function oa_core_get_users_for_space in Open Atrium Core 7.2

Get the users that are in a space (excluding inherited users).

Parameters

int $space_id: The NID of the Space.

int $state: (Optional) The state of the OG membership, for example:

Return value

array An associative array of fully loaded user objects, keyed by user id.

3 calls to oa_core_get_users_for_space()
oa_core_get_inherited_users_for_space in includes/oa_core.util.inc
Get the users that are in a space, including inherited users.
oa_core_members_widget_render in plugins/content_types/oa_core_members_widget.inc
Main render function for oa_core_members_widget.
oa_users_oa_members_toolbar_render in modules/oa_users/plugins/content_types/oa_members_toolbar.inc
Run-time rendering of the body of the block (content type) See ctools_plugin_examples for more advanced info

File

includes/oa_core.util.inc, line 1032
Code for Utility functions for OpenAtrium spaces

Code

function oa_core_get_users_for_space($space_id, $state = OG_STATE_ACTIVE, $sort = FALSE) {
  $query = db_select('og_membership', 'og')
    ->fields('og', array(
    'etid',
  ))
    ->condition('og.entity_type', 'user')
    ->condition('og.state', $state)
    ->condition('og.group_type', 'node')
    ->condition('og.gid', $space_id);
  $query
    ->join('users', 'u', 'u.uid = og.etid');
  $query
    ->condition('u.status', 1);
  if (!empty($sort)) {
    $query
      ->join('realname', 'n', 'n.uid = og.etid');
    $query
      ->orderBy('n.realname');
  }
  $uids = $query
    ->execute()
    ->fetchCol();
  return user_load_multiple($uids);
}