// CRM-7675
const EXPORT_ROW_COUNT = 10000;
+ /**
+ * Get Querymode based on ExportMode
+ *
+ * @param int $exportMode
+ * Export mode.
+ *
+ * return string Querymode
+ */
+ public function getQueryMode($exportMode) {
+ switch ($exportMode) {
+ case CRM_Export_Form_Select::CONTRIBUTE_EXPORT:
+ $queryMode = CRM_Contact_BAO_Query::MODE_CONTRIBUTE;
+ break;
+
+ case CRM_Export_Form_Select::EVENT_EXPORT:
+ $queryMode = CRM_Contact_BAO_Query::MODE_EVENT;
+ break;
+
+ case CRM_Export_Form_Select::MEMBER_EXPORT:
+ $queryMode = CRM_Contact_BAO_Query::MODE_MEMBER;
+ break;
+
+ case CRM_Export_Form_Select::PLEDGE_EXPORT:
+ $queryMode = CRM_Contact_BAO_Query::MODE_PLEDGE;
+ break;
+
+ case CRM_Export_Form_Select::CASE_EXPORT:
+ $queryMode = CRM_Contact_BAO_Query::MODE_CASE;
+ break;
+
+ case CRM_Export_Form_Select::GRANT_EXPORT:
+ $queryMode = CRM_Contact_BAO_Query::MODE_GRANT;
+ break;
+
+ case CRM_Export_Form_Select::ACTIVITY_EXPORT:
+ $queryMode = CRM_Contact_BAO_Query::MODE_ACTIVITY;
+ break;
+ }
+ return $queryMode;
+ }
+
+ /**
+ * Get default return property for export based on mode
+ *
+ * @param int $exportMode
+ * Export mode.
+ * return returnProperties
+ */
+ function defultReturnProperty($exportMode) {
+ // hack to add default returnproperty based on export mode
+ if ($exportMode == CRM_Export_Form_Select::CONTRIBUTE_EXPORT) {
+ $returnProperties['contribution_id'] = 1;
+ }
+ elseif ($exportMode == CRM_Export_Form_Select::EVENT_EXPORT) {
+ $returnProperties['participant_id'] = 1;
+ if (!empty($returnProperties['participant_role'])) {
+ unset($returnProperties['participant_role']);
+ $returnProperties['participant_role_id'] = 1;
+ }
+ }
+ elseif ($exportMode == CRM_Export_Form_Select::MEMBER_EXPORT) {
+ $returnProperties['membership_id'] = 1;
+ }
+ elseif ($exportMode == CRM_Export_Form_Select::PLEDGE_EXPORT) {
+ $returnProperties['pledge_id'] = 1;
+ }
+ elseif ($exportMode == CRM_Export_Form_Select::CASE_EXPORT) {
+ $returnProperties['case_id'] = 1;
+ }
+ elseif ($exportMode == CRM_Export_Form_Select::GRANT_EXPORT) {
+ $returnProperties['grant_id'] = 1;
+ }
+ elseif ($exportMode == CRM_Export_Form_Select::ACTIVITY_EXPORT) {
+ $returnProperties['activity_id'] = 1;
+ }
+ return $returnProperties;
+ }
+
+ /**
+ * Get Export component
+ *
+ * @param int $exportMode
+ * Export mode.
+ *
+ * return string component
+ */
+ public function exportComponent($exportMode) {
+ switch ($exportMode) {
+ case CRM_Export_Form_Select::CONTRIBUTE_EXPORT:
+ $component = 'civicrm_contribution';
+ break;
+
+ case CRM_Export_Form_Select::EVENT_EXPORT:
+ $component = 'civicrm_participant';
+ break;
+
+ case CRM_Export_Form_Select::MEMBER_EXPORT:
+ $component = 'civicrm_membership';
+ break;
+
+ case CRM_Export_Form_Select::PLEDGE_EXPORT:
+ $component = 'civicrm_pledge';
+ break;
+
+ case CRM_Export_Form_Select::GRANT_EXPORT:
+ $component = 'civicrm_grant';
+ break;
+ }
+ return $component;
+ }
+
/**
* Get the list the export fields.
*
);
$queryMode = CRM_Contact_BAO_Query::MODE_CONTACTS;
- switch ($exportMode) {
- case CRM_Export_Form_Select::CONTRIBUTE_EXPORT:
- $queryMode = CRM_Contact_BAO_Query::MODE_CONTRIBUTE;
- break;
-
- case CRM_Export_Form_Select::EVENT_EXPORT:
- $queryMode = CRM_Contact_BAO_Query::MODE_EVENT;
- break;
-
- case CRM_Export_Form_Select::MEMBER_EXPORT:
- $queryMode = CRM_Contact_BAO_Query::MODE_MEMBER;
- break;
-
- case CRM_Export_Form_Select::PLEDGE_EXPORT:
- $queryMode = CRM_Contact_BAO_Query::MODE_PLEDGE;
- break;
-
- case CRM_Export_Form_Select::CASE_EXPORT:
- $queryMode = CRM_Contact_BAO_Query::MODE_CASE;
- break;
-
- case CRM_Export_Form_Select::GRANT_EXPORT:
- $queryMode = CRM_Contact_BAO_Query::MODE_GRANT;
- break;
-
- case CRM_Export_Form_Select::ACTIVITY_EXPORT:
- $queryMode = CRM_Contact_BAO_Query::MODE_ACTIVITY;
- break;
- }
+ $queryMode = self::getQueryMode($exportMode);
+
if ($fields) {
//construct return properties
$locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
}
}
}
-
- // hack to add default returnproperty based on export mode
- if ($exportMode == CRM_Export_Form_Select::CONTRIBUTE_EXPORT) {
- $returnProperties['contribution_id'] = 1;
- }
- elseif ($exportMode == CRM_Export_Form_Select::EVENT_EXPORT) {
- $returnProperties['participant_id'] = 1;
- if (!empty($returnProperties['participant_role'])) {
- unset($returnProperties['participant_role']);
- $returnProperties['participant_role_id'] = 1;
- }
- }
- elseif ($exportMode == CRM_Export_Form_Select::MEMBER_EXPORT) {
- $returnProperties['membership_id'] = 1;
- }
- elseif ($exportMode == CRM_Export_Form_Select::PLEDGE_EXPORT) {
- $returnProperties['pledge_id'] = 1;
- }
- elseif ($exportMode == CRM_Export_Form_Select::CASE_EXPORT) {
- $returnProperties['case_id'] = 1;
- }
- elseif ($exportMode == CRM_Export_Form_Select::GRANT_EXPORT) {
- $returnProperties['grant_id'] = 1;
- }
- elseif ($exportMode == CRM_Export_Form_Select::ACTIVITY_EXPORT) {
- $returnProperties['activity_id'] = 1;
- }
- }
+ self::defultReturnProperty($exportMode);
else {
$primary = TRUE;
$fields = CRM_Contact_BAO_Contact::exportableFields('All', TRUE, TRUE);
}
}
else {
- switch ($exportMode) {
- case CRM_Export_Form_Select::CONTRIBUTE_EXPORT:
- $component = 'civicrm_contribution';
- break;
-
- case CRM_Export_Form_Select::EVENT_EXPORT:
- $component = 'civicrm_participant';
- break;
-
- case CRM_Export_Form_Select::MEMBER_EXPORT:
- $component = 'civicrm_membership';
- break;
-
- case CRM_Export_Form_Select::PLEDGE_EXPORT:
- $component = 'civicrm_pledge';
- break;
-
- case CRM_Export_Form_Select::GRANT_EXPORT:
- $component = 'civicrm_grant';
- break;
- }
+ self::exportComponent($exportMode);
if ($exportMode == CRM_Export_Form_Select::CASE_EXPORT) {
$relIDs = CRM_Case_BAO_Case::retrieveContactIdsByCaseId($ids);