Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php
- index c8818f4..52c5d8c 100644
- --- a/CRM/Contact/BAO/Query.php
- +++ b/CRM/Contact/BAO/Query.php
- @@ -1601,6 +1601,10 @@ class CRM_Contact_BAO_Query {
- }
- }
- + if(array_key_exists('op', $formValues)) {
- + $sqloperator = CRM_Report_Form::getSQLOperator($formValues['op']);
- + }
- +
- foreach ($formValues as $id => $values) {
- if (self::isAlreadyProcessedForQueryFormat($values)) {
- $params[] = $values;
- @@ -1621,7 +1625,8 @@ class CRM_Contact_BAO_Query {
- $subType[$types[1]] = $types[1];
- }
- }
- - $params[] = array('contact_type', 'IN', $contactType, 0, 0);
- + $operatorSQL = !empty($sqloperator) ? 'NOT IN' : 'IN';
- + $params[] = array('contact_type', $operatorSQL, $contactType, 0, 0);
- if ($subType) {
- $params[] = array('contact_sub_type', 'IN', $subType, 0, 0);
- }
- @@ -2042,15 +2047,35 @@ class CRM_Contact_BAO_Query {
- $this->includeContactIds();
- if (!empty($this->_params)) {
- foreach (array_keys($this->_params) as $id) {
- - if (empty($this->_params[$id][0])) {
- - continue;
- + if ($this->_params[$id][0] == 'op') {
- + $operatorFound = TRUE;
- + $operatorSQL = CRM_Report_Form::getSQLOperator($this->_params[$id][2]);
- }
- - // check for both id and contact_id
- - if ($this->_params[$id][0] == 'id' || $this->_params[$id][0] == 'contact_id') {
- - $this->_where[0][] = self::buildClause("contact_a.id", $this->_params[$id][1], $this->_params[$id][2]);
- + }
- + if(isset($operatorFound)) {
- + foreach ($this->_params as $key => $value) {
- + $value['operator'] = $operatorSQL;
- + // check for both id and contact_id
- + if ($value[0] == 'id' || $value[0] == 'contact_id') {
- + $this->_where[0][] = self::buildClause("contact_a.id", $value[1], $value[2]);
- + }
- + else {
- + $this->whereClauseSingle($value, $apiEntity);
- + }
- }
- - else {
- - $this->whereClauseSingle($this->_params[$id], $apiEntity);
- + }
- + else {
- + foreach (array_keys($this->_params) as $id) {
- + if (empty($this->_params[$id][0])) {
- + continue;
- + }
- + // check for both id and contact_id
- + if ($this->_params[$id][0] == 'id' || $this->_params[$id][0] == 'contact_id') {
- + $this->_where[0][] = self::buildClause("contact_a.id", $this->_params[$id][1], $this->_params[$id][2]);
- + }
- + else {
- + $this->whereClauseSingle($this->_params[$id], $apiEntity);
- + }
- }
- }
- @@ -2898,7 +2923,8 @@ class CRM_Contact_BAO_Query {
- */
- public function contactSubType(&$values) {
- list($name, $op, $value, $grouping, $wildcard) = $values;
- - $this->includeContactSubTypes($value, $grouping, $op);
- + $operatorForQuery = !empty($values['operator']) ? $values['operator'] : $op;
- + $this->includeContactSubTypes($value, $grouping, $operatorForQuery);
- }
- /**
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement