From 9b142308515ebb18c9f12d6d455ee57ce0f68f1c Mon Sep 17 00:00:00 2001 From: Michael McMahon Date: Thu, 5 Dec 2019 13:34:04 -0500 Subject: [PATCH] Ian province abbreviation patch - issue 724 --- CRM/Contact/BAO/Query.php | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index e939d36570..b225bf63a7 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -5491,7 +5491,40 @@ AND displayRelType.is_active = 1 } } elseif ($value['pseudoField'] == 'state_province_abbreviation') { - $dao->$key = CRM_Core_PseudoConstant::stateProvinceAbbreviation($val); + //$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 + // list of provinces from Australia, Brazil, Canada, Colombia, Italy, Somalia, United States + // echo 'select id from civicrm_state_province where country_id = 1013 or country_id = 1029 or country_id = 1039 or country_id = 1048 or country_id = 1107 or country_id = 1195 or country_id = 1228;' | mysql civicrm + $fsf_provinces = [ 1638, 1639, 1640, 1641, 1642, 1643, 1644, 1645, 1917, 1918, 1919, 1920, + 1921, 1922, 1923, 1924, 1926, 1927, 1928, 1929, 1930, 1931, 1932, 1933, + 1934, 1935, 1936, 1937, 1938, 1939, 1940, 1941, 1942, 1943, 1944, 1100, + 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, + 2144, 2145, 2146, 2147, 2148, 2149, 2150, 2151, 2152, 2153, 2154, 2155, + 2156, 2157, 2158, 2159, 2160, 2161, 2162, 2163, 2164, 2165, 2166, 2167, + 2168, 2169, 2170, 2171, 2172, 2173, 2174, 2175, 3173, 3174, 3175, 3176, + 3177, 3178, 3179, 3180, 3181, 3182, 3183, 3184, 3185, 3186, 3187, 3188, + 3189, 3190, 3191, 3192, 3193, 3194, 3195, 3196, 3197, 3198, 3199, 3200, + 3201, 3202, 3203, 3204, 3205, 3206, 3207, 3208, 3209, 3210, 3211, 3212, + 3213, 3214, 3215, 3216, 3217, 3218, 3219, 3220, 3221, 3222, 3223, 3224, + 3225, 3226, 3227, 3228, 3229, 3230, 3231, 3232, 3233, 3234, 3235, 3236, + 3237, 3238, 3239, 3240, 3241, 3242, 3243, 3244, 3245, 3246, 3247, 3248, + 3249, 3250, 3251, 3252, 3253, 3254, 3255, 3256, 3257, 3258, 3259, 3260, + 3261, 3262, 3263, 3264, 3265, 3266, 3267, 3268, 3269, 3270, 3271, 3272, + 3273, 3274, 3275, 10000, 10001, 10002, 10003, 10010, 10011, 10012, 4555, + 4556, 4557, 4558, 4559, 4560, 4561, 4562, 4563, 4564, 4565, 4566, 4567, + 4568, 4569, 4570, 4571, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, + 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, + 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, + 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, + 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1052, 1053, 1055, 1056, 1057, + 1058, 1059, 1060, 1061 ]; + if (in_array($val, $fsf_provinces)) { + $dao->$key = CRM_Core_PseudoConstant::stateProvinceAbbreviation($val); + } else { + $dao->$key = CRM_Core_PseudoConstant::stateProvince($val); + } } // FIX ME: we should potentially move this to component Query and write a wrapper function that // handles pseudoconstant fixes for all component -- 2.25.1