Modified code to reflect changes in og_subgroups.module.

When a user creates a "Subgroup" (using OGUR "Create subgroup" link), the current group is stored in og_ancestry table as the "parent" of the subgroup being created.

In hook_nodeapi('insert'):

          // Create a subgroup record for this group
          // 'ognodeadd' is my node add callback, so I know if this node is a group and
          // here, then we need to process it node as a subgroup
          if ($node->type == variable_get('og_user_roles_create_subgroup_value', '') && arg(1) == 'ognodeadd') {
            $gids = $_GET['gids'];
            $gid = $gids[0];
            $subgroup = $node->nid;
            $sql = 'INSERT INTO {og_ancestry} (nid,group_nid,is_public) VALUES (%d,%d,0)';
            db_query($sql, $subgroup, $gid);
            if (module_exists('og_subgroups')) db_query('INSERT INTO {og_subgroups} (gid, parent) VALUES (%d, %d)', $subgroup, $gid);
          }

The og_subgroups moderator changed the code so that the parent/child relationship is maintained in the og_subgroups table now. I modified my code appropriately as indicated above.

Tested with user admin2 in District2. Created "Test District2 Subgroup" in District2. It now shows up as subgroup under District2 automatically.

So, I guess my code change works.

Clicking on "Create Subgroup" link will now place newly created group as subgroup of current group ("parent").

Will release in 3.3.

Comments

Anonymous’s picture

Status: Fixed » Closed (fixed)

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