Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php
  2. index c8818f4..52c5d8c 100644
  3. --- a/CRM/Contact/BAO/Query.php
  4. +++ b/CRM/Contact/BAO/Query.php
  5. @@ -1601,6 +1601,10 @@ class CRM_Contact_BAO_Query {
  6. }
  7. }
  8.  
  9. + if(array_key_exists('op', $formValues)) {
  10. + $sqloperator = CRM_Report_Form::getSQLOperator($formValues['op']);
  11. + }
  12. +
  13. foreach ($formValues as $id => $values) {
  14. if (self::isAlreadyProcessedForQueryFormat($values)) {
  15. $params[] = $values;
  16. @@ -1621,7 +1625,8 @@ class CRM_Contact_BAO_Query {
  17. $subType[$types[1]] = $types[1];
  18. }
  19. }
  20. - $params[] = array('contact_type', 'IN', $contactType, 0, 0);
  21. + $operatorSQL = !empty($sqloperator) ? 'NOT IN' : 'IN';
  22. + $params[] = array('contact_type', $operatorSQL, $contactType, 0, 0);
  23. if ($subType) {
  24. $params[] = array('contact_sub_type', 'IN', $subType, 0, 0);
  25. }
  26. @@ -2042,15 +2047,35 @@ class CRM_Contact_BAO_Query {
  27. $this->includeContactIds();
  28. if (!empty($this->_params)) {
  29. foreach (array_keys($this->_params) as $id) {
  30. - if (empty($this->_params[$id][0])) {
  31. - continue;
  32. + if ($this->_params[$id][0] == 'op') {
  33. + $operatorFound = TRUE;
  34. + $operatorSQL = CRM_Report_Form::getSQLOperator($this->_params[$id][2]);
  35. }
  36. - // check for both id and contact_id
  37. - if ($this->_params[$id][0] == 'id' || $this->_params[$id][0] == 'contact_id') {
  38. - $this->_where[0][] = self::buildClause("contact_a.id", $this->_params[$id][1], $this->_params[$id][2]);
  39. + }
  40. + if(isset($operatorFound)) {
  41. + foreach ($this->_params as $key => $value) {
  42. + $value['operator'] = $operatorSQL;
  43. + // check for both id and contact_id
  44. + if ($value[0] == 'id' || $value[0] == 'contact_id') {
  45. + $this->_where[0][] = self::buildClause("contact_a.id", $value[1], $value[2]);
  46. + }
  47. + else {
  48. + $this->whereClauseSingle($value, $apiEntity);
  49. + }
  50. }
  51. - else {
  52. - $this->whereClauseSingle($this->_params[$id], $apiEntity);
  53. + }
  54. + else {
  55. + foreach (array_keys($this->_params) as $id) {
  56. + if (empty($this->_params[$id][0])) {
  57. + continue;
  58. + }
  59. + // check for both id and contact_id
  60. + if ($this->_params[$id][0] == 'id' || $this->_params[$id][0] == 'contact_id') {
  61. + $this->_where[0][] = self::buildClause("contact_a.id", $this->_params[$id][1], $this->_params[$id][2]);
  62. + }
  63. + else {
  64. + $this->whereClauseSingle($this->_params[$id], $apiEntity);
  65. + }
  66. }
  67. }
  68.  
  69. @@ -2898,7 +2923,8 @@ class CRM_Contact_BAO_Query {
  70. */
  71. public function contactSubType(&$values) {
  72. list($name, $op, $value, $grouping, $wildcard) = $values;
  73. - $this->includeContactSubTypes($value, $grouping, $op);
  74. + $operatorForQuery = !empty($values['operator']) ? $values['operator'] : $op;
  75. + $this->includeContactSubTypes($value, $grouping, $operatorForQuery);
  76. }
  77.  
  78. /**
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement