}
// For single additions - show validation error if the contact has already been registered
// for this event.
- if ($self->_single && ($self->_action & CRM_Core_Action::ADD)) {
+ if (($self->_action & CRM_Core_Action::ADD)) {
if ($self->_context == 'standalone') {
$contactId = $values['contact_id'] ?? NULL;
}
$dupeCheck->whereAdd("status_id != {$cancelledStatusID} ");
$dupeCheck->find(TRUE);
if (!empty($dupeCheck->id)) {
- $errorMsg['event_id'] = ts("This contact has already been assigned to this event.");
+ $errorMsg['event_id'] = ts('This contact has already been assigned to this event.');
}
}
}
- return CRM_Utils_Array::crmIsEmptyArray($errorMsg) ? TRUE : $errorMsg;
+ return empty($errorMsg) ? TRUE : $errorMsg;
}
/**
CRM_Core_Session::setStatus($statusMsg, ts('Saved'), 'success');
}
-
/**
* Add local and global form rules.
*
* list of errors to be posted back to the form
*/
public static function formRule($values, $files, $self) {
- // If $values['_qf_Participant_next'] is Delete or
- // $values['event_id'] is empty, then return
- // instead of proceeding further.
-
- if ((($values['_qf_Participant_next'] ?? NULL) === 'Delete') ||
- empty($values['event_id'])
- ) {
- return TRUE;
- }
-
$errorMsg = [];
-
- if (!empty($values['payment_processor_id'])) {
- // make sure that payment instrument values (e.g. credit card number and cvv) are valid
- CRM_Core_Payment_Form::validatePaymentInstrument($values['payment_processor_id'], $values, $errorMsg, NULL);
- }
-
if (!empty($values['record_contribution'])) {
if (empty($values['financial_type_id'])) {
$errorMsg['financial_type_id'] = ts('Please enter the associated Financial Type');
// do the amount validations.
//skip for update mode since amount is freeze, CRM-6052
- if ((!$self->_id && empty($values['total_amount']) &&
+ if (empty($values['total_amount']) &&
empty($self->_values['line_items'])
- ) ||
- ($self->_id && !$self->_paymentId && isset($self->_values['line_items']) && is_array($self->_values['line_items']))
- ) {
+ ) {
if ($priceSetId = CRM_Utils_Array::value('priceSetId', $values)) {
CRM_Price_BAO_PriceField::priceSetValidation($priceSetId, $values, $errorMsg, TRUE);
}
}
- // For single additions - show validation error if the contact has already been registered
- // for this event.
- if ($self->_single && ($self->_action & CRM_Core_Action::ADD)) {
- if ($self->_context == 'standalone') {
- $contactId = $values['contact_id'] ?? NULL;
- }
- else {
- $contactId = $self->_contactId;
- }
- $eventId = $values['event_id'] ?? NULL;
-
- $event = new CRM_Event_DAO_Event();
- $event->id = $eventId;
- $event->find(TRUE);
-
- if (!$event->allow_same_participant_emails && !empty($contactId) && !empty($eventId)) {
- $cancelledStatusID = CRM_Core_PseudoConstant::getKey('CRM_Event_BAO_Participant', 'status_id', 'Cancelled');
- $dupeCheck = new CRM_Event_BAO_Participant();
- $dupeCheck->contact_id = $contactId;
- $dupeCheck->event_id = $eventId;
- $dupeCheck->whereAdd("status_id != {$cancelledStatusID} ");
- $dupeCheck->find(TRUE);
- if (!empty($dupeCheck->id)) {
- $errorMsg['event_id'] = ts("This contact has already been assigned to this event.");
- }
- }
- }
- return CRM_Utils_Array::crmIsEmptyArray($errorMsg) ? TRUE : $errorMsg;
+ return empty($errorMsg) ? TRUE : $errorMsg;
}
}