3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2018
35 * Class CRM_Export_BAO_ExportProcessor
37 * Class to handle logic of export.
39 class CRM_Export_BAO_ExportProcessor
{
49 protected $exportMode;
52 * Array of fields in the main query.
56 protected $queryFields = [];
63 protected $queryOperator;
66 * CRM_Export_BAO_ExportProcessor constructor.
68 * @param int $exportMode
69 * @param string $queryOperator
71 public function __construct($exportMode, $queryOperator) {
72 $this->setExportMode($exportMode);
73 $this->setQueryMode();
74 $this->setQueryOperator($queryOperator);
80 public function getQueryOperator() {
81 return $this->queryOperator
;
85 * @param string $queryOperator
87 public function setQueryOperator($queryOperator) {
88 $this->queryOperator
= $queryOperator;
94 public function getQueryFields() {
95 return $this->queryFields
;
99 * @param array $queryFields
101 public function setQueryFields($queryFields) {
102 $this->queryFields
= $queryFields;
108 public function getQueryMode() {
109 return $this->queryMode
;
113 * Set the query mode based on the export mode.
115 public function setQueryMode() {
117 switch ($this->getExportMode()) {
118 case CRM_Export_Form_Select
::CONTRIBUTE_EXPORT
:
119 $this->queryMode
= CRM_Contact_BAO_Query
::MODE_CONTRIBUTE
;
122 case CRM_Export_Form_Select
::EVENT_EXPORT
:
123 $this->queryMode
= CRM_Contact_BAO_Query
::MODE_EVENT
;
126 case CRM_Export_Form_Select
::MEMBER_EXPORT
:
127 $this->queryMode
= CRM_Contact_BAO_Query
::MODE_MEMBER
;
130 case CRM_Export_Form_Select
::PLEDGE_EXPORT
:
131 $this->queryMode
= CRM_Contact_BAO_Query
::MODE_PLEDGE
;
134 case CRM_Export_Form_Select
::CASE_EXPORT
:
135 $this->queryMode
= CRM_Contact_BAO_Query
::MODE_CASE
;
138 case CRM_Export_Form_Select
::GRANT_EXPORT
:
139 $this->queryMode
= CRM_Contact_BAO_Query
::MODE_GRANT
;
142 case CRM_Export_Form_Select
::ACTIVITY_EXPORT
:
143 $this->queryMode
= CRM_Contact_BAO_Query
::MODE_ACTIVITY
;
147 $this->queryMode
= CRM_Contact_BAO_Query
::MODE_CONTACTS
;
154 public function getExportMode() {
155 return $this->exportMode
;
159 * @param int $exportMode
161 public function setExportMode($exportMode) {
162 $this->exportMode
= $exportMode;
168 * @param $returnProperties
171 public function runQuery($params, $order, $returnProperties) {
172 $query = new CRM_Contact_BAO_Query($params, $returnProperties, NULL,
173 FALSE, FALSE, $this->getQueryMode(),
174 FALSE, TRUE, TRUE, NULL, $this->getQueryOperator()
179 $query->_sort
= $order;
180 list($select, $from, $where, $having) = $query->query();
181 $this->setQueryFields($query->_fields
);
182 return array($query, $select, $from, $where, $having);