* This class generates form components for processing Event.
*/
class CRM_Event_Form_Registration extends CRM_Core_Form {
+
use CRM_Financial_Form_FrontEndPaymentFormTrait;
/**
public $_isEventFull;
public $_lineItem;
+
public $_lineItemParticipantsCount;
+
public $_availableRegistrations;
/**
$this->_values = $this->_fields = [];
//retrieve event information
- $params = array('id' => $this->_eventId);
+ $params = ['id' => $this->_eventId];
CRM_Event_BAO_Event::retrieve($params, $this->_values['event']);
// check for is_monetary status
$isMonetary = $this->_values['event']['is_monetary'] ?? NULL;
self::initEventFee($this, $this->_eventId);
// get the profile ids
- $ufJoinParams = array(
+ $ufJoinParams = [
'entity_table' => 'civicrm_event',
// CRM-4377: CiviEvent for the main participant, CiviEvent_Additional for additional participants
'module' => 'CiviEvent',
'entity_id' => $this->_eventId,
- );
+ ];
list($this->_values['custom_pre_id'],
$this->_values['custom_post_id']
) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
if ($this->_values['event']['is_monetary']) {
CRM_Core_Payment_Form::setPaymentFieldsByProcessor($this, $this->_paymentProcessor);
}
- $params = array('entity_id' => $this->_eventId, 'entity_table' => 'civicrm_event');
+ $params = ['entity_id' => $this->_eventId, 'entity_table' => 'civicrm_event'];
$this->_values['location'] = CRM_Core_BAO_Location::getValues($params, TRUE);
$this->set('values', $this->_values);
$this->_availableRegistrations
= CRM_Event_BAO_Participant::eventFull(
- $this->_values['event']['id'], TRUE,
- CRM_Utils_Array::value('has_waitlist', $this->_values['event'])
- );
+ $this->_values['event']['id'], TRUE,
+ CRM_Utils_Array::value('has_waitlist', $this->_values['event'])
+ );
$this->set('availableRegistrations', $this->_availableRegistrations);
}
$this->assign_by_ref('paymentProcessor', $this->_paymentProcessor);
$this->assign('billingName', $name);
$this->set('name', $name);
- $vars = array(
+ $vars = [
'amount',
'currencyID',
'credit_card_type',
'trxn_id',
'amount_level',
'receive_date',
- );
+ ];
foreach ($vars as $v) {
if (!empty($params[$v])) {
// we don't allow conflicting fields to be
// configured via profile
- $fieldsToIgnore = array(
+ $fieldsToIgnore = [
'participant_fee_amount' => 1,
'participant_fee_level' => 1,
- );
+ ];
if ($contactID) {
//FIX CRM-9653
if (is_array($id)) {
}
}
if ($isPaidEvent && empty($form->_values['fee'])) {
- if (CRM_Utils_System::getClassName($form) != 'CRM_Event_Form_Participant') {
- CRM_Core_Error::statusBounce(ts('No Fee Level(s) or Price Set is configured for this event.<br />Click <a href=\'%1\'>CiviEvent >> Manage Event >> Configure >> Event Fees</a> to configure the Fee Level(s) or Price Set for this event.', array(1 => CRM_Utils_System::url('civicrm/event/manage/fee', 'reset=1&action=update&id=' . $form->_eventId))));
+ if (!in_array(CRM_Utils_System::getClassName($form), ['CRM_Event_Form_Participant', 'CRM_Event_Form_Task_Register'])) {
+ CRM_Core_Error::statusBounce(ts('No Fee Level(s) or Price Set is configured for this event.<br />Click <a href=\'%1\'>CiviEvent >> Manage Event >> Configure >> Event Fees</a> to configure the Fee Level(s) or Price Set for this event.', [1 => CRM_Utils_System::url('civicrm/event/manage/fee', 'reset=1&action=update&id=' . $form->_eventId)]));
}
}
}
}
$participantFields = CRM_Event_DAO_Participant::fields();
- $participantParams = array(
+ $participantParams = [
'id' => $params['participant_id'] ?? NULL,
'contact_id' => $contactID,
'event_id' => $form->_eventId ? $form->_eventId : $params['event_id'],
'discount_id' => $params['discount_id'] ?? NULL,
'fee_currency' => $params['currencyID'] ?? NULL,
'campaign_id' => $params['campaign_id'] ?? NULL,
- );
+ ];
if ($form->_action & CRM_Core_Action::PREVIEW || CRM_Utils_Array::value('mode', $params) == 'test') {
$participantParams['is_test'] = 1;
//first format the params.
if ($singleFormParams) {
$params = self::formatPriceSetParams($form, $params);
- $params = array($params);
+ $params = [$params];
}
foreach ($params as $key => $values) {
$field = $priceSetDetails['fields'][$fieldId];
if ($field['html_type'] == 'Text') {
$fieldOption = current($field['options']);
- $value = array($fieldOption['id'] => $value);
+ $value = [$fieldOption['id'] => $value];
}
else {
- $value = array($value => TRUE);
+ $value = [$value => TRUE];
}
}
}
foreach ($element->_options as $option) {
if ($option['attr']['value'] === "crm_disabled_opt-{$value[0]}") {
$placeholder = html_entity_decode($option['text'], ENT_QUOTES, "UTF-8");
- $element->updateAttributes(array('placeholder' => $placeholder));
+ $element->updateAttributes(['placeholder' => $placeholder]);
break;
}
}
) {
return;
}
- foreach (array(
- 'constantValues',
- 'submitValues',
- 'defaultValues',
- ) as $val) {
+ foreach (['constantValues', 'submitValues', 'defaultValues'] as $val) {
$values = $form->{"_$val"};
if (!is_array($values) || empty($values)) {
continue;
//validate for price field selection.
if (empty($fieldSelected[$pNum])) {
- $errors[$pNum]['_qf_default'] = ts('Select at least one option from Event Fee(s).');
+ $errors[$pNum]['_qf_default'] = ts('SELECT at least one OPTION FROM EVENT Fee(s).');
}
}
}
elseif (($optMax - $opDbCount) == 1) {
$errors[$soldOutPnum[$optId]]["price_{$fieldId}"]
- = ts('Sorry, currently only a single space is available for this option.', array(1 => ($optMax - $opDbCount)));
+ = ts('Sorry, currently only a single space is available for this option.', [1 => ($optMax - $opDbCount)]);
}
else {
$errors[$soldOutPnum[$optId]]["price_{$fieldId}"]
- = ts('Sorry, currently only %1 spaces are available for this option.', array(1 => ($optMax - $opDbCount)));
+ = ts('Sorry, currently only %1 spaces are available for this option.', [1 => ($optMax - $opDbCount)]);
}
}
}
$this->set('participantId', $this->_participantId);
$ids = $participantValues = [];
- $participantParams = array('id' => $this->_participantId);
+ $participantParams = ['id' => $this->_participantId];
CRM_Event_BAO_Participant::getValues($participantParams, $participantValues, $ids);
$this->_values['participant'] = $participantValues[$this->_participantId];
$this->set('values', $this->_values);
/**
* Check if event is valid.
*
+ * @param string $redirect
+ *
* @todo - combine this with CRM_Event_BAO_Event::validRegistrationRequest
* (probably extract relevant values here & call that with them & handle bounces & redirects here -as
* those belong in the form layer)
*
- * @param string $redirect
*/
public function checkValidEvent($redirect = NULL) {
// is the event active (enabled)?
$startDate &&
$startDate >= $now
) {
- CRM_Core_Error::statusBounce(ts('Registration for this event begins on %1', array(1 => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('registration_start_date', $this->_values['event'])))), $redirect, ts('Sorry'));
+ CRM_Core_Error::statusBounce(ts('Registration for this event begins on %1', [1 => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('registration_start_date', $this->_values['event']))]), $redirect, ts('Sorry'));
}
$regEndDate = CRM_Utils_Date::processDate(CRM_Utils_Array::value('registration_end_date',
if (empty($regEndDate)) {
$endDate = CRM_Utils_Date::customFormat(CRM_Utils_Array::value('event_end_date', $this->_values['event']));
}
- CRM_Core_Error::statusBounce(ts('Registration for this event ended on %1', array(1 => $endDate)), $redirect, ts('Sorry'));
+ CRM_Core_Error::statusBounce(ts('Registration for this event ended on %1', [1 => $endDate]), $redirect, ts('Sorry'));
}
}