}
$result = array($id, 'IN', $values, 0, 0);
}
- elseif ($id == 'contact_type') {
+ elseif ($id == 'contact_type' ||
+ (!empty($values) && is_array($values) && !in_array(key($values), CRM_Core_DAO::acceptedSQLOperators(), TRUE))
+ ) {
$result = array($id, 'IN', $values, 0, $wildcard);
}
else {
case 'grant_type_id':
case 'grant_type':
- $grantTypes = CRM_Core_OptionGroup::values('grant_type');
- if (is_array($value)) {
- foreach ($value as $k => $v) {
- if ($v) {
- $val[] = $v;
- }
- }
- if (count($val) > 0) {
- // Overwrite $value so it works with an IN where statement.
- $op = 'IN';
- $value = '(' . implode(',', $val) . ')';
- }
- }
- if (!empty($val)) {
- foreach ($val as $id) {
- $names[] = CRM_Utils_Array::value($id, $grantTypes);
- }
- }
- else {
- if (!empty($value)) {
- $names[] = $grantTypes[$value];
- }
- }
-
- $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause('civicrm_grant.grant_type_id', $op, $value, "Integer");
-
- $query->_qill[$grouping][] = ts('Grant Type %2 %1', array(
- 1 => implode(' ' . ts('or') . ' ', $names),
- 2 => $op,
- ));
- $query->_tables['civicrm_grant'] = $query->_whereTables['civicrm_grant'] = 1;
-
- return;
-
case 'grant_status_id':
case 'grant_status':
- $grantStatus = CRM_Core_OptionGroup::values('grant_status');
- if (is_array($value)) {
- foreach ($value as $k => $v) {
- if ($v) {
- $val[] = $v;
- }
- }
- if (count($val) > 0) {
- // Overwrite $value so it works with an IN where statement.
- $op = 'IN';
- $value = '(' . implode(',', $val) . ')';
- }
- }
- if (!empty($val)) {
- foreach ($val as $id) {
- $names[] = CRM_Utils_Array::value($id, $grantStatus);
- }
+
+ if (strstr($name, 'type')) {
+ $name = 'grant_type_id';
+ $label = 'Grant Type(s)';
}
else {
- if (!empty($value)) {
- $names[] = $grantStatus[$value];
- }
+ $name = 'status_id';
+ $label = 'Grant Status(s)';
}
- $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause('civicrm_grant.status_id', $op, $value, "Integer");
+ $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_grant.$name", $op, $value, "Integer");
- $query->_qill[$grouping][] = ts('Grant Status %2 %1', array(
- 1 => implode(' ' . ts('or') . ' ', $names),
- 2 => $op,
- ));
+ list($qillop, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Grant_DAO_Grant', $name, $value, $op);
+ $query->_qill[$grouping][] = ts("%1 %2 %3", array(1 => $label, 2 => $qillop, 3 => $qillVal));
$query->_tables['civicrm_grant'] = $query->_whereTables['civicrm_grant'] = 1;
return;
$this->_formValues["member_test"] = 0;
}
- $specialParams = array(
- 'membership_status_id',
- 'membership_type_id',
- );
- foreach ($specialParams as $element) {
- $value = CRM_Utils_Array::value($element, $this->_formValues);
- if (!empty($value) && is_array($value)) {
- $this->_formValues[$element] = array('IN' => $value);
- }
- }
-
CRM_Core_BAO_CustomValue::fixCustomFieldValue($this->_formValues);
$this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);