$queryMode = $relationField = NULL;
$allCampaigns = array();
- $exportCampaign = FALSE;
$phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
$imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
elseif ($fieldName == 'im') {
$imProviderId = CRM_Utils_Array::value(3, $value);
}
- elseif (substr($fieldName, -8) == 'campaign') {
- $exportCampaign = TRUE;
- }
if (array_key_exists($relationshipTypes, $contactRelationshipTypes)) {
if (CRM_Utils_Array::value(2, $value)) {
}
else {
$returnProperties[$fieldName] = 1;
-
- //campaign field export.
- if (substr($fieldName, -8) == 'campaign') {
- $fldNames = explode('_', $fieldName);
- $returnProperties["{$fldNames[0]}_campaign_id"] = 1;
- }
}
}
}
if ($queryMode != CRM_Contact_BAO_Query::MODE_CONTACTS) {
$componentReturnProperties = CRM_Contact_BAO_Query::defaultReturnProperties($queryMode);
-
- $campaignReturnProperties = array();;
- foreach ($componentReturnProperties as $fld => $true) {
- $campaignReturnProperties[$fld] = $true;
- if (substr($fld, -11) == 'campaign_id') {
- $exportCampaign = TRUE;
- $campaignReturnProperties[substr($fld, 0, -3)] = 1;
- }
- }
- $componentReturnProperties = $campaignReturnProperties;
-
$returnProperties = array_merge($returnProperties, $componentReturnProperties);
if (!empty($extraReturnProperties)) {
}
}
+ // CRM-13982 - check if is deleted
+ $excludeTrashed = TRUE;
+ foreach ($params as $value) {
+ if ($value[0] == 'contact_is_deleted') {
+ $excludeTrashed = FALSE;
+ }
+ }
+ if (empty($where) && $excludeTrashed) {
+ $where = "WHERE contact_a.is_deleted != 1";
+ }
+ elseif ($excludeTrashed) {
+ $where .= " AND contact_a.is_deleted != 1";
+ }
+
$queryString = "$select $from $where $having";
$groupBy = "";
$groupBy = " GROUP BY contact_a.id";
}
+ switch ($exportMode) {
+ case CRM_Export_Form_Select::CONTRIBUTE_EXPORT:
+ $groupBy = 'GROUP BY civicrm_contribution.id';
+ break;
+
+ case CRM_Export_Form_Select::EVENT_EXPORT:
+ $groupBy = 'GROUP BY civicrm_participant.id';
+ break;
+
+ case CRM_Export_Form_Select::MEMBER_EXPORT:
+ $groupBy = " GROUP BY civicrm_membership.id";
+ break;
+ }
+
if ($queryMode & CRM_Contact_BAO_Query::MODE_ACTIVITY) {
$groupBy = " GROUP BY civicrm_activity.id ";
}
$nullContributionDetails = array_fill_keys(array_keys($paymentHeaders), NULL);
}
+ // Split campaign into 2 fields for id and title
+ $campaignReturnProperties = array();
+ foreach ($returnProperties as $fld => $true) {
+ $campaignReturnProperties[$fld] = $true;
+ if (substr($fld, -11) == 'campaign_id') {
+ $exportCampaign = TRUE;
+ $campaignReturnProperties[substr($fld, 0, -3)] = 1;
+ }
+ }
+ $returnProperties = $campaignReturnProperties;
//get all campaigns.
- if ($exportCampaign) {
+ if (isset($exportCampaign)) {
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
}
$count++;
$row = array();
- if ($exportMode == CRM_Export_Form_Select::CONTACT_EXPORT) {
- //convert the pseudo constants
- $query->convertToPseudoNames($dao);
- }
+ //convert the pseudo constants
+ $query->convertToPseudoNames($dao);
//first loop through returnproperties so that we return what is required, and in same order.
$relationshipField = 0;
//we should set header only once
if ($setHeader) {
$sqlDone = FALSE;
- if (isset($query->_fields[$field]['title'])) {
+ // Split campaign into 2 fields for id and title
+ if (substr($field, -8) == 'campaign') {
+ $headerRows[] = ts('Campaign Title');
+ }
+ elseif (substr($field, -11) == 'campaign_id') {
+ $headerRows[] = ts('Campaign ID');
+ }
+ elseif (isset($query->_fields[$field]['title'])) {
$headerRows[] = $query->_fields[$field]['title'];
}
elseif ($field == 'phone_type_id') {
elseif ($field == 'pledge_next_pay_amount') {
$row[$field] = $dao->pledge_next_pay_amount + $dao->pledge_outstanding_amount;
}
- elseif (in_array(substr($field, 0, -3), array('gender', 'prefix', 'suffix'))) {
+ elseif (in_array(substr($field, 0, -3), array('gender', 'prefix', 'suffix', 'communication_style'))) {
$row[$field] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', $field, $dao->$field);
}
elseif (is_array($value) && $field == 'location') {
$fieldValue = CRM_Utils_Array::value($relationValue, $imProviders);
}
}
+ // CRM-13995
+ elseif (is_object($relDAO) && in_array($relationField, array(
+ 'email_greeting', 'postal_greeting', 'addressee'))) {
+ //special case for greeting replacement
+ $fldValue = "{$relationField}_display";
+ $fieldValue = $relDAO->$fldValue;
+ }
+ elseif ( is_object($relDAO) && $relationField == 'state_province' ) {
+ $fieldValue = CRM_Core_PseudoConstant::stateProvince($relDAO->state_province_id);
+ }
+ elseif ( is_object($relDAO) && $relationField == 'country' ) {
+ $fieldValue = CRM_Core_PseudoConstant::country($relDAO->country_id);
+ }
else {
$fieldValue = '';
}
$field = $field . '_';
+
if (is_object($relDAO) && $relationField == 'id') {
$row[$field . $relationField] = $relDAO->contact_id;
- } else if ( is_object( $relDAO ) && is_array( $relationValue ) && $relationField == 'location' ) {
+ }
+ elseif ( is_object( $relDAO ) && is_array( $relationValue ) && $relationField == 'location' ) {
foreach ($relationValue as $ltype => $val) {
foreach (array_keys($val) as $fld) {
$type = explode('-', $fld);
$relationQuery[$field]->_options
);
}
- elseif (in_array($relationField, array(
- 'email_greeting', 'postal_greeting', 'addressee'))) {
- //special case for greeting replacement
- $fldValue = "{$relationField}_display";
- $row[$field . $relationField] = $relDAO->$fldValue;
- }
else {
//normal relationship fields
// CRM-3157: localise country, region (both have ‘country’ context) and state_province (‘province’ context)
case 'gender':
case 'preferred_communication_method':
case 'preferred_mail_format':
+ case 'communication_style':
$row[$field] = $i18n->crm_translate($fieldValue);
break;
* Function to handle import error file creation.
*
*/
- function invoke() {
+ static function invoke() {
$type = CRM_Utils_Request::retrieve('type', 'Positive', CRM_Core_DAO::$_nullObject);
$parserName = CRM_Utils_Request::retrieve('parser', 'String', CRM_Core_DAO::$_nullObject);
if (empty($parserName) || empty($type)) {
CRM_Utils_System::civiExit();
}
- function exportCustom($customSearchClass, $formValues, $order) {
+ static function exportCustom($customSearchClass, $formValues, $order) {
$ext = CRM_Extension_System::singleton()->getMapper();
if (!$ext->isExtensionClass($customSearchClass)) {
require_once (str_replace('_', DIRECTORY_SEPARATOR, $customSearchClass) . '.php');
}
else {
if (substr($fieldName, -3, 3) == '_id') {
- $sqlColumns[$fieldName] = "$fieldName varchar(16)";
+ // for trxn_id and its variants use a longer buffer
+ // to accomodate different systems - CRM-13739
+ static $notRealIDFields = NULL;
+ if ($notRealIDFields == NULL) {
+ $notRealIDFields = array( 'trxn_id', 'componentpaymentfield_transaction_id' );
+ }
+
+ if (in_array($fieldName, $notRealIDFields)) {
+ $sqlColumns[$fieldName] = "$fieldName varchar(255)";
+ }
+ else {
+ $sqlColumns[$fieldName] = "$fieldName varchar(16)";
+ }
}
else {
$changeFields = array(
* or have no street address
*
*/
- function postalMailingFormat($exportTempTable, &$headerRows, &$sqlColumns, $exportParams) {
+ static function postalMailingFormat($exportTempTable, &$headerRows, &$sqlColumns, $exportParams) {
$whereClause = array();
if (array_key_exists('is_deceased', $sqlColumns)) {