/** * Implementation of hook_civicrm_install * * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_install */ function hrjobcontract_civicrm_install() { $cType = CRM_Contact_BAO_ContactType::basicTypePairs(false, 'id'); $org_id = array_search('Organization', $cType); $sub_type_name = array('Health Insurance Provider', 'Life Insurance Provider'); $orgSubType = CRM_Contact_BAO_ContactType::subTypes('Organization', true); $orgSubType = CRM_Contact_BAO_ContactType::subTypeInfo('Organization'); $params['parent_id'] = $org_id; $params['is_active'] = 1; if ($org_id) { foreach ($sub_type_name as $sub_type_name) { $subTypeName = ucfirst(CRM_Utils_String::munge($sub_type_name)); $subID = array_key_exists($subTypeName, $orgSubType); if (!$subID) { $params['name'] = $subTypeName; $params['label'] = $sub_type_name; CRM_Contact_BAO_ContactType::add($params); } elseif ($subID && $orgSubType[$subTypeName]['is_active'] == 0) { CRM_Contact_BAO_ContactType::setIsActive($orgSubType[$subTypeName]['id'], 1); } } } // Add Job Contract top menu $jobContractNavigation = new CRM_Core_DAO_Navigation(); $jobContractNavigation->name = 'job_contracts'; $jobContractNavigationResult = $jobContractNavigation->find(); if (!$jobContractNavigationResult) { $contactsWeight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Contacts', 'weight', 'name'); $jobContractNavigation = new CRM_Core_DAO_Navigation(); $params = array('domain_id' => CRM_Core_Config::domainID(), 'label' => ts('Job Contracts'), 'name' => 'job_contracts', 'url' => null, 'operator' => null, 'weight' => $contactsWeight + 1, 'is_active' => 1); $jobContractNavigation->copyValues($params); $jobContractNavigation->save(); $jobContractMenuTree = array(array('label' => ts('Import / Export'), 'name' => 'import_export_job_contracts')); foreach ($jobContractMenuTree as $key => $menuItems) { $menuItems['is_active'] = 1; $menuItems['parent_id'] = $jobContractNavigation->id; $menuItems['weight'] = $key; CRM_Core_BAO_Navigation::add($menuItems); } } return _hrjobcontract_civix_civicrm_install(); }
/** * Implementation of hook_civicrm_install */ function hrjob_civicrm_install() { $cType = CRM_Contact_BAO_ContactType::basicTypePairs(false, 'id'); $org_id = array_search('Organization', $cType); $sub_type_name = array('Health Insurance Provider', 'Life Insurance Provider'); $orgSubType = CRM_Contact_BAO_ContactType::subTypes('Organization', true); $orgSubType = CRM_Contact_BAO_ContactType::subTypeInfo('Organization'); $params['parent_id'] = $org_id; $params['is_active'] = 1; if ($org_id) { foreach ($sub_type_name as $sub_type_name) { $subTypeName = ucfirst(CRM_Utils_String::munge($sub_type_name)); $subID = array_key_exists($subTypeName, $orgSubType); if (!$subID) { $params['name'] = $subTypeName; $params['label'] = $sub_type_name; CRM_Contact_BAO_ContactType::add($params); } elseif ($subID && $orgSubType[$subTypeName]['is_active'] == 0) { CRM_Contact_BAO_ContactType::setIsActive($orgSubType[$subTypeName]['id'], 1); } } } //Add job import navigation menu $weight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Import Contacts', 'weight', 'name'); $contactNavId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Contacts', 'id', 'name'); $administerNavId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Dropdown Options', 'id', 'name'); $importJobNavigation = new CRM_Core_DAO_Navigation(); $params = array('domain_id' => CRM_Core_Config::domainID(), 'label' => ts('Import Jobs'), 'name' => 'jobImport', 'url' => null, 'parent_id' => $contactNavId, 'weight' => $weight + 1, 'permission' => 'access HRJobs', 'separator' => 1, 'is_active' => 1); $importJobNavigation->copyValues($params); $importJobNavigation->save(); $importJobMenuTree = array(array('label' => ts('Hours Types'), 'name' => 'hoursType', 'url' => 'civicrm/hour/editoption', 'permission' => 'administer CiviCRM', 'parent_id' => $administerNavId)); foreach ($importJobMenuTree as $key => $menuItems) { $menuItems['is_active'] = 1; CRM_Core_BAO_Navigation::add($menuItems); } CRM_Core_BAO_Navigation::resetNavigation(); return _hrjob_civix_civicrm_install(); }