diff --git a/CRM/Case/BAO/Query.php b/CRM/Case/BAO/Query.php index a2a37907e5c30fbb499461694b32ea01f34c5221..3b83d8b98e329d413bb95ba63e69b7cc2babbb93 100644 --- a/CRM/Case/BAO/Query.php +++ b/CRM/Case/BAO/Query.php @@ -34,12 +34,14 @@ */ class CRM_Case_BAO_Query { - static function &getFields() { + static function &getFields($excludeActivityFields = FALSE) { $fields = array(); $fields = CRM_Case_BAO_Case::exportableFields(); // add activity related fields - $fields = array_merge($fields, CRM_Activity_BAO_Activity::exportableFields('Case')); + if (!$excludeActivityFields) { + $fields = array_merge($fields, CRM_Activity_BAO_Activity::exportableFields('Case')); + } return $fields; } diff --git a/CRM/Core/BAO/UFField.php b/CRM/Core/BAO/UFField.php index b03ea879181e9f39a9175c428baf65127df03161..7ee7a0d10b7c0a7323d8e0b52dfcb97b3f7aad30 100644 --- a/CRM/Core/BAO/UFField.php +++ b/CRM/Core/BAO/UFField.php @@ -968,6 +968,24 @@ SELECT id } } + 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. diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index cf9b8980bf0235e3018c55150e43060612dd332d..4fe8a6b8ed16532c29b7ae00f5876500d2459403 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -646,7 +646,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { $customFields = CRM_Core_BAO_CustomField::getFieldsForImport($ctype, FALSE, FALSE, FALSE, TRUE, TRUE); // hack to add custom data for components - $components = array('Contribution', 'Participant', 'Membership', 'Activity'); + $components = array('Contribution', 'Participant', 'Membership', 'Activity', 'Case'); foreach ($components as $value) { $customFields = array_merge($customFields, CRM_Core_BAO_CustomField::getFieldsForImport($value)); } @@ -3003,7 +3003,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_UFGroup', $gId, 'group_type', 'null'); } - $componentGroupTypes = array('Contribution', 'Participant', 'Membership', 'Activity'); + $componentGroupTypes = array('Contribution', 'Participant', 'Membership', 'Activity', 'Case'); $validGroupTypes = array_merge(array('Contact', 'Individual', 'Organization', 'Household'), $componentGroupTypes, CRM_Contact_BAO_ContactType::subTypes()); $gTypes = $gTypeValues = array(); diff --git a/CRM/UF/Form/Field.php b/CRM/UF/Form/Field.php index e8e15465e08b8581d71e7e6486631eb02f84a520..5664d5df30518b47ea3cab648b6ea44b1bd5d6a9 100644 --- a/CRM/UF/Form/Field.php +++ b/CRM/UF/Form/Field.php @@ -149,6 +149,10 @@ class CRM_UF_Form_Field extends CRM_Core_Form { $this->_fields = array_merge(CRM_Event_BAO_Query::getParticipantFields(), $this->_fields); } + if (CRM_Core_Permission::access('CiviCase')) { + $this->_fields = array_merge(CRM_Case_BAO_Query::getFields(), $this->_fields); + } + $this->_fields = array_merge($this->_fields, CRM_Contact_BAO_Query_Hook::singleton()->getFields()); $this->_selectFields = array(); @@ -323,6 +327,10 @@ class CRM_UF_Form_Field extends CRM_Core_Form { $sel1['Membership'] = 'Membership'; } + if (!empty($fields['Case'])) { + $sel1['Case'] = 'Case'; + } + if (!empty($fields['Formatting'])) { $sel1['Formatting'] = 'Formatting'; } @@ -559,7 +567,7 @@ class CRM_UF_Form_Field extends CRM_Core_Form { //reset other field is searchable and in selector settings, CRM-4363 if ($this->_hasSearchableORInSelector && - in_array($ufField->field_type, array('Participant', 'Contribution', 'Membership', 'Activity')) + in_array($ufField->field_type, array('Participant', 'Contribution', 'Membership', 'Activity', 'Case')) ) { CRM_Core_BAO_UFField::resetInSelectorANDSearchable($this->_gid); } @@ -674,7 +682,7 @@ class CRM_UF_Form_Field extends CRM_Core_Form { static function formRuleCustomDataExtentColumnValue($customField, $gid, $fieldType, &$errors) { // fix me : check object $customField if (in_array($fieldType, array( - 'Participant', 'Contribution', 'Membership', 'Activity'))) { + 'Participant', 'Contribution', 'Membership', 'Activity', 'Case'))) { $params = array('id' => $customField->custom_group_id); $customGroup = array(); CRM_Core_BAO_CustomGroup::retrieve($params, $customGroup); diff --git a/CRM/UF/Page/Group.php b/CRM/UF/Page/Group.php index 06a9b3296edadaa3d191c226356ac41f7dca2bc8..f648b6ee9399ad563ae30241e0105da6c6838671 100644 --- a/CRM/UF/Page/Group.php +++ b/CRM/UF/Page/Group.php @@ -330,7 +330,7 @@ class CRM_UF_Page_Group extends CRM_Core_Page { } $groupTypes = self::extractGroupTypes($value['group_type']); - $groupComponents = array('Contribution', 'Membership', 'Activity', 'Participant'); + $groupComponents = array('Contribution', 'Membership', 'Activity', 'Participant', 'Case'); // drop Create, Edit and View mode links if profile group_type is Contribution, Membership, Activities or Participant $componentFound = array_intersect($groupComponents, array_keys($groupTypes)); @@ -456,6 +456,10 @@ class CRM_UF_Page_Group extends CRM_Core_Page { $typeName = 'Activity'; $valueLabels = CRM_Core_PseudoConstant::ActivityType(TRUE, TRUE, FALSE, 'label', TRUE); break; + case 'CaseType': + $typeName = 'Case'; + $valueLabels = CRM_Case_PseudoConstant::caseType(); + break; } foreach ($valueParts as $val) {