Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix theoretical regression #16567

Merged
merged 1 commit into from
Feb 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CRM/Event/BAO/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,21 @@ public static function fixEventLevel(&$eventLevel) {
}
}

/**
* Get the ID of the default (first) participant role
*
* @return int
* @throws \CiviCRM_API3_Exception
*/
public static function getDefaultRoleID() {
return (int) civicrm_api3('OptionValue', 'getvalue', [
'return' => 'value',
'option_group_id' => 'participant_role',
'is_active' => 1,
'options' => ['limit' => 1, 'sort' => 'is_default DESC'],
]);
}

/**
* Get the additional participant ids.
*
Expand Down
3 changes: 2 additions & 1 deletion CRM/Event/Form/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -2102,6 +2102,7 @@ public function processContribution(
*
* @return \CRM_Event_BAO_Participant
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
protected function addParticipant(&$form, $params, $contactID) {
$transaction = new CRM_Core_Transaction();
Expand All @@ -2114,7 +2115,7 @@ protected function addParticipant(&$form, $params, $contactID) {
'status_id' => CRM_Utils_Array::value('participant_status',
$params, 1
),
'role_id' => CRM_Utils_Array::value('participant_role_id', $params) ?: self::getDefaultRoleID(),
'role_id' => CRM_Utils_Array::value('participant_role_id', $params) ?: CRM_Event_BAO_Participant::getDefaultRoleID(),
'register_date' => $params['register_date'],
'source' => CRM_Utils_String::ellipsify(
isset($params['participant_source']) ? CRM_Utils_Array::value('participant_source', $params) : CRM_Utils_Array::value('description', $params),
Expand Down
17 changes: 1 addition & 16 deletions CRM/Event/Form/Registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ protected function addParticipant(&$form, $contactID) {
'status_id' => CRM_Utils_Array::value('participant_status',
$params, 1
),
'role_id' => CRM_Utils_Array::value('participant_role_id', $params) ?: self::getDefaultRoleID(),
'role_id' => CRM_Utils_Array::value('participant_role_id', $params) ?: CRM_Event_BAO_Participant::getDefaultRoleID(),
'register_date' => ($registerDate) ? $registerDate : date('YmdHis'),
'source' => CRM_Utils_String::ellipsify(
isset($params['participant_source']) ? CRM_Utils_Array::value('participant_source', $params) : CRM_Utils_Array::value('description', $params),
Expand Down Expand Up @@ -858,21 +858,6 @@ protected function addParticipant(&$form, $contactID) {
return $participant;
}

/**
* Get the ID of the default (first) participant role
*
* @return int
* @throws \CiviCRM_API3_Exception
*/
private static function getDefaultRoleID() {
return (int) civicrm_api3('OptionValue', 'getvalue', [
'return' => "value",
'option_group_id' => "participant_role",
'is_active' => 1,
'options' => ['limit' => 1, 'sort' => "is_default DESC"],
]);
}

/**
* Calculate the total participant count as per params.
*
Expand Down