setExportMode($exportMode); $this->setQueryMode(); $this->setQueryOperator($queryOperator); } /** * @return string */ public function getQueryOperator() { return $this->queryOperator; } /** * @param string $queryOperator */ public function setQueryOperator($queryOperator) { $this->queryOperator = $queryOperator; } /** * @return array */ public function getQueryFields() { return $this->queryFields; } /** * @param array $queryFields */ public function setQueryFields($queryFields) { $this->queryFields = $queryFields; } /** * @return int */ public function getQueryMode() { return $this->queryMode; } /** * Set the query mode based on the export mode. */ public function setQueryMode() { switch ($this->getExportMode()) { case CRM_Export_Form_Select::CONTRIBUTE_EXPORT: $this->queryMode = CRM_Contact_BAO_Query::MODE_CONTRIBUTE; break; case CRM_Export_Form_Select::EVENT_EXPORT: $this->queryMode = CRM_Contact_BAO_Query::MODE_EVENT; break; case CRM_Export_Form_Select::MEMBER_EXPORT: $this->queryMode = CRM_Contact_BAO_Query::MODE_MEMBER; break; case CRM_Export_Form_Select::PLEDGE_EXPORT: $this->queryMode = CRM_Contact_BAO_Query::MODE_PLEDGE; break; case CRM_Export_Form_Select::CASE_EXPORT: $this->queryMode = CRM_Contact_BAO_Query::MODE_CASE; break; case CRM_Export_Form_Select::GRANT_EXPORT: $this->queryMode = CRM_Contact_BAO_Query::MODE_GRANT; break; case CRM_Export_Form_Select::ACTIVITY_EXPORT: $this->queryMode = CRM_Contact_BAO_Query::MODE_ACTIVITY; break; default: $this->queryMode = CRM_Contact_BAO_Query::MODE_CONTACTS; } } /** * @return int */ public function getExportMode() { return $this->exportMode; } /** * @param int $exportMode */ public function setExportMode($exportMode) { $this->exportMode = $exportMode; } /** * @param $params * @param $order * @param $returnProperties * @return array */ public function runQuery($params, $order, $returnProperties) { $query = new CRM_Contact_BAO_Query($params, $returnProperties, NULL, FALSE, FALSE, $this->getQueryMode(), FALSE, TRUE, TRUE, NULL, $this->getQueryOperator() ); //sort by state //CRM-15301 $query->_sort = $order; list($select, $from, $where, $having) = $query->query(); $this->setQueryFields($query->_fields); return array($query, $select, $from, $where, $having); } }