X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FContact%2FBAO%2FQuery.php;h=a42a4032d68875223a84b0de6fb5c9848b19104f;hb=41d9d3cf16473f590b572f4c9851e180b4b0ff0c;hp=e69e958d3f989b60a70f45c0447966ab32ccc36f;hpb=3aa05e9760f8caa785f279f69b260d57a347e168;p=civicrm-core.git diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index e69e958d3f..a42a4032d6 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -4762,19 +4762,20 @@ civicrm_relationship.start_date > {$today} * @param $fieldName * * @return bool - * @throws \CiviCRM_API3_Exception + * @throws Exception */ public static function isCustomDateField($fieldName) { if (($customFieldID = CRM_Core_BAO_CustomField::getKeyID($fieldName)) == FALSE) { return FALSE; } try { - $customFieldDataType = civicrm_api3('CustomField', 'getvalue', ['id' => $customFieldID, 'return' => 'data_type']); + $customFieldData = CRM_Core_BAO_CustomField::getFieldObject($customFieldID); + $customFieldDataType = $customFieldData->data_type; if ('Date' == $customFieldDataType) { return TRUE; } } - catch (CiviCRM_API3_Exception $e) { + catch (Exception $e) { } return FALSE; } @@ -6070,7 +6071,16 @@ AND displayRelType.is_active = 1 } } elseif ($value['pseudoField'] == 'state_province_abbreviation') { - $dao->$key = CRM_Core_PseudoConstant::stateProvinceAbbreviation($val); + // old bad code: +// $dao->$key = CRM_Core_PseudoConstant::stateProvinceAbbreviation($val); + // iank: Return abbreviation if its a province from a country that uses abbreviations, + // otherwise return the name of the province. + // https://lab.civicrm.org/dev/core/issues/724 + if (is_numeric(CRM_Core_PseudoConstant::stateProvinceAbbreviation($val))) { + $dao->$key = CRM_Core_PseudoConstant::stateProvince($val); + } else { + $dao->$key = CRM_Core_PseudoConstant::stateProvinceAbbreviation($val); + } } // @todo handle this in the section above for pseudoconstants. elseif (in_array($value['pseudoField'], ['participant_role_id', 'participant_role'])) { @@ -6308,15 +6318,13 @@ AND displayRelType.is_active = 1 public static function getWildCardedValue($wildcard, $op, $value) { if ($wildcard && $op === 'LIKE') { if (CRM_Core_Config::singleton()->includeWildCardInName && (substr($value, 0, 1) != '%')) { - return "%$value%"; + $value = "%$value"; } - else { - return "$value%"; + if (substr($value, -1, 1) != '%') { + $value = "$value%"; } } - else { - return "$value"; - } + return "$value"; } /**