After creating a node with automatic group membership, the group audience field is assigned to the NID of the group node, not the GID. This means that it works for a group where the nid is the same as the gid, but otherwise the new node has no group membership assigned to it. I am using the following module combination:

Core: 7.10
OG: 7.x-1.3
ctools: 7.x-rc1
Contextual Administration: 7.x-1.1

Comments

cpliakas’s picture

Title: Groups are populated from the node ID rather than the group ID » Groups are

Hi mwallenberg.

Thanks for posting. I am trying to figure out whether this is a bug report of a feature request. Could you help me understand a use case where the node ID would not be the group ID? The more detail the better, as I want to make sure I understand the issue completely.

Thanks,
Chris

cpliakas’s picture

Title: Group membership not applied » Groups are populated from the node ID rather than the group ID
mwallenberg’s picture

Title: Groups are » Groups are populated from the node ID rather than the group ID

As I have understood it, a group ID is separate from a node ID in most cases. Suppose, for example, that you have a site with 20 nodes on it already (none of them being groups). A new node is then created, and this node is specified as a group. It would have nid 21 and gid 1. If another node should be assigned to this group, the group audience field should be populated with the gid (1) rather than the nid (21) for it to work correctly.

There is a common case when the nid and gid will be the same: if the first node on the site is also the first group on the site. In this case, both nid and gid will be 1. But this is a special case, rather than the norm.

Thank you for writing this module - it is a great improvement over the "Content Create Links".

mwallenberg’s picture

StatusFileSize
new778 bytes

I have attached a proposed solution. It loads the node, extracts the group ID from it and then uses that to set the group membership. It works fine with the combination of modules I listed above.

Another option would be to act on a group ID context instead of a node ID context, but that would require a bigger overhaul of the module, and I don't have enough in-depth knowledge of contexts to pull that off at the moment.

Again, thanks for a great module!

mwallenberg’s picture

Status: Active » Needs review
cpliakas’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new1.02 KB
new1.14 KB

Ah, I understand the issue now. Thanks for explaining and posting a patch! Re-rolling with some defensive coding, but the logic is the same. The real patch is mostly whitespace differences, so I am attaching a no-whitespace patch as well to better highlight the changes.

Thanks!
Chris

cpliakas’s picture

Status: Reviewed & tested by the community » Fixed

Committed at http://drupalcode.org/project/context_admin_og.git/commit/f3ea609. This fix will be reflected in the 7.x-1.1 release.

Congrats on your first credited commit!

~Chris

mwallenberg’s picture

Thanks! Glad to see it made it into the module.

/ Mattias

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

Updated with more information.