/** * * This function does 2 things - * 1 - Create menu tabs for all custom groups with style 'Tab' * 2 - Updates tab for custom groups with style 'Inline'. If there * are no inline groups it removes the 'Custom Data' tab * * * @param string $entityType - what entity are we extending here ? * @param string $path - what should be the starting path for the new menus ? * @param int $startWeight - weight to start the local menu tabs * * @return void * * @access public * @static * */ function addMenuTabs($entityType, $path, $startWeight) { // for Tab's $customGroupDAO =& new CRM_Core_DAO_CustomGroup(); // get only 'Tab' groups $customGroupDAO->whereAdd("style = 'Tab'"); $customGroupDAO->whereAdd("is_active = 1"); $customGroupDAO->whereAdd("domain_id =" . CRM_Core_Config::domainID()); // add whereAdd for entity type CRM_Core_BAO_CustomGroup::_addWhereAdd($customGroupDAO, $entityType); // order by weight $customGroupDAO->orderBy('weight'); $customGroupDAO->find(); // process each group with menu tab while ($customGroupDAO->fetch()) { $menu = array(); $menu['path'] = $path; $menu['title'] = "{$customGroupDAO->title}"; $menu['qs'] = 'reset=1&gid=' . $customGroupDAO->id . '&cid=%%cid%%'; $menu['type'] = CRM_UTILS_MENU_CALLBACK; $menu['crmType'] = CRM_UTILS_MENU_LOCAL_TASK; $menu['weight'] = $startWeight++; $menu['extra'] = array('gid' => $customGroupDAO->id); $menus[] = $menu; } if (is_array($menus)) { foreach ($menus as $menu) { CRM_Utils_Menu::add($menu); } } }