From bd7b39e728bde879d0df8398bf40952843da3ddb Mon Sep 17 00:00:00 2001 From: Pratik Joshi Date: Thu, 29 Aug 2013 12:57:32 +0530 Subject: [PATCH] CRM-13248 fix --- CRM/Event/Form/Registration/Confirm.php | 6 ++++++ CRM/Utils/Array.php | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/CRM/Event/Form/Registration/Confirm.php b/CRM/Event/Form/Registration/Confirm.php index 9bd8254f2e..0642e6d638 100644 --- a/CRM/Event/Form/Registration/Confirm.php +++ b/CRM/Event/Form/Registration/Confirm.php @@ -612,6 +612,12 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { } elseif (CRM_Utils_Array::value('is_primary', $value)) { CRM_Core_Payment_Form::mapParams($this->_bltID, $value, $value, TRUE); + // payment email param can be empty for _bltID mapping + // thus provide mapping for it with a different email value + if (empty($value['email'])) { + $value['email'] = CRM_Utils_Array::valueByRegexKey('/^email-/', $value); + } + if (is_object($payment)) { $result = $payment->doDirectPayment($value); } diff --git a/CRM/Utils/Array.php b/CRM/Utils/Array.php index 36af8fca23..296f470a00 100644 --- a/CRM/Utils/Array.php +++ b/CRM/Utils/Array.php @@ -622,5 +622,18 @@ class CRM_Utils_Array { $elementArray = array_combine($keys, array_values($elementArray)); return $elementArray; } + + /* + * function to get value of first matched + * regex key element of an array + */ + static function valueByRegexKey($regexKey, $list, $default = NULL) { + if (is_array($list) && $regexKey) { + $matches = preg_grep($regexKey, array_keys($list)); + $key = reset($matches); + return ($key && array_key_exists($key, $list)) ? $list[$key] : $default; + } + return $default; + } } -- 2.25.1