/** * Implementation of hook_civicrm_navigationMenu * * @param $params array */ function sumfields_civicrm_navigationMenu(&$params) { $path = "Administer/Customize Data and Screens"; $item = array('label' => ts('Summary Fields', array('net.ourpowerbase.sumfields')), 'name' => 'Summary Fields', 'url' => 'civicrm/admin/setting/sumfields', 'permission' => 'administer CiviCRM', 'operator' => '', 'separator' => '', 'active' => 1); $ret = _sumfields_civix_insert_navigation_menu($params, $path, $item); }
/** * Inserts a navigation menu item at a given place in the hierarchy * * $menu - menu hierarchy * $path - path where insertion should happen (ie. Administer/System Settings) * $item - menu you need to insert (parent/child attributes will be filled for you) * $parentId - used internally to recurse in the menu structure */ function _sumfields_civix_insert_navigation_menu(&$menu, $path, $item, $parentId = NULL) { static $navId; // If we are done going down the path, insert menu if (empty($path)) { if (!$navId) { $navId = CRM_Core_DAO::singleValueQuery("SELECT max(id) FROM civicrm_navigation"); } $navId++; $menu[$navId] = array('attributes' => array_merge($item, array('label' => CRM_Utils_Array::value('name', $item), 'active' => 1, 'parentID' => $parentId, 'navID' => $navId))); return true; } else { // Find an recurse into the next level down $found = false; $path = explode('/', $path); $first = array_shift($path); foreach ($menu as $key => &$entry) { if ($entry['attributes']['name'] == $first) { if (!$entry['child']) { $entry['child'] = array(); } $found = _sumfields_civix_insert_navigation_menu($entry['child'], implode('/', $path), $item, $key); } } return $found; } }