<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
class CRM_Event_Form_Registration extends CRM_Core_Form {
/**
- * how many locationBlocks should we display?
+ * How many locationBlocks should we display?
*
* @var int
* @const
*/
- CONST LOCATION_BLOCKS = 1;
+ const LOCATION_BLOCKS = 1;
/**
- * the id of the event we are proceessing
+ * The id of the event we are proceessing
*
* @var int
- * @protected
*/
public $_eventId;
/**
- * the array of ids of all the participant we are proceessing
+ * The array of ids of all the participant we are proceessing
*
* @var int
- * @protected
*/
protected $_participantIDS = NULL;
/**
- * the id of the participant we are proceessing
+ * The id of the participant we are proceessing
*
* @var int
- * @protected
*/
protected $_participantId;
/**
- * is participant able to walk registration wizard.
+ * Is participant able to walk registration wizard.
*
* @var Boolean
- * @protected
*/
public $_allowConfirmation;
/**
- * is participant requires approval
+ * Is participant requires approval
*
* @var Boolean
- * @public
*/
public $_requireApproval;
/**
- * is event configured for waitlist.
+ * Is event configured for waitlist.
*
* @var Boolean
- * @public
*/
public $_allowWaitlist;
/**
- * store additional participant ids
+ * Store additional participant ids
* when there are pre-registered.
*
* @var array
- * @public
*/
public $_additionalParticipantIds;
/**
- * the mode that we are in
+ * The mode that we are in
*
* @var string
* @protect
public $_mode;
/**
- * the values for the contribution db object
+ * The values for the contribution db object
*
* @var array
- * @protected
*/
public $_values;
/**
- * the paymentProcessor attributes for this page
+ * The paymentProcessor attributes for this page
*
* @var array
- * @protected
*/
public $_paymentProcessor;
* The params submitted by the form and computed by the app
*
* @var array
- * @protected
*/
protected $_params;
* The fields involved in this contribution page
*
* @var array
- * @protected
*/
public $_fields;
* The billing location id for this contribiution page
*
* @var int
- * @protected
*/
public $_bltID;
* Price Set ID, if the new price set method is used
*
* @var int
- * @protected
*/
public $_priceSetId = NULL;
* Array of fields for the price set
*
* @var array
- * @protected
*/
public $_priceSet;
/* Is event already full.
*
* @var boolean
- * @protected
*/
public $_isEventFull;
public $_forcePayement;
+ public $_isBillingAddressRequiredForPayLater;
+
/**
- * Function to set variables up before form is built
+ * Set variables up before form is built
*
* @return void
- * @access public
*/
- function preProcess() {
+ public function preProcess() {
$this->_eventId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE);
}
$this->set('bltID', $this->_bltID);
- if ($this->_values['event']['is_monetary'] &&
- ($this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_FORM)
- ) {
- CRM_Core_Payment_Form::setCreditCardFields($this);
+ if ($this->_values['event']['is_monetary']) {
+ CRM_Core_Payment_Form::setPaymentFieldsByProcessor($this, $this->_paymentProcessor);
}
$params = array('entity_id' => $this->_eventId, 'entity_table' => 'civicrm_event');
$this->_values['location'] = CRM_Core_BAO_Location::getValues($params, TRUE);
if ($campID && CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Campaign', $campID)) {
$this->_values['event']['campaign_id'] = $campID;
}
+
+ // check if billing block is required for pay later
+ if (CRM_Utils_Array::value('is_pay_later', $this->_values['event'])) {
+ $this->_isBillingAddressRequiredForPayLater = CRM_Utils_Array::value('is_billing_required', $this->_values['event']);
+ $this->assign('isBillingAddressRequiredForPayLater', $this->_isBillingAddressRequiredForPayLater);
+ }
}
/**
- * assign the minimal set of variables to the template
+ * Assign the minimal set of variables to the template
*
* @return void
- * @access public
*/
- function assignToTemplate() {
+ public function assignToTemplate() {
//process only primary participant params
$this->_params = $this->get('params');
if (isset($this->_params[0])) {
}
/**
- * Function to add the custom fields
+ * Add the custom fields
*
- * @param $id
- * @param $name
+ * @param int $id
+ * @param string $name
* @param bool $viewOnly
*
* @return void
- * @access public
*/
- function buildCustom($id, $name, $viewOnly = FALSE) {
+ public function buildCustom($id, $name, $viewOnly = FALSE) {
if ($id) {
$button = substr($this->controller->getButtonName(), -4);
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
}
/**
- * @param $form
- * @param $eventID
+ * @param CRM_Core_Form $form
+ * @param int $eventID
*
* @throws Exception
*/
- static function initEventFee(&$form, $eventID) {
+ public static function initEventFee(&$form, $eventID) {
// get price info
// retrive all active price set fields.
}
/**
- * Function to handle process after the confirmation of payment by User
+ * Handle process after the confirmation of payment by User
*
- * @param null $contactID
+ * @param int $contactID
* @param null $contribution
* @param null $payment
*
* @return void
- * @access public
*/
- function confirmPostProcess($contactID = NULL, $contribution = NULL, $payment = NULL) {
+ public function confirmPostProcess($contactID = NULL, $contribution = NULL, $payment = NULL) {
// add/update contact information
$fields = array();
unset($this->_params['note']);
if (array_key_exists('email-5', $this->_params)) {
$mail = 'email-5';
- } else {
+ }
+ else {
foreach ($this->_params as $name => $dontCare) {
if (substr($name, 0, 5) == 'email') {
$mail = $name;
/**
* Process the participant
*
- * @param $params
- * @param $contactID
+ * @param array $params
+ * @param int $contactID
*
* @return void
- * @access public
*/
public static function addParticipant(&$form, $contactID) {
if (empty($form->_params)) {
/* Calculate the total participant count as per params.
*
- * @param array $params user params.
+ * @param array $params
+ * User params.
*
* @return $totalCount total participant count.
- * @access public
*/
/**
- * @param $form
- * @param $params
+ * @param CRM_Core_Form $form
+ * @param array $params
* @param bool $skipCurrent
*
* @return int|string
/* Format user submitted price set params.
* Convert price set each param as an array.
*
- * @param $params an array of user submitted params.
+ * @param $params
+ * An array of user submitted params.
*
*
* @return array $formatted, formatted price set params.
- * @access public
*/
/**
- * @param $form
- * @param $params
+ * @param CRM_Core_Form $form
+ * @param array $params
*
* @return mixed
*/
/* Calculate total count for each price set options.
* those are currently selected by user.
*
- * @param $form form object.
+ * @param $form
+ * Form object.
*
*
* @return array $optionsCount, array of each option w/ count total.
- * @access public
*/
/**
* @param $form
$addParticipantNum = substr($form->_name, 12);
foreach ($params as $pCnt => $values) {
if ($values == 'skip' ||
- $pCnt == $addParticipantNum
+ $pCnt === $addParticipantNum
) {
continue;
}
*
* @return null|string
*/
- function checkTemplateFileExists($suffix = '') {
+ public function checkTemplateFileExists($suffix = '') {
if ($this->_eventId) {
$templateName = $this->_name;
if (substr($templateName, 0, 12) == 'Participant_') {
/**
* @return null|string
*/
- function getTemplateFileName() {
+ public function getTemplateFileName() {
$fileName = $this->checkTemplateFileExists();
return $fileName ? $fileName : parent::getTemplateFileName();
}
/**
* @return null|string
*/
- function overrideExtraTemplateFileName() {
+ public function overrideExtraTemplateFileName() {
$fileName = $this->checkTemplateFileExists('extra.');
return $fileName ? $fileName : parent::overrideExtraTemplateFileName();
}
* @param unknown_type $params
* @return multitype:|Ambigous <multitype:, string, string>
*/
- static function validatePriceSet(&$form, $params) {
+ public static function validatePriceSet(&$form, $params) {
$errors = array();
$hasOptMaxValue = FALSE;
if (!is_array($params) || empty($params)) {
$opDbCount = CRM_Utils_Array::value('db_total_count', $options[$optId], 0);
$total += $opDbCount;
if ($optMax && $total > $optMax) {
+ $errors['soldOutOptions'][] = ts('Option %1 has sold out.', array(1 => $feeBlock[$fieldId]['options'][$optId]['label']));
if ($opDbCount && ($opDbCount >= $optMax)) {
$errors[$currentParticipantNum]["price_{$fieldId}"] =
ts('Sorry, this option is currently sold out.');
// set the first participant ID if not set, CRM-10032
/**
- * @param $participantID
+ * @param int $participantID
*/
- function processFirstParticipant($participantID) {
+ public function processFirstParticipant($participantID) {
$this->_participantId = $participantID;
$this->set('participantId', $this->_participantId);
*
* @param string $redirect
*/
- function checkValidEvent($redirect = NULL) {
+ public function checkValidEvent($redirect = NULL) {
// is the event active (enabled)?
if (!$this->_values['event']['is_active']) {
// form is inactive, die a fatal death
$endDate = CRM_Utils_Date::processDate(CRM_Utils_Array::value('registration_end_date',
$this->_values['event']
));
+ $eventEndDate = CRM_Utils_Date::processDate(CRM_Utils_Array::value('event_end_date', $this->_values['event']));
if (
$endDate &&
$endDate < $now
) {
CRM_Core_Error::statusBounce(ts('Registration for this event ended on %1', array(1 => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('registration_end_date', $this->_values['event'])))), $redirect);
}
+ if (!empty($eventEndDate) && $eventEndDate < $now) {
+ CRM_Core_Error::statusBounce(ts('Event ended on %1', array(1 => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('event_end_date', $this->_values['event'])))), $redirect);
+ }
}
}
-