You are here

function oa_notifications_get_users_for_node in Open Atrium Notifications 7.2

Gets the users for a particular node.

Get the listing of users that are in the specified space, or the current space if no space is specified that also have access to the provided node.

Parameters

int $gid: The space ID.

File

./oa_notifications.module, line 181

Code

function oa_notifications_get_users_for_node($node, $gid = NULL) {
  if (!isset($gid)) {
    $gid = oa_core_get_space_context();
  }

  // @TODO: This won't scale. We need users that have access to the given node
  // which is controlled by node_access grants, etc.  Not easily queried.
  // The move to an autocomplete might make this potential performance problem
  // disappear.
  $users = oa_core_get_inherited_users_for_space($gid);

  // The loop below is currently a performance issue that needs more work
  // Lets just return the list of users that have access to space without
  // actually calling full node_access. Unfortunately, og_subgroups_node_grants
  // will cause all subspaces to be entity-loaded!

  /*
  if (isset($node->nid)) {
    foreach ($users as $uid => $user) {
      if (!node_access('view', $node, $user)) {
        unset($users[$uid]);
      }
    }
  }
  */
  return $users;
}