From e1ce628e752b053bf8887948f293c04a13d8a627 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 15 Aug 2013 00:21:44 +1200 Subject: [PATCH] CRM-13179 fix event to 'listen' to contact id as set --- CRM/Core/Form.php | 7 +++++-- CRM/Event/Form/Registration/Confirm.php | 12 ++++++++++++ CRM/Event/Form/Registration/Register.php | 3 ++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index ad6b4730e9..c3b6bc5a90 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -1318,10 +1318,13 @@ class CRM_Core_Form extends HTML_QuickForm_Page { */ function getContactID() { $tempID = CRM_Utils_Request::retrieve('cid', 'Positive', $this); - if(isset($this->_params) && isset($this->_params['select_contact_id '])) { + if(isset($this->_params) && isset($this->_params['select_contact_id'])) { $tempID = $this->_params['select_contact_id']; } - + if(isset($this->_params, $this->_params[0]) && !empty($this->_params[0]['select_contact_id'])) { + // event form stores as an indexed array, contribution form not so much... + $tempID = $this->_params[0]['select_contact_id']; + } // force to ignore the authenticated user if ($tempID === '0') { return $tempID; diff --git a/CRM/Event/Form/Registration/Confirm.php b/CRM/Event/Form/Registration/Confirm.php index 1a4a0b3eae..9bd8254f2e 100644 --- a/CRM/Event/Form/Registration/Confirm.php +++ b/CRM/Event/Form/Registration/Confirm.php @@ -452,6 +452,9 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { $this->_params = $this->get('params'); if (CRM_Utils_Array::value('contact_id', $this->_params[0])) { + // unclear when this would be set & whether it could be checked in getContactID. + // perhaps it relates to when cid is in the url + //@todo someone who knows add comments on the various contactIDs in this form $contactID = $this->_params[0]['contact_id']; } else { @@ -1083,6 +1086,15 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { $contactID, 'contact_type' ); + + if(array_key_exists('contact_id', $params) && empty($params['contact_id'])) { + // we unset this here because the downstream function ignores the contactID we give it + // if it is set & it is difficult to understand the implications of 'fixing' this downstream + // but if we are passing a contact id into this function it's reasonable to assume we don't + // want it ignored + unset($params['contact_id']); + } + $contactID = CRM_Contact_BAO_Contact::createProfileContact( $params, $fields, diff --git a/CRM/Event/Form/Registration/Register.php b/CRM/Event/Form/Registration/Register.php index be8e3ca65a..6d9fef410a 100644 --- a/CRM/Event/Form/Registration/Register.php +++ b/CRM/Event/Form/Registration/Register.php @@ -437,7 +437,8 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { $pps[$key] = $name['name']; } } - if($this->getContactID() === '0') { + if($this->getContactID() === '0' && !$this->_values['event']['is_multiple_registrations']) { + //@todo we are blocking for multiple registrations because we haven't tested $this->addCidZeroOptions($onlinePaymentProcessorEnabled); } if (CRM_Utils_Array::value('is_pay_later', $this->_values['event']) && -- 2.25.1