diff --git a/og_vocab.module b/og_vocab.module index 54173ec75144f0ba697bc225c532a252f9c5783c..44b19f9a015ee4159a6adb18ef4fb90b8f667367 100644 --- a/og_vocab.module +++ b/og_vocab.module @@ -463,6 +463,7 @@ function og_vocab_field_widget_form(&$form, &$form_state, $field, $instance, $la foreach ($vids as $vid) { $og_vocab = og_vocab_load_og_vocab($vid, $entity_type, $bundle); $element[$vid] = $og_vocab->getFormElement($entity_type, $entity, $form, $form_state); + $element[$vid]['#gid'] = og_vocab_relation_get($vid); } return $element; @@ -1371,10 +1372,20 @@ function og_vocab_get_accessible_vocabs($entity_type, $bundle, $field_name, $acc $context = FALSE; $gids = array(); - if (in_array($use_context, array('force', 'yes')) && module_exists('og_context') && $context = og_context()) { + if (in_array($use_context, array('force', 'yes', 'all')) && module_exists('og_context') && $context = og_context()) { $gids[$context['group_type']][$context['gid']] = array($context['gid']); } + elseif (in_array($use_context, array('all')) && !$gids) { + // These are groups you have access to + $field = field_info_field(OG_AUDIENCE_FIELD); + $field_instance = field_info_instance($entity_type, OG_AUDIENCE_FIELD, $bundle); + $handler = EntityReference_SelectionHandler_Generic::getInstance($field, $field_instance, $entity_type); + $result = $handler->getReferencableEntities(); + $group_bundle = key($result); + $gids = array($entity_type => array_keys($result[$group_bundle])); + } elseif (in_array($use_context, array('yes', 'no')) && !$gids) { + // These are groups you belong to $gids = og_get_entity_groups('user', $account); } diff --git a/plugins/behavior/OgVocabBehaviorHandler.class.php b/plugins/behavior/OgVocabBehaviorHandler.class.php index d4621e24fc054d6fb00a752f2fea56ceb8cb47df..78f7fa6c6efe3ed4cd7c8ad21dbe4c97618813e1 100644 --- a/plugins/behavior/OgVocabBehaviorHandler.class.php +++ b/plugins/behavior/OgVocabBehaviorHandler.class.php @@ -23,12 +23,14 @@ class OgVocabBehaviorHandler extends EntityReference_BehaviorHandler_Abstract { '#required' => TRUE, '#options' => array( 'force' => t('Hide widget if no context found'), - 'yes' => t('Use if possible'), + 'all' => t('Use if possible, otherwise show all available groups'), + 'yes' => t('Use if possible, otherwise show groups user is a member of'), 'no' => t('Do not use'), ), '#description' => t('Should the OG vocabularies appear according to OG context. Depends on OG-context module.'), '#default_value' => $settings['use_context'], ); + return $form; }