本文整理汇总了PHP中CRM_Core_BAO_CustomField::getDisplayValue方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_CustomField::getDisplayValue方法的具体用法?PHP CRM_Core_BAO_CustomField::getDisplayValue怎么用?PHP CRM_Core_BAO_CustomField::getDisplayValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_CustomField
的用法示例。
在下文中一共展示了CRM_Core_BAO_CustomField::getDisplayValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetDisplayedValues
public function testGetDisplayedValues()
{
$customGroup = Custom::createGroup(array(), 'Individual');
$fields = array('label' => 'testCountryFld1', 'data_type' => 'Country', 'html_type' => 'Select Country', 'is_active' => 1, 'default_value' => 1228, 'custom_group_id' => $customGroup->id);
$customField1 = CRM_Core_BAO_CustomField::create($fields);
$customFieldID1 = $this->assertDBNotNull('CRM_Core_DAO_CustomField', $customGroup->id, 'id', 'custom_group_id', 'Database check for created CustomField.');
$options = array();
$options[$customFieldID1]['attributes'] = array('label' => 'testCountryFld1', 'data_type' => 'Country', 'html_type' => 'Select Country');
$display = CRM_Core_BAO_CustomField::getDisplayValue($fields['default_value'], $customFieldID1, $options);
$this->assertEquals('UNITED STATES', $display, 'Confirm Country display Name');
Custom::deleteGroup($customGroup);
}
示例2: exportComponents
//.........这里部分代码省略.........
$is_valid = null;
$data = null;
if ($val['result']) {
foreach ($val['result'] as $k => $v) {
//consider only active relationships
if ($v['is_active'] && $v['rtype'] == $direction) {
$cID['contact_id'] = $v['cid'];
if ($cID) {
//Get Contact Details
$data = CRM_Contact_BAO_Contact::retrieve($cID, $defaults);
}
$is_valid = true;
break;
}
}
}
$relCustomIDs = array();
foreach ($value as $relationkey => $relationvalue) {
if ($val['result'] && ($cfID = CRM_Core_BAO_CustomField::getKeyID($relationkey))) {
foreach ($val['result'] as $k1 => $v1) {
$contID = $v1['cid'];
$param1 = array('entityID' => $contID, $relationkey => 1);
$getcustomValue = CRM_Core_BAO_CustomValueTable::getValues($param1);
$custom_ID = CRM_Core_BAO_CustomField::getKeyID($relationkey);
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($relationkey)) {
if (empty($query->_options)) {
$relCustomIDs[$cfID] = array();
$relQuery = new CRM_Core_BAO_CustomQuery($relCustomIDs);
$relQuery->query();
$relOptions = $relQuery->_options;
} else {
$relOptions = $query->_options;
}
$custom_data = CRM_Core_BAO_CustomField::getDisplayValue($getcustomValue[$relationkey], $cfID, $relOptions);
} else {
$custom_data = '';
}
}
}
//Get all relationships type custom fields
list($id, $atype, $btype) = explode('_', $field);
$relCustomData = CRM_Core_BAO_CustomField::getFields('Relationship', null, null, $id, null, null);
$tmpArray = array_keys($relCustomData);
$customIDs = array();
foreach ($tmpArray as $customID) {
$customIDs[$customID] = array();
}
require_once 'CRM/Core/BAO/CustomQuery.php';
$customQuery = new CRM_Core_BAO_CustomQuery($customIDs);
$customQuery->query();
$options = $customQuery->_options;
foreach ($relCustomData as $id => $customdatavalue) {
if (in_array($relationkey, $customdatavalue)) {
$customkey = "custom_{$id}";
if ($val['result']) {
foreach ($val['result'] as $k => $v) {
$cid = $v['id'];
$param = array('entityID' => $cid, $customkey => 1);
//Get custom data values
$getCustomValueRel = CRM_Core_BAO_CustomValueTable::getValues($param);
if (!array_key_exists('error_message', $getCustomValueRel)) {
$customData = CRM_Core_BAO_CustomField::getDisplayValue($getCustomValueRel[$customkey], $id, $options);
} else {
$customData = '';
}
if ($customData) {
示例3: array
/**
* returns all the rows in the given offset and rowCount
*
* @param enum $action the action being performed
* @param int $offset the row number to start from
* @param int $rowCount the number of rows to return
* @param string $sort the sql string that describes the sort order
* @param enum $output what should the result set include (web/email/csv)
*
* @return int the total number of rows for this action
*/
function &getRows($action, $offset, $rowCount, $sort, $output = NULL)
{
$config = CRM_Core_Config::singleton();
if (($output == CRM_Core_Selector_Controller::EXPORT || $output == CRM_Core_Selector_Controller::SCREEN) && $this->_formValues['radio_ts'] == 'ts_sel') {
$includeContactIds = TRUE;
} else {
$includeContactIds = FALSE;
}
// note the formvalues were given by CRM_Contact_Form_Search to us
// and contain the search criteria (parameters)
// note that the default action is basic
if ($rowCount) {
$cacheKey = $this->buildPrevNextCache($sort);
$result = $this->_query->getCachedContacts($cacheKey, $offset, $rowCount, $includeContactIds);
} else {
$result = $this->_query->searchQuery($offset, $rowCount, $sort, FALSE, $includeContactIds);
}
// process the result of the query
$rows = array();
$permissions = array(CRM_Core_Permission::getPermission());
if (CRM_Core_Permission::check('delete contacts')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
// mask value to hide map link if there are not lat/long
$mapMask = $mask & 4095;
if ($this->_searchContext == 'smog') {
$gc = CRM_Core_SelectValues::groupContactStatus();
}
if ($this->_ufGroupID) {
$locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
$names = array();
static $skipFields = array('group', 'tag');
foreach ($this->_fields as $key => $field) {
if (!empty($field['in_selector']) && !in_array($key, $skipFields)) {
if (strpos($key, '-') !== FALSE) {
list($fieldName, $id, $type) = CRM_Utils_System::explode('-', $key, 3);
if ($id == 'Primary') {
$locationTypeName = 1;
} else {
$locationTypeName = CRM_Utils_Array::value($id, $locationTypes);
if (!$locationTypeName) {
continue;
}
}
$locationTypeName = str_replace(' ', '_', $locationTypeName);
if (in_array($fieldName, array('phone', 'im', 'email'))) {
if ($type) {
$names[] = "{$locationTypeName}-{$fieldName}-{$type}";
} else {
$names[] = "{$locationTypeName}-{$fieldName}";
}
} else {
$names[] = "{$locationTypeName}-{$fieldName}";
}
} else {
$names[] = $field['name'];
}
}
}
$names[] = "status";
} elseif (!empty($this->_returnProperties)) {
$names = self::makeProperties($this->_returnProperties);
} else {
$names = self::$_properties;
}
$multipleSelectFields = array('preferred_communication_method' => 1);
$links = self::links($this->_context, $this->_contextMenu, $this->_key);
//check explicitly added contact to a Smart Group.
$groupID = CRM_Utils_Array::key('1', $this->_formValues['group']);
$pseudoconstants = array();
// for CRM-3157 purposes
if (in_array('world_region', $names)) {
$pseudoconstants['world_region'] = array('dbName' => 'world_region_id', 'values' => CRM_Core_PseudoConstant::worldRegion());
}
$seenIDs = array();
while ($result->fetch()) {
$row = array();
$this->_query->convertToPseudoNames($result);
// the columns we are interested in
foreach ($names as $property) {
if ($property == 'status') {
continue;
}
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($property)) {
$row[$property] = CRM_Core_BAO_CustomField::getDisplayValue($result->{$property}, $cfID, $this->_options, $result->contact_id);
} elseif ($multipleSelectFields && array_key_exists($property, $multipleSelectFields)) {
$key = $property;
$paramsNew = array($key => $result->{$property});
//.........这里部分代码省略.........
示例4: displayProfile
//.........这里部分代码省略.........
if ($fieldName == 'im') {
$providerName = null;
if ($providerId = $detailName . '-provider_id') {
$providerName = CRM_Utils_Array::value($params[$providerId], $imProviders);
}
if ($providerName) {
$values[$index] = $params[$detailName] . " (" . $providerName . ")";
} else {
$values[$index] = $params[$detailName];
}
} else {
$values[$index] = $params[$detailName];
}
}
} else {
if (substr($name, 0, 7) === 'do_not_' or substr($name, 0, 3) === 'is_') {
if ($params[$name]) {
$values[$index] = '[ x ]';
}
} else {
require_once 'CRM/Core/BAO/CustomField.php';
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name)) {
$query = "\nSELECT html_type, data_type\nFROM civicrm_custom_field\nWHERE id = {$cfID}\n";
$dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
$dao->fetch();
$htmlType = $dao->html_type;
$dataType = $dao->data_type;
if ($htmlType == 'File') {
//$fileURL = CRM_Core_BAO_CustomField::getFileURL( $contactID, $cfID );
//$params[$index] = $values[$index] = $fileURL['file_url'];
$values[$index] = $params[$index];
} else {
if ($dao->data_type == 'Int' || $dao->data_type == 'Boolean') {
$customVal = (int) $params[$name];
} else {
if ($dao->data_type == 'Float') {
$customVal = (double) $params[$name];
} else {
if ($dao->data_type == 'Date') {
$date = CRM_Utils_Date::format($params[$name], null, 'invalidDate');
if ($date != 'invalidDate') {
$customVal = $date;
}
} else {
$customVal = $params[$name];
}
}
}
//take the custom field options
$returnProperties = array($name => 1);
require_once 'CRM/Contact/BAO/Query.php';
$query = new CRM_Contact_BAO_Query($params, $returnProperties, $fields);
$options =& $query->_options;
$displayValue = CRM_Core_BAO_CustomField::getDisplayValue($customVal, $cfID, $options);
//Hack since we dont have function to check empty.
//FIXME in 2.3 using crmIsEmptyArray()
$customValue = true;
if (is_array($customVal) && is_array($displayValue)) {
$customValue = array_diff($customVal, $displayValue);
}
//use difference of arrays
if (empty($customValue) || !$customValue) {
$values[$index] = '';
} else {
$values[$index] = $displayValue;
}
if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $cfID, 'is_search_range')) {
$customFieldName = "{$name}_from";
}
}
} else {
if ($name == 'home_URL' && !empty($params[$name])) {
$url = CRM_Utils_System::fixURL($params[$name]);
$values[$index] = "<a href=\"{$url}\">{$params[$name]}</a>";
} else {
if (in_array($name, array('birth_date', 'deceased_date', 'participant_register_date'))) {
require_once 'CRM/Utils/Date.php';
$values[$index] = CRM_Utils_Date::customFormat(CRM_Utils_Date::format($params[$name]));
} else {
$values[$index] = $params[$name];
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
示例5: displayProfile
//.........这里部分代码省略.........
} elseif ('participant_status_id' == $name or 'participant_status' == $name) {
$status = CRM_Event_PseudoConstant::participantStatus();
$values[$index] = $status[$params[$name]];
} elseif (substr($name, -11) == 'campaign_id') {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($params[$name]);
$values[$index] = CRM_Utils_Array::value($params[$name], $campaigns);
} elseif (strpos($name, '-') !== FALSE) {
list($fieldName, $id) = CRM_Utils_System::explode('-', $name, 2);
$detailName = str_replace(' ', '_', $name);
if (in_array($fieldName, array('state_province', 'country', 'county'))) {
$values[$index] = $params[$detailName];
$idx = $detailName . '_id';
$values[$index] = $params[$idx];
} elseif ($fieldName == 'im') {
$providerName = NULL;
if ($providerId = $detailName . '-provider_id') {
$providerName = CRM_Utils_Array::value($params[$providerId], $imProviders);
}
if ($providerName) {
$values[$index] = $params[$detailName] . " (" . $providerName . ")";
} else {
$values[$index] = $params[$detailName];
}
} elseif ($fieldName == 'phone') {
$phoneExtField = str_replace('phone', 'phone_ext', $detailName);
if (isset($params[$phoneExtField])) {
$values[$index] = $params[$detailName] . " (" . $params[$phoneExtField] . ")";
} else {
$values[$index] = $params[$detailName];
}
} else {
$values[$index] = $params[$detailName];
}
} else {
if (substr($name, 0, 7) === 'do_not_' or substr($name, 0, 3) === 'is_') {
if ($params[$name]) {
$values[$index] = '[ x ]';
}
} else {
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name)) {
$query = "\nSELECT html_type, data_type\nFROM civicrm_custom_field\nWHERE id = {$cfID}\n";
$dao = CRM_Core_DAO::executeQuery($query);
$dao->fetch();
$htmlType = $dao->html_type;
if ($htmlType == 'File') {
$values[$index] = $params[$index];
} else {
if ($dao->data_type == 'Int' || $dao->data_type == 'Boolean') {
$v = $params[$name];
if (!CRM_Utils_System::isNull($v)) {
$customVal = (int) $v;
}
} elseif ($dao->data_type == 'Float') {
$customVal = (double) $params[$name];
} elseif ($dao->data_type == 'Date') {
//@todo note the currently we are using default date time formatting. Since you can select/set
// different date and time format specific to custom field we should consider fixing this
// sometime in the future
$customVal = $displayValue = CRM_Utils_Date::customFormat(CRM_Utils_Date::processDate($params[$name]), $config->dateformatFull);
if (!empty($params[$name . '_time'])) {
$customVal = $displayValue = CRM_Utils_Date::customFormat(CRM_Utils_Date::processDate($params[$name], $params[$name . '_time']), $config->dateformatDatetime);
}
$skip = TRUE;
} else {
$customVal = $params[$name];
}
//take the custom field options
$returnProperties = array($name => 1);
$query = new CRM_Contact_BAO_Query($params, $returnProperties, $fields);
$options =& $query->_options;
if (!$skip) {
$displayValue = CRM_Core_BAO_CustomField::getDisplayValue($customVal, $cfID, $options);
}
//Hack since we dont have function to check empty.
//FIXME in 2.3 using crmIsEmptyArray()
$customValue = TRUE;
if (is_array($customVal) && is_array($displayValue)) {
$customValue = array_diff($customVal, $displayValue);
}
//use difference of arrays
if (empty($customValue) || !$customValue) {
$values[$index] = '';
} else {
$values[$index] = $displayValue;
}
}
} elseif ($name == 'home_URL' && !empty($params[$name])) {
$url = CRM_Utils_System::fixURL($params[$name]);
$values[$index] = "<a href=\"{$url}\">{$params[$name]}</a>";
} elseif (in_array($name, array('birth_date', 'deceased_date', 'participant_register_date'))) {
$values[$index] = CRM_Utils_Date::customFormat(CRM_Utils_Date::format($params[$name]));
} else {
$values[$index] = $params[$name];
}
}
}
$profileFields[$name] = $field;
}
}
}
示例6: getCustomData
function getCustomData($clientID, $activityDAO, &$activityTypeInfo)
{
list($typeValues, $options, $sql) = $this->getActivityTypeCustomSQL($activityTypeInfo['id'], '%Y-%m-%d');
$params = array(1 => array($activityDAO->id, 'Integer'));
$customGroups = array();
foreach ($sql as $tableName => $sqlClause) {
$dao = CRM_Core_DAO::executeQuery($sqlClause, $params);
if ($dao->fetch()) {
$customGroup = array();
foreach ($typeValues[$tableName] as $columnName => $typeValue) {
$value = CRM_Core_BAO_CustomField::getDisplayValue($dao->{$columnName}, $typeValue['fieldID'], $options);
if (CRM_Utils_Array::value('type', $typeValue) == 'Date') {
$value = $dao->{$columnName};
}
if ($value) {
// Note: this is already taken care in getDisplayValue above, but sometimes
// strings like '^A^A' creates problem. So to fix this special case -
if (strstr($value, CRM_Core_DAO::VALUE_SEPARATOR)) {
$value = trim($value, CRM_Core_DAO::VALUE_SEPARATOR);
}
if (CRM_Utils_Array::value('type', $typeValue) == 'String' || CRM_Utils_Array::value('type', $typeValue) == 'Memo') {
$value = $this->redact($value);
} elseif (CRM_Utils_Array::value('type', $typeValue) == 'File') {
$tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_EntityFile', $typeValue, 'entity_table');
$value = CRM_Core_BAO_File::attachmentInfo($tableName, $activityDAO->id);
} elseif (CRM_Utils_Array::value('type', $typeValue) == 'Link') {
$value = CRM_Utils_System::formatWikiURL($value);
}
}
//$typeValue
$customGroup[] = array('label' => $typeValue['label'], 'value' => $value, 'type' => $typeValue['type']);
}
$customGroups[$dao->groupTitle] = $customGroup;
}
}
return empty($customGroups) ? NULL : $customGroups;
}
示例7: array
//.........这里部分代码省略.........
}
} elseif ($field['name'] == 'id') {
$names[] = 'contact_id';
} else {
$names[] = $field['name'];
}
}
}
$multipleSelectFields = array('preferred_communication_method' => 1);
$multiRecordTableId = NULL;
if ($this->_multiRecordTableName) {
$multiRecordTableId = "{$this->_multiRecordTableName}_id";
}
// we need to determine of overlay profile should be shown
$showProfileOverlay = CRM_Core_BAO_UFGroup::showOverlayProfile();
while ($result->fetch()) {
$this->_query->convertToPseudoNames($result);
if (isset($result->country)) {
// the query returns the untranslated country name
$i18n = CRM_Core_I18n::singleton();
$result->country = $i18n->translate($result->country);
}
$row = array();
$empty = TRUE;
$row[] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id, $showProfileOverlay);
if ($result->sort_name) {
$row[] = $result->sort_name;
$empty = FALSE;
} else {
continue;
}
foreach ($names as $name) {
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name)) {
$row[] = CRM_Core_BAO_CustomField::getDisplayValue($result->{$name}, $cfID, $this->_options, $result->contact_id);
} elseif (substr($name, -4) == '-url' && !empty($result->{$name})) {
$url = CRM_Utils_System::fixURL($result->{$name});
$typeId = substr($name, 0, -4) . "-website_type_id";
$typeName = CRM_Core_PseudoConstant::getLabel('CRM_Core_DAO_Website', 'website_type_id', $result->{$typeId});
if ($typeName) {
$row[] = "<a href=\"{$url}\">{$result->{$name}} ({$typeName})</a>";
} else {
$row[] = "<a href=\"{$url}\">{$result->{$name}}</a>";
}
} elseif ($name == 'preferred_language') {
$row[] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', 'preferred_language', $result->{$name});
} elseif ($multipleSelectFields && array_key_exists($name, $multipleSelectFields)) {
$paramsNew = array($name => $result->{$name});
$name = array($name => array('newName' => $name, 'groupName' => $name));
CRM_Core_OptionGroup::lookupValues($paramsNew, $name, FALSE);
$row[] = $paramsNew[$key];
} elseif (strpos($name, '-im')) {
if (!empty($result->{$name})) {
$providerId = $name . "-provider_id";
$providerName = CRM_Core_PseudoConstant::getLabel('CRM_Core_DAO_IM', 'provider_id', $result->{$providerId});
$row[] = $result->{$name} . " ({$providerName})";
} else {
$row[] = '';
}
} elseif (strpos($name, '-phone-')) {
$phoneExtField = str_replace('phone', 'phone_ext', $name);
if (isset($result->{$phoneExtField})) {
$row[] = $result->{$name} . " (" . $result->{$phoneExtField} . ")";
} else {
$row[] = $result->{$name};
}
} elseif (in_array($name, array('addressee', 'email_greeting', 'postal_greeting'))) {
示例8: buildBadges
/**
* Build badges parameters before actually creating badges.
*
* @param array $params
* Associated array of submitted values.
* @param CRM_Core_Form $form
*
* @return void
*/
public static function buildBadges(&$params, &$form)
{
// get name badge layout info
$layoutInfo = CRM_Badge_BAO_Layout::buildLayout($params);
// split/get actual field names from token and individual contact image URLs
$returnProperties = array();
if (!empty($layoutInfo['data']['token'])) {
foreach ($layoutInfo['data']['token'] as $index => $value) {
$element = '';
if ($value) {
$token = CRM_Utils_Token::getTokens($value);
if (key($token) == 'contact') {
$element = $token['contact'][0];
} elseif (key($token) == 'event') {
$element = $token['event'][0];
//FIX ME - we need to standardize event token names
if (substr($element, 0, 6) != 'event_') {
$element = 'event_' . $element;
}
} elseif (key($token) == 'participant') {
$element = $token['participant'][0];
}
// build returnproperties for query
$returnProperties[$element] = 1;
}
// add actual field name to row element
$layoutInfo['data']['rowElements'][$index] = $element;
}
}
// add additional required fields for query execution
$additionalFields = array('participant_register_date', 'participant_id', 'event_id', 'contact_id', 'image_URL');
foreach ($additionalFields as $field) {
$returnProperties[$field] = 1;
}
if ($form->_single) {
$queryParams = NULL;
} else {
$queryParams = $form->get('queryParams');
}
$query = new CRM_Contact_BAO_Query($queryParams, $returnProperties, NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_EVENT);
list($select, $from, $where, $having) = $query->query();
if (empty($where)) {
$where = "WHERE {$form->_componentClause}";
} else {
$where .= " AND {$form->_componentClause}";
}
$sortOrder = NULL;
if ($form->get(CRM_Utils_Sort::SORT_ORDER)) {
$sortOrder = $form->get(CRM_Utils_Sort::SORT_ORDER);
if (!empty($sortOrder)) {
$sortOrder = " ORDER BY {$sortOrder}";
}
}
$queryString = "{$select} {$from} {$where} {$having} {$sortOrder}";
$dao = CRM_Core_DAO::executeQuery($queryString);
$rows = array();
while ($dao->fetch()) {
$query->convertToPseudoNames($dao);
$rows[$dao->participant_id] = array();
foreach ($returnProperties as $key => $dontCare) {
$value = isset($dao->{$key}) ? $dao->{$key} : NULL;
// Format custom fields
if (strstr($key, 'custom_') && isset($value)) {
$value = CRM_Core_BAO_CustomField::getDisplayValue($value, substr($key, 7), $query->_options, $dao->contact_id);
}
$rows[$dao->participant_id][$key] = $value;
}
}
$eventBadgeClass = new CRM_Badge_BAO_Badge();
$eventBadgeClass->createLabels($rows, $layoutInfo);
}
示例9: exportContacts
//.........这里部分代码省略.........
if ($key) {
$returnProperties[$key] = 1;
}
}
}
if ($primary) {
$returnProperties['location_type'] = 1;
$returnProperties['im_provider'] = 1;
$returnProperties['phone_type'] = 1;
}
$session =& new CRM_Core_Session();
if ($selectAll) {
if ($primary) {
$query =& new CRM_Contact_BAO_Query($formValues, $returnProperties, $fields);
} else {
$query =& new CRM_Contact_BAO_Query($formValues, $returnProperties);
}
} else {
$params = array();
foreach ($ids as $id) {
$params[CRM_CORE_FORM_CB_PREFIX . $id] = 1;
}
if ($primary) {
$query =& new CRM_Contact_BAO_Query($params, $returnProperties, $fields, true);
} else {
$query =& new CRM_Contact_BAO_Query($params, $returnProperties, null, true);
}
}
list($select, $from, $where) = $query->query();
$queryString = "{$select} {$from} {$where}";
if ($order) {
list($field, $dir) = explode(' ', $order, 2);
$field = trim($field);
if (CRM_Utils_Array::value($field, $returnProperties)) {
$queryString .= " ORDER BY {$order}";
}
}
if (CRM_Utils_Array::value('tags', $returnProperties) || CRM_Utils_Array::value('groups', $returnProperties)) {
$queryString .= " GROUP BY civicrm_contact.id";
}
$dao =& CRM_Core_DAO::executeQuery($queryString);
$header = false;
$contactDetails = array();
while ($dao->fetch()) {
$row = array();
$validRow = false;
foreach ($dao as $key => $varValue) {
$flag = false;
foreach ($returnProperties as $propKey => $props) {
if (is_array($props)) {
foreach ($props as $propKey1 => $prop) {
foreach ($prop as $propkey2 => $prop1) {
if ($propKey1 . "-" . $propkey2 == $key) {
$flag = true;
}
}
}
}
}
if (array_key_exists($key, $returnProperties)) {
$flag = true;
}
if ($flag) {
if (isset($varValue) && $varValue != '') {
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($key)) {
$row[$key] = CRM_Core_BAO_CustomField::getDisplayValue($varValue, $cfID, $query->_options);
} else {
$row[$key] = $varValue;
}
$validRow = true;
} else {
$row[$key] = '';
}
if (!$header) {
if (isset($query->_fields[$key]['title'])) {
$headerRows[] = $query->_fields[$key]['title'];
} else {
if ($key == 'phone_type') {
$headerRows[] = 'Phone Type';
} else {
$keyArray = explode('-', $key);
$hdr = $keyArray[0] . "-" . $query->_fields[$keyArray[1]]['title'];
if (CRM_Utils_Array::value(2, $keyArray)) {
$hdr .= " " . $keyArray[2];
}
$headerRows[] = $hdr;
}
}
}
}
}
if ($validRow) {
$contactDetails[$dao->contact_id] = $row;
}
$header = true;
}
require_once 'CRM/Core/Report/Excel.php';
CRM_Core_Report_Excel::writeCSVFile(CRM_Contact_BAO_Export::getExportFileName(), $headerRows, $contactDetails);
exit;
}
示例10: postProcess
//.........这里部分代码省略.........
}
// FIXME: fix gender, prefix and postfix, so they're edible by createProfileContact()
$names['gender'] = array('newName' => 'gender_id', 'groupName' => 'gender');
$names['individual_prefix'] = array('newName' => 'prefix_id', 'groupName' => 'individual_prefix');
$names['individual_suffix'] = array('newName' => 'suffix_id', 'groupName' => 'individual_suffix');
$names['addressee'] = array('newName' => 'addressee_id', 'groupName' => 'addressee');
$names['email_greeting'] = array('newName' => 'email_greeting_id', 'groupName' => 'email_greeting');
$names['postal_greeting'] = array('newName' => 'postal_greeting_id', 'groupName' => 'postal_greeting');
CRM_Core_OptionGroup::lookupValues($submitted, $names, true);
// FIXME: fix custom fields so they're edible by createProfileContact()
$cgTree =& CRM_Core_BAO_CustomGroup::getTree($this->_contactType, $this, null, -1);
foreach ($cgTree as $key => $group) {
if (!isset($group['fields'])) {
continue;
}
foreach ($group['fields'] as $fid => $field) {
$cFields[$fid]['attributes'] = $field;
}
}
if (!isset($submitted)) {
$submitted = array();
}
foreach ($submitted as $key => $value) {
if (substr($key, 0, 7) == 'custom_') {
$fid = (int) substr($key, 7);
$htmlType = $cFields[$fid]['attributes']['html_type'];
switch ($htmlType) {
case 'File':
$customFiles[] = $fid;
unset($submitted["custom_{$fid}"]);
break;
case 'Select Country':
case 'Select State/Province':
$submitted[$key] = CRM_Core_BAO_CustomField::getDisplayValue($value, $fid, $cFields);
break;
case 'CheckBox':
case 'AdvMulti-Select':
case 'Multi-Select':
case 'Multi-Select Country':
case 'Multi-Select State/Province':
// Merge values from both contacts for multivalue fields, CRM-4385
// get the existing custom values from db.
require_once 'CRM/Core/BAO/CustomValueTable.php';
$customParams = array('entityID' => $this->_cid, $key => true);
$customfieldValues = CRM_Core_BAO_CustomValueTable::getValues($customParams);
if (CRM_Utils_array::value($key, $customfieldValues)) {
$existingValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $customfieldValues[$key]);
if (is_array($existingValue) && !empty($existingValue)) {
$mergeValue = $submmtedCustomValue = array();
if ($value) {
$submmtedCustomValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
}
//hack to remove null and duplicate values from array.
foreach (array_merge($submmtedCustomValue, $existingValue) as $k => $v) {
if ($v != '' && !in_array($v, $mergeValue)) {
$mergeValue[] = $v;
}
}
//keep state and country as array format.
//for checkbox and m-select format w/ VALUE_SEPERATOR
if (in_array($htmlType, array('CheckBox', 'Multi-Select', 'AdvMulti-Select'))) {
$submitted[$key] = CRM_Core_BAO_CustomOption::VALUE_SEPERATOR . implode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, $mergeValue) . CRM_Core_BAO_CustomOption::VALUE_SEPERATOR;
} else {
$submitted[$key] = $mergeValue;
}
}
示例11: where
/**
* generate the where clause and also the english language
* equivalent
*
* @param NULL
*
* @return void
*
* @access public
*/
function where()
{
//CRM_Core_Error::debug( 'fld', $this->_fields );
//CRM_Core_Error::debug( 'ids', $this->_ids );
foreach ($this->_ids as $id => $value) {
// Fixed for Isuue CRM 607
if ($value == null || CRM_Utils_Array::value($id, $this->_fields) === null) {
continue;
}
// fix $value here to escape sql injection attacks
$field = $this->_fields[$id];
$qillValue = CRM_Core_BAO_CustomField::getDisplayValue($value, $id, $this->_options);
if (!is_array($value)) {
$value = addslashes(trim($value));
}
switch ($field['data_type']) {
case 'String':
$sql = 'LOWER(' . CRM_CORE_BAO_CUSTOMQUERY_PREFIX . $field['id'] . '.char_data) LIKE ';
// if we are coming in from listings, for checkboxes the value is already in the right format and is NOT an array
if ($field['html_type'] == 'CheckBox' && is_array($value)) {
$this->_where[] = $sql . "'%" . implode('%', array_keys($value)) . "%'";
$this->_qill[] = ts('%1 like - %2', array(1 => $field['label'], 2 => $qillValue));
} else {
if ($field['is_search_range']) {
$this->searchRange($field['id'], $field['label'], 'char_data', $value);
} else {
$val = CRM_Utils_Type::escape(strtolower(trim($value)), 'String');
$this->_where[] = "{$sql} '%{$val}%'";
$this->_qill[] = ts('%1 like - %2', array(1 => $field['label'], 2 => $qillValue));
}
}
continue;
case 'Int':
if ($field['is_search_range']) {
$this->searchRange($field['id'], $field['label'], 'int_data', $value);
} else {
$this->_where[] = CRM_CORE_BAO_CUSTOMQUERY_PREFIX . $field['id'] . '.int_data = ' . CRM_Utils_Type::escape($value, 'Integer');
$this->_qill[] = $field['label'] . " - {$value}";
}
continue;
case 'Boolean':
$value = (int) $value;
$value = $value == 1 ? 1 : 0;
$this->_where[] = CRM_CORE_BAO_CUSTOMQUERY_PREFIX . $field['id'] . '.int_data = ' . CRM_Utils_Type::escape($value, 'Integer');
$value = $value ? ts('Yes') : ts('No');
$this->_qill[] = $field['label'] . " - {$value}";
continue;
case 'Float':
if ($field['is_search_range']) {
$this->searchRange($field['id'], $field['label'], 'float_data', $value);
} else {
$this->_where[] = CRM_CORE_BAO_CUSTOMQUERY_PREFIX . $field['id'] . '.float_data = ' . CRM_Utils_Type::escape($value, 'Float');
$this->_qill[] = $field['label'] . " - {$value}";
}
continue;
case 'Money':
if ($field['is_search_range']) {
$this->searchRange($field['id'], $field['label'], 'decimal_data', $value);
} else {
$this->_where[] = CRM_CORE_BAO_CUSTOMQUERY_PREFIX . $field['id'] . '.decimal_data = ' . CRM_Utils_Type::escape($value, 'Float');
$this->_qill[] = $field['label'] . " - {$value}";
}
continue;
case 'Memo':
$val = CRM_Utils_Type::escape(strtolower(trim($value)), 'String');
$this->_where[] = CRM_CORE_BAO_CUSTOMQUERY_PREFIX . $field['id'] . ".memo_data LIKE '%{$val}%'";
$this->_qill[] = ts('%1 like - %2', array(1 => $field['label'], 2 => $value));
continue;
case 'Date':
$fromValue = CRM_Utils_Array::value('from', $value);
$toValue = CRM_Utils_Array::value('to', $value);
if (!$fromValue && !$toValue) {
$date = CRM_Utils_Date::format($value);
if (!$date) {
continue;
}
$this->_where[] = CRM_CORE_BAO_CUSTOMQUERY_PREFIX . $field['id'] . ".date_data = {$date}";
$date = CRM_Utils_Date::format($value, '-');
$this->_qill[] = $field['label'] . ' = ' . CRM_Utils_Date::customFormat($date);
} else {
$fromDate = CRM_Utils_Date::format($fromValue);
$toDate = CRM_Utils_Date::format($toValue);
if (!$fromDate && !$toDate) {
continue;
}
if ($fromDate) {
$this->_where[] = CRM_CORE_BAO_CUSTOMQUERY_PREFIX . $field['id'] . ".date_data >= {$fromDate}";
$fromDate = CRM_Utils_Date::format($fromValue, '-');
$this->_qill[] = $field['label'] . ' >= ' . CRM_Utils_Date::customFormat($fromDate);
}
//.........这里部分代码省略.........
示例12: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
* @return void
*/
public function postProcess()
{
$fv = $this->controller->exportValues($this->_name);
$config =& CRM_Core_Config::singleton();
$locName = null;
//get the address format sequence from the config file
require_once 'CRM/Core/BAO/Preferences.php';
$sequence = CRM_Core_BAO_Preferences::value('mailing_sequence');
foreach ($sequence as $v) {
$address[$v] = 1;
}
if (array_key_exists('postal_code', $address)) {
$address['postal_code_suffix'] = 1;
}
//build the returnproperties
$returnProperties = array('display_name' => 1);
$mailingFormat = CRM_Core_BAO_Preferences::value('mailing_format');
$mailingFormatProperties = array();
if ($mailingFormat) {
$mailingFormatProperties = self::getReturnProperties($mailingFormat);
$returnProperties = array_merge($returnProperties, $mailingFormatProperties);
}
$customFormatProperties = array();
if (stristr($mailingFormat, 'custom_')) {
foreach ($mailingFormatProperties as $token => $true) {
if (substr($token, 0, 7) == 'custom_') {
if (!CRM_Utils_Array::value($token, $customFormatProperties)) {
$customFormatProperties[$token] = $mailingFormatProperties[$token];
}
}
}
}
if (!empty($customFormatProperties)) {
$returnProperties = array_merge($returnProperties, $customFormatProperties);
}
//get the contacts information
$params = array();
if (CRM_Utils_Array::value('location_type_id', $fv)) {
$locType = CRM_Core_PseudoConstant::locationType();
$locName = $locType[$fv['location_type_id']];
$location = array('location' => array("{$locName}" => $address));
$returnProperties = array_merge($returnProperties, $location);
$params[] = array('location_type', '=', array($fv['location_type_id'] => 1), 0, 0);
} else {
$returnProperties = array_merge($returnProperties, $address);
}
$rows = array();
foreach ($this->_contactIds as $key => $contactID) {
$params[] = array(CRM_Core_Form::CB_PREFIX . $contactID, '=', 1, 0, 0);
}
// fix for CRM-2651
if (CRM_Utils_Array::value('do_not_mail', $fv)) {
$params[] = array('do_not_mail', '=', 0, 0, 0);
}
// fix for CRM-2613
$params[] = array('is_deceased', '=', 0, 0, 0);
$custom = array();
foreach ($returnProperties as $name => $dontCare) {
$cfID = CRM_Core_BAO_CustomField::getKeyID($name);
if ($cfID) {
$custom[] = $cfID;
}
}
//get the total number of contacts to fetch from database.
$numberofContacts = count($this->_contactIds);
require_once 'CRM/Contact/BAO/Query.php';
$query =& new CRM_Contact_BAO_Query($params, $returnProperties);
$details = $query->apiQuery($params, $returnProperties, NULL, NULL, 0, $numberofContacts);
// also get all token values
require_once 'CRM/Utils/Hook.php';
CRM_Utils_Hook::tokenValues($details[0], $this->_contactIds);
$tokens = array();
CRM_Utils_Hook::tokens($tokens);
$tokenFields = array();
foreach ($tokens as $category => $catTokens) {
foreach ($catTokens as $token) {
$tokenFields[] = $token;
}
}
foreach ($this->_contactIds as $value) {
foreach ($custom as $cfID) {
if (isset($details[0][$value]["custom_{$cfID}"])) {
$details[0][$value]["custom_{$cfID}"] = CRM_Core_BAO_CustomField::getDisplayValue($details[0][$value]["custom_{$cfID}"], $cfID, $details[1]);
}
}
$contact = CRM_Utils_Array::value($value, $details['0']);
if (is_a($contact, 'CRM_Core_Error')) {
return null;
}
// we need to remove all the "_id"
unset($contact['contact_id']);
if ($locName && CRM_Utils_Array::value($locName, $contact)) {
// If location type is not primary, $contact contains
// one more array as "$contact[$locName] = array( values... )"
//.........这里部分代码省略.........
示例13: array
/**
* returns all the rows in the given offset and rowCount
*
* @param enum $action the action being performed
* @param int $offset the row number to start from
* @param int $rowCount the number of rows to return
* @param string $sort the sql string that describes the sort order
* @param enum $output what should the result set include (web/email/csv)
*
* @return int the total number of rows for this action
*/
function &getRows($action, $offset, $rowCount, $sort, $output = null)
{
$config =& CRM_Core_Config::singleton();
if (($output == CRM_Core_Selector_Controller::EXPORT || $output == CRM_Core_Selector_Controller::SCREEN) && $this->_formValues['radio_ts'] == 'ts_sel') {
$includeContactIds = true;
} else {
$includeContactIds = false;
}
// note the formvalues were given by CRM_Contact_Form_Search to us
// and contain the search criteria (parameters)
// note that the default action is basic
$result = $this->_query->searchQuery($offset, $rowCount, $sort, false, $includeContactIds);
// process the result of the query
$rows = array();
$permissions = array(CRM_Core_Permission::getPermission());
if (CRM_Core_Permission::check('delete contacts')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
$mapMask = $mask & 4095;
// mask value to hide map link if there are not lat/long
$gc = CRM_Core_SelectValues::groupContactStatus();
if ($this->_ufGroupID) {
require_once 'CRM/Core/PseudoConstant.php';
$locationTypes = CRM_Core_PseudoConstant::locationType();
$names = array();
static $skipFields = array('group', 'tag');
foreach ($this->_fields as $key => $field) {
if (CRM_Utils_Array::value('in_selector', $field) && !in_array($key, $skipFields)) {
if (strpos($key, '-') !== false) {
list($fieldName, $id, $type) = explode('-', $key);
if ($id == 'Primary') {
$locationTypeName = 1;
} else {
$locationTypeName = CRM_Utils_Array::value($id, $locationTypes);
if (!$locationTypeName) {
continue;
}
}
$locationTypeName = str_replace(' ', '_', $locationTypeName);
if (in_array($fieldName, array('phone', 'im', 'email'))) {
if ($type) {
$names[] = "{$locationTypeName}-{$fieldName}-{$type}";
} else {
$names[] = "{$locationTypeName}-{$fieldName}";
}
} else {
$names[] = "{$locationTypeName}-{$fieldName}";
}
} else {
$names[] = $field['name'];
}
}
}
$names[] = "status";
} else {
if (!empty($this->_returnProperties)) {
$names =& self::makeProperties($this->_returnProperties);
} else {
$names = self::$_properties;
}
}
//hack for student data (checkboxs)
$multipleSelectFields = array('preferred_communication_method' => 1);
if (CRM_Core_Permission::access('Quest')) {
require_once 'CRM/Quest/BAO/Student.php';
$multipleSelectFields = CRM_Quest_BAO_Student::$multipleSelectFields;
}
$searchType = null;
if ($this->_action == CRM_Core_Action::BASIC) {
$searchType = 'basic';
} elseif ($this->_action == CRM_Core_Action::ADVANCED) {
$searchType = 'advance';
}
require_once 'CRM/Core/OptionGroup.php';
$links =& self::links($searchType, $this->_contextMenu);
//check explicitly added contact to a Smart Group.
$groupID = CRM_Utils_Array::key('1', $this->_formValues['group']);
while ($result->fetch()) {
$row = array();
// the columns we are interested in
foreach ($names as $property) {
if ($property == 'status') {
continue;
}
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($property)) {
$row[$property] = CRM_Core_BAO_CustomField::getDisplayValue($result->{$property}, $cfID, $this->_options, $result->contact_id);
} else {
if ($multipleSelectFields && array_key_exists($property, $multipleSelectFields)) {
//.........这里部分代码省略.........
示例14: 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);
}
示例15: exportComponents
//.........这里部分代码省略.........
$tempRowCount = 100;
$count = -1;
// for CRM-3157 purposes
$i18n = CRM_Core_I18n::singleton();
$outputColumns = array();
//@todo - it would be clearer to start defining output columns earlier in this function rather than stick with return properties until this point
// as the array is not actually 'returnProperties' after the sql query is formed - making the alterations to it confusing
foreach ($returnProperties as $key => $value) {
$outputColumns[$key] = $value;
}
while (1) {
$limitQuery = "{$queryString} LIMIT {$offset}, {$rowCount}";
$dao = CRM_Core_DAO::executeQuery($limitQuery);
if ($dao->N <= 0) {
break;
}
while ($dao->fetch()) {
$count++;
$row = array();
//convert the pseudo constants
// CRM-14398 there is problem in this architecture that is not easily solved. For now we are using the cloned
// temporary iterationDAO object to get around it.
// the issue is that the convertToPseudoNames function is adding additional properties (e.g for campaign) to the DAO object
// these additional properties are NOT reset when the $dao cycles through the while loop
// nor are they overwritten as they are not in the loop
// the convertToPseudoNames will not adequately over-write them either as it doesn't 'kick-in' unless the
// relevant property is set.
// It may be that a long-term fix could be introduced there - however, it's probably necessary to figure out how to test the
// export class before tackling a better architectural fix
$iterationDAO = clone $dao;
//first loop through output columns so that we return what is required, and in same order.
foreach ($outputColumns as $field => $value) {
//we should set header only once
if ($setHeader) {
$sqlDone = FALSE;
$headerRows[] = $query->_fields[$field]['title'];
if (!$sqlDone) {
self::sqlColumnDefn($query, $sqlColumns, $field);
}
}
//build row values (data)
$fieldValue = NULL;
if (property_exists($iterationDAO, $field)) {
$fieldValue = $iterationDAO->{$field};
}
if ($field == 'id') {
$row[$field] = $iterationDAO->relationship_id;
} elseif (isset($fieldValue) && $fieldValue != '') {
//check for custom data
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($field)) {
$row[$field] = CRM_Core_BAO_CustomField::getDisplayValue($fieldValue, $cfID, $query->_options);
} else {
//normal fields with a touch of CRM-3157
$row[$field] = $fieldValue;
}
} else {
// if field is empty or null
$row[$field] = '';
}
}
if ($setHeader) {
$exportTempTable = self::createTempTable($sqlColumns);
}
//build header only once
$setHeader = FALSE;
// add component info
// write the row to a file
$componentDetails[] = $row;
// output every $tempRowCount rows
if ($count % $tempRowCount == 0) {
self::writeDetailsToTable($exportTempTable, $componentDetails, $sqlColumns);
$componentDetails = array();
}
}
$dao->free();
$offset += $rowCount;
}
if ($exportTempTable) {
self::writeDetailsToTable($exportTempTable, $componentDetails, $sqlColumns);
// do merge same address and merge same household processing
if ($mergeSameAddress) {
self::mergeSameAddress($exportTempTable, $headerRows, $sqlColumns, $exportParams);
}
// merge the records if they have corresponding households
if ($mergeSameHousehold) {
self::mergeSameHousehold($exportTempTable, $headerRows, $sqlColumns, $relationKeyMOH);
self::mergeSameHousehold($exportTempTable, $headerRows, $sqlColumns, $relationKeyHOH);
}
// call export hook
CRM_Utils_Hook::export($exportTempTable, $headerRows, $sqlColumns, $exportMode);
// now write the CSV file
self::writeCSVFromTable($exportTempTable, $headerRows, $sqlColumns, $exportMode);
// delete the export temp table and component table
$sql = "DROP TABLE IF EXISTS {$exportTempTable}";
CRM_Core_DAO::executeQuery($sql);
CRM_Utils_System::civiExit();
} else {
CRM_Core_Error::fatal(ts('No records to export'));
}
}