You are here

function og_menu_node_insert in Organic Groups Menu (OG Menu) 7.2

Same name and namespace in other branches
  1. 7.3 og_menu.module \og_menu_node_insert()

Implementation of hook_node_insert()

File

./og_menu.module, line 595
Integrates Menu with Organic Groups. Lots of menu forms duplication in OG context.

Code

function og_menu_node_insert($node) {
  if (og_is_group_type('node', $node->type)) {
    $og = og_get_group('node', $node->nid, FALSE, array(
      OG_STATE_ACTIVE,
      OG_STATE_PENDING,
    ));
    if ($node->og_menu) {
      menu_save(array(
        'menu_name' => 'menu-og-' . $og->gid,
        'title' => $node->title,
        'description' => t('OG Menu for') . ' ' . $node->title,
      ));
      og_menu_update_menu('menu-og-' . $og->gid, $og->gid);
    }
  }
}