本文整理汇总了PHP中CRM_Contact_BAO_ContactType::subTypeInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_ContactType::subTypeInfo方法的具体用法?PHP CRM_Contact_BAO_ContactType::subTypeInfo怎么用?PHP CRM_Contact_BAO_ContactType::subTypeInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_BAO_ContactType
的用法示例。
在下文中一共展示了CRM_Contact_BAO_ContactType::subTypeInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hrjobcontract_civicrm_uninstall
/**
* Implementation of hook_civicrm_uninstall
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_uninstall
*/
function hrjobcontract_civicrm_uninstall()
{
$subTypeInfo = CRM_Contact_BAO_ContactType::subTypeInfo('Organization');
$sub_type_name = array('Health Insurance Provider', 'Life Insurance Provider');
foreach ($sub_type_name as $sub_type_name) {
$subTypeName = ucfirst(CRM_Utils_String::munge($sub_type_name));
$orid = array_key_exists($subTypeName, $subTypeInfo);
if ($orid) {
$id = $subTypeInfo[$subTypeName]['id'];
CRM_Contact_BAO_ContactType::del($id);
}
}
$jobContractMenu = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'job_contracts', 'id', 'name');
if (!empty($jobContractMenu)) {
CRM_Core_BAO_Navigation::processDelete($jobContractMenu);
}
CRM_Core_DAO::executeQuery("DELETE FROM civicrm_navigation WHERE name IN ('job_contracts', 'import_export_job_contracts', 'jobImport', 'hoursType', 'pay_scale','hours_location', 'hrjc_contact_type', 'hrjc_location', 'hrjc_pay_cycle', 'hrjc_benefit_name', 'hrjc_benefit_type', 'hrjc_deduction_name', 'hrjc_deduction_type', 'hrjc_health_provider', 'hrjc_life_provider', 'hrjc_pension_type', 'hrjc_revision_change_reason')");
CRM_Core_BAO_Navigation::resetNavigation();
//delete custom groups and field
$customGroup = civicrm_api3('CustomGroup', 'get', array('name' => "HRJobContract_Summary"));
$customGroupData = CRM_Utils_Array::first($customGroup['values']);
if (!empty($customGroupData['id'])) {
civicrm_api3('CustomGroup', 'delete', array('id' => $customGroupData['id']));
}
$customGroup = civicrm_api3('CustomGroup', 'get', array('name' => "HRJobContract_Summary"));
$customGroupData = CRM_Utils_Array::first($customGroup['values']);
if (!empty($customGroupData['id'])) {
civicrm_api3('CustomGroup', 'delete', array('id' => $customGroupData['id']));
}
//delete all option group and values
CRM_Core_DAO::executeQuery("DELETE FROM civicrm_option_group WHERE name IN ('job_contracts', 'hoursType', 'pay_scale','hours_location', 'hrjc_contact_type', 'hrjc_location', 'hrjc_pay_cycle', 'hrjc_benefit_name', 'hrjc_benefit_type', 'hrjc_deduction_name', 'hrjc_deduction_type', 'hrjc_health_provider', 'hrjc_life_provider', 'hrjc_pension_type', 'hrjc_revision_change_reason', 'hrjc_contract_type', 'hrjc_level_type', 'hrjc_department', 'hrjc_hours_type', 'hrjc_pay_grade', 'hrjc_health_provider', 'hrjc_life_provider', 'hrjc_location', 'hrjc_pension_type', 'hrjc_region', 'hrjc_pay_scale')");
//delete job contract files to entities relations
CRM_Core_DAO::executeQuery("DELETE FROM civicrm_entity_file WHERE entity_table LIKE 'civicrm_hrjobcontract_%'");
return _hrjobcontract_civix_civicrm_uninstall();
}
示例2: browse
function browse()
{
$basicType = CRM_Contact_BAO_ContactType::contactTypeInfo(true);
$subType = CRM_Contact_BAO_ContactType::subTypeInfo(null, true);
$rows = array_merge($basicType, $subType);
foreach ($rows as $key => $value) {
$mask = null;
if (CRM_Utils_Array::value('is_reserved', $value)) {
$mask -= CRM_Core_Action::DELETE + 1;
}
$rows[$key]['action'] = CRM_Core_Action::formLink(self::links(), $mask, array('id' => $value['id']));
}
$this->assign('rows', $rows);
}
示例3: getContactType
/**
* Retrieve the first non-generic contact type
*
* @param int $id id of uf_group
*
* @return string contact type
*/
static function getContactType($id)
{
$validTypes = array_filter(array_keys(CRM_Core_SelectValues::contactType()));
$validSubTypes = CRM_Contact_BAO_ContactType::subTypeInfo();
$typesParts = explode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $id, 'group_type'));
$types = explode(',', $typesParts[0]);
$cType = NULL;
foreach ($types as $type) {
if (in_array($type, $validTypes)) {
$cType = $type;
} elseif (array_key_exists($type, $validSubTypes)) {
$cType = CRM_Utils_Array::value('parent', $validSubTypes[$type]);
}
if ($cType) {
break;
}
}
return $cType;
}
示例4: getContactType
/**
* Retrieve the first non-generic contact type
*
* @param int $id id of uf_group
* @return string contact type
*/
static function getContactType($id)
{
require_once 'CRM/Contact/BAO/ContactType.php';
$validTypes = array_filter(array_keys(CRM_Core_SelectValues::contactType()));
$validSubTypes = CRM_Contact_BAO_ContactType::subTypeInfo();
$types = explode(',', CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $id, 'group_type'));
$cType = null;
foreach ($types as $type) {
if (in_array($type, $validTypes)) {
$cType = $type;
} else {
if (array_key_exists($type, $validSubTypes)) {
$cType = CRM_Utils_Array::value('parent', $validSubTypes[$type]);
}
}
if ($cType) {
break;
}
}
return $cType;
}
示例5: browse
/**
* Browse all custom data groups.
*
* @param string $action the action to be invoked
*
* @return void
* @access public
*/
function browse($action = NULL)
{
// get all custom groups sorted by weight
$customGroup = array();
$dao = new CRM_Core_DAO_CustomGroup();
$dao->orderBy('weight, title');
$dao->find();
while ($dao->fetch()) {
$customGroup[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $customGroup[$dao->id]);
// form all action links
$action = array_sum(array_keys($this->actionLinks()));
// update enable/disable links depending on custom_group properties.
if ($dao->is_active) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
$customGroup[$dao->id]['order'] = $customGroup[$dao->id]['weight'];
$customGroup[$dao->id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('id' => $dao->id));
}
$customGroupExtends = CRM_Core_SelectValues::customGroupExtends();
foreach ($customGroup as $key => $array) {
CRM_Core_DAO_CustomGroup::addDisplayEnums($customGroup[$key]);
$customGroup[$key]['extends_display'] = $customGroupExtends[$customGroup[$key]['extends']];
}
//fix for Displaying subTypes
$subTypes = array();
$subTypes['Activity'] = CRM_Core_PseudoConstant::activityType(FALSE, TRUE, FALSE, 'label', TRUE);
$subTypes['Contribution'] = CRM_Contribute_PseudoConstant::contributionType();
$subTypes['Membership'] = CRM_Member_BAO_MembershipType::getMembershipTypes(FALSE);
$subTypes['Event'] = CRM_Core_OptionGroup::values('event_type');
$subTypes['Grant'] = CRM_Core_OptionGroup::values('grant_type');
$subTypes['Campaign'] = CRM_Campaign_PseudoConstant::campaignType();
$subTypes['Participant'] = array();
$subTypes['ParticipantRole'] = CRM_Core_OptionGroup::values('participant_role');
$subTypes['ParticipantEventName'] = CRM_Event_PseudoConstant::event();
$subTypes['ParticipantEventType'] = CRM_Core_OptionGroup::values('event_type');
$subTypes['Individual'] = CRM_Contact_BAO_ContactType::subTypePairs('Individual', FALSE, NULL);
$subTypes['Household'] = CRM_Contact_BAO_ContactType::subTypePairs('Household', FALSE, NULL);
$subTypes['Organization'] = CRM_Contact_BAO_ContactType::subTypePairs('Organization', FALSE, NULL);
$relTypeInd = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, 'Individual');
$relTypeOrg = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, 'Organization');
$relTypeHou = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, 'Household');
$allRelationshipType = array();
$allRelationshipType = array_merge($relTypeInd, $relTypeOrg);
$allRelationshipType = array_merge($allRelationshipType, $relTypeHou);
//adding subtype specific relationships CRM-5256
$relSubType = CRM_Contact_BAO_ContactType::subTypeInfo();
foreach ($relSubType as $subType => $val) {
$subTypeRelationshipTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, $val['parent'], FALSE, 'label', TRUE, $subType);
$allRelationshipType = array_merge($allRelationshipType, $subTypeRelationshipTypes);
}
$subTypes['Relationship'] = $allRelationshipType;
$cSubTypes = CRM_Core_Component::contactSubTypes();
$contactSubTypes = array();
foreach ($cSubTypes as $key => $value) {
$contactSubTypes[$key] = $key;
}
$subTypes['Contact'] = $contactSubTypes;
CRM_Core_BAO_CustomGroup::getExtendedObjectTypes($subTypes);
foreach ($customGroup as $key => $values) {
$subValue = CRM_Utils_Array::value('extends_entity_column_value', $customGroup[$key]);
$subName = CRM_Utils_Array::value('extends_entity_column_id', $customGroup[$key]);
$type = CRM_Utils_Array::value('extends', $customGroup[$key]);
if ($subValue) {
$subValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($subValue, 1, -1));
$colValue = NULL;
foreach ($subValue as $sub) {
if ($sub) {
if ($type == 'Participant') {
if ($subName == 1) {
$colValue = $colValue ? $colValue . ', ' . $subTypes['ParticipantRole'][$sub] : $subTypes['ParticipantRole'][$sub];
} elseif ($subName == 2) {
$colValue = $colValue ? $colValue . ', ' . $subTypes['ParticipantEventName'][$sub] : $subTypes['ParticipantEventName'][$sub];
} elseif ($subName == 3) {
$colValue = $colValue ? $colValue . ', ' . $subTypes['ParticipantEventType'][$sub] : $subTypes['ParticipantEventType'][$sub];
}
} elseif ($type == 'Relationship') {
$colValue = $colValue ? $colValue . ', ' . $subTypes[$type][$sub . '_a_b'] : $subTypes[$type][$sub . '_a_b'];
if (isset($subTypes[$type][$sub . '_b_a'])) {
$colValue = $colValue ? $colValue . ', ' . $subTypes[$type][$sub . '_b_a'] : $subTypes[$type][$sub . '_b_a'];
}
} else {
$colValue = $colValue ? $colValue . (isset($subTypes[$type][$sub]) ? ', ' . $subTypes[$type][$sub] : '') : (isset($subTypes[$type][$sub]) ? $subTypes[$type][$sub] : '');
}
}
}
$customGroup[$key]["extends_entity_column_value"] = $colValue;
} else {
if (is_array(CRM_Utils_Array::value($type, $subTypes))) {
$customGroup[$key]["extends_entity_column_value"] = ts("Any");
//.........这里部分代码省略.........
示例6: getAvailableFields
/**
* Get a list of fields which can be added to profiles.
*
* @param int $gid : UF group ID
* @param array $defaults : Form defaults
* @return array, multidimensional; e.g. $result['FieldGroup']['field_name']['label']
*/
public static function getAvailableFields($gid = NULL, $defaults = array())
{
$fields = array('Contact' => array(), 'Individual' => CRM_Contact_BAO_Contact::importableFields('Individual', FALSE, FALSE, TRUE, TRUE, TRUE), 'Household' => CRM_Contact_BAO_Contact::importableFields('Household', FALSE, FALSE, TRUE, TRUE, TRUE), 'Organization' => CRM_Contact_BAO_Contact::importableFields('Organization', FALSE, FALSE, TRUE, TRUE, TRUE));
// include hook injected fields
$fields['Contact'] = array_merge($fields['Contact'], CRM_Contact_BAO_Query_Hook::singleton()->getFields());
// add current employer for individuals
$fields['Individual']['current_employer'] = array('name' => 'organization_name', 'title' => ts('Current Employer'));
$addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options', TRUE, NULL, TRUE);
if (!$addressOptions['county']) {
unset($fields['Individual']['county'], $fields['Household']['county'], $fields['Organization']['county']);
}
// break out common contact fields array CRM-3037.
// from a UI perspective this makes very little sense
foreach ($fields['Individual'] as $key => $value) {
if (!empty($fields['Household'][$key]) && !empty($fields['Organization'][$key])) {
$fields['Contact'][$key] = $value;
unset($fields['Individual'][$key], $fields['Household'][$key], $fields['Organization'][$key]);
}
}
// Internal field not exposed to forms
unset($fields['Contact']['contact_type']);
unset($fields['Contact']['master_id']);
// convert phone extension in to psedo-field phone + phone extension
//unset extension
unset($fields['Contact']['phone_ext']);
//add psedo field
$fields['Contact']['phone_and_ext'] = array('name' => 'phone_and_ext', 'title' => ts('Phone and Extension'), 'hasLocationType' => 1);
// include Subtypes For Profile
$subTypes = CRM_Contact_BAO_ContactType::subTypeInfo();
foreach ($subTypes as $name => $val) {
//custom fields for sub type
$subTypeFields = CRM_Core_BAO_CustomField::getFieldsForImport($name, FALSE, FALSE, FALSE, TRUE, TRUE);
if (array_key_exists($val['parent'], $fields)) {
$fields[$name] = $fields[$val['parent']] + $subTypeFields;
} else {
$fields[$name] = $subTypeFields;
}
}
if (CRM_Core_Permission::access('CiviContribute')) {
$contribFields = CRM_Contribute_BAO_Contribution::getContributionFields(FALSE);
if (!empty($contribFields)) {
unset($contribFields['is_test']);
unset($contribFields['is_pay_later']);
unset($contribFields['contribution_id']);
$contribFields['contribution_note'] = array('name' => 'contribution_note', 'title' => ts('Contribution Note'));
$fields['Contribution'] = array_merge($contribFields, self::getContribBatchEntryFields());
}
}
if (CRM_Core_Permission::access('CiviEvent')) {
$participantFields = CRM_Event_BAO_Query::getParticipantFields();
if ($participantFields) {
// Remove fields not supported by profiles
CRM_Utils_Array::remove($participantFields, 'external_identifier', 'event_id', 'participant_contact_id', 'participant_role_id', 'participant_status_id', 'participant_is_test', 'participant_fee_level', 'participant_id', 'participant_is_pay_later', 'participant_campaign');
if (isset($participantFields['participant_campaign_id'])) {
$participantFields['participant_campaign_id']['title'] = ts('Campaign');
}
$fields['Participant'] = $participantFields;
}
}
if (CRM_Core_Permission::access('CiviMember')) {
$membershipFields = CRM_Member_BAO_Membership::getMembershipFields();
// Remove fields not supported by profiles
CRM_Utils_Array::remove($membershipFields, 'membership_id', 'membership_type_id', 'member_is_test', 'is_override', 'status_id', 'member_is_pay_later');
if ($gid && CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $gid, 'name') == 'membership_batch_entry') {
$fields['Membership'] = array_merge($membershipFields, self::getMemberBatchEntryFields());
} else {
$fields['Membership'] = $membershipFields;
}
}
if (CRM_Core_Permission::access('CiviCase')) {
$caseFields = CRM_Case_BAO_Query::getFields(TRUE);
$caseFields = array_merge($caseFields, CRM_Core_BAO_CustomField::getFieldsForImport('Case'));
if ($caseFields) {
// Remove fields not supported by profiles
CRM_Utils_Array::remove($caseFields, 'case_id', 'case_type', 'case_start_date', 'case_end_date', 'case_role', 'case_status', 'case_deleted');
}
$fields['Case'] = $caseFields;
}
$activityFields = CRM_Activity_BAO_Activity::getProfileFields();
if ($activityFields) {
// campaign related fields.
if (isset($activityFields['activity_campaign_id'])) {
$activityFields['activity_campaign_id']['title'] = ts('Campaign');
}
$fields['Activity'] = $activityFields;
}
$fields['Formatting']['format_free_html_' . rand(1000, 9999)] = array('name' => 'free_html', 'import' => FALSE, 'export' => FALSE, 'title' => 'Free HTML');
// Sort by title
foreach ($fields as &$values) {
$values = CRM_Utils_Array::crmArraySortByField($values, 'title');
}
//group selected and unwanted fields list
$ufFields = $gid ? CRM_Core_BAO_UFGroup::getFields($gid, FALSE, NULL, NULL, NULL, TRUE, NULL, TRUE) : array();
//.........这里部分代码省略.........
示例7: getValues
//.........这里部分代码省略.........
// CRM-8362: User and User Admin visibility groups should be included in display if user has
// VIEW permission on that group
$groupPerm = CRM_Contact_BAO_Group::checkPermission($g['group_id'], $g['title']);
if ($g['visibility'] != 'User and User Admin Only' || CRM_Utils_Array::key(CRM_Core_Permission::VIEW, $groupPerm)) {
$title[] = $g['title'];
if ($g['visibility'] == 'Public Pages') {
$ids[] = $g['group_id'];
}
}
}
$values[$index] = implode(', ', $title);
$params[$index] = implode(',', $ids);
} elseif ($name == 'tag') {
$entityTags = CRM_Core_BAO_EntityTag::getTag($cid);
$allTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
$title = array();
foreach ($entityTags as $tagId) {
$title[] = $allTags[$tagId];
}
$values[$index] = implode(', ', $title);
$params[$index] = implode(',', $entityTags);
} elseif ($name == 'activity_status_id') {
$activityStatus = CRM_Core_PseudoConstant::activityStatus();
$values[$index] = $activityStatus[$details->{$name}];
$params[$index] = $details->{$name};
} elseif ($name == 'activity_date_time') {
$values[$index] = CRM_Utils_Date::customFormat($details->{$name});
$params[$index] = $details->{$name};
} elseif ($name == 'contact_sub_type') {
$contactSubTypeNames = explode(CRM_Core_DAO::VALUE_SEPARATOR, $details->{$name});
if (!empty($contactSubTypeNames)) {
$contactSubTypeLabels = array();
// get all contact subtypes
$allContactSubTypes = CRM_Contact_BAO_ContactType::subTypeInfo();
// build contact subtype labels array
foreach ($contactSubTypeNames as $cstName) {
if ($cstName) {
$contactSubTypeLabels[] = $allContactSubTypes[$cstName]['label'];
}
}
$values[$index] = implode(',', $contactSubTypeLabels);
}
$params[$index] = $details->{$name};
} else {
if (substr($name, 0, 7) === 'do_not_' || substr($name, 0, 3) === 'is_') {
if ($details->{$name}) {
$values[$index] = '[ x ]';
}
} else {
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name)) {
$htmlType = $field['html_type'];
// field_type is only set when we are retrieving profile values
// when sending email, we call the same function to get custom field
// values etc, i.e. emulating a profile
$fieldType = CRM_Utils_Array::value('field_type', $field);
if ($htmlType == 'File') {
$entityId = $cid;
if (!$cid && $fieldType == 'Activity' && !empty($componentWhere[0][2])) {
$entityId = $componentWhere[0][2];
}
$fileURL = CRM_Core_BAO_CustomField::getFileURL($entityId, $cfID, NULL, $absolute, $additionalWhereClause);
$params[$index] = $values[$index] = $fileURL['file_url'];
} else {
$customVal = NULL;
if (isset($dao) && property_exists($dao, 'data_type') && ($dao->data_type == 'Int' || $dao->data_type == 'Boolean')) {
$customVal = (int) $details->{$name};
示例8: buildQuickForm
/**
* Function to actually build the form
*
* @return void
* @access public
*/
public function buildQuickForm()
{
if ($this->_action & CRM_Core_Action::DELETE) {
$this->addButtons(array(array('type' => 'next', 'name' => ts('Delete Profile Field'), 'spacing' => ' ', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
return;
}
if (isset($this->_id)) {
$params = array('id' => $this->_id);
CRM_Core_BAO_UFField::retrieve($params, $defaults);
// set it to null if so (avoids crappy E_NOTICE errors below
$defaults['location_type_id'] = CRM_Utils_Array::value('location_type_id', $defaults);
$specialFields = array('street_address', 'supplemental_address_1', 'supplemental_address_2', 'city', 'postal_code', 'postal_code_suffix', 'geo_code_1', 'geo_code_2', 'state_province', 'country', 'county', 'phone', 'email', 'im', 'address_name');
if (!$defaults['location_type_id'] && in_array($defaults['field_name'], $specialFields)) {
$defaults['location_type_id'] = 0;
}
$defaults['field_name'] = array($defaults['field_type'], $defaults['field_name'], $defaults['location_type_id'], CRM_Utils_Array::value('phone_type_id', $defaults));
$this->_gid = $defaults['uf_group_id'];
} else {
$defaults['is_active'] = 1;
}
if ($this->_action & CRM_Core_Action::ADD) {
$fieldValues = array('uf_group_id' => $this->_gid);
$defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_UFField', $fieldValues);
}
// lets trim all the whitespace
$this->applyFilter('__ALL__', 'trim');
//hidden field to catch the group id in profile
$this->add('hidden', 'group_id', $this->_gid);
//hidden field to catch the field id in profile
$this->add('hidden', 'field_id', $this->_id);
$fields = array();
$fields['Individual'] =& CRM_Contact_BAO_Contact::importableFields('Individual', false, false, true);
$fields['Household'] =& CRM_Contact_BAO_Contact::importableFields('Household', false, false, true);
$fields['Organization'] =& CRM_Contact_BAO_Contact::importableFields('Organization', false, false, true);
// add current employer for individuals
$fields['Individual']['current_employer'] = array('name' => 'organization_name', 'title' => ts('Current Employer'));
// unset unwanted fields
$unsetFieldArray = array('note', 'email_greeting_custom', 'postal_greeting_custom', 'addressee_custom', 'id');
foreach ($unsetFieldArray as $value) {
unset($fields['Individual'][$value]);
unset($fields['Household'][$value]);
unset($fields['Organization'][$value]);
}
require_once 'CRM/Core/BAO/Preferences.php';
$addressOptions = CRM_Core_BAO_Preferences::valueOptions('address_options', true, null, true);
if (!$addressOptions['county']) {
unset($fields['Individual']['county']);
unset($fields['Household']['county']);
unset($fields['Organization']['county']);
}
//build the common contact fields array CRM-3037.
foreach ($fields['Individual'] as $key => $value) {
if (CRM_Utils_Array::value($key, $fields['Household']) && CRM_Utils_Array::value($key, $fields['Organization'])) {
$fields['Contact'][$key] = $value;
//as we move common fields to contacts. There fore these fields
//are unset from resoective array's.
unset($fields['Individual'][$key]);
unset($fields['Household'][$key]);
unset($fields['Organization'][$key]);
}
}
// add current employer for individuals
$fields['Contact']['id'] = array('name' => 'id', 'title' => ts('Internal Contact ID'));
unset($fields['Contact']['contact_type']);
// since we need a hierarchical list to display contact types & subtypes,
// this is what we going to display in first selector
$contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(false, false);
unset($contactTypes['']);
// include Subtypes For Profile
$subTypes = CRM_Contact_BAO_ContactType::subTypeInfo();
foreach ($subTypes as $name => $val) {
//custom fields for sub type
$subTypeFields = CRM_Core_BAO_CustomField::getFieldsForImport($name);
if (array_key_exists($val['parent'], $fields)) {
$fields[$name] = $fields[$val['parent']] + $subTypeFields;
} else {
$fields[$name] = $subTypeFields;
}
}
unset($subTypes);
if (CRM_Core_Permission::access('Quest')) {
require_once 'CRM/Quest/BAO/Student.php';
$fields['Student'] =& CRM_Quest_BAO_Student::exportableFields();
}
if (CRM_Core_Permission::access('CiviContribute')) {
$contribFields =& CRM_Contribute_BAO_Contribution::getContributionFields();
if (!empty($contribFields)) {
unset($contribFields['is_test']);
unset($contribFields['is_pay_later']);
unset($contribFields['contribution_id']);
$fields['Contribution'] =& $contribFields;
}
}
if (CRM_Core_Permission::access('CiviEvent')) {
//.........这里部分代码省略.........
示例9: buildQuickForm
/**
* Build the form object.
*
*
* @return void
*/
public function buildQuickForm()
{
$this->applyFilter('__ALL__', 'trim');
$attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_CustomGroup');
//title
$this->add('text', 'title', ts('Set Name'), $attributes['title'], TRUE);
//Fix for code alignment, CRM-3058
$contactTypes = array('Contact', 'Individual', 'Household', 'Organization');
$this->assign('contactTypes', json_encode($contactTypes));
$sel1 = array("" => ts("- select -")) + CRM_Core_SelectValues::customGroupExtends();
$sel2 = array();
$activityType = CRM_Core_PseudoConstant::activityType(FALSE, TRUE, FALSE, 'label', TRUE);
$eventType = CRM_Core_OptionGroup::values('event_type');
$grantType = CRM_Core_OptionGroup::values('grant_type');
$campaignTypes = CRM_Campaign_PseudoConstant::campaignType();
$membershipType = CRM_Member_BAO_MembershipType::getMembershipTypes(FALSE);
$participantRole = CRM_Core_OptionGroup::values('participant_role');
$relTypeInd = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, 'Individual');
$relTypeOrg = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, 'Organization');
$relTypeHou = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, 'Household');
ksort($sel1);
asort($activityType);
asort($eventType);
asort($grantType);
asort($membershipType);
asort($participantRole);
$allRelationshipType = array();
$allRelationshipType = array_merge($relTypeInd, $relTypeOrg);
$allRelationshipType = array_merge($allRelationshipType, $relTypeHou);
//adding subtype specific relationships CRM-5256
$subTypes = CRM_Contact_BAO_ContactType::subTypeInfo();
foreach ($subTypes as $subType => $val) {
$subTypeRelationshipTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, $val['parent'], FALSE, 'label', TRUE, $subType);
$allRelationshipType = array_merge($allRelationshipType, $subTypeRelationshipTypes);
}
$sel2['Event'] = $eventType;
$sel2['Grant'] = $grantType;
$sel2['Activity'] = $activityType;
$sel2['Campaign'] = $campaignTypes;
$sel2['Membership'] = $membershipType;
$sel2['ParticipantRole'] = $participantRole;
$sel2['ParticipantEventName'] = CRM_Event_PseudoConstant::event(NULL, FALSE, "( is_template IS NULL OR is_template != 1 )");
$sel2['ParticipantEventType'] = $eventType;
$sel2['Contribution'] = CRM_Contribute_PseudoConstant::financialType();
$sel2['Relationship'] = $allRelationshipType;
$sel2['Individual'] = CRM_Contact_BAO_ContactType::subTypePairs('Individual', FALSE, NULL);
$sel2['Household'] = CRM_Contact_BAO_ContactType::subTypePairs('Household', FALSE, NULL);
$sel2['Organization'] = CRM_Contact_BAO_ContactType::subTypePairs('Organization', FALSE, NULL);
CRM_Core_BAO_CustomGroup::getExtendedObjectTypes($sel2);
foreach ($sel2 as $main => $sub) {
if (!empty($sel2[$main])) {
if ($main == 'Relationship') {
$relName = self::getFormattedList($sel2[$main]);
$sel2[$main] = array('' => ts("- Any -")) + $relName;
} else {
$sel2[$main] = array('' => ts("- Any -")) + $sel2[$main];
}
}
}
$cSubTypes = CRM_Core_Component::contactSubTypes();
if (!empty($cSubTypes)) {
$contactSubTypes = array();
foreach ($cSubTypes as $key => $value) {
$contactSubTypes[$key] = $key;
}
$sel2['Contact'] = array("" => "- Any -") + $contactSubTypes;
} else {
if (!isset($this->_id)) {
$formName = 'document.forms.' . $this->_name;
$js = "<script type='text/javascript'>\n";
$js .= "{$formName}['extends_1'].style.display = 'none';\n";
$js .= "</script>";
$this->assign('initHideBlocks', $js);
}
}
$sel =& $this->add('hierselect', 'extends', ts('Used For'), array('name' => 'extends[0]', 'style' => 'vertical-align: top;'), TRUE);
$sel->setOptions(array($sel1, $sel2));
if (is_a($sel->_elements[1], 'HTML_QuickForm_select')) {
// make second selector a multi-select -
$sel->_elements[1]->setMultiple(TRUE);
$sel->_elements[1]->setSize(5);
}
if ($this->_action == CRM_Core_Action::UPDATE) {
$subName = CRM_Utils_Array::value('extends_entity_column_id', $this->_defaults);
if ($this->_defaults['extends'] == 'Participant') {
if ($subName == 1) {
$this->_defaults['extends'] = 'ParticipantRole';
} elseif ($subName == 2) {
$this->_defaults['extends'] = 'ParticipantEventName';
} elseif ($subName == 3) {
$this->_defaults['extends'] = 'ParticipantEventType';
}
}
//allow to edit settings if custom set is empty CRM-5258
//.........这里部分代码省略.........
示例10: buildMappingForm
//.........这里部分代码省略.........
}
if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::PLEDGE_EXPORT) {
if (CRM_Core_Permission::access('CiviPledge')) {
$fields['Pledge'] = CRM_Pledge_BAO_Pledge::exportableFields();
unset($fields['Pledge']['pledge_contact_id']);
$compArray['Pledge'] = ts('Pledge');
}
}
if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::CASE_EXPORT) {
if (CRM_Core_Permission::access('CiviCase')) {
$fields['Case'] = CRM_Case_BAO_Case::exportableFields();
$compArray['Case'] = ts('Case');
$fields['Activity'] = CRM_Activity_BAO_Activity::exportableFields('Case');
$compArray['Activity'] = ts('Case Activity');
unset($fields['Case']['case_contact_id']);
}
}
if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::GRANT_EXPORT) {
if (CRM_Core_Permission::access('CiviGrant')) {
$fields['Grant'] = CRM_Grant_BAO_Grant::exportableFields();
unset($fields['Grant']['grant_contact_id']);
if ($mappingType == 'Search Builder') {
unset($fields['Grant']['grant_type_id']);
}
$compArray['Grant'] = ts('Grant');
}
}
if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::ACTIVITY_EXPORT) {
$fields['Activity'] = CRM_Activity_BAO_Activity::exportableFields('Activity');
$compArray['Activity'] = ts('Activity');
}
//Contact Sub Type For export
$contactSubTypes = array();
$subTypes = CRM_Contact_BAO_ContactType::subTypeInfo();
foreach ($subTypes as $subType => $val) {
//adding subtype specific relationships CRM-5256
$csRelationships = array();
if ($mappingType == 'Export') {
$subTypeRelationshipTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, $val['parent'], FALSE, 'label', TRUE, $subType);
foreach ($subTypeRelationshipTypes as $key => $var) {
if (!array_key_exists($key, $fields[$val['parent']])) {
list($type) = explode('_', $key);
$csRelationships[$key]['title'] = $var;
$csRelationships[$key]['headerPattern'] = '/' . preg_quote($var, '/') . '/';
$csRelationships[$key]['export'] = TRUE;
$csRelationships[$key]['relationship_type_id'] = $type;
$csRelationships[$key]['related'] = TRUE;
$csRelationships[$key]['hasRelationType'] = 1;
}
}
}
$fields[$subType] = $fields[$val['parent']] + $csRelationships;
//custom fields for sub type
$subTypeFields = CRM_Core_BAO_CustomField::getFieldsForImport($subType);
$fields[$subType] += $subTypeFields;
if (!empty($subTypeFields) || !empty($csRelationships)) {
$contactSubTypes[$subType] = $val['label'];
}
}
unset($subTypes);
foreach ($fields as $key => $value) {
foreach ($value as $key1 => $value1) {
//CRM-2676, replacing the conflict for same custom field name from different custom group.
$customGroupName = self::getCustomGroupName($key1);
if ($customGroupName) {
$relatedMapperFields[$key][$key1] = $mapperFields[$key][$key1] = $customGroupName . ': ' . $value1['title'];
示例11: hrjob_civicrm_uninstall
/**
* Implementation of hook_civicrm_uninstall
*/
function hrjob_civicrm_uninstall()
{
$subTypeInfo = CRM_Contact_BAO_ContactType::subTypeInfo('Organization');
$sub_type_name = array('Health Insurance Provider', 'Life Insurance Provider');
foreach ($sub_type_name as $sub_type_name) {
$subTypeName = ucfirst(CRM_Utils_String::munge($sub_type_name));
$orid = array_key_exists($subTypeName, $subTypeInfo);
if ($orid) {
$id = $subTypeInfo[$subTypeName]['id'];
CRM_Contact_BAO_ContactType::del($id);
}
}
//delete job import navigation menu
CRM_Core_DAO::executeQuery("DELETE FROM civicrm_navigation WHERE name IN ('jobImport','hoursType')");
CRM_Core_BAO_Navigation::resetNavigation();
//delete custom groups and field
$customGroup = civicrm_api3('CustomGroup', 'getsingle', array('return' => "id", 'name' => "HRJob_Summary"));
civicrm_api3('CustomGroup', 'delete', array('id' => $customGroup['id']));
//delete all option group and values
CRM_Core_DAO::executeQuery("DELETE FROM civicrm_option_group WHERE name IN ('hrjob_contract_type', 'hrjob_level_type', 'hrjob_department', 'hrjob_hours_type', 'hrjob_pay_grade', 'hrjob_health_provider', 'hrjob_life_provider', 'hrjob_location', 'hrjob_pension_type', 'hrjob_region', 'hrjob_pay_scale')");
return _hrjob_civix_civicrm_uninstall();
}
示例12: getSubtypes
/**
* get subtypes given the contact type
*
* @param string $contactType
* @return array $subTypes
*/
public static function getSubtypes($contactType)
{
$subTypes = array();
$types = CRM_Contact_BAO_ContactType::subTypeInfo($contactType);
if (count($types) > 0) {
foreach ($types as $type) {
$subTypes[] = $type['name'];
}
}
return $subTypes;
}
示例13: buildQuickForm
/**
* Function to actually build the form
*
* @param null
*
* @return void
* @access public
*/
public function buildQuickForm()
{
$this->applyFilter('__ALL__', 'trim');
$attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_CustomGroup');
//title
$this->add('text', 'title', ts('Group Name'), $attributes['title'], true);
$this->addRule('title', ts('Name already exists in Database.'), 'objectExists', array('CRM_Core_DAO_CustomGroup', $this->_id, 'title'));
//Fix for code alignment, CRM-3058
require_once "CRM/Contribute/PseudoConstant.php";
require_once "CRM/Member/BAO/MembershipType.php";
require_once 'CRM/Event/PseudoConstant.php';
require_once "CRM/Contact/BAO/Relationship.php";
require_once 'CRM/Core/OptionGroup.php';
require_once 'CRM/Contact/BAO/ContactType.php';
$contactTypes = array('Contact', 'Individual', 'Household', 'Organization');
$this->assign('contactTypes', json_encode($contactTypes));
$sel1 = array("" => "- select -") + CRM_Core_SelectValues::customGroupExtends();
$sel2 = array();
$activityType = CRM_Core_PseudoConstant::activityType(false, true);
$eventType = CRM_Core_OptionGroup::values('event_type');
$membershipType = CRM_Member_BAO_MembershipType::getMembershipTypes(false);
$participantRole = CRM_Core_OptionGroup::values('participant_role');
$relTypeInd = CRM_Contact_BAO_Relationship::getContactRelationshipType(null, 'null', null, 'Individual');
$relTypeOrg = CRM_Contact_BAO_Relationship::getContactRelationshipType(null, 'null', null, 'Organization');
$relTypeHou = CRM_Contact_BAO_Relationship::getContactRelationshipType(null, 'null', null, 'Household');
ksort($sel1);
asort($activityType);
asort($eventType);
asort($membershipType);
asort($participantRole);
$allRelationshipType = array();
$allRelationshipType = array_merge($relTypeInd, $relTypeOrg);
$allRelationshipType = array_merge($allRelationshipType, $relTypeHou);
//adding subtype specific relationships CRM-5256
$subTypes = CRM_Contact_BAO_ContactType::subTypeInfo();
foreach ($subTypes as $subType => $val) {
$subTypeRelationshipTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(null, null, null, $val['parent'], false, 'label', true, $subType);
$allRelationshipType = array_merge($allRelationshipType, $subTypeRelationshipTypes);
}
$sel2['Event'] = $eventType;
$sel2['Activity'] = $activityType;
$sel2['Membership'] = $membershipType;
$sel2['ParticipantRole'] = $participantRole;
$sel2['ParticipantEventName'] = CRM_Event_PseudoConstant::event(null, false, "( is_template IS NULL OR is_template != 1 )");
$sel2['ParticipantEventType'] = $eventType;
$sel2['Contribution'] = CRM_Contribute_PseudoConstant::contributionType();
$sel2['Relationship'] = $allRelationshipType;
$sel2['Individual'] = CRM_Contact_BAO_ContactType::subTypePairs('Individual', false, null);
$sel2['Household'] = CRM_Contact_BAO_ContactType::subTypePairs('Household', false, null);
$sel2['Organization'] = CRM_Contact_BAO_ContactType::subTypePairs('Organization', false, null);
foreach ($sel2 as $main => $sub) {
if (!empty($sel2[$main])) {
$sel2[$main] = array('' => ts("- Any -")) + $sel2[$main];
}
}
require_once "CRM/Core/Component.php";
$cSubTypes = CRM_Core_Component::contactSubTypes();
if (!empty($cSubTypes)) {
$contactSubTypes = array();
foreach ($cSubTypes as $key => $value) {
$contactSubTypes[$key] = $key;
}
$sel2['Contact'] = array("" => "-- Any --") + $contactSubTypes;
} else {
if (!isset($this->_id)) {
$formName = 'document.forms.' . $this->_name;
$js = "<script type='text/javascript'>\n";
$js .= "{$formName}['extends[1]'].style.display = 'none';\n";
$js .= "</script>";
$this->assign('initHideBlocks', $js);
}
}
$sel =& $this->add('hierselect', 'extends', ts('Used For'), array('onClick' => 'showHideStyle();', 'name' => 'extends[0]', 'style' => 'vertical-align: top;'), true);
$sel->setOptions(array($sel1, $sel2));
if (is_a($sel->_elements[1], 'HTML_QuickForm_select')) {
// make second selector a multi-select -
$sel->_elements[1]->setMultiple(true);
$sel->_elements[1]->setSize(5);
}
if ($this->_action == CRM_Core_Action::UPDATE) {
//allow to edit settings if custom group is empty CRM-5258
$this->_isGroupEmpty = CRM_Core_BAO_CustomGroup::isGroupEmpty($this->_id);
if (!$this->_isGroupEmpty) {
if (!empty($this->_subtypes) && count(array_intersect($this->_subtypes, $sel2[$this->_defaults['extends']])) < count($sel2[$this->_defaults['extends']])) {
// we want to allow adding subtypes for this case,
// and therefore freeze the first selector only.
$sel->_elements[0]->freeze();
} else {
// freeze both the selectors
$sel->freeze();
}
}
//.........这里部分代码省略.........
示例14: upgrade_1108
public function upgrade_1108()
{
$this->ctx->log->info('Applying update 1108');
if (CRM_Core_DAO::checkFieldExists('civicrm_hrjob_health', 'provider') && CRM_Core_DAO::checkFieldExists('civicrm_hrjob_health', 'provider_life_insurance')) {
$opt_grp_name = array('hrjob_health_provider' => array('name' => 'Health_Insurance_Provider', 'label' => ts('Health Insurance Provider'), 'column' => 'provider'), 'hrjob_life_provider' => array('name' => 'Life_Insurance_Provider', 'label' => ts('Life Insurance Provider'), 'column' => 'provider_life_insurance'));
$org_id = array_search('Organization', CRM_Contact_BAO_ContactType::basicTypePairs(FALSE, 'id'));
$orgSubType = CRM_Contact_BAO_ContactType::subTypeInfo('Organization');
foreach ($opt_grp_name as $oKey => $oValue) {
$subID = array_key_exists($oValue['name'], $orgSubType);
if (!$subID) {
CRM_Contact_BAO_ContactType::add(array('parent_id' => $org_id, 'is_active' => 1, 'name' => $oValue['name'], 'label' => $oValue['label']));
}
$options = CRM_Core_OptionGroup::values($oKey, TRUE, FALSE);
foreach ($options as $orgKey => $orgValue) {
$params = array('organization_name' => $orgValue, 'sort_name' => $orgValue, 'display_name' => $orgValue, 'legal_name' => $orgValue, 'contact_type' => 'Organization', 'contact_sub_type' => $oValue['name']);
$result = civicrm_api3('contact', 'create', $params);
if ($result['id']) {
CRM_Core_DAO::executeQuery("UPDATE civicrm_hrjob_health SET {$oValue['column']} = {$result['id']} WHERE {$oValue['column']} LIKE '{$orgValue}'");
CRM_Core_DAO::executeQuery("UPDATE civicrm_hrjob_health SET {$oValue['column']} = NULL WHERE {$oValue['column']} = ''");
}
}
CRM_Core_OptionGroup::deleteAssoc($oKey);
}
CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_hrjob_health`\n MODIFY COLUMN `provider` int(10) unsigned DEFAULT NULL,\n MODIFY COLUMN `provider_life_insurance` int(10) unsigned DEFAULT NULL,\n ADD CONSTRAINT `FK_civicrm_hrjob_health_provider` FOREIGN KEY (`provider`) REFERENCES `civicrm_contact`(`id`) ON DELETE SET NULL,\n ADD CONSTRAINT `FK_civicrm_hrjob_health_provider_life_insurance` FOREIGN KEY (`provider_life_insurance`) REFERENCES `civicrm_contact`(`id`) ON DELETE SET NULL");
}
return TRUE;
}
示例15: validateSubTypeByEntity
/**
* Clean and validate the filter before it is used in a db query.
*
* @param string $entityType
* @param string $subType
*
* @return string
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
protected static function validateSubTypeByEntity($entityType, $subType)
{
$subType = trim($subType, CRM_Core_DAO::VALUE_SEPARATOR);
if (is_numeric($subType)) {
return $subType;
}
$contactTypes = CRM_Contact_BAO_ContactType::basicTypeInfo(TRUE);
if ($entityType != 'Contact' && !array_key_exists($entityType, $contactTypes)) {
throw new CRM_Core_Exception('Invalid Entity Filter');
}
$subTypes = CRM_Contact_BAO_ContactType::subTypeInfo($entityType, TRUE);
if (!array_key_exists($subType, $subTypes)) {
throw new CRM_Core_Exception('Invalid Filter');
}
return $subType;
}