When editing a group node, which already has a menu, "Enable menu for this group" remains unchecked.

og_menu_get_menus() is called in og_menu_node_prepare() but it doesn't return the existing menu correctly. I believe it's because the group id should be carried in the arguments.

Attached a patch which fixes the problem for me.

Comments

rv0’s picture

Status: Needs review » Fixed

Makes sense, og_menu_get_menus() without arguments just gets all og menu's (regardless of the og) that belong to the user, so this is wrong indeed.

committed your patch with a minor edit: http://drupalcode.org/project/og_menu.git/blobdiff/5f5dfe6bc5dfb466cf357...

thank you!

jastraat’s picture

Status: Fixed » Active

Sadly, the fix for this causes a PHP error when creating a new group because $nid has not yet been set. Suggestion:

  if (og_is_group_type('node', $node->type)) {
    if (isset($node->nid)) { //Updating an existing node
      $og = og_get_group('node', $node->nid);
      $node->og_menu = og_menu_get_menus(array($og->gid));
	}
	else {
	  $node->og_menu = og_menu_get_menus();
	}
  }
juhaniemi’s picture

@jastraat: I just tested creating a new group, and didn't get any errors. The menu was created correctly. $node->nid is available in hook_node_insert(), which is called after the group has been created.

Which version are you using?

jastraat’s picture

I downloaded the latest dev today. (packaging script on 2011-11-03)

jastraat’s picture

This hook_node_prepare that is causing the problem btw -

rv0’s picture

Come to think of it,
the initial problem
"When editing a group node, which already has a menu, "Enable menu for this group" remains unchecked."

was never there afaik :s
This week I wont have time to delve into this.. all I can do is roll back the patch for now..

jastraat’s picture

Looks like the original patch is still in the current dev; still getting that PHP error on group create.

rv0’s picture

Status: Active » Postponed (maintainer needs more info)

Reverted this patch...

I cannot reproduce the original issue

rv0’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

Works here, No feedback, closing this.