}
}
+ if (in_array($name, array('prefix_id', 'suffix_id', 'gender_id'))) {
+ if (CRM_Utils_Array::value($field['pseudoconstant']['optionGroupName'], $this->_returnProperties)) {
+ $makeException = TRUE;
+ }
+ }
+
$cfID = CRM_Core_BAO_CustomField::getKeyID($name);
if (
CRM_Utils_Array::value($name, $this->_paramLookup) ||
case 'group':
$this->group($values);
return;
+
case 'group_type':
// so we resolve this into a list of groups & proceed as if they had been
// handed in
$this->_paramLookup['group'][0][2] = $values[2] = $this->getGroupsFromTypeCriteria($value);
$this->group($values);
return;
- // case tag comes from find contacts
+ // case tag comes from find contacts
case 'tag_search':
$this->tagSearch($values);
return;
case 'activity_campaign_id':
case 'activity_engagement_level':
case 'activity_id':
+ case 'activity_result':
case 'source_contact':
CRM_Activity_BAO_Query::whereClauseSingle($values, $this);
return;
$op = 'LIKE';
}
$wc = self::caseImportant($op) ? "LOWER(contact_a.organization_name)" : "contact_a.organization_name";
- $this->_where[$grouping][] = self::buildClause($wc, $op,
- "'$value' AND contact_a.contact_type ='Individual'"
+ $ceWhereClause = self::buildClause($wc, $op,
+ $value
);
+ $ceWhereClause .= " AND contact_a.contact_type = 'Individual'";
+ $this->_where[$grouping][] = $ceWhereClause;
$this->_qill[$grouping][] = "$field[title] $op \"$value\"";
}
elseif ($name === 'email_greeting') {
}
$wc = 'civicrm_website.url';
- $this->_where[$grouping][] = self::buildClause($wc, $op, "'$value'");
+ $this->_where[$grouping][] = $d = self::buildClause($wc, $op, $value);
$this->_qill[$grouping][] = "$field[title] $op \"$value\"";
}
elseif ($name === 'contact_is_deleted') {
if (!$skipGroup) {
$gcTable = "`civicrm_group_contact-{$groupIds}`";
- $this->_tables[$gcTable] = $this->_whereTables[$gcTable] = " LEFT JOIN civicrm_group_contact {$gcTable} ON contact_a.id = {$gcTable}.contact_id ";
+ $this->_tables[$gcTable] = $this->_whereTables[$gcTable] = " LEFT JOIN civicrm_group_contact {$gcTable} ON ( contact_a.id = {$gcTable}.contact_id AND {$gcTable}.group_id $op ( $groupIds ) )";
}
$qill = ts('Contacts %1', array(1 => $op));
*/
function phone_numeric(&$values) {
list($name, $op, $value, $grouping, $wildcard) = $values;
- // Strip non-numeric characters
- $number = preg_replace('/[^\d]/', '', $value);
+ // Strip non-numeric characters; allow wildcards
+ $number = preg_replace('/[^\d%]/', '', $value);
if ($number) {
+ if ( strpos($number, '%') === FALSE ) {
+ $number = "%$number%";
+ }
+
$this->_qill[$grouping][] = ts('Phone number contains') . " $number";
- $this->_where[$grouping][] = self::buildClause('civicrm_phone.phone_numeric', 'LIKE', "%$number%", 'String');
+ $this->_where[$grouping][] = self::buildClause('civicrm_phone.phone_numeric', 'LIKE', "$number", 'String');
$this->_tables['civicrm_phone'] = $this->_whereTables['civicrm_phone'] = 1;
}
}
list($name, $op, $value, $grouping, $wildcard) = $values;
$pref = array();
- if (!is_array($value)) {
+ if (in_array($op, array( 'IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY'))) {
+ $value = NULL;
+ }
+ elseif (!is_array($value)) {
$v = array();
$value = trim($value, ' ()');
if (strpos($value, CRM_Core_DAO::VALUE_SEPARATOR) !== FALSE) {
$commPref = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method');
$sqlValue = array();
+ $showValue = array();
$sql = "contact_a.preferred_communication_method";
- foreach ($pref as $val) {
- $sqlValue[] = "( $sql like '%" . CRM_Core_DAO::VALUE_SEPARATOR . $val . CRM_Core_DAO::VALUE_SEPARATOR . "%' ) ";
- $showValue[] = $commPref[$val];
+ if (in_array($op, array('IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY'))) {
+ $sqlValue[] = "{$sql} {$op}";
+ }
+ else {
+ foreach ($pref as $val) {
+ $sqlValue[] = "( $sql like '%" . CRM_Core_DAO::VALUE_SEPARATOR . $val . CRM_Core_DAO::VALUE_SEPARATOR . "%' ) ";
+ $showValue[] = $commPref[$val];
+ }
}
$this->_where[$grouping][] = "( " . implode(' OR ', $sqlValue) . " )";
$this->_qill[$grouping][] = ts('Preferred Communication Method') . " $op " . implode(' ' . ts('or') . ' ', $showValue);
// for relatinship search we always do wildcard
$targetName = $this->getWhereValues('relation_target_name', $grouping);
$relStatus = $this->getWhereValues('relation_status', $grouping);
+ $relPermission = $this->getWhereValues('relation_permission', $grouping);
$targetGroup = $this->getWhereValues('relation_target_group', $grouping);
$nameClause = $name = NULL;
$this->_qill[$grouping][] = ts('Relationship - Inactive or not Current');
}
+ //check for permissioned, non-permissioned and all permissioned relations
+ if ($relPermission[2] == 1) {
+ $this->_where[$grouping][] = "(
+civicrm_relationship.is_permission_a_b = 1
+)";
+ $this->_qill[$grouping][] = ts('Relationship - Permissioned');
+ } elseif ($relPermission[2] == 2) {
+ //non-allowed permission relationship.
+ $this->_where[$grouping][] = "(
+civicrm_relationship.is_permission_a_b = 0
+)";
+ $this->_qill[$grouping][] = ts('Relationship - Non-permissioned');
+ }
+
$this->addRelationshipDateClauses($grouping, $where);
if(!empty($rType) && isset($rType->id)){
$where[$grouping][] = 'civicrm_relationship.relationship_type_id = ' . $rType->id;
$convertedVals = $query->convertToPseudoNames($dao, TRUE);
if (!empty($convertedVals)) {
- $val = array_merge_recursive($val, $convertedVals);
+ $val = array_replace_recursive($val, $convertedVals);
}
$values[$dao->contact_id] = $val;
}
}
$value = CRM_Utils_Type::escape($value, $dataType);
-
// if we dont have a dataType we should assume
if ($dataType == 'String' || $dataType == 'Text') {
$value = "'" . strtolower($value) . "'";