You are here

function oa_sections_og_menu_single_menu_parent in Open Atrium Core 7.2

Implements hook_og_menu_single_menu_parent().

File

modules/oa_sections/oa_sections.module, line 97

Code

function oa_sections_og_menu_single_menu_parent($conf) {
  if ($plid = og_menu_single_get_active_plid()) {
    $node = menu_get_object();
    if ($node && $node->type == 'oa_section') {

      // Menu will be cached via core, so just get it.and look for the parent
      $section_id = $node->nid;
    }
    elseif ($node && ($values = field_get_items('node', $node, 'oa_section_ref'))) {
      $value = reset($values);
      $section_id = $value['target_id'];
    }
    else {
      $section_id = oa_core_get_section_context();
    }

    // If in a section, find the the secondary link that section is in.
    if ($section_id) {
      if ($mlid = og_menu_single_get_link_mlid('node', $section_id)) {
        foreach (og_menu_single_children_items($plid) as $item) {
          if (_oa_sections_is_parent($item, $mlid)) {
            return $item['link']['mlid'];
          }
        }
      }
    }
    return $plid;
  }
}