function oa_core_member_of_team in Open Atrium Core 7.2
Determine if a user is a member of a team
Parameters
int $team_id:
int $user_id:
Return value
boolean TRUE if user is in team
1 call to oa_core_member_of_team()
- oa_core_section_access in includes/
oa_core.access.inc - Determine access to a Open Atrium Section do NOT use node_load here as it gets called from hook_node_grants() TODO: No longer called from node_grants, but called from tests. Is this still needed?
1 string reference to 'oa_core_member_of_team'
File
- includes/
oa_core.util.inc, line 643 - Code for Utility functions for OpenAtrium spaces
Code
function oa_core_member_of_team($team_id, $user_id) {
$cache =& drupal_static(__FUNCTION__);
if (!isset($cache[$team_id][$user_id])) {
$result = db_select('field_data_field_oa_team_users', 'f')
->fields('f', array(
'field_oa_team_users_target_id',
))
->condition('field_oa_team_users_target_id', $user_id)
->condition('entity_type', 'node')
->condition('entity_id', $team_id)
->condition('deleted', 0)
->execute();
if ($result
->rowCount() > 0) {
$access = TRUE;
}
else {
// not explicitly in team, but check ownership of team node
// do NOT use node_load as this is called from hook_node_grants()
$result = db_select('node', 'n')
->fields('n', array(
'uid',
))
->condition('nid', $team_id)
->execute()
->fetchAssoc();
$access = $result['uid'] == $user_id ? TRUE : FALSE;
}
$cache[$team_id][$user_id] = $access;
}
return $cache[$team_id][$user_id];
}