When a node is edited and saved it is automatically added to groups to which the user is a member but should not have write permission. The problem is that group nids are being added to $form['og_invisible']['og_groups_inaccessible'] by og_read_only which actually forces the node to be added to the controlled groups rather than preventing them being added, which is what og_read_only should be doing. Removing this code solves the problem:

    // Create or merge list of inaccessible groups

//    if (count($inaccessible_groups)) {
//      if ($form['og_invisible']['og_groups_inaccessible']) {
//        $form['og_invisible']['og_groups_inaccessible'] = array('#type' => 'value', '#value' => $inaccessible_groups);
//      }
//      else
//      {
//        $form['og_invisible']['og_groups_inaccessible'] = array_merge($form['og_invisible']['og_groups_inaccessible'], $inaccessible_groups);
//      }
//    }

Comments

John Hodgins’s picture

The above was a hasty solution. A much better solution is to not remove the code above, abut instead to check if the group was already selected (in og_initial_groups) before adding it to og_groups_inaccessible. So slightly higher in the 'Group checkboxes' section as these conditionals:

              if (in_array($key2, $form['og_initial_groups']['#value'])) {
                $inaccessible_groups[$key2] = $key2;
              }

and

            if (in_array($key, $form['og_initial_groups']['#value'])) {
              $inaccessible_groups[$key] = $key;
            }
yrocq’s picture

Assigned: Unassigned » yrocq

Commited in CVS. Thanks !

yrocq’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.