See this part of the function og_form_add_og_audience() (line 2081 ff.):

elseif ($cnt = count($options, COUNT_RECURSIVE)) {
    // show multi-select. if less than 20 choices, use checkboxes.
    $type = $cnt >= 20 || $is_optgroup ? 'select' : 'checkboxes';
    $form['og_nodeapi']['visible']['og_groups'] = array(
      '#type' => $type, 
      '#title' => t('Audience'), 
      '#attributes' => array('class' => 'og-audience'),
      '#options' => $options[t('My groups')],
      '#required' => $required, 
      '#description' =>  format_plural(count($options[t('My groups')]), 'Show this post in this group.', 'Show this post in these groups.'),
      '#default_value' => $groups ? $groups : array(),
      '#required' => $required, 
      '#multiple' => TRUE);
  }

In the code of the current version only $options is used. The [t('My groups')] is missing.
Without the 'My groups' it is not possible to select a group!

CommentFileSizeAuthor
#3 og.module-node-edit-select-group.patch820 bytesMichaelK-1

Comments

MichaelK-1’s picture

Status: Active » Needs work

After some more tests it occurs that the [t('My groups')] is only necessary for users who are not members in all groups. For users who are members in all groups this key is unset. So an if-then-else is the solution.

MichaelK-1’s picture

So, this is the working code:

  elseif ($cnt = count($options, COUNT_RECURSIVE)) {
    // show multi-select. if less than 20 choices, use checkboxes.
    $type = $cnt >= 20 || $is_optgroup ? 'select' : 'checkboxes';
    $form['og_nodeapi']['visible']['og_groups'] = array(
      '#type' => $type, 
      '#title' => t('Audience'), 
      '#attributes' => array('class' => 'og-audience'),
      '#options' => $options[t('My groups')] ? $options[t('My groups')] : $options,
      '#required' => $required, 
      '#description' => format_plural(count($options[t('My groups')] ? $options[t('My groups')] : $options), 'Show this post in this group.', 'Show this post in these groups.'),
      '#default_value' => $groups ? $groups : array(),
      '#required' => $required, 
      '#multiple' => TRUE);
  }
MichaelK-1’s picture

Version: 6.x-1.1 » master
Priority: Critical » Normal
Status: Needs work » Needs review
StatusFileSize
new820 bytes

And last but not least, here is the patch against the head file

moshe weitzman’s picture

Status: Needs review » Needs work

How do I reproduce the problem? Is user editing own post or that of someone else? Is user an admin? The fix looks like it is coding around a problem.

ashiwebi’s picture

I want to know whether your change applicable for removing the checkbox and implementing the multiple select option in OG module

kasiawaka’s picture

I have the same problem: if user belongs to more then one group, the Audience list of groups is empty when user tries to create any content in the group.
I described it here http://drupal.org/node/573656#comment-2403062 because the problem was related to the module OG Content Type admin - when disabled, everything went back to normal.

jvieille’s picture

It seems that the problem reappeared in OG 2.0.

When a user creates a node from a group context, the audience is limited to that group even if the user is subscribed to other groups. If logged as admin, however, all groups are displayed for selecting audience.

This is the code on og.module in OG 6x-2.0

  elseif ($cnt = count($options, COUNT_RECURSIVE)) {
    // show multi-select. if less than 20 choices, use checkboxes.
    $type = $cnt >= 20 || $is_optgroup ? 'select' : 'checkboxes';
    $form['og_nodeapi']['visible']['og_groups'] = array(
      '#type' => $type, 
      '#title' => t('Audience'), 
      '#attributes' => array('class' => 'og-audience'),
      '#options' => $type == 'checkboxes' ? array_map('filter_xss', $options) : $options, 
      '#required' => $required, 
      '#description' =>  format_plural(count($options), 'Show this post in this group.', 'Show this post in these groups.'),
      '#default_value' => $groups ? $groups : array(),
      '#required' => $required, 
      '#multiple' => TRUE);
  }
jvieille’s picture

Recall of the issue:
- when a (non admin) user who is member of several groups creates a new post or edit an existing one, he cannot select the audience apart of "Public"
- The administrator can select any group for a node audience.

Grayside’s picture

Title: missing ability to select group when creating/editing node (missing array key in og_form_add_og_audience();) » missing ability to select group when creating/editing node
Version: master » 6.x-2.x-dev
jvieille’s picture

Project: Organic Groups » Content Type Administration by Organic Group
Version: 6.x-2.x-dev » 6.x-1.x-dev
Component: og.module » Code
Status: Needs work » Closed (duplicate)

This is most certainly an OGCTA problem as mentioned in #6 by kasiawaka

http://drupal.org/node/573656