CRM-15317 - Database error on event registration when event title is too long
authoratif-shaikh <shaikh388@gmail.com>
Wed, 24 Sep 2014 12:01:11 +0000 (17:31 +0530)
committeratif-shaikh <shaikh388@gmail.com>
Wed, 24 Sep 2014 12:01:11 +0000 (17:31 +0530)
https://issues.civicrm.org/jira/browse/CRM-15317

CRM/Event/Form/Participant.php
CRM/Event/Form/Registration.php
CRM/Event/Form/Registration/Confirm.php

index eaacc1b9a5c5dbbe12f3c440fdd9c3fd5bc8a7ad..2b18f13ffa3f08d8b6adfb91b8c39da54d1632dc 100644 (file)
@@ -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,
index 0123eb65d82f683b8600e4a4fc4d57699721760f..41f2b87e91caa4fb145f319be778d7fd399a61cf 100644 (file)
@@ -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";
index 69cb4a72728b4d6c535cf8860f4f6aaee20bc544..9f2a2c78e9308292ca0340b89ed4a24975c9b1e8 100644 (file)
@@ -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'],