From bf2c70af69f82abc2b6c92c4b67af4dea871bad4 Mon Sep 17 00:00:00 2001 From: atif-shaikh Date: Wed, 24 Sep 2014 17:31:11 +0530 Subject: [PATCH] CRM-15317 - Database error on event registration when event title is too long https://issues.civicrm.org/jira/browse/CRM-15317 --- CRM/Event/Form/Participant.php | 4 ++-- CRM/Event/Form/Registration.php | 25 ++++++++++++++----------- CRM/Event/Form/Registration/Confirm.php | 4 ++-- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index eaacc1b9a5..2b18f13ffa 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -1244,7 +1244,7 @@ class CRM_Event_Form_Participant extends CRM_Contact_Form_Task { $payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this); - $result = &$payment->doDirectPayment($paymentParams); + $result = $payment->doDirectPayment($paymentParams); if (is_a($result, 'CRM_Core_Error')) { CRM_Core_Error::displaySessionError($result); @@ -1287,7 +1287,7 @@ class CRM_Event_Form_Participant extends CRM_Contact_Form_Task { $this->_params['role_id'] ); } - $participants[] = CRM_Event_Form_Registration::addParticipant($this->_params, $contactID); + $participants[] = CRM_Event_Form_Registration::addParticipant($this, $contactID); //add custom data for participant CRM_Core_BAO_CustomValueTable::postProcess($this->_params, diff --git a/CRM/Event/Form/Registration.php b/CRM/Event/Form/Registration.php index 0123eb65d8..41f2b87e91 100644 --- a/CRM/Event/Form/Registration.php +++ b/CRM/Event/Form/Registration.php @@ -750,7 +750,7 @@ class CRM_Event_Form_Registration extends CRM_Core_Form { } // add participant record - $participant = $this->addParticipant($this->_params, $contactID); + $participant = CRM_Event_Form_Registration::addParticipant($this, $contactID); $this->_participantIDS[] = $participant->id; //setting register_by_id field and primaryContactId @@ -838,8 +838,11 @@ class CRM_Event_Form_Registration extends CRM_Core_Form { * @return void * @access public */ - public function addParticipant($params, $contactID) { - + public static function addParticipant(&$form, $contactID) { + if (empty($form->_params)) { + return; + } + $params = $form->_params; $transaction = new CRM_Core_Transaction(); $groupName = 'participant_role'; @@ -861,7 +864,7 @@ WHERE v.option_group_id = g.id // handle register date CRM-4320 $registerDate = NULL; - if ($this->_allowConfirmation && $this->_participantId) { + if (!empty($form->_allowConfirmation) && $form->_participantId) { $registerDate = $params['participant_register_date']; } elseif (!empty($params['participant_register_date']) && @@ -874,7 +877,7 @@ WHERE v.option_group_id = g.id $participantFields = CRM_Event_DAO_Participant::fields(); $participantParams = array('id' => CRM_Utils_Array::value('participant_id', $params), 'contact_id' => $contactID, - 'event_id' => $this->_eventId ? $this->_eventId : $params['event_id'], + 'event_id' => $form->_eventId ? $form->_eventId : $params['event_id'], 'status_id' => CRM_Utils_Array::value('participant_status', $params, 1 ), @@ -896,18 +899,18 @@ WHERE v.option_group_id = g.id 'campaign_id' => CRM_Utils_Array::value('campaign_id', $params), ); - if ($this->_action & CRM_Core_Action::PREVIEW || CRM_Utils_Array::value('mode', $params) == 'test') { + if ($form->_action & CRM_Core_Action::PREVIEW || CRM_Utils_Array::value('mode', $params) == 'test') { $participantParams['is_test'] = 1; } else { $participantParams['is_test'] = 0; } - if (!empty($this->_params['note'])) { - $participantParams['note'] = $this->_params['note']; + if (!empty($form->_params['note'])) { + $participantParams['note'] = $form->_params['note']; } - elseif (!empty($this->_params['participant_note'])) { - $participantParams['note'] = $this->_params['participant_note']; + elseif (!empty($form->_params['participant_note'])) { + $participantParams['note'] = $form->_params['participant_note']; } // reuse id if one already exists for this one (can happen @@ -920,7 +923,7 @@ WHERE v.option_group_id = g.id ); $participantParams['id'] = $pID; } - $participantParams['discount_id'] = CRM_Core_BAO_Discount::findSet($this->_eventId, 'civicrm_event'); + $participantParams['discount_id'] = CRM_Core_BAO_Discount::findSet($form->_eventId, 'civicrm_event'); if (!$participantParams['discount_id']) { $participantParams['discount_id'] = "null"; diff --git a/CRM/Event/Form/Registration/Confirm.php b/CRM/Event/Form/Registration/Confirm.php index 69cb4a7272..9f2a2c78e9 100644 --- a/CRM/Event/Form/Registration/Confirm.php +++ b/CRM/Event/Form/Registration/Confirm.php @@ -835,7 +835,7 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { $now = date('YmdHis'); $receiptDate = NULL; - if ($form->_values['event']['is_email_confirm']) { + if (!empty($form->_values['event']['is_email_confirm'])) { $receiptDate = $now; } //CRM-4196 @@ -845,7 +845,7 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { $contribParams = array( 'contact_id' => $contactID, - 'financial_type_id' => $form->_values['event']['financial_type_id'] ? + 'financial_type_id' => !empty($form->_values['event']['financial_type_id']) ? $form->_values['event']['financial_type_id'] : $params['financial_type_id'], 'receive_date' => $now, 'total_amount' => $params['amount'], -- 2.25.1