Commit 4312a80d authored by Jamie McClelland's avatar Jamie McClelland

ensure working match if using state for matching field.

parent 2ca2143f
...@@ -858,7 +858,7 @@ function petitionemail_get_allowed_matching_fields() { ...@@ -858,7 +858,7 @@ function petitionemail_get_allowed_matching_fields() {
'street_name' => 'civicrm_address', 'street_name' => 'civicrm_address',
'city' => 'civicrm_address', 'city' => 'civicrm_address',
'county_id' => 'civicrm_address', 'county_id' => 'civicrm_address',
'state_province_id' => 'civicrm_address', 'state_province' => 'civicrm_address',
'postal_code' => 'civicrm_address', 'postal_code' => 'civicrm_address',
'postal_code_suffix' => 'civicrm_address', 'postal_code_suffix' => 'civicrm_address',
'country_id' => 'civicrm_address', 'country_id' => 'civicrm_address',
...@@ -1043,6 +1043,17 @@ function petitionemail_get_recipients($contact_id, $petition_id) { ...@@ -1043,6 +1043,17 @@ function petitionemail_get_recipients($contact_id, $petition_id) {
$from[] = "LEFT JOIN civicrm_address a ON a.contact_id = c.id"; $from[] = "LEFT JOIN civicrm_address a ON a.contact_id = c.id";
$added_tables[] = 'civicrm_address'; $added_tables[] = 'civicrm_address';
} }
// We have to make a special case for states, since the value we get
// from the user is the abbreviation rather than the state_province_id
// that is in the civicrm_address table.
if($field_name == 'state_province') {
if(!in_array('civicrm_state_province', $added_tables)) {
$from[] = "LEFT JOIN civicrm_state_province sp ON a.state_province_id = sp.id";
$added_tables[] = 'civicrm_state_province';
}
$field_name = 'sp.abbreviation';
}
$where_fragment[] = $field_name . ' = %' . $id; $where_fragment[] = $field_name . ' = %' . $id;
$where_fragment[] = 'a.is_primary = 1'; $where_fragment[] = 'a.is_primary = 1';
$params[$id] = array($value, 'String'); $params[$id] = array($value, 'String');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment