function og_vocab_get_accessible_vocabs in OG Vocabulary 6
Same name and namespace in other branches
- 7 og_vocab.module \og_vocab_get_accessible_vocabs()
API function; Get all the vocabs a user may access.
This will include the global vocabualries (i.e. ones that aren't associated with a group), and the ones that are associated with a group the user is a member.
Parameters
$account: User object.
Return value
An array with the vocabulary IDs or an empty array if no vocabulary was found.
1 call to og_vocab_get_accessible_vocabs()
- og_vocab_taxonomy_form_all in ./
og_vocab.module - Helper function; Generate a set of options for selecting a term from all vocabularies that user has access to.
File
- ./
og_vocab.module, line 471 - Give each group its own system controlled vocabularies.
Code
function og_vocab_get_accessible_vocabs($account = NULL) {
if (empty($account)) {
global $user;
$account = $user;
}
$vocabs = taxonomy_get_vocabularies();
if (!user_access('administer organic groups')) {
// Get all the groups a member is subscribed to.
$gids = drupal_map_assoc(array_keys(og_get_subscriptions($account->uid)));
foreach ($vocabs as $vid) {
// If vocabulary is associated with a group and the user isn't a member -
// remove it from the list.
if (($gid = og_vocab_get_group($vid->vid)) && !in_array($gid['nid'], $gids)) {
unset($vocabs[$vid->vid]);
}
}
}
return $vocabs;
}