/**
  * Set variables up before form is built.
  */
 public function preProcess()
 {
     // Check permission for action.
     if (!CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     parent::preProcess();
     $this->_formType = CRM_Utils_Array::value('formType', $_GET);
     // Get price set id.
     $this->_priceSetId = CRM_Utils_Array::value('priceSetId', $_GET);
     $this->set('priceSetId', $this->_priceSetId);
     $this->assign('priceSetId', $this->_priceSetId);
     // Get the pledge payment id
     $this->_ppID = CRM_Utils_Request::retrieve('ppid', 'Positive', $this);
     $this->assign('action', $this->_action);
     // Get the contribution id if update
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     if (!empty($this->_id)) {
         $this->assign('contribID', $this->_id);
     }
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('context', $this->_context);
     $this->_compId = CRM_Utils_Request::retrieve('compId', 'Positive', $this);
     $this->_compContext = CRM_Utils_Request::retrieve('compContext', 'String', $this);
     //set the contribution mode.
     $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
     $this->assign('contributionMode', $this->_mode);
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     $this->assign('showCheckNumber', TRUE);
     $this->_fromEmails = CRM_Core_BAO_Email::getFromEmail();
     $this->assignPaymentRelatedVariables();
     if (in_array('CiviPledge', CRM_Core_Config::singleton()->enableComponents) && !$this->_formType) {
         $this->preProcessPledge();
     }
     if ($this->_id) {
         $this->showRecordLinkMesssage($this->_id);
     }
     $this->_values = array();
     // Current contribution id.
     if ($this->_id) {
         $this->assignPremiumProduct($this->_id);
         $this->buildValuesAndAssignOnline_Note_Type($this->_id, $this->_values);
     }
     // when custom data is included in this page
     if (!empty($_POST['hidden_custom'])) {
         $this->applyCustomData('Contribution', CRM_Utils_Array::value('financial_type_id', $_POST), $this->_id);
     }
     $this->_lineItems = array();
     if ($this->_id) {
         if (!empty($this->_compId) && $this->_compContext == 'participant') {
             $this->assign('compId', $this->_compId);
             $lineItem = CRM_Price_BAO_LineItem::getLineItems($this->_compId);
         } else {
             $lineItem = CRM_Price_BAO_LineItem::getLineItems($this->_id, 'contribution', 1, TRUE, TRUE);
         }
         empty($lineItem) ? NULL : ($this->_lineItems[] = $lineItem);
     }
     $this->assign('lineItem', empty($this->_lineItems) ? FALSE : $this->_lineItems);
     // Set title
     if ($this->_mode) {
         $this->setPageTitle($this->_ppID ? ts('Credit Card Pledge Payment') : ts('Credit Card Contribution'));
     } else {
         $this->setPageTitle($this->_ppID ? ts('Pledge Payment') : ts('Contribution'));
     }
     if ($this->_id) {
         CRM_Contribute_Form_SoftCredit::preprocess($this);
     }
 }
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     //check permission for action.
     if (!CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
     }
     $this->_cdType = CRM_Utils_Array::value('type', $_GET);
     $this->assign('cdType', FALSE);
     if ($this->_cdType) {
         $this->assign('cdType', TRUE);
         CRM_Custom_Form_CustomData::preProcess($this);
         return;
     }
     $config = CRM_Core_Config::singleton();
     $this->_formType = CRM_Utils_Array::value('formType', $_GET);
     // get price set id.
     $this->_priceSetId = CRM_Utils_Array::value('priceSetId', $_GET);
     $this->set('priceSetId', $this->_priceSetId);
     $this->assign('priceSetId', $this->_priceSetId);
     //get the pledge payment id
     $this->_ppID = CRM_Utils_Request::retrieve('ppid', 'Positive', $this);
     //get the contact id
     $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     //get the action.
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add');
     $this->assign('action', $this->_action);
     //get the contribution id if update
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     if (!empty($this->_id)) {
         $this->assign('contribID', $this->_id);
     }
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('context', $this->_context);
     $this->_compId = CRM_Utils_Request::retrieve('compId', 'Positive', $this);
     $this->_compContext = CRM_Utils_Request::retrieve('compContext', 'String', $this);
     //set the contribution mode.
     $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
     $this->assign('contributionMode', $this->_mode);
     $this->_paymentProcessor = array('billing_mode' => 1);
     $this->assign('showCheckNumber', TRUE);
     $this->_fromEmails = CRM_Core_BAO_Email::getFromEmail();
     $this->assignProcessors();
     if ($this->_contactID) {
         list($this->userDisplayName, $this->userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID);
         $this->assign('displayName', $this->userDisplayName);
     }
     // also check for billing information
     // get the billing location type
     $this->assignBillingType();
     $this->_fields = array();
     CRM_Core_Payment_Form::setPaymentFieldsByType(CRM_Utils_Array::value('payment_type', $this->_processors), $this);
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     if (in_array('CiviPledge', $config->enableComponents) && !$this->_formType) {
         $this->preProcessPledge();
     }
     $this->_values = array();
     // current contribution id
     if ($this->_id) {
         $this->assignPremiumProduct($this->_id);
         $this->buildValuesAndAssignOnline_Note_Type($this->_id, $this->_values);
     }
     // when custom data is included in this page
     if (!empty($_POST['hidden_custom'])) {
         $this->applyCustomData('Contribution', CRM_Utils_Array::value('financial_type_id', $_POST), $this->_id);
     }
     $this->_lineItems = array();
     if ($this->_id) {
         if (!empty($this->_compId) && $this->_compContext == 'participant') {
             $this->assign('compId', $this->_compId);
             $lineItem = CRM_Price_BAO_LineItem::getLineItems($this->_compId);
         } else {
             $lineItem = CRM_Price_BAO_LineItem::getLineItems($this->_id, 'contribution', 1);
         }
         empty($lineItem) ? NULL : ($this->_lineItems[] = $lineItem);
     }
     $this->assign('lineItem', empty($this->_lineItems) ? FALSE : $this->_lineItems);
     // Set title
     if ($this->_contactID) {
         $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactID);
         // Check if this is default domain contact CRM-10482
         if (CRM_Contact_BAO_Contact::checkDomainContact($this->_contactID)) {
             $displayName .= ' (' . ts('default organization') . ')';
         }
         // omitting contactImage from title for now since the summary overlay css doesn't work outside of our crm-container
         CRM_Utils_System::setTitle(ts('Contribution from') . ' ' . $displayName);
     }
     if ($this->_id) {
         CRM_Contribute_Form_SoftCredit::preprocess($this);
     }
 }