/**
  * Set variables up before form is built.
  *
  * @return void
  */
 public function preProcess()
 {
     $this->_showFeeBlock = CRM_Utils_Array::value('eventId', $_GET);
     $this->assign('showFeeBlock', FALSE);
     $this->assign('feeBlockPaid', FALSE);
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
     $this->_eID = CRM_Utils_Request::retrieve('eid', 'Positive', $this);
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('context', $this->_context);
     if ($this->_contactId) {
         $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
         $this->assign('displayName', $displayName);
         $this->setPageTitle(ts('Event Registration for %1', array(1 => $displayName)));
     } else {
         $this->setPageTitle(ts('Event Registration'));
     }
     // check the current path, if search based, then dont get participantID
     // CRM-5792
     $path = CRM_Utils_System::currentPath();
     if (strpos($path, 'civicrm/contact/search') === 0 || strpos($path, 'civicrm/group/search') === 0) {
         $this->_id = NULL;
     } else {
         $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     }
     if ($this->_id) {
         $this->assign('participantId', $this->_id);
         $this->_paymentId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'id', 'participant_id');
         $this->assign('hasPayment', $this->_paymentId);
         // CRM-12615 - Get payment information from the primary registration
         if (!$this->_paymentId && $this->_action == CRM_Core_Action::UPDATE) {
             $registered_by_id = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'registered_by_id', 'id');
             if ($registered_by_id) {
                 $this->_paymentId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $registered_by_id, 'id', 'participant_id');
                 $this->assign('registeredByParticipantId', $registered_by_id);
             }
         }
     }
     // get the option value for custom data type
     $this->_roleCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantRole', 'name');
     $this->_eventNameCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventName', 'name');
     $this->_eventTypeCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventType', 'name');
     $this->assign('roleCustomDataTypeID', $this->_roleCustomDataTypeID);
     $this->assign('eventNameCustomDataTypeID', $this->_eventNameCustomDataTypeID);
     $this->assign('eventTypeCustomDataTypeID', $this->_eventTypeCustomDataTypeID);
     if ($this->_mode) {
         $this->assign('participantMode', $this->_mode);
         $this->assignPaymentRelatedVariables();
     }
     if ($this->_showFeeBlock) {
         $this->assign('showFeeBlock', TRUE);
         $isMonetary = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_showFeeBlock, 'is_monetary');
         if ($isMonetary) {
             $this->assign('feeBlockPaid', TRUE);
         }
         return CRM_Event_Form_EventFees::preProcess($this);
     }
     //check the mode when this form is called either single or as
     //search task action
     if ($this->_id || $this->_contactId || $this->_context == 'standalone') {
         $this->_single = TRUE;
         $this->assign('urlPath', 'civicrm/contact/view/participant');
         if (!$this->_id && !$this->_contactId) {
             $breadCrumbs = array(array('title' => ts('CiviEvent Dashboard'), 'url' => CRM_Utils_System::url('civicrm/event', 'reset=1')));
             CRM_Utils_System::appendBreadCrumb($breadCrumbs);
         }
     } else {
         //set the appropriate action
         $context = $this->get('context');
         $urlString = 'civicrm/contact/search';
         $this->_action = CRM_Core_Action::BASIC;
         switch ($context) {
             case 'advanced':
                 $urlString = 'civicrm/contact/search/advanced';
                 $this->_action = CRM_Core_Action::ADVANCED;
                 break;
             case 'builder':
                 $urlString = 'civicrm/contact/search/builder';
                 $this->_action = CRM_Core_Action::PROFILE;
                 break;
             case 'basic':
                 $urlString = 'civicrm/contact/search/basic';
                 $this->_action = CRM_Core_Action::BASIC;
                 break;
             case 'custom':
                 $urlString = 'civicrm/contact/search/custom';
                 $this->_action = CRM_Core_Action::COPY;
                 break;
         }
         CRM_Contact_Form_Task::preProcessCommon($this);
         $this->_single = FALSE;
         $this->_contactId = NULL;
         //set ajax path, this used for custom data building
         $this->assign('urlPath', $urlString);
         $this->assign('urlPathVar', "_qf_Participant_display=true&qfKey={$this->controller->_key}");
     }
     $this->assign('single', $this->_single);
     if (!$this->_id) {
         $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add');
     }
     $this->assign('action', $this->_action);
     // check for edit permission
     if (!CRM_Core_Permission::checkActionPermission('CiviEvent', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     if ($this->_action & CRM_Core_Action::DELETE) {
         // check delete permission for contribution
         if ($this->_id && $this->_paymentId && !CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) {
             CRM_Core_Error::fatal(ts("This Participant is linked to a contribution. You must have 'delete in CiviContribute' permission in order to delete this record."));
         }
         return;
     }
     if ($this->_id) {
         // assign participant id to the template
         $this->assign('participantId', $this->_id);
         $this->_roleId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'role_id');
     }
     // when fee amount is included in form
     if (!empty($_POST['hidden_feeblock']) || !empty($_POST['send_receipt'])) {
         CRM_Event_Form_EventFees::preProcess($this);
         CRM_Event_Form_EventFees::buildQuickForm($this);
         CRM_Event_Form_EventFees::setDefaultValues($this);
     }
     // when custom data is included in this page
     if (!empty($_POST['hidden_custom'])) {
         // Custom data of type participant role
         // Note: Some earlier commits imply $_POST['role_id'] could be a comma separated string,
         //       not sure if that ever really happens
         if (!empty($_POST['role_id'])) {
             foreach ($_POST['role_id'] as $roleID) {
                 CRM_Custom_Form_CustomData::preProcess($this, $this->_roleCustomDataTypeID, $roleID, 1, 'Participant', $this->_id);
                 CRM_Custom_Form_CustomData::buildQuickForm($this);
                 CRM_Custom_Form_CustomData::setDefaultValues($this);
             }
         }
         //custom data of type participant event
         CRM_Custom_Form_CustomData::preProcess($this, $this->_eventNameCustomDataTypeID, $_POST['event_id'], 1, 'Participant', $this->_id);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
         // custom data of type participant event type
         $eventTypeId = NULL;
         if ($eventId = CRM_Utils_Array::value('event_id', $_POST)) {
             $eventTypeId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $eventId, 'event_type_id', 'id');
         }
         CRM_Custom_Form_CustomData::preProcess($this, $this->_eventTypeCustomDataTypeID, $eventTypeId, 1, 'Participant', $this->_id);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
         //custom data of type participant, ( we 'null' to reset subType and subName)
         CRM_Custom_Form_CustomData::preProcess($this, 'null', 'null', 1, 'Participant', $this->_id);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
     // CRM-4395, get the online pending contribution id.
     $this->_onlinePendingContributionId = NULL;
     if (!$this->_mode && $this->_id && $this->_action & CRM_Core_Action::UPDATE) {
         $this->_onlinePendingContributionId = CRM_Contribute_BAO_Contribution::checkOnlinePendingContribution($this->_id, 'Event');
     }
     $this->set('onlinePendingContributionId', $this->_onlinePendingContributionId);
 }
Exemple #2
0
 /** 
  * Function to set variables up before form is built 
  *                                                           
  * @return void 
  * @access public 
  */
 public function preProcess()
 {
     $this->_showFeeBlock = CRM_Utils_Array::value('eventId', $_GET);
     $this->assign('showFeeBlock', false);
     $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
     $this->_participantId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('context', $this->_context);
     // get the option value for custom data type
     $this->_roleCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantRole', 'name');
     $this->_eventNameCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventName', 'name');
     $this->assign('roleCustomDataTypeID', $this->_roleCustomDataTypeID);
     $this->assign('eventNameCustomDataTypeID', $this->_eventNameCustomDataTypeID);
     if ($this->_mode) {
         $this->assign('participantMode', $this->_mode);
         $this->_paymentProcessor = array('billing_mode' => 1);
         $validProcessors = array();
         $processors = CRM_Core_PseudoConstant::paymentProcessor(false, false, "billing_mode IN ( 1, 3 )");
         foreach ($processors as $ppID => $label) {
             require_once 'CRM/Core/BAO/PaymentProcessor.php';
             require_once 'CRM/Core/Payment.php';
             $paymentProcessor =& CRM_Core_BAO_PaymentProcessor::getPayment($ppID, $this->_mode);
             if ($paymentProcessor['payment_processor_type'] == 'PayPal' && !$paymentProcessor['user_name']) {
                 continue;
             } else {
                 if ($paymentProcessor['payment_processor_type'] == 'Dummy' && $this->_mode == 'live') {
                     continue;
                 } else {
                     $paymentObject =& CRM_Core_Payment::singleton($this->_mode, 'Contribute', $paymentProcessor, $this);
                     $error = $paymentObject->checkConfig();
                     if (empty($error)) {
                         $validProcessors[$ppID] = $label;
                     }
                     $paymentObject = null;
                 }
             }
         }
         if (empty($validProcessors)) {
             CRM_Core_Error::fatal(ts('Could not find valid payment processor for this page'));
         } else {
             $this->_processors = $validProcessors;
         }
         // also check for billing information
         // get the billing location type
         $locationTypes =& CRM_Core_PseudoConstant::locationType();
         $this->_bltID = array_search('Billing', $locationTypes);
         if (!$this->_bltID) {
             CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
         }
         $this->set('bltID', $this->_bltID);
         $this->assign('bltID', $this->_bltID);
         $this->_fields = array();
         require_once 'CRM/Core/Payment/Form.php';
         CRM_Core_Payment_Form::setCreditCardFields($this);
         // this required to show billing block
         $this->assign_by_ref('paymentProcessor', $paymentProcessor);
         $this->assign('hidePayPalExpress', true);
     }
     if ($this->_showFeeBlock) {
         $this->assign('showFeeBlock', true);
         $this->assign('paid', true);
         return CRM_Event_Form_EventFees::preProcess($this);
     }
     //custom data related code
     $this->_cdType = CRM_Utils_Array::value('type', $_GET);
     $this->assign('cdType', false);
     if ($this->_cdType) {
         $this->assign('cdType', true);
         return CRM_Custom_Form_CustomData::preProcess($this);
     }
     //check the mode when this form is called either single or as
     //search task action
     if ($this->_participantId || $this->_contactID || $this->_context == 'standalone') {
         $this->_single = true;
         $this->assign('urlPath', 'civicrm/contact/view/participant');
         if (!$this->_participantId && !$this->_contactID) {
             $breadCrumbs = array(array('title' => ts('CiviEvent Dashboard'), 'url' => CRM_Utils_System::url('civicrm/event', 'reset=1')));
             CRM_Utils_System::appendBreadCrumb($breadCrumbs);
         }
     } else {
         //set the appropriate action
         $advanced = null;
         $builder = null;
         $session =& CRM_Core_Session::singleton();
         $advanced = $session->get('isAdvanced');
         $builder = $session->get('isSearchBuilder');
         $searchType = "basic";
         if ($advanced == 1) {
             $this->_action = CRM_Core_Action::ADVANCED;
             $searchType = "advanced";
         } else {
             if ($advanced == 2 && ($builder = 1)) {
                 $this->_action = CRM_Core_Action::PROFILE;
                 $searchType = "builder";
             } else {
                 if ($advanced == 3) {
                     $searchType = "custom";
                 }
             }
         }
         parent::preProcess();
         $this->_single = false;
         $this->_contactID = null;
         //set ajax path, this used for custom data building
         $this->assign('urlPath', "civicrm/contact/search/{$searchType}");
         $this->assign('urlPathVar', "_qf_Participant_display=true&qfKey={$this->controller->_key}");
     }
     $this->assign('single', $this->_single);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'add');
     $this->assign('action', $this->_action);
     // check for edit permission
     if (!CRM_Core_Permission::checkActionPermission('CiviEvent', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
     }
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     if ($this->_participantId) {
         // assign participant id to the template
         $this->assign('participantId', $this->_participantId);
         $this->_roleId = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Participant", $this->_participantId, 'role_id');
     }
     // when fee amount is included in form
     if (CRM_Utils_Array::value('hidden_feeblock', $_POST) || CRM_Utils_Array::value('send_receipt', $_POST)) {
         CRM_Event_Form_EventFees::preProcess($this);
         CRM_Event_Form_EventFees::buildQuickForm($this);
         CRM_Event_Form_EventFees::setDefaultValues($this);
     }
     // when custom data is included in this page
     if (CRM_Utils_Array::value("hidden_custom", $_POST)) {
         //custom data of type participant role
         CRM_Custom_Form_Customdata::preProcess($this, $this->_roleCustomDataTypeID, $_POST['role_id'], 1, 'Participant', $this->_participantId);
         CRM_Custom_Form_Customdata::buildQuickForm($this);
         CRM_Custom_Form_Customdata::setDefaultValues($this);
         //custom data of type participant event
         CRM_Custom_Form_Customdata::preProcess($this, $this->_eventNameCustomDataTypeID, $_POST['event_id'], 1, 'Participant', $this->_participantId);
         CRM_Custom_Form_Customdata::buildQuickForm($this);
         CRM_Custom_Form_Customdata::setDefaultValues($this);
         //custom data of type participant, ( we 'null' to reset subType and subName)
         CRM_Custom_Form_Customdata::preProcess($this, 'null', 'null', 1, 'Participant', $this->_participantId);
         CRM_Custom_Form_Customdata::buildQuickForm($this);
         CRM_Custom_Form_Customdata::setDefaultValues($this);
     }
     // CRM-4395, get the online pending contribution id.
     $this->_onlinePendingContributionId = null;
     if (!$this->_mode && $this->_participantId && $this->_action & CRM_Core_Action::UPDATE) {
         require_once 'CRM/Contribute/BAO/Contribution.php';
         $this->_onlinePendingContributionId = CRM_Contribute_BAO_Contribution::checkOnlinePendingContribution($this->_participantId, 'Event');
     }
     $this->set('onlinePendingContributionId', $this->_onlinePendingContributionId);
 }
Exemple #3
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     $this->_showFeeBlock = CRM_Utils_Array::value('eventId', $_GET);
     $this->assign('showFeeBlock', FALSE);
     $this->assign('feeBlockPaid', FALSE);
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
     $this->_eID = CRM_Utils_Request::retrieve('eid', 'Positive', $this);
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('context', $this->_context);
     if ($this->_contactId) {
         $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
         $this->assign('displayName', $displayName);
         // omitting contactImage from title for now since the summary overlay css doesn't work outside of our crm-container
         CRM_Utils_System::setTitle(ts('Event Registration for') . ' ' . $displayName);
     }
     // check the current path, if search based, then dont get participantID
     // CRM-5792
     $path = CRM_Utils_System::currentPath();
     if (strpos($path, 'civicrm/contact/search') === 0 || strpos($path, 'civicrm/group/search') === 0) {
         $this->_id = NULL;
     } else {
         $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     }
     if ($this->_id) {
         $this->_paymentId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'id', 'participant_id');
         // CRM-12615 - Get payment information from the primary registration
         if (!$this->_paymentId && $this->_action == CRM_Core_Action::UPDATE) {
             $registered_by_id = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'registered_by_id', 'id');
             if ($registered_by_id) {
                 $this->_paymentId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $registered_by_id, 'id', 'participant_id');
                 $this->assign('registeredByParticipantId', $registered_by_id);
             }
         }
     }
     // get the option value for custom data type
     $this->_roleCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantRole', 'name');
     $this->_eventNameCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventName', 'name');
     $this->_eventTypeCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventType', 'name');
     $this->assign('roleCustomDataTypeID', $this->_roleCustomDataTypeID);
     $this->assign('eventNameCustomDataTypeID', $this->_eventNameCustomDataTypeID);
     $this->assign('eventTypeCustomDataTypeID', $this->_eventTypeCustomDataTypeID);
     if ($this->_mode) {
         $this->assign('participantMode', $this->_mode);
         $this->_paymentProcessor = array('billing_mode' => 1);
         $validProcessors = array();
         $processors = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE, "billing_mode IN ( 1, 3 )");
         foreach ($processors as $ppID => $label) {
             $paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($ppID, $this->_mode);
             if ($paymentProcessor['payment_processor_type'] == 'PayPal' && !$paymentProcessor['user_name']) {
                 continue;
             } elseif ($paymentProcessor['payment_processor_type'] == 'Dummy' && $this->_mode == 'live') {
                 continue;
             } else {
                 $paymentObject = CRM_Core_Payment::singleton($this->_mode, $paymentProcessor, $this);
                 $error = $paymentObject->checkConfig();
                 if (empty($error)) {
                     $validProcessors[$ppID] = $label;
                 }
                 $paymentObject = NULL;
             }
         }
         if (empty($validProcessors)) {
             CRM_Core_Error::fatal(ts('Could not find valid payment processor for this page'));
         } else {
             $this->_processors = $validProcessors;
         }
         // also check for billing information
         // get the billing location type
         $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
         // CRM-8108 remove ts around Billing location type
         //$this->_bltID = array_search( ts('Billing'),  $locationTypes );
         $this->_bltID = array_search('Billing', $locationTypes);
         if (!$this->_bltID) {
             CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
         }
         $this->set('bltID', $this->_bltID);
         $this->assign('bltID', $this->_bltID);
         $this->_fields = array();
         CRM_Core_Payment_Form::setCreditCardFields($this);
         // this required to show billing block
         $this->assign_by_ref('paymentProcessor', $paymentProcessor);
         $this->assign('hidePayPalExpress', TRUE);
     }
     if ($this->_showFeeBlock) {
         $this->assign('showFeeBlock', TRUE);
         $isMonetary = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_showFeeBlock, 'is_monetary');
         if ($isMonetary) {
             $this->assign('feeBlockPaid', TRUE);
         }
         return CRM_Event_Form_EventFees::preProcess($this);
     }
     //custom data related code
     $this->_cdType = CRM_Utils_Array::value('type', $_GET);
     $this->assign('cdType', FALSE);
     if ($this->_cdType) {
         $this->assign('cdType', TRUE);
         return CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, NULL, NULL, NULL, TRUE);
     }
     //check the mode when this form is called either single or as
     //search task action
     if ($this->_id || $this->_contactId || $this->_context == 'standalone') {
         $this->_single = TRUE;
         $this->assign('urlPath', 'civicrm/contact/view/participant');
         if (!$this->_id && !$this->_contactId) {
             $breadCrumbs = array(array('title' => ts('CiviEvent Dashboard'), 'url' => CRM_Utils_System::url('civicrm/event', 'reset=1')));
             CRM_Utils_System::appendBreadCrumb($breadCrumbs);
         }
     } else {
         //set the appropriate action
         $context = $this->get('context');
         $urlString = 'civicrm/contact/search';
         $this->_action = CRM_Core_Action::BASIC;
         switch ($context) {
             case 'advanced':
                 $urlString = 'civicrm/contact/search/advanced';
                 $this->_action = CRM_Core_Action::ADVANCED;
                 break;
             case 'builder':
                 $urlString = 'civicrm/contact/search/builder';
                 $this->_action = CRM_Core_Action::PROFILE;
                 break;
             case 'basic':
                 $urlString = 'civicrm/contact/search/basic';
                 $this->_action = CRM_Core_Action::BASIC;
                 break;
             case 'custom':
                 $urlString = 'civicrm/contact/search/custom';
                 $this->_action = CRM_Core_Action::COPY;
                 break;
         }
         parent::preProcess();
         $this->_single = FALSE;
         $this->_contactId = NULL;
         //set ajax path, this used for custom data building
         $this->assign('urlPath', $urlString);
         $this->assign('urlPathVar', "_qf_Participant_display=true&qfKey={$this->controller->_key}");
     }
     $this->assign('single', $this->_single);
     if (!$this->_id) {
         $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add');
     }
     $this->assign('action', $this->_action);
     // check for edit permission
     if (!CRM_Core_Permission::checkActionPermission('CiviEvent', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
     }
     if ($this->_action & CRM_Core_Action::DELETE) {
         // check delete permission for contribution
         if ($this->_id && $this->_paymentId && !CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) {
             CRM_Core_Error::fatal(ts("This Participant is linked to a contribution. You must have 'delete in CiviContribute' permission in order to delete this record."));
         }
         return;
     }
     if ($this->_id) {
         // assign participant id to the template
         $this->assign('participantId', $this->_id);
         $this->_roleId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'role_id');
     }
     // when fee amount is included in form
     if (CRM_Utils_Array::value('hidden_feeblock', $_POST) || CRM_Utils_Array::value('send_receipt', $_POST)) {
         CRM_Event_Form_EventFees::preProcess($this);
         CRM_Event_Form_EventFees::buildQuickForm($this);
         CRM_Event_Form_EventFees::setDefaultValues($this);
     }
     // when custom data is included in this page
     if (CRM_Utils_Array::value('hidden_custom', $_POST)) {
         //custom data of type participant role
         if (CRM_Utils_Array::value('role_id', $_POST)) {
             foreach ($_POST['role_id'] as $k => $val) {
                 $roleID = $val;
                 CRM_Custom_Form_CustomData::preProcess($this, $this->_roleCustomDataTypeID, $k, 1, 'Participant', $this->_id);
                 CRM_Custom_Form_CustomData::buildQuickForm($this);
                 CRM_Custom_Form_CustomData::setDefaultValues($this);
             }
         }
         //custom data of type participant event
         CRM_Custom_Form_CustomData::preProcess($this, $this->_eventNameCustomDataTypeID, $_POST['event_id'], 1, 'Participant', $this->_id);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
         // custom data of type participant event type
         $eventTypeId = NULL;
         if ($eventId = CRM_Utils_Array::value('event_id', $_POST)) {
             $eventTypeId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $eventId, 'event_type_id', 'id');
         }
         CRM_Custom_Form_CustomData::preProcess($this, $this->_eventTypeCustomDataTypeID, $eventTypeId, 1, 'Participant', $this->_id);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
         //custom data of type participant, ( we 'null' to reset subType and subName)
         CRM_Custom_Form_CustomData::preProcess($this, 'null', 'null', 1, 'Participant', $this->_id);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
     // CRM-4395, get the online pending contribution id.
     $this->_onlinePendingContributionId = NULL;
     if (!$this->_mode && $this->_id && $this->_action & CRM_Core_Action::UPDATE) {
         $this->_onlinePendingContributionId = CRM_Contribute_BAO_Contribution::checkOnlinePendingContribution($this->_id, 'Event');
     }
     $this->set('onlinePendingContributionId', $this->_onlinePendingContributionId);
     $roleIds = CRM_Event_PseudoConstant::participantRole();
     if (!empty($roleIds)) {
         $query = "\nSELECT civicrm_custom_group.name as name,\n       civicrm_custom_group.id as id,\n       extends_entity_column_value as value\n  FROM civicrm_custom_group\n WHERE ( extends_entity_column_value REGEXP '[[:<:]]" . implode('[[:>:]]|[[:<:]]', array_keys($roleIds)) . "[[:>:]]'\n    OR extends_entity_column_value IS NULL )\n   AND extends_entity_column_id = '{$this->_roleCustomDataTypeID}'\n   AND extends = 'Participant'\n   AND is_active = 1";
         $dao = CRM_Core_DAO::executeQuery($query);
         while ($dao->fetch()) {
             if ($dao->value) {
                 $getRole = explode(CRM_Core_DAO::VALUE_SEPARATOR, $dao->value);
                 foreach ($getRole as $r) {
                     if (!$r) {
                         continue;
                     }
                     if (isset($this->_participantRoleIds[$r])) {
                         $this->_participantRoleIds[$r] .= ',' . $dao->name;
                     } else {
                         $this->_participantRoleIds[$r] = $dao->name;
                     }
                 }
             } else {
                 if (isset($this->_participantRoleIds[0])) {
                     $this->_participantRoleIds[0] .= ',' . $dao->name;
                 } else {
                     $this->_participantRoleIds[0] = $dao->name;
                 }
             }
         }
         $dao->free();
     }
     foreach ($roleIds as $k => $v) {
         if (!isset($this->_participantRoleIds[$k])) {
             $this->_participantRoleIds[$k] = '';
         }
     }
     $this->assign('participantRoleIds', $this->_participantRoleIds);
 }
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     parent::preProcess();
     //CRM-4320.
     //here we can't use parent $this->_allowWaitlist as user might
     //walk back and we maight set this value in this postProcess.
     //(we set when spaces < group count and want to allow become part of waiting )
     $eventFull = CRM_Event_BAO_Participant::eventFull($this->_eventId, FALSE, CRM_Utils_Array::value('has_waitlist', $this->_values['event']));
     // Get payment processors if appropriate for this event
     // We hide the payment fields if the event is full or requires approval,
     // and the current user has not yet been approved CRM-12279
     $this->_noFees = ($eventFull || $this->_requireApproval) && !$this->_allowConfirmation;
     CRM_Contribute_Form_Contribution_Main::preProcessPaymentOptions($this, $this->_noFees);
     if ($this->_snippet) {
         return;
     }
     $this->_allowWaitlist = FALSE;
     if ($eventFull && !$this->_allowConfirmation && CRM_Utils_Array::value('has_waitlist', $this->_values['event'])) {
         $this->_allowWaitlist = TRUE;
         $this->_waitlistMsg = CRM_Utils_Array::value('waitlist_text', $this->_values['event']);
         if (!$this->_waitlistMsg) {
             $this->_waitlistMsg = ts('This event is currently full. However you can register now and get added to a waiting list. You will be notified if spaces become available.');
         }
     }
     $this->set('allowWaitlist', $this->_allowWaitlist);
     //To check if the user is already registered for the event(CRM-2426)
     if (!$this->_skipDupeRegistrationCheck) {
         self::checkRegistration(NULL, $this);
     }
     $this->assign('availableRegistrations', $this->_availableRegistrations);
     // get the participant values from EventFees.php, CRM-4320
     if ($this->_allowConfirmation) {
         CRM_Event_Form_EventFees::preProcess($this);
     }
 }
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     parent::preProcess();
     $this->_ppType = CRM_Utils_Array::value('type', $_GET);
     $this->assign('ppType', FALSE);
     if ($this->_ppType) {
         $this->assign('ppType', TRUE);
         return CRM_Core_Payment_ProcessorForm::preProcess($this);
     }
     //get payPal express id and make it available to template
     $paymentProcessors = $this->get('paymentProcessors');
     $this->assign('payPalExpressId', 0);
     if (!empty($paymentProcessors)) {
         foreach ($paymentProcessors as $ppId => $values) {
             $payPalExpressId = $values['payment_processor_type'] == 'PayPal_Express' ? $values['id'] : 0;
             $this->assign('payPalExpressId', $payPalExpressId);
             if ($payPalExpressId) {
                 break;
             }
         }
     }
     //CRM-4320.
     //here we can't use parent $this->_allowWaitlist as user might
     //walk back and we maight set this value in this postProcess.
     //(we set when spaces < group count and want to allow become part of waiting )
     $eventFull = CRM_Event_BAO_Participant::eventFull($this->_eventId, FALSE, CRM_Utils_Array::value('has_waitlist', $this->_values['event']));
     $this->_allowWaitlist = FALSE;
     if ($eventFull && !$this->_allowConfirmation && CRM_Utils_Array::value('has_waitlist', $this->_values['event'])) {
         $this->_allowWaitlist = TRUE;
         $this->_waitlistMsg = CRM_Utils_Array::value('waitlist_text', $this->_values['event']);
         if (!$this->_waitlistMsg) {
             $this->_waitlistMsg = ts('This event is currently full. However you can register now and get added to a waiting list. You will be notified if spaces become available.');
         }
     }
     $this->set('allowWaitlist', $this->_allowWaitlist);
     //To check if the user is already registered for the event(CRM-2426)
     if (!$this->_skipDupeRegistrationCheck) {
         self::checkRegistration(NULL, $this);
     }
     $this->assign('availableRegistrations', $this->_availableRegistrations);
     // get the participant values from EventFees.php, CRM-4320
     if ($this->_allowConfirmation) {
         CRM_Event_Form_EventFees::preProcess($this);
     }
     if (CRM_Utils_Array::value('hidden_processor', $_POST)) {
         $this->set('type', CRM_Utils_Array::value('payment_processor', $_POST));
         $this->set('mode', $this->_mode);
         $this->set('paymentProcessor', $this->_paymentProcessor);
         CRM_Core_Payment_ProcessorForm::preProcess($this);
         CRM_Core_Payment_ProcessorForm::buildQuickForm($this);
     }
 }
 /** 
  * Function to set variables up before form is built 
  *                                                           
  * @return void 
  * @access public 
  */
 function preProcess()
 {
     parent::preProcess();
     //CRM-4320.
     //here we can't use parent $this->_allowWaitlist as user might
     //walk back and we maight set this value in this postProcess.
     //(we set when spaces < group count and want to allow become part of waiting )
     require_once 'CRM/Event/BAO/Participant.php';
     $eventFull = CRM_Event_BAO_Participant::eventFull($this->_eventId);
     $this->_allowWaitlist = false;
     if ($eventFull && !$this->_allowConfirmation && CRM_Utils_Array::value('has_waitlist', $this->_values['event'])) {
         $this->_allowWaitlist = true;
         $this->_waitlistMsg = CRM_Utils_Array::value('waitlist_text', $this->_values['event']);
         if (!$this->_waitlistMsg) {
             $this->_waitlistMsg = ts('This event is currently full. However you can register now and get added to a waiting list. You will be notified if spaces become available.');
         }
     }
     $this->set('allowWaitlist', $this->_allowWaitlist);
     //To check if the user is already registered for the event(CRM-2426)
     self::checkRegistration(null, $this);
     $this->assign('availableRegistrations', $this->_availableRegistrations);
     // get the participant values from EventFees.php, CRM-4320
     if ($this->_allowConfirmation) {
         require_once 'CRM/Event/Form/EventFees.php';
         CRM_Event_Form_EventFees::preProcess($this);
     }
     // Assign pageTitle
     $this->assign('pageTitle', ts('Event Registration'));
 }