From 9a00474224259a4a6a30bf901496d5f187c2b4e2 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Tue, 19 Sep 2017 11:16:16 +1000 Subject: [PATCH] CRM-20907 Ensure that contact_type is valid in deduperules --- CRM/Contact/Form/DedupeRules.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CRM/Contact/Form/DedupeRules.php b/CRM/Contact/Form/DedupeRules.php index ebfde46b91..912cd68063 100644 --- a/CRM/Contact/Form/DedupeRules.php +++ b/CRM/Contact/Form/DedupeRules.php @@ -58,7 +58,14 @@ class CRM_Contact_Form_DedupeRules extends CRM_Admin_Form { } $this->_options = CRM_Core_SelectValues::getDedupeRuleTypes(); $this->_rgid = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0); - $this->_contactType = CRM_Utils_Request::retrieve('contact_type', 'String', $this, FALSE, 0); + $contactTypes = civicrm_api3('Contact', 'getOptions', array('field' => "contact_type")); + $contactType = CRM_Utils_Request::retrieve('contact_type', 'String', $this, FALSE, 0); + if (in_array($contactType, $contactTypes['values'])) { + $this->_contactType = $contactTypes['values'][$contactType]; + } + else { + throw new CRM_Core_Exception('Contact Type is Not valid'); + } if ($this->_rgid) { $rgDao = new CRM_Dedupe_DAO_RuleGroup(); $rgDao->id = $this->_rgid; -- 2.25.1