if (!array_key_exists($cfID, $this->_cfIDs)) {
$this->_cfIDs[$cfID] = array();
}
+ // Set wildcard value based on "and/or" selection
+ foreach ($this->_params as $key => $param) {
+ if ($param[0] == $value[0] . '_operator') {
+ $value[4] = $param[2] == 'or';
+ break;
+ }
+ }
$this->_cfIDs[$cfID][] = $value;
}
$this->_where[0][] = "contact_a.id IN ({$idList})";
}
else {
- $this->_where[0][] = "contact_a.id {$this->_params[$id][1]} {$this->_params[$id][2]}";
+ $this->_where[0][] = self::buildClause("contact_a.id", "{$this->_params[$id][1]}", "{$this->_params[$id][2]}");
}
}
else {
$name, $op, $value, $grouping,
CRM_Core_PseudoConstant::worldRegion(),
$field,
- ts('World Region')
+ ts('World Region'),
+ 'Positive',
+ TRUE
);
}
elseif ($name === 'birth_date') {
}
else {
$type = array_pop($clause);
- $this->_where[$grouping][] = "contact_a.contact_type $op $type";
+ $this->_where[$grouping][] = self::buildClause("contact_a.contact_type", $op, $contactType);
}
$this->_qill[$grouping][] = ts('Contact Type') . ' - ' . implode(' ' . ts('or') . ' ', $quill);
return $clause;
case 'IS EMPTY':
- $clause = " ( $field IS NULL OR $field = '' ) ";
+ $clause = " (NULLIF($field, '') IS NULL) ";
return $clause;
case 'IS NOT EMPTY':
- $clause = " ( $field IS NOT NULL AND $field <> '' ) ";
+ $clause = " (NULLIF($field, '') IS NOT NULL) ";
return $clause;
case 'IN':
$useIDsOnly = FALSE
) {
- if (!empty($selectValues) && !empty($selectValues[$value])) {
+ if (!empty($selectValues) && !is_array($value) && !empty($selectValues[$value])) {
$qill = $selectValues[$value];
}
else {
$qill = $selectValues[(int ) $value];
}
elseif ($op == 'IN' || $op == 'NOT IN') {
- $values = self::parseSearchBuilderString($value);
- if (is_array($values)) {
+ if (is_array($value)) {
$intVals = array();
$newValues = array();
- foreach ($values as $v) {
- $intVals[] = (int) $v;
- $newValues[] = $selectValues[(int ) $v];
+ foreach ($value as $k => $v) {
+ $intVals[$k] = (int) $k;
+ $newValues[] = $selectValues[(int) $k];
}
$value = (in_array($name, $pseudoFields)) ? $intVals : $newValues;
if ($tableName == 'civicrm_contact') {
$wc = "contact_a.$fieldName";
}
+ else {
+ $wc = "$tableName.id";
+ }
}
else {
$wc = self::caseImportant($op) ? "LOWER({$field['where']})" : "{$field['where']}";