Merge pull request #12460 from freephile/patch-1
[civicrm-core.git] / CRM / Export / BAO / ExportProcessor.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
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. |
13 | |
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. |
18 | |
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 +--------------------------------------------------------------------+
26 */
27
28 /**
29 *
30 * @package CRM
31 * @copyright CiviCRM LLC (c) 2004-2018
32 */
33
34 /**
35 * Class CRM_Export_BAO_ExportProcessor
36 *
37 * Class to handle logic of export.
38 */
39 class CRM_Export_BAO_ExportProcessor {
40
41 /**
42 * @var int
43 */
44 protected $queryMode;
45
46 /**
47 * @var int
48 */
49 protected $exportMode;
50
51 /**
52 * CRM_Export_BAO_ExportProcessor constructor.
53 *
54 * @param int $exportMode
55 */
56 public function __construct($exportMode) {
57 $this->setExportMode($exportMode);
58 $this->setQueryMode();
59 }
60
61 /**
62 * @return int
63 */
64 public function getQueryMode() {
65 return $this->queryMode;
66 }
67
68 /**
69 * Set the query mode based on the export mode.
70 */
71 public function setQueryMode() {
72
73 switch ($this->getExportMode()) {
74 case CRM_Export_Form_Select::CONTRIBUTE_EXPORT:
75 $this->queryMode = CRM_Contact_BAO_Query::MODE_CONTRIBUTE;
76 break;
77
78 case CRM_Export_Form_Select::EVENT_EXPORT:
79 $this->queryMode = CRM_Contact_BAO_Query::MODE_EVENT;
80 break;
81
82 case CRM_Export_Form_Select::MEMBER_EXPORT:
83 $this->queryMode = CRM_Contact_BAO_Query::MODE_MEMBER;
84 break;
85
86 case CRM_Export_Form_Select::PLEDGE_EXPORT:
87 $this->queryMode = CRM_Contact_BAO_Query::MODE_PLEDGE;
88 break;
89
90 case CRM_Export_Form_Select::CASE_EXPORT:
91 $this->queryMode = CRM_Contact_BAO_Query::MODE_CASE;
92 break;
93
94 case CRM_Export_Form_Select::GRANT_EXPORT:
95 $this->queryMode = CRM_Contact_BAO_Query::MODE_GRANT;
96 break;
97
98 case CRM_Export_Form_Select::ACTIVITY_EXPORT:
99 $this->queryMode = CRM_Contact_BAO_Query::MODE_ACTIVITY;
100 break;
101
102 default:
103 $this->queryMode = CRM_Contact_BAO_Query::MODE_CONTACTS;
104 }
105 }
106
107 /**
108 * @return int
109 */
110 public function getExportMode() {
111 return $this->exportMode;
112 }
113
114 /**
115 * @param int $exportMode
116 */
117 public function setExportMode($exportMode) {
118 $this->exportMode = $exportMode;
119 }
120
121 }