This sounds like a common use case, especially since I think the setting "group manager full access" should usually be turned off.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

amitaibu’s picture

Assigned: amitaibu » Unassigned
Status: Active » Fixed
FileSize
57.32 KB

Committed.

RoySegall’s picture

Status: Fixed » Needs review
FileSize
1.09 KB

Attached test.

amitaibu’s picture

Status: Needs review » Fixed

Committed test, thanks.

ohthehugemanatee’s picture

Thanks for the patch! It looks like it tries to detect which role to apply. It would be simpler to just add a form element to admin/config/group/settings to "apply a default role to the Group creator", with a pulldown to select which role you want to apply.

amitaibu’s picture

> It would be simpler to just add a form element to admin/config/group/settings to "apply a default role to the Group creator", with a pulldown to select which role you want to apply.

It's doing exactly that.

ohthehugemanatee’s picture

Well I feel foolish - I'd applied it against an earlier version of dev. Thanks! :)

Status: Fixed » Closed (fixed)

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

paolomainardi’s picture

This patch seems to be broken, i'm working on og "version = "7.x-2.2".

How to reproduce:

1) Group type: "Community"
2) Set as default role "administration member"

This what is saved in "og_group_manager_default_rids_node_community" variable:

array (size=1)
  3 => string '3' (length=1)

RID 3 is the default administration member role created by og.

Full Texts	rid Primary Key: Unique role ID.	gid Ascending The group’s unique ID.	group_type The group’s entity type.	group_bundle The group’s bundle name.	name Unique role name per group.
	Edit	Delete	1	0	node	comunita	non-member
	Edit	Delete	2	0	node	comunita	member
	Edit	Delete	3	0	node	comunita	administrator member

Lastly, what happens at insert/update of this og entity content type:

 $name = 'og_group_manager_default_rids_' . $entity_type . '_' . $bundle;
    if ($rids = variable_get($name)) {
      foreach ($rids as $rid) {
        og_role_grant($entity_type, $id, $entity->uid, $rid);
      }
    }

And when it fails:

function og_role_grant($group_type, $gid, $uid, $rid) {
  // Make sure the role is valid.
  $group = entity_load_single($group_type, $gid);
  list(,, $bundle) = entity_extract_ids($group_type, $group);
  $og_roles = og_roles($group_type, $bundle, $gid, FALSE, FALSE);
  
   /**
var_dump($og_roles);
array (size=1)
  165 => string 'administrator member' (length=20)
  **/
  if (empty($og_roles[$rid])) {
    // Role isn't valid.
    return;
  }

As you can see we are going to check for "rid == 3" but new groups has new roles with new rid (in this case: rid=165) and it fails each time.

I'm going to write a patch.

paolomainardi’s picture

Status: Needs review » Closed (fixed)

Seems that your patch does not take in charge groups with overridden rules.

paolomainardi’s picture

Status: Closed (fixed) » Needs review
FileSize
2.51 KB

Patch attached.

Status: Closed (fixed) » Needs work

The last submitted patch, og-default-role-member-1444516-7463892.patch, failed testing.

amitaibu’s picture

Status: Needs work » Closed (fixed)

Please open a new issue.

paolomainardi’s picture

Amitaibu, ok, but i don't understand why to open a new issue when this patch is strictly related to this one.