I did not find any existing issue for this even if this functionality seems to be broken for a while now. I think priority is major because it makes the user dashboard a little senseless. Looks like this is broken since oa_core_og_group_ref_views_handler_filter_entityreference_autocomplete uses the select2widget functionality. Anyway the shown results are not complete.
Steps to reproduce in 2.43:
1. Create Space - create Discussion Section - Create Discussion Post
2. Create Subspace - create Discussion Section - Create Discussion Post
3. Add a "View: Open Atrium Comment Topic List: Topics" - Pane and check "Limit to groups of current user"
The first problem was easy to find. In oa_core.module you have the following code:
// If "My Spaces" is checked, restrict to user's groups
global $user;
if (!empty($exposed[$id . '_mine'])) {
$groups = oa_core_get_groups_by_user($user, 'node');
if ($groups && ($gids = array_intersect_key($groups, $filter->get_value_options()))) {
$exposed[$id] = $gids;
$filter->options['expose']['multiple'] = TRUE;
}
else {
// If restricting to My Spaces but the user has no spaces, fail the build
return FALSE;
}
}
The result of array_intersect_key() is wrong because oa_core_get_groups_by_user() returns an array with indexes and we would need the ids as keys. This could be easily done by replacing
if ($groups && ($gids = array_intersect_key($groups, $filter->get_value_options()))) { with
if ($groups && ($gids = array_intersect_key(array_combine($groups, $groups), $filter->get_value_options()))) {
After this it took me some while to dig into it and I don't really know how to handle it correctly. This is why it makes no sense if I provide a patch. I think the problem is located in oa_core_og_group_ref_views_handler_filter_entityreference_autocomplete.inc. In exposed_validate(&$form, &$form_state) it seems like $form_state['values']['og_group_ref_target_id'] is used for filtering which is not set correctly. I was able to find the correct values in $form['og_group_ref_target_id ']['og_group_ref_target_id ']['#value'].
Hope this helps!
Greetings,
Leo
Comments
Comment #1
hefox commentedIf want a list of user's topics, the ""View: Open Atrium Comment Topic List: User Topics" was made for that.
Looks like this was allowed to break because nothing uses this functionality anymore by default (e.g. no view by default has that checkbox checked). Going to consult with mpotter to see if the functionality should be fixed or removed before fixing it.
Comment #2
hefox commentedShould be fixed in f9c563d680cc1d7283a2a2b545fa1ceaa5ed2fb4 to oa_core
the key was oa_core_get_groups_by_user was suppose to be returned it keyed by nid (and had been at some stage, according to the comments) and that when using it, the exposed field needed to be switched to a 'value' instead of select2 for the values to work