[REF] Simplify non-creditcard participant.create
authoreileen <emcnaughton@wikimedia.org>
Mon, 17 Feb 2020 12:57:33 +0000 (01:57 +1300)
committereileen <emcnaughton@wikimedia.org>
Tue, 17 Mar 2020 00:42:41 +0000 (13:42 +1300)
The wrangling for role_id is done in the Participant::add function now so we don't need it.

One loop hurts our heads less

CRM/Event/Form/Participant.php

index ff9b315d553855dc46cc0125585e8a7b01a6af44..5b82ef18ef9eb4a3a9d7e9f510cf96e960fc51da 100644 (file)
@@ -1262,33 +1262,15 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
       $this->_contactIds[] = $this->_contactId;
     }
     else {
-      $participants = [];
-      if ($this->_single) {
-        if ($params['role_id']) {
-          $params['role_id'] = $roleIdWithSeparator;
-        }
-        else {
-          $params['role_id'] = 'NULL';
-        }
-        $participants[] = CRM_Event_BAO_Participant::create($params);
-      }
-      else {
-        foreach ($this->_contactIds as $contactID) {
-          $commonParams = $params;
-          $commonParams['contact_id'] = $contactID;
-          if ($commonParams['role_id']) {
-            $commonParams['role_id'] = $commonParams['role_id'] = str_replace(',', CRM_Core_DAO::VALUE_SEPARATOR, $params['role_id']);
-          }
-          else {
-            $commonParams['role_id'] = 'NULL';
-          }
-          $participants[] = CRM_Event_BAO_Participant::create($commonParams);
-        }
-      }
-
       if ($this->_single) {
         $this->_contactIds[] = $this->_contactId;
       }
+      $participants = [];
+      foreach ($this->_contactIds as $contactID) {
+        $commonParams = $params;
+        $commonParams['contact_id'] = $contactID;
+        $participants[] = CRM_Event_BAO_Participant::create($commonParams);
+      }
 
       $contributions = [];
       if (!empty($params['record_contribution'])) {