本文整理汇总了PHP中CRM_Core_BAO_CustomValueTable::getEntityValues方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_CustomValueTable::getEntityValues方法的具体用法?PHP CRM_Core_BAO_CustomValueTable::getEntityValues怎么用?PHP CRM_Core_BAO_CustomValueTable::getEntityValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_CustomValueTable
的用法示例。
在下文中一共展示了CRM_Core_BAO_CustomValueTable::getEntityValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: retreiveContactFieldValue
/**
*Retrieve Name, Type and Id of record contain government value from customvalue table
*/
static function retreiveContactFieldValue($contactID)
{
$govInfo = array();
$govFieldId = self::retreiveContactFieldId('Identify');
if (!empty($govFieldId) && $contactID) {
$govValues = CRM_Core_BAO_CustomValueTable::getEntityValues($contactID, NULL, $govFieldId, TRUE);
foreach ($govValues as $key => $val) {
if ($val[$govFieldId['is_government']] == 1) {
$govInfo['type'] = $val[$govFieldId['Type']];
$govInfo['typeNumber'] = $val[$govFieldId['Number']];
$govInfo['key'] = $val[$govFieldId['is_government']];
$govInfo['id'] = ":{$key}";
break;
}
}
}
return $govInfo;
}
示例2: testGetEntityValues
/**
* Test getEntityValues function for stored value.
*/
public function testGetEntityValues()
{
$params = array();
$contactID = $this->individualCreate();
$customGroup = $this->customGroupCreate(array('extends' => 'Individual'));
$fields = array('custom_group_id' => $customGroup['id'], 'html_type' => 'RichTextEditor', 'data_type' => 'Memo');
$customField = $this->customFieldCreate($fields);
$params[] = array($customField['id'] => array('value' => '<p><strong>This is a <u>test</u></p>', 'type' => 'Memo', 'custom_field_id' => $customField['id'], 'custom_group_id' => $customGroup['id'], 'table_name' => $customGroup['values'][$customGroup['id']]['table_name'], 'column_name' => $customField['values'][$customField['id']]['column_name'], 'file_id' => ''));
CRM_Core_BAO_CustomValueTable::store($params, 'civicrm_contact', $contactID);
$entityValues = CRM_Core_BAO_CustomValueTable::getEntityValues($contactID, 'Individual');
$this->assertEquals($entityValues[$customField['id']], '<p><strong>This is a <u>test</u></p>', 'Checking same for returned value.');
$this->customFieldDelete($customField['id']);
$this->customGroupDelete($customGroup['id']);
$this->contactDelete($contactID);
}
示例3: copyExtendedActivityData
/**
* Copy custom fields and attachments from an existing activity to another.
*
* @see CRM_Case_Page_AJAX::_convertToCaseActivity()
*
* @param array $params
*/
public static function copyExtendedActivityData($params)
{
// attach custom data to the new activity
$customParams = $htmlType = array();
$customValues = CRM_Core_BAO_CustomValueTable::getEntityValues($params['activityID'], 'Activity');
if (!empty($customValues)) {
$fieldIds = implode(', ', array_keys($customValues));
$sql = "SELECT id FROM civicrm_custom_field WHERE html_type = 'File' AND id IN ( {$fieldIds} )";
$result = CRM_Core_DAO::executeQuery($sql);
while ($result->fetch()) {
$htmlType[] = $result->id;
}
foreach ($customValues as $key => $value) {
if ($value !== NULL) {
// CRM-10542
if (in_array($key, $htmlType)) {
$fileValues = CRM_Core_BAO_File::path($value, $params['activityID']);
$customParams["custom_{$key}_-1"] = array('name' => $fileValues[0], 'path' => $fileValues[1]);
} else {
$customParams["custom_{$key}_-1"] = $value;
}
}
}
CRM_Core_BAO_CustomValueTable::postProcess($customParams, 'civicrm_activity', $params['mainActivityId'], 'Activity');
}
// copy activity attachments ( if any )
CRM_Core_BAO_File::copyEntityFile('civicrm_activity', $params['activityID'], 'civicrm_activity', $params['mainActivityId']);
}
示例4: checkDuplicateCustomFields
/**
* this function checks whether the values of the custom fields in $params are
* the same as the values of the custom fields of the relation with given
* $relationshipId.
*
* @param array $params (reference) an assoc array of name/value pairs
* @param int $relationshipId ID of an existing duplicate relation
*
* @return boolean true if custom field values are identical
* @access private
* @static
*/
private static function checkDuplicateCustomFields(&$params, $relationshipId)
{
// Get the custom values of the existing relationship.
$existingValues = CRM_Core_BAO_CustomValueTable::getEntityValues($relationshipId, 'Relationship');
// Create a similar array for the new relationship.
$newValues = array();
if (array_key_exists('custom', $params)) {
// $params['custom'] seems to be an array. Each value is again an array.
// This array contains one value (key -1), and this value seems to be
// an array with the information about the custom value.
foreach ($params['custom'] as $value) {
foreach ($value as $customValue) {
$newValues[$customValue['custom_field_id']] = $customValue['value'];
}
}
}
// Calculate difference between arrays. If the only key-value pairs
// that are in one array but not in the other are empty, the
// custom fields are considered to be equal.
// See https://github.com/civicrm/civicrm-core/pull/6515#issuecomment-137985667
$diff1 = array_diff_assoc($existingValues, $newValues);
$diff2 = array_diff_assoc($newValues, $existingValues);
return !array_filter($diff1) && !array_filter($diff2);
}
示例5: findDifferences
/**
* Find differences between contacts.
*/
function findDifferences($mainId, $otherId)
{
require_once 'api/v2/Contact.php';
$mainParams = array('contact_id' => (int) $mainId);
$otherParams = array('contact_id' => (int) $otherId);
// API 2 has to have the requested fields spelt-out for it
foreach (self::$validFields as $field) {
$mainParams["return.{$field}"] = $otherParams["return.{$field}"] = 1;
}
$main =& civicrm_contact_get($mainParams);
$other =& civicrm_contact_get($otherParams);
//CRM-4524
$main = reset($main);
$other = reset($other);
if ($main['contact_type'] != $other['contact_type']) {
return false;
}
$diffs = array();
foreach (self::$validFields as $validField) {
if (CRM_Utils_Array::value($validField, $main) != CRM_Utils_Array::value($validField, $other)) {
$diffs['contact'][] = $validField;
}
}
require_once 'CRM/Core/BAO/CustomValueTable.php';
$mainEvs =& CRM_Core_BAO_CustomValueTable::getEntityValues($mainId);
$otherEvs =& CRM_Core_BAO_CustomValueTable::getEntityValues($otherId);
$keys = array_keys($mainEvs) + array_keys($otherEvs);
foreach ($keys as $key) {
if ($mainEvs[$key] != $otherEvs[$key]) {
$diffs['custom'][] = $key;
}
}
return $diffs;
}
示例6: setDefaultsValues
/**
* Set default values for the form. Note that in edit/view mode
* the default values are retrieved from the database
*
*
* @return void
*/
public function setDefaultsValues()
{
$this->_defaults = array();
if ($this->_multiRecordProfile && $this->_multiRecord == CRM_Core_Action::DELETE) {
return;
}
if ($this->_mode != self::MODE_SEARCH) {
// set default values for country / state to start with
CRM_Core_BAO_UFGroup::setRegisterDefaults($this->_fields, $this->_defaults);
}
if ($this->_id && !$this->_multiRecordProfile) {
if ($this->_isContactActivityProfile) {
$contactFields = $activityFields = array();
foreach ($this->_fields as $fieldName => $field) {
if (CRM_Utils_Array::value('field_type', $field) == 'Activity') {
$activityFields[$fieldName] = $field;
} else {
$contactFields[$fieldName] = $field;
}
}
CRM_Core_BAO_UFGroup::setProfileDefaults($this->_id, $contactFields, $this->_defaults, TRUE);
if ($this->_activityId) {
CRM_Core_BAO_UFGroup::setComponentDefaults($activityFields, $this->_activityId, 'Activity', $this->_defaults, TRUE);
}
} else {
CRM_Core_BAO_UFGroup::setProfileDefaults($this->_id, $this->_fields, $this->_defaults, TRUE);
}
}
//set custom field defaults
if ($this->_multiRecordProfile) {
foreach ($this->_multiRecordFields as $key => $field) {
$fieldIds[] = CRM_Core_BAO_CustomField::getKeyID($key);
}
$defaultValues = array();
if ($this->_multiRecord && $this->_multiRecord == CRM_Core_Action::UPDATE) {
$defaultValues = CRM_Core_BAO_CustomValueTable::getEntityValues($this->_id, NULL, $fieldIds, TRUE);
if ($this->_recordExists == TRUE) {
$defaultValues = $defaultValues[$this->_recordId];
} else {
$defaultValues = NULL;
}
}
if (!empty($defaultValues)) {
foreach ($defaultValues as $key => $value) {
$name = "custom_{$key}";
$htmlType = $this->_multiRecordFields[$name]['html_type'];
if ($htmlType != 'File') {
if (isset($value)) {
CRM_Core_BAO_CustomField::setProfileDefaults($key, $name, $this->_defaults, $this->_id, $this->_mode, $value);
} else {
$this->_defaults[$name] = "";
}
}
if ($htmlType == 'File') {
$entityId = $this->_id;
if (CRM_Utils_Array::value('field_type', $field) == 'Activity' && $this->_activityId) {
$entityId = $this->_activityId;
}
$url = CRM_Core_BAO_CustomField::getFileURL($entityId, $key);
if ($url) {
$customFiles[$name]['displayURL'] = ts("Attached File") . ": {$url['file_url']}";
$deleteExtra = ts("Are you sure you want to delete attached file?");
$fileId = $url['file_id'];
$deleteURL = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileId}&eid={$entityId}&fid={$key}&action=delete");
$text = ts("Delete Attached File");
$customFiles[$field['name']]['deleteURL'] = "<a href=\"{$deleteURL}\" onclick = \"if (confirm( ' {$deleteExtra} ' )) this.href+='&confirmed=1'; else return false;\">{$text}</a>";
// also delete the required rule that we've set on the form element
$this->removeFileRequiredRules($name);
}
}
}
}
} else {
foreach ($this->_fields as $name => $field) {
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
$htmlType = $field['html_type'];
if ((!isset($this->_defaults[$name]) || $htmlType == 'File') && CRM_Utils_Array::value('field_type', $field) != 'Activity') {
CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $this->_defaults, $this->_id, $this->_mode);
}
if ($htmlType == 'File') {
$entityId = $this->_id;
if (CRM_Utils_Array::value('field_type', $field) == 'Activity' && $this->_activityId) {
$entityId = $this->_activityId;
}
$url = CRM_Core_BAO_CustomField::getFileURL($entityId, $customFieldID);
if ($url) {
$customFiles[$field['name']]['displayURL'] = ts("Attached File") . ": {$url['file_url']}";
$deleteExtra = ts("Are you sure you want to delete attached file?");
$fileId = $url['file_id'];
$deleteURL = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileId}&eid={$entityId}&fid={$customFieldID}&action=delete");
$text = ts("Delete Attached File");
$customFiles[$field['name']]['deleteURL'] = "<a href=\"{$deleteURL}\" onclick = \"if (confirm( ' {$deleteExtra} ' )) this.href+='&confirmed=1'; else return false;\">{$text}</a>";
// also delete the required rule that we've set on the form element
//.........这里部分代码省略.........
示例7: findDifferences
/**
* Find differences between contacts.
*
* @param array $main
* Contact details.
* @param array $other
* Contact details.
*
* @return array
*/
public static function findDifferences($main, $other)
{
$result = array('contact' => array(), 'custom' => array());
foreach (self::getContactFields() as $validField) {
if (CRM_Utils_Array::value($validField, $main) != CRM_Utils_Array::value($validField, $other)) {
$result['contact'][] = $validField;
}
}
$mainEvs = CRM_Core_BAO_CustomValueTable::getEntityValues($main['id']);
$otherEvs = CRM_Core_BAO_CustomValueTable::getEntityValues($other['id']);
$keys = array_unique(array_merge(array_keys($mainEvs), array_keys($otherEvs)));
foreach ($keys as $key) {
// Exclude multi-value fields CRM-13836
if (strpos($key, '_')) {
continue;
}
$key1 = CRM_Utils_Array::value($key, $mainEvs);
$key2 = CRM_Utils_Array::value($key, $otherEvs);
if ($key1 != $key2) {
$result['custom'][] = $key;
}
}
return $result;
}
示例8: testCreateValidCustomDataToIndividualStudent
/**
* Add valid custom data to a Contact Type : Individual Subtype: Student
*/
function testCreateValidCustomDataToIndividualStudent()
{
$params = array('contact_id' => $this->individualStudent, 'contact_type' => 'Individual', "custom_{$this->IndiStudentField['id']}" => 'Test String');
$result = $this->callAPISuccess('contact', 'create', $params);
$this->assertNotNull($result['id'], 'In line ' . __LINE__);
$entityValues = CRM_Core_BAO_CustomValueTable::getEntityValues($this->individualStudent);
$elements["custom_{$this->IndiStudentField['id']}"] = $entityValues["{$this->IndiStudentField['id']}"];
// Check the Value in Database
$this->assertEquals($elements["custom_{$this->IndiStudentField['id']}"], 'Test String', 'in line ' . __LINE__);
}
示例9: retrieveFields
/**
* Load all non-empty fields for the contacts
*
* @param array $main
* Contact details.
* @param array $other
* Contact details.
*
* @return array
*/
public static function retrieveFields($main, $other)
{
$result = array('contact' => array(), 'custom' => array());
foreach (self::getContactFields() as $validField) {
// CRM-17556 Get all non-empty fields, to make comparison easier
if (!empty($main[$validField]) || !empty($other[$validField])) {
$result['contact'][] = $validField;
}
}
$mainEvs = CRM_Core_BAO_CustomValueTable::getEntityValues($main['id']);
$otherEvs = CRM_Core_BAO_CustomValueTable::getEntityValues($other['id']);
$keys = array_unique(array_merge(array_keys($mainEvs), array_keys($otherEvs)));
foreach ($keys as $key) {
// Exclude multi-value fields CRM-13836
if (strpos($key, '_')) {
continue;
}
$key1 = CRM_Utils_Array::value($key, $mainEvs);
$key2 = CRM_Utils_Array::value($key, $otherEvs);
// CRM-17556 Get all non-empty fields, to make comparison easier
if (!empty($key1) || !empty($key2)) {
$result['custom'][] = $key;
}
}
return $result;
}
示例10: browse
/**
* Browse the listing.
*
* @return void
*/
public function browse()
{
$dateFields = NULL;
$cgcount = 0;
$attributes = array();
$dateFieldsVals = NULL;
if ($this->_pageViewType == 'profileDataView' && $this->_profileId) {
$fields = CRM_Core_BAO_UFGroup::getFields($this->_profileId, FALSE, NULL, NULL, NULL, FALSE, NULL, FALSE, NULL, CRM_Core_Permission::EDIT);
$multiRecordFields = array();
$fieldIDs = NULL;
$result = NULL;
$multiRecordFieldsWithSummaryListing = CRM_Core_BAO_UFGroup::shiftMultiRecordFields($fields, $multiRecordFields, TRUE);
$multiFieldId = CRM_Core_BAO_CustomField::getKeyID(key($multiRecordFields));
$customGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $multiFieldId, 'custom_group_id');
$reached = CRM_Core_BAO_CustomGroup::hasReachedMaxLimit($customGroupId, $this->_contactId);
if (!$reached) {
$this->assign('contactId', $this->_contactId);
$this->assign('gid', $this->_profileId);
}
$this->assign('reachedMax', $reached);
if ($multiRecordFieldsWithSummaryListing && !empty($multiRecordFieldsWithSummaryListing)) {
$fieldIDs = array_keys($multiRecordFieldsWithSummaryListing);
}
} elseif ($this->_pageViewType == 'customDataView') {
// require custom group id for _pageViewType of customDataView
$customGroupId = $this->_customGroupId;
$reached = CRM_Core_BAO_CustomGroup::hasReachedMaxLimit($customGroupId, $this->_contactId);
if (!$reached) {
$this->assign('contactId', $this->_contactId);
$this->assign('customGroupId', $customGroupId);
$this->assign('ctype', $this->_contactType);
}
$this->assign('reachedMax', $reached);
// custom group info : this consists of the field title of group fields
$groupDetail = CRM_Core_BAO_CustomGroup::getGroupDetail($customGroupId, NULL, CRM_Core_DAO::$_nullObject, TRUE);
// field ids of fields in_selector for the custom group id provided
$fieldIDs = array_keys($groupDetail[$customGroupId]['fields']);
// field labels for headers
$fieldLabels = $groupDetail[$customGroupId]['fields'];
// from the above customGroupInfo we can get $this->_customGroupTitle
$this->_customGroupTitle = $groupDetail[$customGroupId]['title'];
}
if ($fieldIDs && !empty($fieldIDs) && $this->_contactId) {
$options = array();
$returnProperities = array('html_type', 'data_type', 'date_format', 'time_format', 'default_value', 'is_required');
foreach ($fieldIDs as $key => $fieldID) {
$fieldIDs[$key] = !is_numeric($fieldID) ? CRM_Core_BAO_CustomField::getKeyID($fieldID) : $fieldID;
$param = array('id' => $fieldIDs[$key]);
$returnValues = array();
CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $param, $returnValues, $returnProperities);
if ($returnValues['data_type'] == 'Date') {
$dateFields[$fieldIDs[$key]] = 1;
$actualPHPFormats = CRM_Core_SelectValues::datePluginToPHPFormats();
$dateFormat = (array) CRM_Utils_Array::value($returnValues['date_format'], $actualPHPFormats);
$timeFormat = CRM_Utils_Array::value('time_format', $returnValues);
}
$optionValuePairs = CRM_Core_BAO_CustomOption::getCustomOption($fieldIDs[$key]);
if (!empty($optionValuePairs)) {
foreach ($optionValuePairs as $optionPairs) {
$options[$fieldIDs[$key]][$optionPairs['value']] = $optionPairs['label'];
}
}
$options[$fieldIDs[$key]]['attributes']['html_type'] = $returnValues['html_type'];
$options[$fieldIDs[$key]]['attributes']['data_type'] = $returnValues['data_type'];
$options[$fieldIDs[$key]]['attributes']['is_required'] = !empty($returnValues['is_required']);
$options[$fieldIDs[$key]]['attributes']['default_value'] = CRM_Utils_Array::value('default_value', $returnValues);
$options[$fieldIDs[$key]]['attributes']['format'] = $options[$fieldIDs[$key]]['attributes']['date_format'] = CRM_Utils_Array::value('date_format', $returnValues);
$options[$fieldIDs[$key]]['attributes']['time_format'] = CRM_Utils_Array::value('time_format', $returnValues);
}
// commonly used for both views i.e profile listing view (profileDataView) and custom data listing view (customDataView)
$result = CRM_Core_BAO_CustomValueTable::getEntityValues($this->_contactId, NULL, $fieldIDs, TRUE);
if ($this->_pageViewType == 'profileDataView') {
if (!empty($fieldIDs)) {
//get the group info of multi rec fields in listing view
$fieldInput = $fieldIDs;
$fieldIdInput = $fieldIDs[0];
} else {
//if no listing fields exist, take the group title for display
$nonListingFieldIds = array_keys($multiRecordFields);
$singleField = CRM_Core_BAO_CustomField::getKeyID($nonListingFieldIds[0]);
$fieldIdInput = $singleField;
$singleField = array($singleField);
$fieldInput = $singleField;
}
$customGroupInfo = CRM_Core_BAO_CustomGroup::getGroupTitles($fieldInput);
$this->_customGroupTitle = $customGroupInfo[$fieldIdInput]['groupTitle'];
}
// $cgcount is defined before 'if' condition as enitiy may have no record
// and $cgcount is used to build new record url
$cgcount = 1;
if ($result && !empty($result)) {
$links = self::links();
if ($this->_pageViewType == 'profileDataView') {
$pageCheckSum = $this->get('pageCheckSum');
if ($pageCheckSum) {
//.........这里部分代码省略.........
示例11: printCaseReport
//.........这里部分代码省略.........
$report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, array($value['name'] => 'name_' . rand(10000, 100000)));
}
$value['name'] = self::redact($value['name'], TRUE, $report->_redactionStringRules);
if (!empty($value['email']) && !array_key_exists($value['email'], $report->_redactionStringRules)) {
$report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, array($value['email'] => 'email_' . rand(10000, 100000)));
}
$value['email'] = self::redact($value['email'], TRUE, $report->_redactionStringRules);
if (!empty($value['phone']) && !array_key_exists($value['phone'], $report->_redactionStringRules)) {
$report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, array($value['phone'] => 'phone_' . rand(10000, 100000)));
}
$value['phone'] = self::redact($value['phone'], TRUE, $report->_redactionStringRules);
}
}
$caseRoles['client'] = CRM_Case_BAO_Case::getContactNames($caseID);
if ($isRedact) {
if (!array_key_exists($caseRoles['client']['sort_name'], $report->_redactionStringRules)) {
$report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, array($caseRoles['client']['sort_name'] => 'name_' . rand(10000, 100000)));
}
if (!array_key_exists($caseRoles['client']['display_name'], $report->_redactionStringRules)) {
$report->_redactionStringRules[$caseRoles['client']['display_name']] = $report->_redactionStringRules[$caseRoles['client']['sort_name']];
}
$caseRoles['client']['sort_name'] = self::redact($caseRoles['client']['sort_name'], TRUE, $report->_redactionStringRules);
if (!empty($caseRoles['client']['email']) && !array_key_exists($caseRoles['client']['email'], $report->_redactionStringRules)) {
$report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, array($caseRoles['client']['email'] => 'email_' . rand(10000, 100000)));
}
$caseRoles['client']['email'] = self::redact($caseRoles['client']['email'], TRUE, $report->_redactionStringRules);
if (!empty($caseRoles['client']['phone']) && !array_key_exists($caseRoles['client']['phone'], $report->_redactionStringRules)) {
$report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, array($caseRoles['client']['phone'] => 'phone_' . rand(10000, 100000)));
}
$caseRoles['client']['phone'] = self::redact($caseRoles['client']['phone'], TRUE, $report->_redactionStringRules);
}
// Retrieve ALL client relationships
$relClient = CRM_Contact_BAO_Relationship::getRelationship($clientID, CRM_Contact_BAO_Relationship::CURRENT, 0, 0, 0, NULL, NULL, FALSE);
foreach ($relClient as $r) {
if ($isRedact) {
if (!array_key_exists($r['name'], $report->_redactionStringRules)) {
$report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, array($r['name'] => 'name_' . rand(10000, 100000)));
}
if (!array_key_exists($r['display_name'], $report->_redactionStringRules)) {
$report->_redactionStringRules[$r['display_name']] = $report->_redactionStringRules[$r['name']];
}
$r['name'] = self::redact($r['name'], TRUE, $report->_redactionStringRules);
if (!empty($r['phone']) && !array_key_exists($r['phone'], $report->_redactionStringRules)) {
$report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, array($r['phone'] => 'phone_' . rand(10000, 100000)));
}
$r['phone'] = self::redact($r['phone'], TRUE, $report->_redactionStringRules);
if (!empty($r['email']) && !array_key_exists($r['email'], $report->_redactionStringRules)) {
$report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, array($r['email'] => 'email_' . rand(10000, 100000)));
}
$r['email'] = self::redact($r['email'], TRUE, $report->_redactionStringRules);
}
if (!array_key_exists($r['id'], $caseRelationships)) {
$otherRelationships[] = $r;
}
}
// Now global contact list that appears on all cases.
$relGlobal = CRM_Case_BAO_Case::getGlobalContacts($globalGroupInfo);
foreach ($relGlobal as &$r) {
if ($isRedact) {
if (!array_key_exists($r['sort_name'], $report->_redactionStringRules)) {
$report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, array($r['sort_name'] => 'name_' . rand(10000, 100000)));
}
if (!array_key_exists($r['display_name'], $report->_redactionStringRules)) {
$report->_redactionStringRules[$r['display_name']] = $report->_redactionStringRules[$r['sort_name']];
}
$r['sort_name'] = self::redact($r['sort_name'], TRUE, $report->_redactionStringRules);
if (!empty($r['phone']) && !array_key_exists($r['phone'], $report->_redactionStringRules)) {
$report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, array($r['phone'] => 'phone_' . rand(10000, 100000)));
}
$r['phone'] = self::redact($r['phone'], TRUE, $report->_redactionStringRules);
if (!empty($r['email']) && !array_key_exists($r['email'], $report->_redactionStringRules)) {
$report->_redactionStringRules = CRM_Utils_Array::crmArrayMerge($report->_redactionStringRules, array($r['email'] => 'email_' . rand(10000, 100000)));
}
$r['email'] = self::redact($r['email'], TRUE, $report->_redactionStringRules);
}
}
// Retrieve custom values for cases.
$customValues = CRM_Core_BAO_CustomValueTable::getEntityValues($caseID, 'Case');
$extends = array('case');
$groupTree = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, NULL, $extends);
$caseCustomFields = array();
while (list($gid, $group_values) = each($groupTree)) {
while (list($id, $field_values) = each($group_values['fields'])) {
if (array_key_exists($id, $customValues)) {
$caseCustomFields[$gid]['title'] = $group_values['title'];
$caseCustomFields[$gid]['values'][$id] = array('label' => $field_values['label'], 'value' => $customValues[$id]);
}
}
}
$template->assign('caseRelationships', $caseRelationships);
$template->assign('caseRoles', $caseRoles);
$template->assign('otherRelationships', $otherRelationships);
$template->assign('globalRelationships', $relGlobal);
$template->assign('globalGroupInfo', $globalGroupInfo);
$template->assign('caseCustomFields', $caseCustomFields);
$contents = self::getCaseReport($clientID, $caseID, $activitySetName, $params, $report);
$printReport = CRM_Case_Audit_Audit::run($contents, $clientID, $caseID, TRUE);
echo $printReport;
CRM_Utils_System::civiExit();
}
示例12: browse
/**
* Browse the listing
*
* @return void
* @access public
*/
function browse()
{
if ($this->_profileId) {
$fields = CRM_Core_BAO_UFGroup::getFields($this->_profileId, FALSE, NULL, NULL, NULL, FALSE, NULL, FALSE, NULL, CRM_Core_Permission::EDIT);
$multiRecordFields = array();
$fieldIDs = NULL;
$result = NULL;
$multiRecordFieldsWithSummaryListing = CRM_Core_BAO_UFGroup::shiftMultiRecordFields($fields, $multiRecordFields, TRUE);
$multiFieldId = CRM_Core_BAO_CustomField::getKeyID(key($multiRecordFields));
$customGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $multiFieldId, 'custom_group_id');
$reached = CRM_Core_BAO_CustomGroup::hasReachedMaxLimit($customGroupId, $this->_contactId);
if (!$reached) {
$this->assign('contactId', $this->_contactId);
$this->assign('gid', $this->_profileId);
}
$this->assign('reachedMax', $reached);
if ($multiRecordFieldsWithSummaryListing && !empty($multiRecordFieldsWithSummaryListing)) {
$fieldIDs = array_keys($multiRecordFieldsWithSummaryListing);
}
}
if ($fieldIDs && !empty($fieldIDs) && $this->_contactId) {
$options = array();
$returnProperities = array('html_type', 'data_type', 'date_format', 'time_format');
foreach ($fieldIDs as $key => $fieldID) {
$fieldIDs[$key] = CRM_Core_BAO_CustomField::getKeyID($fieldID);
$param = array('id' => $fieldIDs[$key]);
$returnValues = array();
CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $param, $returnValues, $returnProperities);
$optionValuePairs = CRM_Core_BAO_CustomOption::getCustomOption($fieldIDs[$key]);
if (!empty($optionValuePairs)) {
foreach ($optionValuePairs as $optionPairs) {
$options[$fieldIDs[$key]][$optionPairs['value']] = $optionPairs['label'];
}
}
$options[$fieldIDs[$key]]['attributes']['html_type'] = $returnValues['html_type'];
$options[$fieldIDs[$key]]['attributes']['data_type'] = $returnValues['data_type'];
$options[$fieldIDs[$key]]['attributes']['format'] = $options[$fieldIDs[$key]]['attributes']['date_format'] = CRM_Utils_Array::value('date_format', $returnValues);
$options[$fieldIDs[$key]]['attributes']['time_format'] = CRM_Utils_Array::value('time_format', $returnValues);
}
$result = CRM_Core_BAO_CustomValueTable::getEntityValues($this->_contactId, NULL, $fieldIDs, TRUE);
if (!empty($fieldIDs)) {
//get the group info of multi rec fields in listing view
$fieldInput = $fieldIDs;
$fieldIdInput = $fieldIDs[0];
} else {
//if no listing fields exist, take the group title for display
$nonListingFieldIds = array_keys($multiRecordFields);
$singleField = CRM_Core_BAO_CustomField::getKeyID($nonListingFieldIds[0]);
$fieldIdInput = $singleField;
$singleField = array($singleField);
$fieldInput = $singleField;
}
$customGroupInfo = CRM_Core_BAO_CustomGroup::getGroupTitles($fieldInput);
$this->_customGroupTitle = $customGroupInfo[$fieldIdInput]['groupTitle'];
if ($result && !empty($result)) {
$links = self::links();
$pageCheckSum = $this->get('pageCheckSum');
if ($pageCheckSum) {
foreach ($links as $key => $link) {
$links[$key] = $link['qs'] . "&cs=%%cs%%";
}
}
$linkAction = array_sum(array_keys($this->links()));
foreach ($result as $recId => &$value) {
foreach ($value as $fieldId => &$val) {
if (is_numeric($fieldId)) {
$customValue =& $val;
$customValue = CRM_Core_BAO_CustomField::getDisplayValue($customValue, $fieldId, $options);
if (!$customValue) {
$customValue = "";
}
$actionParams = array('recordId' => $recId, 'gid' => $this->_profileId, 'id' => $this->_contactId, 'onPopupClose' => $this->_onPopupClose);
if ($pageCheckSum) {
$actionParams['cs'] = $pageCheckSum;
}
$value['action'] = CRM_Core_Action::formLink($links, $linkAction, $actionParams, ts('more'), FALSE, 'profile.multiValue.row', 'customValue', $fieldId);
}
}
}
}
}
$headers = array();
if (!empty($fieldIDs)) {
foreach ($fieldIDs as $fieldID) {
$headers[$fieldID] = $customGroupInfo[$fieldID]['fieldLabel'];
}
}
$this->assign('customGroupTitle', $this->_customGroupTitle);
$this->assign('headers', $headers);
$this->assign('records', $result);
}
示例13: browse
/**
* Browse the listing
*
* @return void
* @access public
*/
function browse()
{
$dateFields = NULL;
$cgcount = 0;
$dateFieldsVals = NULL;
if ($this->_pageViewType == 'profileDataView' && $this->_profileId) {
$fields = CRM_Core_BAO_UFGroup::getFields($this->_profileId, FALSE, NULL, NULL, NULL, FALSE, NULL, FALSE, NULL, CRM_Core_Permission::EDIT);
$multiRecordFields = array();
$fieldIDs = NULL;
$result = NULL;
$multiRecordFieldsWithSummaryListing = CRM_Core_BAO_UFGroup::shiftMultiRecordFields($fields, $multiRecordFields, TRUE);
$multiFieldId = CRM_Core_BAO_CustomField::getKeyID(key($multiRecordFields));
$customGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $multiFieldId, 'custom_group_id');
$reached = CRM_Core_BAO_CustomGroup::hasReachedMaxLimit($customGroupId, $this->_contactId);
if (!$reached) {
$this->assign('contactId', $this->_contactId);
$this->assign('gid', $this->_profileId);
}
$this->assign('reachedMax', $reached);
if ($multiRecordFieldsWithSummaryListing && !empty($multiRecordFieldsWithSummaryListing)) {
$fieldIDs = array_keys($multiRecordFieldsWithSummaryListing);
}
} elseif ($this->_pageViewType == 'customDataView') {
// require custom group id for _pageViewType of customDataView
$customGroupId = $this->_customGroupId;
$reached = CRM_Core_BAO_CustomGroup::hasReachedMaxLimit($customGroupId, $this->_contactId);
if (!$reached) {
$this->assign('contactId', $this->_contactId);
$this->assign('customGroupId', $customGroupId);
$this->assign('ctype', $this->_contactType);
}
$this->assign('reachedMax', $reached);
// custom group info : this consists of the field title of group fields
$groupDetail = CRM_Core_BAO_CustomGroup::getGroupDetail($customGroupId, NULL, CRM_Core_DAO::$_nullObject, TRUE);
// field ids of fields in_selector for the custom group id provided
$fieldIDs = array_keys($groupDetail[$customGroupId]['fields']);
// field labels for headers
$fieldLabels = $groupDetail[$customGroupId]['fields'];
// from the above customGroupInfo we can get $this->_customGroupTitle
$this->_customGroupTitle = $groupDetail[$customGroupId]['title'];
}
if ($fieldIDs && !empty($fieldIDs) && $this->_contactId) {
$options = array();
$returnProperities = array('html_type', 'data_type', 'date_format', 'time_format');
foreach ($fieldIDs as $key => $fieldID) {
$fieldIDs[$key] = !is_numeric($fieldID) ? CRM_Core_BAO_CustomField::getKeyID($fieldID) : $fieldID;
$param = array('id' => $fieldIDs[$key]);
$returnValues = array();
CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $param, $returnValues, $returnProperities);
if ($returnValues['data_type'] == 'Date') {
$dateFields[$fieldIDs[$key]] = 1;
}
$optionValuePairs = CRM_Core_BAO_CustomOption::getCustomOption($fieldIDs[$key]);
if (!empty($optionValuePairs)) {
foreach ($optionValuePairs as $optionPairs) {
$options[$fieldIDs[$key]][$optionPairs['value']] = $optionPairs['label'];
}
}
$options[$fieldIDs[$key]]['attributes']['html_type'] = $returnValues['html_type'];
$options[$fieldIDs[$key]]['attributes']['data_type'] = $returnValues['data_type'];
$options[$fieldIDs[$key]]['attributes']['format'] = $options[$fieldIDs[$key]]['attributes']['date_format'] = CRM_Utils_Array::value('date_format', $returnValues);
$options[$fieldIDs[$key]]['attributes']['time_format'] = CRM_Utils_Array::value('time_format', $returnValues);
}
// commonly used for both views i.e profile listing view (profileDataView) and custom data listing view (customDataView)
$result = CRM_Core_BAO_CustomValueTable::getEntityValues($this->_contactId, NULL, $fieldIDs, TRUE);
if ($this->_pageViewType == 'profileDataView') {
if (!empty($fieldIDs)) {
//get the group info of multi rec fields in listing view
$fieldInput = $fieldIDs;
$fieldIdInput = $fieldIDs[0];
} else {
//if no listing fields exist, take the group title for display
$nonListingFieldIds = array_keys($multiRecordFields);
$singleField = CRM_Core_BAO_CustomField::getKeyID($nonListingFieldIds[0]);
$fieldIdInput = $singleField;
$singleField = array($singleField);
$fieldInput = $singleField;
}
$customGroupInfo = CRM_Core_BAO_CustomGroup::getGroupTitles($fieldInput);
$this->_customGroupTitle = $customGroupInfo[$fieldIdInput]['groupTitle'];
}
// $cgcount is defined before 'if' condition as enitiy may have no record
// and $cgcount is used to build new record url
$cgcount = 1;
if ($result && !empty($result)) {
$links = self::links();
if ($this->_pageViewType == 'profileDataView') {
$pageCheckSum = $this->get('pageCheckSum');
if ($pageCheckSum) {
foreach ($links as $key => $link) {
$links[$key] = $link['qs'] . "&cs=%%cs%%";
}
}
}
//.........这里部分代码省略.........
示例14: testgetEntityValues
function testgetEntityValues()
{
$params = array();
$contactID = Contact::createIndividual();
$customGroup = Custom::createGroup($params, 'Individual');
$fields = array('groupId' => $customGroup->id, 'htmlType' => 'RichTextEditor', 'dataType' => 'Memo');
$customField = Custom::createField($params, $fields);
$params[] = array($customField->id => array('value' => '<p><strong>This is a <u>test</u></p>', 'type' => 'Memo', 'custom_field_id' => $customField->id, 'custom_group_id' => $customGroup->id, 'table_name' => 'civicrm_value_test_group_' . $customGroup->id, 'column_name' => 'test_Memo_' . $customField->id, 'file_id' => ''));
require_once 'CRM/Core/BAO/CustomValueTable.php';
CRM_Core_BAO_CustomValueTable::store($params, 'civicrm_contact', $contactID);
// $this->assertDBCompareValue('CRM_Custom_DAO_CustomValue', )
require_once 'CRM/Core/BAO/CustomValueTable.php';
$entityValues = CRM_Core_BAO_CustomValueTable::getEntityValues($contactID, 'Individual');
$this->assertEquals($entityValues[$customField->id], '<p><strong>This is a <u>test</u></p>', 'Checking same for returned value.');
Custom::deleteField($customField);
Custom::deleteGroup($customGroup);
Contact::delete($contactID);
}
示例15: findDifferences
/**
* Find differences between contacts.
*/
function findDifferences($mainId, $otherId)
{
$mainParams = array('contact_id' => (int) $mainId, 'version' => 3);
$otherParams = array('contact_id' => (int) $otherId, 'version' => 3);
foreach (self::$validFields as $field) {
$mainParams["return.{$field}"] = $otherParams["return.{$field}"] = 1;
}
$main =& civicrm_api('contact', 'get', $mainParams);
$other =& civicrm_api('contact', 'get', $otherParams);
//CRM-4524
$main = reset($main['values']);
$other = reset($other['values']);
if ($main['contact_type'] != $other['contact_type']) {
return FALSE;
}
$diffs = array();
foreach (self::$validFields as $validField) {
if (CRM_Utils_Array::value($validField, $main) != CRM_Utils_Array::value($validField, $other)) {
$diffs['contact'][] = $validField;
}
}
$mainEvs = CRM_Core_BAO_CustomValueTable::getEntityValues($mainId);
$otherEvs = CRM_Core_BAO_CustomValueTable::getEntityValues($otherId);
$keys = array_unique(array_merge(array_keys($mainEvs), array_keys($otherEvs)));
foreach ($keys as $key) {
$key1 = CRM_Utils_Array::value($key, $mainEvs);
$key2 = CRM_Utils_Array::value($key, $otherEvs);
if ($key1 != $key2) {
$diffs['custom'][] = $key;
}
}
unset($main, $other, $mainEvs, $otherEvs);
return $diffs;
}