function _oa_core_build_visibility_links in Open Atrium Core 7.2
Helper function, builds links for the various visibility fields on content.
1 call to _oa_core_build_visibility_links()
- oa_core_visibility_data in includes/
oa_core.access.inc - Utility function to return visibility data for a given node $data['public'] TRUE if node is public, FALSE if private $data['title'] either "Public" or "Private" $data['accessors']['group']…
File
- includes/
oa_core.access.inc, line 655 - Code for Access Control functions for OpenAtrium spaces
Code
function _oa_core_build_visibility_links($type, $node, $field, $bundle = '') {
$links = array();
$nids = array();
if ($field == OA_SPACE_FIELD) {
// Get all parent spaces instead of just direct parent
$spaces = field_get_items('node', $node, $field);
if (!empty($spaces)) {
$space = current($spaces);
$nids = oa_core_get_parents($space['target_id'], $bundle, NODE_PUBLISHED, FALSE, TRUE);
// Add current space to list
if ($bundle == OA_SPACE_TYPE) {
$nids[] = $space['target_id'];
}
}
}
else {
$values = field_get_items('node', $node, $field);
if (!empty($values)) {
foreach ($values as $value) {
$nids[] = $value['target_id'];
}
}
}
if (!empty($nids)) {
if ($type == 'node') {
$titles = oa_core_get_titles($nids, $bundle);
$links = $titles['links'];
}
elseif ($type == 'user') {
$links = array();
$query = db_select('realname', 'u');
$query
->fields('u', array(
'uid',
'realname',
))
->condition('u.uid', $nids, 'IN');
$users = $query
->execute()
->fetchAllAssoc('uid');
foreach ($users as $uid => $user) {
$links[] = l($user->realname, "user/" . $uid);
}
}
}
return $links;
}