本文整理汇总了PHP中CRM_Core_BAO_Navigation::add方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_Navigation::add方法的具体用法?PHP CRM_Core_BAO_Navigation::add怎么用?PHP CRM_Core_BAO_Navigation::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_Navigation
的用法示例。
在下文中一共展示了CRM_Core_BAO_Navigation::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hrprofile_civicrm_install
/**
* Implementation of hook_civicrm_install
*/
function hrprofile_civicrm_install()
{
$groups = CRM_Core_PseudoConstant::get('CRM_Core_BAO_UFField', 'uf_group_id', array('labelColumn' => 'name'));
$profileId = array_search('hrstaffdir_listing', $groups);
$path = array('url' => "civicrm/profile?reset=1&gid={$profileId}&force=1");
$navigationPath = CRM_Core_BAO_Navigation::retrieve($path, $defaultpath);
if ($profileId && $navigationPath) {
$originalUrl = "civicrm/profile?reset=1&gid={$profileId}&force=1";
$updatedUrl = "civicrm/profile/table?reset=1&gid={$profileId}&force=1";
hrprofile_updateNavigation($originalUrl, $updatedUrl);
} elseif ($profileId && !$navigationPath) {
// add to navigation
$navigationParams = array('label' => 'Directory', 'url' => "civicrm/profile/table?reset=1&gid={$profileId}&force=1", 'is_active' => 1);
$navigation = CRM_Core_BAO_Navigation::add($navigationParams);
CRM_Core_BAO_Navigation::resetNavigation();
// set the profile as search view
$params = array();
CRM_Core_BAO_ConfigSetting::retrieve($params);
if (!empty($params)) {
$params['defaultSearchProfileID'] = $profileId;
CRM_Core_BAO_ConfigSetting::create($params);
}
}
return _hrprofile_civix_civicrm_install();
}
示例2: testGetNavItemByUrl
/**
* Test that a navigation item can be retrieved by it's url.
*/
public function testGetNavItemByUrl()
{
$random_string = substr(sha1(rand()), 0, 7);
$name = "Test Menu Link {$random_string}";
$url = "civicrm/test/{$random_string}";
$url_params = "reset=1";
$params = array('name' => $name, 'label' => ts($name), 'url' => "{$url}?{$url_params}", 'parent_id' => NULL, 'is_active' => TRUE, 'permission' => array('access CiviCRM'));
CRM_Core_BAO_Navigation::add($params);
$new_nav = CRM_Core_BAO_Navigation::getNavItemByUrl($url, $url_params);
$this->assertObjectHasAttribute('id', $new_nav);
$this->assertNotNull($new_nav->id);
$new_nav->delete();
}
示例3: mailchimpsync_civicrm_navigationMenu
function mailchimpsync_civicrm_navigationMenu(&$params)
{
// get the id of Administer Menu
$administerMenuId = CRM_Core_DAO::getFieldValue('CRM_Core_BAO_Navigation', 'Administer', 'id', 'name');
CRM_Core_Error::debug_var('$administerMenuId', $administerMenuId);
// skip adding menu if there is no administer menu
if ($administerMenuId) {
// get the maximum key under adminster menu
$maxKey = max(array_keys($params[$administerMenuId]['child']));
$params[$administerMenuId]['child'][$maxKey + 1] = array('attributes' => array('label' => 'MailChimp Settings', 'name' => 'MailChimp Settings', 'url' => 'civicrm/mailchimp/apikeyregister', 'permission' => 'administer CiviCRM', 'operator' => NULL, 'separator' => TRUE, 'parentID' => $administerMenuId, 'navID' => $maxKey + 1, 'active' => 1));
CRM_Core_BAO_Navigation::add($params);
}
}
示例4: maxadditionalparticipants_civicrm_install
/**
* Implementation of hook_civicrm_install
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_install
*/
function maxadditionalparticipants_civicrm_install()
{
$parentId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Administer', 'id', 'name');
$weight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'CiviReport', 'weight', 'name');
if ($parentId) {
$maxparticipantMenuTree = array(array('label' => ts('Max Participant'), 'name' => 'Participant_Settings', 'url' => 'civicrm/participant/config?reset=1'));
foreach ($maxparticipantMenuTree as $key => $menuItems) {
$menuItems['is_active'] = 1;
$menuItems['parent_id'] = $parentId;
$menuItems['weight'] = ++$weight;
$menuItems['permission'] = 'administer CiviCRM';
CRM_Core_BAO_Navigation::add($menuItems);
}
CRM_Core_BAO_Navigation::resetNavigation();
}
return _maxadditionalparticipants_civix_civicrm_install();
}
开发者ID:Kajakaran,项目名称:uk.co.vedaconsulting.maxadditionalparticipants,代码行数:22,代码来源:maxadditionalparticipants.php
示例5: hrrecruitment_civicrm_install
/**
* Implementation of hook_civicrm_install
*/
function hrrecruitment_civicrm_install()
{
$activityTypesResult = civicrm_api3('activity_type', 'get', array());
$weight = count($activityTypesResult["values"]);
foreach (array('Evaluation', 'Comment') as $activityType) {
if (!in_array($activityType, $activityTypesResult["values"])) {
civicrm_api3('activity_type', 'create', array('weight' => $weight++, 'name' => $activityType, 'label' => $activityType, 'is_active' => 1));
}
}
$result = civicrm_api3('OptionGroup', 'create', array('name' => 'vacancy_status', 'title' => ts('Vacancy Status'), 'is_reserved' => 1, 'is_active' => 1));
$vacancyStatus = array('Draft' => ts('Draft'), 'Open' => ts('Open'), 'Closed' => ts('Closed'), 'Cancelled' => ts('Cancelled'), 'Rejected' => ts('Rejected'));
$weight = 1;
foreach ($vacancyStatus as $name => $label) {
$statusParam = array('option_group_id' => $result['id'], 'label' => $label, 'name' => $name, 'value' => $weight++, 'is_active' => 1);
if ($name == 'Draft') {
$statusParam['is_default'] = 1;
} elseif ($name == 'Open') {
$statusParam['is_reserved'] = 1;
}
civicrm_api3('OptionValue', 'create', $statusParam);
}
$stages = array('Apply' => ts('Apply'), 'Ongoing_Vacancy' => ts('Ongoing'), 'Phone_Interview' => ts('Phone Interview'), 'Manager_Interview' => ts('Manager Interview'), 'Board_Interview' => ts('Board Interview'), 'Group_Interview' => ts('Group Interview'), 'Psych_Exam' => ts('Psych Exam'), 'Offer' => ts('Offer'), 'Hired' => ts('Hired'));
$count = count(CRM_Core_OptionGroup::values('case_status'));
foreach ($stages as $name => $label) {
$count++;
$caseStatusParam = array('option_group_id' => 'case_status', 'label' => $label, 'name' => $name, 'value' => $count, 'grouping' => 'Vacancy', 'filter' => 1);
civicrm_api3('OptionValue', 'create', $caseStatusParam);
}
$reportWeight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Reports', 'weight', 'name');
$vacancyNavigation = new CRM_Core_DAO_Navigation();
$params = array('domain_id' => CRM_Core_Config::domainID(), 'label' => ts('Vacancies'), 'name' => 'Vacancies', 'url' => null, 'operator' => null, 'weight' => $reportWeight - 1, 'is_active' => 1);
$vacancyNavigation->copyValues($params);
$vacancyNavigation->save();
$evalID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Evaluation');
$vacancyMenuTree = array(array('label' => ts('Dashboard'), 'name' => 'dashboard', 'url' => 'civicrm/vacancy/dashboard?reset=1', 'permission' => 'view Applicants, manage Applicants, evaluate Applicants, administer Vacancy, administer CiviCRM', 'permission_operator' => 'OR'), array('label' => ts('Public Vacancy List'), 'name' => 'public_list', 'url' => 'civicrm/vacancy/publiclisting?reset=1', 'permission' => NULL, 'has_separator' => 1), array('label' => ts('New Vacancy'), 'name' => 'new_vacancy', 'url' => 'civicrm/vacancy/add?reset=1', 'permission' => 'administer Vacancy, administer CiviCRM', 'permission_operator' => 'OR'), array('label' => ts('New Template'), 'name' => 'new_template', 'url' => 'civicrm/vacancy/add?reset=1&template=1', 'permission' => 'administer Vacancy, administer CiviCRM', 'permission_operator' => 'OR'), array('label' => ts('New Applicant'), 'name' => 'new_applicant', 'has_separator' => 1), array('label' => ts('Find Vacancies'), 'name' => 'find_vacancies', 'url' => 'civicrm/vacancy/find?reset=1', 'permission' => 'view Applicants, manage Applicants, evaluate Applicants, administer Vacancy, administer CiviCRM', 'permission_operator' => 'OR'), array('label' => ts('Find Templates'), 'name' => 'find_templates', 'url' => 'civicrm/vacancy/find?reset=1&template=1', 'permission' => 'view Applicants, manage Applicants, evaluate Applicants, administer Vacancy, administer CiviCRM', 'permission_operator' => 'OR'), array('label' => ts('Search by Application Form Fields'), 'name' => 'find_application', 'url' => 'civicrm/case/search?reset=1', 'permission' => 'view Applicants, manage Applicants, evaluate Applicants, administer Vacancy, administer CiviCRM', 'permission_operator' => 'OR'), array('label' => ts('Search by Evaluation Criteria'), 'name' => 'find_evaluation', 'url' => "civicrm/activity/search?force=1&type={$evalID}&reset=1", 'permission' => 'view Applicants, manage Applicants, evaluate Applicants, administer Vacancy, administer CiviCRM', 'permission_operator' => 'OR'));
foreach ($vacancyMenuTree as $key => $menuItems) {
$menuItems['is_active'] = 1;
$menuItems['parent_id'] = $vacancyNavigation->id;
$menuItems['weight'] = $key;
CRM_Core_BAO_Navigation::add($menuItems);
}
CRM_Core_BAO_Navigation::resetNavigation();
return _hrrecruitment_civix_civicrm_install();
}
示例6: hrjobcontract_civicrm_install
/**
* 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();
}
示例7: simpledonate_civicrm_install
/**
* Implementation of hook_civicrm_install
*/
function simpledonate_civicrm_install()
{
//Add menu for donation page link under Contribution parent navigation
//And Configuration link under Admin navigation
$civiContributeParentId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'CiviContribute', 'id', 'name');
$params = array('domain_id' => CRM_Core_Config::domainID(), 'label' => 'Simple Donate Configuration', 'name' => 'Simple Donate Configuration', 'url' => 'civicrm/simple/donation/configuration?reset=1', 'permission' => 'access CiviContribute', 'parent_id' => $civiContributeParentId, 'has_separator' => 1, 'is_active' => 1);
CRM_Core_BAO_Navigation::add($params);
$contributionsParentId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Contributions', 'id', 'name');
$donationNavigation = new CRM_Core_DAO_Navigation();
$params = array('domain_id' => CRM_Core_Config::domainID(), 'label' => 'Simple Donate', 'name' => 'Simple Donate', 'url' => NULL, 'permission' => 'access CiviContribute', 'parent_id' => $contributionsParentId, 'has_separator' => 1, 'is_active' => 1, 'weight' => 100);
$donationNavigation->copyValues($params);
$donationNavigation->save();
$donationMenuTree = array(array('label' => ts('Test mode'), 'name' => 'Test Donation', 'url' => 'civicrm/simple?test=1#/donation', 'permission' => 'access CiviContribute'), array('label' => ts('Live mode'), 'name' => 'Live Donation', 'url' => 'civicrm/simple/#/donation', 'permission' => 'access CiviContribute'));
foreach ($donationMenuTree as $key => $menuItems) {
$menuItems['is_active'] = 1;
$menuItems['parent_id'] = $donationNavigation->id;
$menuItems['weight'] = $key;
CRM_Core_BAO_Navigation::add($menuItems);
}
return _simpledonate_civix_civicrm_install();
}
示例8: hrreport_civicrm_install
/**
* Implementation of hook_civicrm_install
*/
function hrreport_civicrm_install()
{
$isEnabled = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Extension', 'org.civicrm.hrabsence', 'is_active', 'full_name');
$absenceReport = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'absenceReport', 'id', 'name');
if ($isEnabled && !$absenceReport) {
$reportParentId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Reports', 'id', 'name');
$params = array('domain_id' => CRM_Core_Config::domainID(), 'label' => 'Absence Report', 'name' => 'absenceReport', 'url' => 'civicrm/report/list?grp=absence&reset=1', 'permission' => 'access HRReport', 'parent_id' => $reportParentId, 'is_active' => 1);
CRM_Core_BAO_Navigation::add($params);
$absenceParentId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Absences', 'id', 'name');
$calendarId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'calendar', 'id', 'name');
if (empty($calendarId)) {
$params = array('domain_id' => CRM_Core_Config::domainID(), 'label' => 'Calendar', 'name' => 'calendar', 'url' => null, 'permission' => 'access HRReport', 'parent_id' => $absenceParentId, 'is_active' => 1, 'weight' => 2);
CRM_Core_BAO_Navigation::add($params);
}
$absenceReportId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'absence_report', 'id', 'name');
if (empty($absenceReportId)) {
$params = array('domain_id' => CRM_Core_Config::domainID(), 'label' => 'Absence Report', 'name' => 'absence_report', 'url' => 'civicrm/report/list?grp=absence&reset=1', 'permission' => 'access HRReport', 'parent_id' => $absenceParentId, 'is_active' => 1, 'weight' => 7);
CRM_Core_BAO_Navigation::add($params);
}
}
return _hrreport_civix_civicrm_install();
}
示例9: hrjob_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();
}
示例10: upgrade_0007
/**
* Install Appraisals top navigation
*
* @return boolean
*/
public function upgrade_0007()
{
// Add Appraisals to the Top Navigation menu
CRM_Core_DAO::executeQuery("DELETE FROM `civicrm_navigation` WHERE name = 'appraisals' and parent_id IS NULL");
$weight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Contacts', 'weight', 'name');
//$contactNavId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Contacts', 'id', 'name');
$appraisalsNavigation = new CRM_Core_DAO_Navigation();
$params = array('domain_id' => CRM_Core_Config::domainID(), 'label' => ts('Appraisals'), 'name' => 'appraisals', 'url' => null, 'parent_id' => null, 'weight' => $weight + 1, 'separator' => 1, 'is_active' => 1);
$appraisalsNavigation->copyValues($params);
$appraisalsNavigation->save();
if ($appraisalsNavigation->id) {
$submenu = array(array('label' => ts('Appraisals Dashboard'), 'name' => 'appraisals_dashboard', 'url' => 'civicrm/appraisals/dashboard'), array('label' => ts('Search Appraisals'), 'name' => 'search_appraisals', 'url' => 'civicrm/appraisals/search'), array('label' => ts('Import Appraisals'), 'name' => 'import_appraisals', 'url' => 'civicrm/appraisals/import'));
foreach ($submenu as $key => $item) {
$item['parent_id'] = $appraisalsNavigation->id;
$item['weight'] = $key;
$item['is_active'] = 1;
CRM_Core_BAO_Navigation::add($item);
}
}
$administerNavId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Administer', 'id', 'name');
$aministerAppraisalMenu = array('label' => ts('Appraisal grade labels'), 'name' => 'appraisal_grade_labels', 'url' => 'civicrm/appraisal_criteria', 'permission' => 'administer CiviCRM', 'parent_id' => $administerNavId, 'is_active' => 1);
CRM_Core_BAO_Navigation::add($aministerAppraisalMenu);
CRM_Core_BAO_Navigation::resetNavigation();
return TRUE;
}
示例11: add
/**
* Add or update Contact SubTypes.
*
* @param array $params
* An assoc array of name/value pairs.
*
* @return object|void
*/
public static function add(&$params)
{
// label or name
if (empty($params['id']) && empty($params['label'])) {
return NULL;
}
if (!empty($params['parent_id']) && !CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_ContactType', $params['parent_id'])) {
return NULL;
}
$contactType = new CRM_Contact_DAO_ContactType();
$contactType->copyValues($params);
$contactType->id = CRM_Utils_Array::value('id', $params);
$contactType->is_active = CRM_Utils_Array::value('is_active', $params, 0);
$contactType->save();
if ($contactType->find(TRUE)) {
$contactName = $contactType->name;
$contact = ucfirst($contactType->label);
$active = $contactType->is_active;
}
if (!empty($params['id'])) {
$params = array('name' => "New {$contactName}");
$newParams = array('label' => "New {$contact}", 'is_active' => $active);
CRM_Core_BAO_Navigation::processUpdate($params, $newParams);
} else {
$name = self::getBasicType($contactName);
if (!$name) {
return;
}
$value = array('name' => "New {$name}");
CRM_Core_BAO_Navigation::retrieve($value, $navinfo);
$navigation = array('label' => "New {$contact}", 'name' => "New {$contactName}", 'url' => "civicrm/contact/add?ct={$name}&cst={$contactName}&reset=1", 'permission' => 'add contacts', 'parent_id' => $navinfo['id'], 'is_active' => $active);
CRM_Core_BAO_Navigation::add($navigation);
}
CRM_Core_BAO_Navigation::resetNavigation();
// reset the cache after adding
self::subTypeInfo(NULL, FALSE, FALSE, TRUE);
return $contactType;
}
示例12: createReportNavItem
/**
* Create a navigation item for a report instance.
*
* @param string $name
* @param string $url
* @param string $url_params
* @param int $parent_id
* @param string $permission
* @param int $id
* @param int $domain_id
* ID of domain to create item in.
*
* @return \CRM_Core_DAO_Navigation
*/
public static function createReportNavItem($name, $url, $url_params, $parent_id, $permission, $id, $domain_id)
{
if ($url !== NULL) {
$url = "{$url}?{$url_params}";
}
$params = array('name' => $name, 'label' => ts($name), 'url' => $url, 'parent_id' => $parent_id, 'is_active' => TRUE, 'permission' => array($permission), 'domain_id' => $domain_id);
if ($id) {
$params['id'] = $id;
}
return CRM_Core_BAO_Navigation::add($params);
}
示例13: add
/**
* Function to add or update Contact SubTypes
*
* @param array $params an assoc array of name/value pairs
* @return object
* @access public
* @static
*/
static function add($params)
{
$contactType =& new CRM_Contact_DAO_ContactType();
$contactType->copyValues($params);
$contactType->id = CRM_Utils_Array::value('id', $params);
if (CRM_Utils_Array::value('parent_id', $params)) {
$contactType->is_active = CRM_Utils_Array::value('is_active', $params, 0);
}
$contactType->save();
if ($contactType->find(true)) {
$contactName = $contactType->name;
$contact = ucfirst($contactType->label);
$active = $contactType->is_active;
}
if (CRM_Utils_Array::value('id', $params)) {
$params = array('name' => "New {$contactName}");
$newParams = array('label' => "New {$contact}", 'is_active' => $active);
CRM_Core_BAO_Navigation::processUpdate($params, $newParams);
} else {
if (CRM_Utils_Array::value('parent_id', $params)) {
$name = self::getBasicType($contactName);
$value = array('name' => "New {$name}");
CRM_Core_BAO_Navigation::retrieve($value, $navinfo);
$navigation = array('label' => "New {$contact}", 'name' => "New {$contactName}", 'url' => "civicrm/contact/add&ct={$name}&cst={$contactName}&reset=1", 'permission' => "add contacts", 'parent_id' => $navinfo['id'], 'is_active' => $active);
CRM_Core_BAO_Navigation::add($navigation);
}
}
CRM_Core_BAO_Navigation::resetNavigation();
return $contactType;
}
示例14: upgrade_1401
public function upgrade_1401()
{
$this->ctx->log->info('Applying update 1401');
$administerNavId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Dropdown Options', 'id', 'name');
$params = array('label' => ts('Hours Types'), 'name' => 'hoursType', 'url' => 'civicrm/hour/editoption', 'permission' => 'administer CiviCRM', 'parent_id' => $administerNavId, 'is_active' => 1);
CRM_Core_BAO_Navigation::add($params);
CRM_Core_BAO_Navigation::resetNavigation();
return TRUE;
}
示例15: hrabsence_civicrm_install
/**
* Implementation of hook_civicrm_install
*/
function hrabsence_civicrm_install()
{
$reportWeight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Reports', 'weight', 'name');
$absenceNavigation = new CRM_Core_DAO_Navigation();
$params = array('domain_id' => CRM_Core_Config::domainID(), 'label' => 'Absences', 'name' => 'Absences', 'url' => null, 'operator' => null, 'weight' => $reportWeight - 1, 'is_active' => 1);
$absenceNavigation->copyValues($params);
$absenceNavigation->save();
$absenceMenuTree = array(array('label' => ts('My Absences'), 'name' => 'my_absences', 'url' => 'civicrm/absences', 'permission' => 'view HRAbsences, edit HRAbsences, administer CiviCRM, manage own HRAbsences'), array('label' => ts('Calendar'), 'name' => 'calendar', 'url' => null, 'permission' => 'access HRReport'), array('label' => ts('New Absence'), 'name' => 'new_absence', 'url' => null, 'permission' => 'edit HRAbsences,administer CiviCRM,manage own HRAbsences', 'permission_operator' => 'OR', 'has_separator' => 1), array('label' => ts('Public Holidays'), 'name' => 'publicHolidays', 'url' => 'civicrm/absence/holidays?reset=1', 'permission' => 'administer CiviCRM'), array('label' => ts('Absence Periods'), 'name' => 'absencePeriods', 'url' => 'civicrm/absence/period?reset=1', 'permission' => 'administer CiviCRM'), array('label' => ts('Absence Types'), 'name' => 'absenceTypes', 'url' => 'civicrm/absence/type?reset=1', 'permission' => 'administer CiviCRM', 'has_separator' => 1), array('label' => ts('Absence Report'), 'name' => 'absence_report', 'url' => 'civicrm/report/list?grp=absence&reset=1', 'permission' => 'access HRReport'));
foreach ($absenceMenuTree as $key => $menuItems) {
$menuItems['is_active'] = 1;
$menuItems['parent_id'] = $absenceNavigation->id;
$menuItems['weight'] = $key;
CRM_Core_BAO_Navigation::add($menuItems);
}
$isEnabled = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Extension', 'org.civicrm.hrreport', 'is_active', 'full_name');
$reportParentId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Reports', 'id', 'name');
$params = array('domain_id' => CRM_Core_Config::domainID(), 'label' => 'Absence Report', 'name' => 'absenceReport', 'url' => 'civicrm/report/list?grp=absence&reset=1', 'permission' => 'access HRReport', 'parent_id' => $reportParentId, 'is_active' => $isEnabled);
CRM_Core_BAO_Navigation::add($params);
CRM_Core_BAO_Navigation::resetNavigation();
$params = array('sequential' => 1, 'option_group_id' => 'activity_status', 'name' => 'Rejected', 'is_reserved' => 1, 'is_active' => 1);
civicrm_api3('OptionValue', 'create', $params);
/* Create message template for absence leave application */
$msg_text = '{ts}Dear{/ts} {$displayName},
{ts}Employee:{/ts} {$empName}
{ts}Position:{/ts} {$empPosition}
{ts}Absence Type:{/ts} {$absenceType}
{ts}Dates:{/ts} {$startDate} - {$endDate}
{if $cancel}
{ts}Leave has been cancelled.{/ts}
{elseif $reject}
{ts}Leave has been rejected.{/ts}
{elseif $approval}
Leave has been approved for {$appDays}.
{/if}
{ts}Date{/ts} | {ts}Absence{/ts} | {if $approval and $totDays neq $appDays} {ts}Approve{/ts} {/if}
{foreach from=$absentDateDurations item=value key=label}
{if $value.duration != 0}
{$label|date_format} | {if $value.duration == $jobHoursTime.Full_Time*60} {ts}Full Day{/ts} {elseif $value.duration == $jobHoursTime.Part_Time*60} {ts}Half Day{/ts} {/if} | {if $approval and $totDays neq $appDays} {if $value.approval == 2}{ts}Approved{/ts} {elseif $value.approval == 9} {ts}Unapproved{/ts} {/if} {/if}
{/if}
{/foreach}
{ts}Total{/ts} | {$totDays}
{if $customGroup}
{foreach from=$customGroup item=value key=customName}
{foreach from=$value item=v key=n}
{$customName} : {$v}
{/foreach}
{/foreach}
{/if}';
$msg_html = '<p>{ts}Dear{/ts} {$displayName},</p>
<table>
<tbody>
<tr>
<td>{ts}Employee:{/ts}</td>
<td>{$empName}</td>
</tr>
<tr>
<td>{ts}Position:{/ts}</td>
<td>{$empPosition}</td>
</tr>
<tr>
<td>{ts}Absence Type:{/ts}</td>
<td>{$absenceType}</td>
</tr>
<tr>
<td>{ts}Dates:{/ts}</td>
<td>{$startDate|date_format} - {$endDate|date_format}</td>
</tr>
</tbody>
</table>
{if $cancel}
<p> {ts}Leave has been cancelled.{/ts} </p>
{elseif $reject}
<p> {ts}Leave has been rejected.{/ts} </p>
{elseif $approval}
<p> Leave has been approved for {$appDays}.</p>
{/if}
<br/>
<table border="1" border-spacing="0">
<tbody>
<tr>
<th> {ts}Date{/ts} </th>
<th> {ts}Absence{/ts} </th>
{if $approval and $totDays neq $appDays}
<th> {ts}Status{/ts} </th>
{/if}
</tr>
{foreach from=$absentDateDurations item=value key=label}
{if $value.duration != 0}
<tr>
<td>{$label|date_format}</td>
<td>{if $value.duration == $jobHoursTime.Full_Time*60} {ts}Full Day{/ts} {elseif $value.duration == $jobHoursTime.Part_Time*60} {ts}Half Day{/ts} {else} {/if}</td>
{if $approval and $totDays neq $appDays}
<td>{if $value.approval == 2} {ts}Approved{/ts} {elseif $value.approval == 9} {ts}Unapproved{/ts} {else}{/if}</td>
{/if}
</tr>
//.........这里部分代码省略.........