Example #1
0
 /**
  * Set variables up before form is built.
  */
 public function preProcess()
 {
     parent::preProcess();
     $this->_paymentProcessors = $this->get('paymentProcessors');
     $this->preProcessPaymentOptions();
     // Make the contributionPageID available to the template
     $this->assign('contributionPageID', $this->_id);
     $this->assign('isShare', CRM_Utils_Array::value('is_share', $this->_values));
     $this->assign('isConfirmEnabled', CRM_Utils_Array::value('is_confirm_enabled', $this->_values));
     $this->assign('reset', CRM_Utils_Request::retrieve('reset', 'Boolean', CRM_Core_DAO::$_nullObject));
     $this->assign('mainDisplay', CRM_Utils_Request::retrieve('_qf_Main_display', 'Boolean', CRM_Core_DAO::$_nullObject));
     if (!empty($this->_pcpInfo['id']) && !empty($this->_pcpInfo['intro_text'])) {
         $this->assign('intro_text', $this->_pcpInfo['intro_text']);
     } elseif (!empty($this->_values['intro_text'])) {
         $this->assign('intro_text', $this->_values['intro_text']);
     }
     $qParams = "reset=1&id={$this->_id}";
     if ($pcpId = CRM_Utils_Array::value('pcp_id', $this->_pcpInfo)) {
         $qParams .= "&pcpId={$pcpId}";
     }
     $this->assign('qParams', $qParams);
     if (!empty($this->_values['footer_text'])) {
         $this->assign('footer_text', $this->_values['footer_text']);
     }
 }
Example #2
0
 /** 
  * Function to set variables up before form is built 
  *                                                           
  * @return void 
  * @access public 
  */
 function preProcess()
 {
     parent::preProcess();
     $this->assign('intro_text', $this->_values['intro_text']);
     $this->assign('footer_text', $this->_values['footer_text']);
     // to process Custom data that are appended to URL
     require_once 'CRM/Core/BAO/CustomGroup.php';
     CRM_Core_BAO_CustomGroup::extractGetParams($this, 'Contribution');
 }
Example #3
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     $config =& CRM_Core_Config::singleton();
     parent::preProcess();
     if ($this->_contributeMode == 'express') {
         $nullObject = null;
         // rfp == redirect from paypal
         $rfp = CRM_Utils_Request::retrieve('rfp', $nullObject, false, null, 'GET');
         if ($rfp) {
             require_once 'CRM/Contribute/Payment.php';
             $payment =& CRM_Contribute_Payment::singleton($this->_mode);
             $this->_params = $payment->getExpressCheckoutDetails($this->get('token'));
             // fix state and country id if present
             if (CRM_Utils_Array::value('state_province', $this->_params)) {
                 $states =& CRM_Core_PseudoConstant::stateProvinceAbbreviation();
                 $states = array_flip($states);
                 $this->_params['state_province_id'] = CRM_Utils_Array::value($this->_params['state_province'], $states);
             }
             if (CRM_Utils_Array::value('country', $this->_params)) {
                 $states =& CRM_Core_PseudoConstant::countryIsoCode();
                 $states = array_flip($states);
                 $this->_params['country_id'] = CRM_Utils_Array::value($this->_params['country'], $states);
             }
             // set a few other parameters for PayPal
             $this->_params['token'] = $this->get('token');
             $this->_params['amount'] = $this->get('amount');
             $this->_params['currencyID'] = $config->defaultCurrency;
             $this->_params['payment_action'] = 'Sale';
             // also merge all the other values from the profile fields
             $values = $this->controller->exportValues('Main');
             $skipFields = array('amount', 'amount_other', 'first_name', 'middle_name', 'last_name', 'street_address', 'city', 'state_province_id', 'postal_code', 'country_id');
             foreach ($values as $name => $value) {
                 // skip amount field
                 if (!in_array($name, $skipFields)) {
                     $this->_params[$name] = $value;
                 }
             }
             $this->set('getExpressCheckoutDetails', $this->_params);
         } else {
             $this->_params = $this->get('getExpressCheckoutDetails');
         }
     } else {
         $this->_params = $this->controller->exportValues('Main');
         $this->_params['state_province'] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params['state_province_id']);
         $this->_params['country'] = CRM_Core_PseudoConstant::countryIsoCode($this->_params['country_id']);
         $this->_params['year'] = $this->_params['credit_card_exp_date']['Y'];
         $this->_params['month'] = $this->_params['credit_card_exp_date']['M'];
         $this->_params['ip_address'] = $_SERVER['REMOTE_ADDR'];
         $this->_params['amount'] = $this->get('amount');
         $this->_params['currencyID'] = $config->defaultCurrency;
         $this->_params['payment_action'] = 'Sale';
     }
     $this->_params['invoiceID'] = $this->get('invoiceID');
     $this->set('params', $this->_params);
 }
Example #4
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     parent::preProcess();
     $this->_params = $this->get('params');
     $is_deductible = $this->get('is_deductible');
     $this->assign('is_deductible', $is_deductible);
     $this->assign('thankyou_title', $this->_values['thankyou_title']);
     $this->assign('thankyou_text', $this->_values['thankyou_text']);
     $this->assign('thankyou_footer', $this->_values['thankyou_footer']);
     CRM_Utils_System::setTitle($this->_values['thankyou_title']);
 }
Example #5
0
 /**
  * Set variables up before form is built.
  */
 public function preProcess()
 {
     parent::preProcess();
     $this->_paymentProcessors = $this->get('paymentProcessors');
     $this->preProcessPaymentOptions();
     if (!empty($this->_ccid)) {
         $payment = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_ccid, 'contribution');
         //bounce if the contribution is not pending.
         if (empty($payment['balance'])) {
             CRM_Core_Error::statusBounce(ts("Returning since contribution has already been handled."));
         }
         if (!empty($payment['total'])) {
             $this->_pendingAmount = $payment['total'];
             $this->assign('pendingAmount', $this->_pendingAmount);
         }
         $lineItems = CRM_Price_BAO_LineItem::getLineItemsByContributionID($this->_ccid);
         foreach (array_keys($lineItems) as $id) {
             $lineItems[$id]['id'] = $id;
         }
         $itemId = key($lineItems);
         if ($itemId && !empty($lineItems[$itemId]['price_field_id'])) {
             $this->_priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $lineItems[$itemId]['price_field_id'], 'price_set_id');
         }
         if (!empty($lineItems[$itemId]['price_field_id'])) {
             $this->_lineItem[$this->_priceSetId] = $lineItems;
         }
         $isQuickConfig = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config');
         $this->assign('lineItem', $this->_lineItem);
         $this->assign('is_quick_config', $isQuickConfig);
         $this->assign('priceSetID', $this->_priceSetId);
     }
     // Make the contributionPageID available to the template
     $this->assign('contributionPageID', $this->_id);
     $this->assign('ccid', $this->_ccid);
     $this->assign('isShare', CRM_Utils_Array::value('is_share', $this->_values));
     $this->assign('isConfirmEnabled', CRM_Utils_Array::value('is_confirm_enabled', $this->_values));
     $this->assign('reset', CRM_Utils_Request::retrieve('reset', 'Boolean', CRM_Core_DAO::$_nullObject));
     $this->assign('mainDisplay', CRM_Utils_Request::retrieve('_qf_Main_display', 'Boolean', CRM_Core_DAO::$_nullObject));
     if (!empty($this->_pcpInfo['id']) && !empty($this->_pcpInfo['intro_text'])) {
         $this->assign('intro_text', $this->_pcpInfo['intro_text']);
     } elseif (!empty($this->_values['intro_text'])) {
         $this->assign('intro_text', $this->_values['intro_text']);
     }
     $qParams = "reset=1&id={$this->_id}";
     if ($pcpId = CRM_Utils_Array::value('pcp_id', $this->_pcpInfo)) {
         $qParams .= "&pcpId={$pcpId}";
     }
     $this->assign('qParams', $qParams);
     if (!empty($this->_values['footer_text'])) {
         $this->assign('footer_text', $this->_values['footer_text']);
     }
 }
Example #6
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     parent::preProcess();
     $this->_params = $this->get('params');
     $this->_lineItem = $this->get('lineItem');
     $is_deductible = $this->get('is_deductible');
     $this->assign('is_deductible', $is_deductible);
     $this->assign('thankyou_title', $this->_values['thankyou_title']);
     $this->assign('thankyou_text', CRM_Utils_Array::value('thankyou_text', $this->_values));
     $this->assign('thankyou_footer', CRM_Utils_Array::value('thankyou_footer', $this->_values));
     $this->assign('max_reminders', CRM_Utils_Array::value('max_reminders', $this->_values));
     $this->assign('initial_reminder_day', CRM_Utils_Array::value('initial_reminder_day', $this->_values));
     CRM_Utils_System::setTitle($this->_values['thankyou_title']);
 }
Example #7
0
 /** 
  * Function to set variables up before form is built 
  *                                                           
  * @return void 
  * @access public 
  */
 public function preProcess()
 {
     parent::preProcess();
     // make sure we have right permission to edit this user
     $csContactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, false, $this->_userID);
     require_once 'CRM/Contact/BAO/Contact.php';
     if ($csContactID != $this->_userID) {
         require_once 'CRM/Contact/BAO/Contact/Permission.php';
         if (CRM_Contact_BAO_Contact_Permission::validateChecksumContact($csContactID, $this)) {
             $session = CRM_Core_Session::singleton();
             $session->set('userID', $csContactID);
             $this->_userID = $csContactID;
         }
     }
     if (CRM_Utils_Array::value('id', $this->_pcpInfo) && CRM_Utils_Array::value('intro_text', $this->_pcpInfo)) {
         $this->assign('intro_text', $this->_pcpInfo['intro_text']);
     } else {
         if (CRM_Utils_Array::value('intro_text', $this->_values)) {
             $this->assign('intro_text', $this->_values['intro_text']);
         }
     }
     if (CRM_Utils_Array::value('footer_text', $this->_values)) {
         $this->assign('footer_text', $this->_values['footer_text']);
     }
     //CRM-5001
     if ($this->_values['is_for_organization']) {
         $msg = ts('Mixed profile not allowed for on behalf of registration/sign up.');
         require_once 'CRM/Core/BAO/UFGroup.php';
         if ($preID = CRM_Utils_Array::value('custom_pre_id', $this->_values)) {
             $preProfile = CRM_Core_BAO_UFGroup::profileGroups($preID);
             foreach (array('Individual', 'Organization', 'Household') as $contactType) {
                 if (in_array($contactType, $preProfile) && (in_array('Membership', $preProfile) || in_array('Contribution', $preProfile))) {
                     CRM_Core_Error::fatal($msg);
                 }
             }
         }
         if ($postID = CRM_Utils_Array::value('custom_post_id', $this->_values)) {
             $postProfile = CRM_Core_BAO_UFGroup::profileGroups($postID);
             foreach (array('Individual', 'Organization', 'Household') as $contactType) {
                 if (in_array($contactType, $postProfile) && (in_array('Membership', $postProfile) || in_array('Contribution', $postProfile))) {
                     CRM_Core_Error::fatal($msg);
                 }
             }
         }
     }
 }
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     parent::preProcess();
     $this->_params = $this->get('params');
     $this->_lineItem = $this->get('lineItem');
     $is_deductible = $this->get('is_deductible');
     $this->assign('is_deductible', $is_deductible);
     $this->assign('thankyou_title', CRM_Utils_Array::value('thankyou_title', $this->_values));
     $this->assign('thankyou_text', CRM_Utils_Array::value('thankyou_text', $this->_values));
     $this->assign('thankyou_footer', CRM_Utils_Array::value('thankyou_footer', $this->_values));
     $this->assign('max_reminders', CRM_Utils_Array::value('max_reminders', $this->_values));
     $this->assign('initial_reminder_day', CRM_Utils_Array::value('initial_reminder_day', $this->_values));
     CRM_Utils_System::setTitle(CRM_Utils_Array::value('thankyou_title', $this->_values));
     // Make the contributionPageID avilable to the template
     $this->assign('contributionPageID', $this->_id);
     $this->assign('isShare', $this->_values['is_share']);
     $this->_params['is_pay_later'] = $this->get('is_pay_later');
     $this->assign('is_pay_later', $this->_params['is_pay_later']);
     if ($this->_params['is_pay_later']) {
         $this->assign('pay_later_receipt', $this->_values['pay_later_receipt']);
     }
 }
Example #9
0
 /**
  * Set variables up before form is built.
  */
 public function preProcess()
 {
     $config = CRM_Core_Config::singleton();
     parent::preProcess();
     // lineItem isn't set until Register postProcess
     $this->_lineItem = $this->get('lineItem');
     $this->_paymentProcessor = $this->get('paymentProcessor');
     $this->_params = $this->controller->exportValues('Main');
     $this->_params['ip_address'] = CRM_Utils_System::ipAddress();
     $this->_params['amount'] = $this->get('amount');
     if (isset($this->_params['amount'])) {
         $this->setFormAmountFields($this->_params['priceSetId']);
     }
     $this->_params['tax_amount'] = $this->get('tax_amount');
     $this->_useForMember = $this->get('useForMember');
     if (isset($this->_params['credit_card_exp_date'])) {
         $this->_params['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($this->_params);
         $this->_params['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($this->_params);
     }
     $this->_params['currencyID'] = $config->defaultCurrency;
     if (!empty($this->_membershipBlock)) {
         $this->_params['selectMembership'] = $this->get('selectMembership');
     }
     if (!empty($this->_paymentProcessor) && $this->_paymentProcessor['object']->supports('preApproval')) {
         $preApprovalParams = $this->_paymentProcessor['object']->getPreApprovalDetails($this->get('pre_approval_parameters'));
         $this->_params = array_merge($this->_params, $preApprovalParams);
     }
     // We may have fetched some billing details from the getPreApprovalDetails function so we
     // want to ensure we set this after that function has been called.
     CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $this->_params, FALSE);
     $this->_params['is_pay_later'] = $this->get('is_pay_later');
     $this->assign('is_pay_later', $this->_params['is_pay_later']);
     if ($this->_params['is_pay_later']) {
         $this->assign('pay_later_receipt', $this->_values['pay_later_receipt']);
     }
     // if onbehalf-of-organization
     if (!empty($this->_values['onbehalf_profile_id']) && !empty($this->_params['onbehalf']['organization_name'])) {
         // CRM-15182
         $this->_params['organization_id'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_params['onbehalf']['organization_name'], 'id', 'display_name');
         $this->_params['organization_name'] = $this->_params['onbehalf']['organization_name'];
         $addressBlocks = array('street_address', 'city', 'state_province', 'postal_code', 'country', 'supplemental_address_1', 'supplemental_address_2', 'supplemental_address_3', 'postal_code_suffix', 'geo_code_1', 'geo_code_2', 'address_name');
         $blocks = array('email', 'phone', 'im', 'url', 'openid');
         foreach ($this->_params['onbehalf'] as $loc => $value) {
             $field = $typeId = NULL;
             if (strstr($loc, '-')) {
                 list($field, $locType) = explode('-', $loc);
             }
             if (in_array($field, $addressBlocks)) {
                 if ($locType == 'Primary') {
                     $defaultLocationType = CRM_Core_BAO_LocationType::getDefault();
                     $locType = $defaultLocationType->id;
                 }
                 if ($field == 'country') {
                     $value = CRM_Core_PseudoConstant::countryIsoCode($value);
                 } elseif ($field == 'state_province') {
                     $value = CRM_Core_PseudoConstant::stateProvinceAbbreviation($value);
                 }
                 $isPrimary = 1;
                 if (isset($this->_params['onbehalf_location']['address']) && count($this->_params['onbehalf_location']['address']) > 0) {
                     $isPrimary = 0;
                 }
                 $this->_params['onbehalf_location']['address'][$locType][$field] = $value;
                 if (empty($this->_params['onbehalf_location']['address'][$locType]['is_primary'])) {
                     $this->_params['onbehalf_location']['address'][$locType]['is_primary'] = $isPrimary;
                 }
                 $this->_params['onbehalf_location']['address'][$locType]['location_type_id'] = $locType;
             } elseif (in_array($field, $blocks)) {
                 if (!$typeId || is_numeric($typeId)) {
                     $blockName = $fieldName = $field;
                     $locationType = 'location_type_id';
                     if ($locType == 'Primary') {
                         $defaultLocationType = CRM_Core_BAO_LocationType::getDefault();
                         $locationValue = $defaultLocationType->id;
                     } else {
                         $locationValue = $locType;
                     }
                     $locTypeId = '';
                     $phoneExtField = array();
                     if ($field == 'url') {
                         $blockName = 'website';
                         $locationType = 'website_type_id';
                         list($field, $locationValue) = explode('-', $loc);
                     } elseif ($field == 'im') {
                         $fieldName = 'name';
                         $locTypeId = 'provider_id';
                         $typeId = $this->_params['onbehalf']["{$loc}-provider_id"];
                     } elseif ($field == 'phone') {
                         list($field, $locType, $typeId) = explode('-', $loc);
                         $locTypeId = 'phone_type_id';
                         //check if extension field exists
                         $extField = str_replace('phone', 'phone_ext', $loc);
                         if (isset($this->_params['onbehalf'][$extField])) {
                             $phoneExtField = array('phone_ext' => $this->_params['onbehalf'][$extField]);
                         }
                     }
                     $isPrimary = 1;
                     if (isset($this->_params['onbehalf_location'][$blockName]) && count($this->_params['onbehalf_location'][$blockName]) > 0) {
                         $isPrimary = 0;
                     }
                     if ($locationValue) {
                         $blockValues = array($fieldName => $value, $locationType => $locationValue, 'is_primary' => $isPrimary);
                         if ($locTypeId) {
                             $blockValues = array_merge($blockValues, array($locTypeId => $typeId));
                         }
                         if (!empty($phoneExtField)) {
                             $blockValues = array_merge($blockValues, $phoneExtField);
                         }
                         $this->_params['onbehalf_location'][$blockName][] = $blockValues;
                     }
                 }
             } elseif (strstr($loc, 'custom')) {
                 if ($value && isset($this->_params['onbehalf']["{$loc}_id"])) {
                     $value = $this->_params['onbehalf']["{$loc}_id"];
                 }
                 $this->_params['onbehalf_location']["{$loc}"] = $value;
             } else {
                 if ($loc == 'contact_sub_type') {
                     $this->_params['onbehalf_location'][$loc] = $value;
                 } else {
                     $this->_params['onbehalf_location'][$field] = $value;
                 }
             }
         }
     } elseif (!empty($this->_values['is_for_organization'])) {
         // no on behalf of an organization, CRM-5519
         // so reset loc blocks from main params.
         foreach (array('phone', 'email', 'address') as $blk) {
             if (isset($this->_params[$blk])) {
                 unset($this->_params[$blk]);
             }
         }
     }
     $this->setRecurringMembershipParams();
     if ($this->_pcpId) {
         $params = $this->processPcp($this, $this->_params);
         $this->_params = $params;
     }
     $this->_params['invoiceID'] = $this->get('invoiceID');
     //carry campaign from profile.
     if (array_key_exists('contribution_campaign_id', $this->_params)) {
         $this->_params['campaign_id'] = $this->_params['contribution_campaign_id'];
     }
     // assign contribution page id to the template so we can add css class for it
     $this->assign('contributionPageID', $this->_id);
     $this->set('params', $this->_params);
 }
Example #10
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     $config = CRM_Core_Config::singleton();
     parent::preProcess();
     // lineItem isn't set until Register postProcess
     $this->_lineItem = $this->get('lineItem');
     $this->_paymentProcessor = $this->get('paymentProcessor');
     if ($this->_contributeMode == 'express') {
         // rfp == redirect from paypal
         $rfp = CRM_Utils_Request::retrieve('rfp', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'GET');
         if ($rfp) {
             $payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
             $expressParams = $payment->getExpressCheckoutDetails($this->get('token'));
             $this->_params['payer'] = $expressParams['payer'];
             $this->_params['payer_id'] = $expressParams['payer_id'];
             $this->_params['payer_status'] = $expressParams['payer_status'];
             CRM_Core_Payment_Form::mapParams($this->_bltID, $expressParams, $this->_params, FALSE);
             // fix state and country id if present
             if (!empty($this->_params["billing_state_province_id-{$this->_bltID}"]) && $this->_params["billing_state_province_id-{$this->_bltID}"]) {
                 $this->_params["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params["billing_state_province_id-{$this->_bltID}"]);
             }
             if (!empty($this->_params["billing_country_id-{$this->_bltID}"]) && $this->_params["billing_country_id-{$this->_bltID}"]) {
                 $this->_params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($this->_params["billing_country_id-{$this->_bltID}"]);
             }
             // set a few other parameters for PayPal
             $this->_params['token'] = $this->get('token');
             $this->_params['amount'] = $this->get('amount');
             if (!empty($this->_membershipBlock)) {
                 $this->_params['selectMembership'] = $this->get('selectMembership');
             }
             // we use this here to incorporate any changes made by folks in hooks
             $this->_params['currencyID'] = $config->defaultCurrency;
             $this->_params['payment_action'] = 'Sale';
             // also merge all the other values from the profile fields
             $values = $this->controller->exportValues('Main');
             $skipFields = array('amount', 'amount_other', "billing_street_address-{$this->_bltID}", "billing_city-{$this->_bltID}", "billing_state_province_id-{$this->_bltID}", "billing_postal_code-{$this->_bltID}", "billing_country_id-{$this->_bltID}");
             foreach ($values as $name => $value) {
                 // skip amount field
                 if (!in_array($name, $skipFields)) {
                     $this->_params[$name] = $value;
                 }
             }
             $this->set('getExpressCheckoutDetails', $this->_params);
         } else {
             $this->_params = $this->get('getExpressCheckoutDetails');
         }
     } else {
         $this->_params = $this->controller->exportValues('Main');
         if (!empty($this->_params["billing_state_province_id-{$this->_bltID}"])) {
             $this->_params["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params["billing_state_province_id-{$this->_bltID}"]);
         }
         if (!empty($this->_params["billing_country_id-{$this->_bltID}"])) {
             $this->_params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($this->_params["billing_country_id-{$this->_bltID}"]);
         }
         if (isset($this->_params['credit_card_exp_date'])) {
             $this->_params['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($this->_params);
             $this->_params['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($this->_params);
         }
         $this->_params['ip_address'] = CRM_Utils_System::ipAddress();
         $this->_params['amount'] = $this->get('amount');
         $this->_useForMember = $this->get('useForMember');
         if (isset($this->_params['amount'])) {
             $priceField = new CRM_Price_DAO_PriceField();
             $priceField->price_set_id = $this->_params['priceSetId'];
             $priceField->orderBy('weight');
             $priceField->find();
             $contriPriceId = NULL;
             $isQuickConfig = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_params['priceSetId'], 'is_quick_config');
             while ($priceField->fetch()) {
                 if ($priceField->name == "contribution_amount") {
                     $contriPriceId = $priceField->id;
                 }
                 if ($isQuickConfig && !empty($this->_params["price_{$priceField->id}"])) {
                     if ($this->_values['fee'][$priceField->id]['html_type'] != 'Text') {
                         $this->_params['amount_level'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $this->_params["price_{$priceField->id}"], 'label');
                     }
                     if ($priceField->name == "membership_amount") {
                         $this->_params['selectMembership'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $this->_params["price_{$priceField->id}"], 'membership_type_id');
                     }
                 } elseif (CRM_Utils_Array::value('is_separate_payment', $this->_membershipBlock) && !empty($this->_values['fee'][$priceField->id]) && $this->_values['fee'][$priceField->id]['name'] == "other_amount" && CRM_Utils_Array::value("price_{$contriPriceId}", $this->_params) < 1 && empty($this->_params["price_{$priceField->id}"])) {
                     $this->_params['amount'] = null;
                 }
             }
         }
         $this->_params['currencyID'] = $config->defaultCurrency;
         $this->_params['payment_action'] = 'Sale';
     }
     $this->_params['is_pay_later'] = $this->get('is_pay_later');
     $this->assign('is_pay_later', $this->_params['is_pay_later']);
     if ($this->_params['is_pay_later']) {
         $this->assign('pay_later_receipt', $this->_values['pay_later_receipt']);
     }
     // if onbehalf-of-organization
     if (!empty($this->_params['hidden_onbehalf_profile'])) {
         if (!empty($this->_params['org_option']) && !empty($this->_params['organization_id'])) {
             if (!empty($this->_params['onbehalfof_id'])) {
                 $this->_params['organization_id'] = $this->_params['onbehalfof_id'];
             }
         }
         $this->_params['organization_name'] = $this->_params['onbehalf']['organization_name'];
         $addressBlocks = array('street_address', 'city', 'state_province', 'postal_code', 'country', 'supplemental_address_1', 'supplemental_address_2', 'supplemental_address_3', 'postal_code_suffix', 'geo_code_1', 'geo_code_2', 'address_name');
         $blocks = array('email', 'phone', 'im', 'url', 'openid');
         foreach ($this->_params['onbehalf'] as $loc => $value) {
             $field = $typeId = NULL;
             if (strstr($loc, '-')) {
                 list($field, $locType) = explode('-', $loc);
             }
             if (in_array($field, $addressBlocks)) {
                 if ($locType == 'Primary') {
                     $defaultLocationType = CRM_Core_BAO_LocationType::getDefault();
                     $locType = $defaultLocationType->id;
                 }
                 if ($field == 'country') {
                     $value = CRM_Core_PseudoConstant::countryIsoCode($value);
                 } elseif ($field == 'state_province') {
                     $value = CRM_Core_PseudoConstant::stateProvinceAbbreviation($value);
                 }
                 $isPrimary = 1;
                 if (isset($this->_params['onbehalf_location']['address']) && count($this->_params['onbehalf_location']['address']) > 0) {
                     $isPrimary = 0;
                 }
                 $this->_params['onbehalf_location']['address'][$locType][$field] = $value;
                 if (empty($this->_params['onbehalf_location']['address'][$locType]['is_primary'])) {
                     $this->_params['onbehalf_location']['address'][$locType]['is_primary'] = $isPrimary;
                 }
                 $this->_params['onbehalf_location']['address'][$locType]['location_type_id'] = $locType;
             } elseif (in_array($field, $blocks)) {
                 if (!$typeId || is_numeric($typeId)) {
                     $blockName = $fieldName = $field;
                     $locationType = 'location_type_id';
                     if ($locType == 'Primary') {
                         $defaultLocationType = CRM_Core_BAO_LocationType::getDefault();
                         $locationValue = $defaultLocationType->id;
                     } else {
                         $locationValue = $locType;
                     }
                     $locTypeId = '';
                     $phoneExtField = array();
                     if ($field == 'url') {
                         $blockName = 'website';
                         $locationType = 'website_type_id';
                         $locationValue = CRM_Utils_Array::value("{$loc}-website_type_id", $this->_params['onbehalf']);
                     } elseif ($field == 'im') {
                         $fieldName = 'name';
                         $locTypeId = 'provider_id';
                         $typeId = $this->_params['onbehalf']["{$loc}-provider_id"];
                     } elseif ($field == 'phone') {
                         list($field, $locType, $typeId) = explode('-', $loc);
                         $locTypeId = 'phone_type_id';
                         //check if extension field exists
                         $extField = str_replace('phone', 'phone_ext', $loc);
                         if (isset($this->_params['onbehalf'][$extField])) {
                             $phoneExtField = array('phone_ext' => $this->_params['onbehalf'][$extField]);
                         }
                     }
                     $isPrimary = 1;
                     if (isset($this->_params['onbehalf_location'][$blockName]) && count($this->_params['onbehalf_location'][$blockName]) > 0) {
                         $isPrimary = 0;
                     }
                     if ($locationValue) {
                         $blockValues = array($fieldName => $value, $locationType => $locationValue, 'is_primary' => $isPrimary);
                         if ($locTypeId) {
                             $blockValues = array_merge($blockValues, array($locTypeId => $typeId));
                         }
                         if (!empty($phoneExtField)) {
                             $blockValues = array_merge($blockValues, $phoneExtField);
                         }
                         $this->_params['onbehalf_location'][$blockName][] = $blockValues;
                     }
                 }
             } elseif (strstr($loc, 'custom')) {
                 if ($value && isset($this->_params['onbehalf']["{$loc}_id"])) {
                     $value = $this->_params['onbehalf']["{$loc}_id"];
                 }
                 $this->_params['onbehalf_location']["{$loc}"] = $value;
             } else {
                 if ($loc == 'contact_sub_type') {
                     $this->_params['onbehalf_location'][$loc] = $value;
                 } else {
                     $this->_params['onbehalf_location'][$field] = $value;
                 }
             }
         }
     } elseif (!empty($this->_values['is_for_organization'])) {
         // no on behalf of an organization, CRM-5519
         // so reset loc blocks from main params.
         foreach (array('phone', 'email', 'address') as $blk) {
             if (isset($this->_params[$blk])) {
                 unset($this->_params[$blk]);
             }
         }
     }
     // if auto renew checkbox is set, initiate a open-ended recurring membership
     if ((!empty($this->_params['selectMembership']) || !empty($this->_params['priceSetId'])) && !empty($this->_paymentProcessor['is_recur']) && CRM_Utils_Array::value('auto_renew', $this->_params) && empty($this->_params['is_recur']) && empty($this->_params['frequency_interval'])) {
         $this->_params['is_recur'] = $this->_values['is_recur'] = 1;
         // check if price set is not quick config
         if (!empty($this->_params['priceSetId']) && !$isQuickConfig) {
             list($this->_params['frequency_interval'], $this->_params['frequency_unit']) = CRM_Price_BAO_PriceSet::getRecurDetails($this->_params['priceSetId']);
         } else {
             // FIXME: set interval and unit based on selected membership type
             $this->_params['frequency_interval'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_params['selectMembership'], 'duration_interval');
             $this->_params['frequency_unit'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_params['selectMembership'], 'duration_unit');
         }
     }
     if ($this->_pcpId) {
         $params = $this->processPcp($this, $this->_params);
         $this->_params = $params;
     }
     $this->_params['invoiceID'] = $this->get('invoiceID');
     //carry campaign from profile.
     if (array_key_exists('contribution_campaign_id', $this->_params)) {
         $this->_params['campaign_id'] = $this->_params['contribution_campaign_id'];
     }
     // assign contribution page id to the template so we can add css class for it
     $this->assign('contributionPageID', $this->_id);
     $this->set('params', $this->_params);
 }
Example #11
0
 /**
  * Set variables up before form is built.
  */
 public function preProcess()
 {
     parent::preProcess();
     self::preProcessPaymentOptions($this);
     // Make the contributionPageID available to the template
     $this->assign('contributionPageID', $this->_id);
     $this->assign('isShare', CRM_Utils_Array::value('is_share', $this->_values));
     $this->assign('isConfirmEnabled', CRM_Utils_Array::value('is_confirm_enabled', $this->_values));
     $this->assign('reset', CRM_Utils_Request::retrieve('reset', 'Boolean', CRM_Core_DAO::$_nullObject));
     $this->assign('mainDisplay', CRM_Utils_Request::retrieve('_qf_Main_display', 'Boolean', CRM_Core_DAO::$_nullObject));
     // Possible values for 'is_for_organization':
     // * 0 - org profile disabled
     // * 1 - org profile optional
     // * 2 - org profile required
     $this->_onbehalf = FALSE;
     if (!empty($this->_values['is_for_organization'])) {
         if ($this->_values['is_for_organization'] == 2) {
             $this->_onBehalfRequired = TRUE;
         }
         // Add organization profile if 1 of the following are true:
         // If the org profile is required
         if ($this->_onBehalfRequired || empty($_POST) || !empty($_POST['is_for_organization'])) {
             $this->_onbehalf = TRUE;
             CRM_Contribute_Form_Contribution_OnBehalfOf::preProcess($this);
         }
     }
     $this->assign('onBehalfRequired', $this->_onBehalfRequired);
     if ($this->_honor_block_is_active) {
         CRM_Contact_Form_ProfileContact::preprocess($this);
     }
     if ($this->_snippet) {
         $this->assign('isOnBehalfCallback', CRM_Utils_Array::value('onbehalf', $_GET, FALSE));
         return;
     }
     if (!empty($this->_pcpInfo['id']) && !empty($this->_pcpInfo['intro_text'])) {
         $this->assign('intro_text', $this->_pcpInfo['intro_text']);
     } elseif (!empty($this->_values['intro_text'])) {
         $this->assign('intro_text', $this->_values['intro_text']);
     }
     $qParams = "reset=1&amp;id={$this->_id}";
     if ($pcpId = CRM_Utils_Array::value('pcp_id', $this->_pcpInfo)) {
         $qParams .= "&amp;pcpId={$pcpId}";
     }
     $this->assign('qParams', $qParams);
     if (!empty($this->_values['footer_text'])) {
         $this->assign('footer_text', $this->_values['footer_text']);
     }
     //CRM-5001
     //CRM-15787
     $member = CRM_Member_BAO_Membership::getMembershipBlock($this->_id);
     if (!empty($this->_values['is_for_organization']) && empty($member['is_active'])) {
         $msg = ts('Mixed profile not allowed for on behalf of registration/sign up.');
         $ufJoinParams = array('module' => 'onBehalf', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $this->_id);
         $onBehalfProfileIDs = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
         // getUFGroupIDs returns an array with the first item being the ID we need
         $onBehalfProfileID = $onBehalfProfileIDs[0];
         if ($onBehalfProfileID) {
             $onBehalfProfile = CRM_Core_BAO_UFGroup::profileGroups($onBehalfProfileID);
             foreach (array('Individual', 'Organization', 'Household') as $contactType) {
                 if (in_array($contactType, $onBehalfProfile) && (in_array('Membership', $onBehalfProfile) || in_array('Contribution', $onBehalfProfile))) {
                     CRM_Core_Error::fatal($msg);
                 }
             }
         }
         if ($postID = CRM_Utils_Array::value('custom_post_id', $this->_values)) {
             $postProfile = CRM_Core_BAO_UFGroup::profileGroups($postID);
             foreach (array('Individual', 'Organization', 'Household') as $contactType) {
                 if (in_array($contactType, $postProfile) && (in_array('Membership', $postProfile) || in_array('Contribution', $postProfile))) {
                     CRM_Core_Error::fatal($msg);
                 }
             }
         }
     }
 }
Example #12
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     parent::preProcess();
     self::preProcessPaymentOptions($this);
     // Make the contributionPageID avilable to the template
     $this->assign('contributionPageID', $this->_id);
     $this->assign('isShare', CRM_Utils_Array::value('is_share', $this->_values));
     $this->assign('isConfirmEnabled', CRM_Utils_Array::value('is_confirm_enabled', $this->_values));
     // make sure we have right permission to edit this user
     $csContactID = $this->getContactID();
     $reset = CRM_Utils_Request::retrieve('reset', 'Boolean', CRM_Core_DAO::$_nullObject);
     $mainDisplay = CRM_Utils_Request::retrieve('_qf_Main_display', 'Boolean', CRM_Core_DAO::$_nullObject);
     if ($reset) {
         $this->assign('reset', $reset);
     }
     if ($mainDisplay) {
         $this->assign('mainDisplay', $mainDisplay);
     }
     // Possible values for 'is_for_organization':
     // * 0 - org profile disabled
     // * 1 - org profile optional
     // * 2 - org profile required
     $this->_onbehalf = FALSE;
     if (!empty($this->_values['is_for_organization'])) {
         if ($this->_values['is_for_organization'] == 2) {
             $this->_onBehalfRequired = TRUE;
         }
         // Add organization profile if 1 of the following are true:
         // If the org profile is required
         if ($this->_onBehalfRequired || empty($_POST) || !empty($_POST['is_for_organization'])) {
             $this->_onbehalf = TRUE;
             CRM_Contribute_Form_Contribution_OnBehalfOf::preProcess($this);
         }
     }
     $this->assign('onBehalfRequired', $this->_onBehalfRequired);
     if (!empty($this->_values['honor_block_is_active'])) {
         CRM_Contact_Form_ProfileContact::preprocess($this);
     }
     if ($this->_snippet) {
         $this->assign('isOnBehalfCallback', CRM_Utils_Array::value('onbehalf', $_GET, FALSE));
         return;
     }
     if (!empty($this->_pcpInfo['id']) && !empty($this->_pcpInfo['intro_text'])) {
         $this->assign('intro_text', $this->_pcpInfo['intro_text']);
     } elseif (!empty($this->_values['intro_text'])) {
         $this->assign('intro_text', $this->_values['intro_text']);
     }
     $qParams = "reset=1&amp;id={$this->_id}";
     if ($pcpId = CRM_Utils_Array::value('pcp_id', $this->_pcpInfo)) {
         $qParams .= "&amp;pcpId={$pcpId}";
     }
     $this->assign('qParams', $qParams);
     if (!empty($this->_values['footer_text'])) {
         $this->assign('footer_text', $this->_values['footer_text']);
     }
     //CRM-5001
     if (!empty($this->_values['is_for_organization'])) {
         $msg = ts('Mixed profile not allowed for on behalf of registration/sign up.');
         if ($preID = CRM_Utils_Array::value('custom_pre_id', $this->_values)) {
             $preProfile = CRM_Core_BAO_UFGroup::profileGroups($preID);
             foreach (array('Individual', 'Organization', 'Household') as $contactType) {
                 if (in_array($contactType, $preProfile) && (in_array('Membership', $preProfile) || in_array('Contribution', $preProfile))) {
                     CRM_Core_Error::fatal($msg);
                 }
             }
         }
         if ($postID = CRM_Utils_Array::value('custom_post_id', $this->_values)) {
             $postProfile = CRM_Core_BAO_UFGroup::profileGroups($postID);
             foreach (array('Individual', 'Organization', 'Household') as $contactType) {
                 if (in_array($contactType, $postProfile) && (in_array('Membership', $postProfile) || in_array('Contribution', $postProfile))) {
                     CRM_Core_Error::fatal($msg);
                 }
             }
         }
     }
 }
Example #13
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     $config =& CRM_Core_Config::singleton();
     parent::preProcess();
     // lineItem isn't set until Register postProcess
     $this->_lineItem = $this->get('lineItem');
     if ($this->_contributeMode == 'express') {
         // rfp == redirect from paypal
         $rfp = CRM_Utils_Request::retrieve('rfp', 'Boolean', CRM_Core_DAO::$_nullObject, false, null, 'GET');
         if ($rfp) {
             require_once 'CRM/Core/Payment.php';
             $payment =& CRM_Core_Payment::singleton($this->_mode, 'Contribute', $this->_paymentProcessor, $this);
             $expressParams = $payment->getExpressCheckoutDetails($this->get('token'));
             $this->_params['payer'] = $expressParams['payer'];
             $this->_params['payer_id'] = $expressParams['payer_id'];
             $this->_params['payer_status'] = $expressParams['payer_status'];
             require_once 'CRM/Core/Payment/Form.php';
             CRM_Core_Payment_Form::mapParams($this->_bltID, $expressParams, $this->_params, false);
             // fix state and country id if present
             if (!empty($this->_params["billing_state_province_id-{$this->_bltID}"]) && $this->_params["billing_state_province_id-{$this->_bltID}"]) {
                 $this->_params["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params["billing_state_province_id-{$this->_bltID}"]);
             }
             if (!empty($this->_params["billing_country_id-{$this->_bltID}"]) && $this->_params["billing_country_id-{$this->_bltID}"]) {
                 $this->_params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($this->_params["billing_country_id-{$this->_bltID}"]);
             }
             // set a few other parameters for PayPal
             $this->_params['token'] = $this->get('token');
             $this->_params['amount'] = $this->get('amount');
             // we use this here to incorporate any changes made by folks in hooks
             $this->_params['currencyID'] = $config->defaultCurrency;
             $this->_params['payment_action'] = 'Sale';
             // also merge all the other values from the profile fields
             $values = $this->controller->exportValues('Main');
             $skipFields = array('amount', 'amount_other', "billing_street_address-{$this->_bltID}", "billing_city-{$this->_bltID}", "billing_state_province_id-{$this->_bltID}", "billing_postal_code-{$this->_bltID}", "billing_country_id-{$this->_bltID}");
             foreach ($values as $name => $value) {
                 // skip amount field
                 if (!in_array($name, $skipFields)) {
                     $this->_params[$name] = $value;
                 }
             }
             $this->set('getExpressCheckoutDetails', $this->_params);
         } else {
             $this->_params = $this->get('getExpressCheckoutDetails');
         }
     } else {
         $this->_params = $this->controller->exportValues('Main');
         if (!empty($this->_params["billing_state_province_id-{$this->_bltID}"])) {
             $this->_params["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params["billing_state_province_id-{$this->_bltID}"]);
         }
         if (!empty($this->_params["billing_country_id-{$this->_bltID}"])) {
             $this->_params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($this->_params["billing_country_id-{$this->_bltID}"]);
         }
         if (isset($this->_params['credit_card_exp_date'])) {
             $this->_params['year'] = $this->_params['credit_card_exp_date']['Y'];
             $this->_params['month'] = $this->_params['credit_card_exp_date']['M'];
         }
         $this->_params['ip_address'] = $_SERVER['REMOTE_ADDR'];
         // hack for safari
         if ($this->_params['ip_address'] == '::1') {
             $this->_params['ip_address'] = '127.0.0.1';
         }
         $this->_params['amount'] = $this->get('amount');
         if ($this->_params['amount']) {
             require_once 'CRM/Core/OptionGroup.php';
             $this->_params['amount_level'] = CRM_Core_OptionGroup::optionLabel("civicrm_contribution_page.amount.{$this->_id}", $this->_params['amount']);
         }
         $this->_params['currencyID'] = $config->defaultCurrency;
         $this->_params['payment_action'] = 'Sale';
     }
     // if onbehalf-of-organization
     if (CRM_Utils_Array::value('is_for_organization', $this->_params)) {
         if (CRM_Utils_Array::value('org_option', $this->_params) && CRM_Utils_Array::value('organization_id', $this->_params)) {
             if (CRM_Utils_Array::value('onbehalfof_id', $this->_params)) {
                 $this->_params['organization_id'] = $this->_params['onbehalfof_id'];
             }
         }
         if (!empty($this->_params['address'][1]['country_id'])) {
             $this->_params['address'][1]['country'] = CRM_Core_PseudoConstant::countryIsoCode($this->_params['address'][1]['country_id']);
         }
         if (!empty($this->_params['address'][1]['state_province_id'])) {
             $this->_params['address'][1]['state_province'] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params['address'][1]['state_province_id']);
         }
         // hardcode blocks for now. We might shift to generalized model in 3.1 which uses profiles
         foreach (array('phone', 'email', 'address') as $loc) {
             $this->_params['onbehalf_location'][$loc] = $this->_params[$loc];
             unset($this->_params[$loc]);
         }
     } else {
         if (CRM_Utils_Array::value('is_for_organization', $this->_values)) {
             // no on behalf of an organization, CRM-5519
             // so reset loc blocks from main params.
             foreach (array('phone', 'email', 'address') as $blk) {
                 if (isset($this->_params[$blk])) {
                     unset($this->_params[$blk]);
                 }
             }
         }
     }
     if ($this->_pcpId) {
         $this->_params['pcp_made_through_id'] = $this->_pcpInfo['pcp_id'];
         $this->assign('pcpBlock', true);
         if (CRM_Utils_Array::value('pcp_display_in_roll', $this->_params) && !CRM_Utils_Array::value('pcp_roll_nickname', $this->_params)) {
             $this->_params['pcp_roll_nickname'] = ts('Anonymous');
             $this->_params['pcp_is_anonymous'] = 1;
         } else {
             $this->_params['pcp_is_anonymous'] = 0;
         }
         foreach (array('pcp_display_in_roll', 'pcp_is_anonymous', 'pcp_roll_nickname', 'pcp_personal_note') as $val) {
             if (CRM_Utils_Array::value($val, $this->_params)) {
                 $this->assign($val, $this->_params[$val]);
             }
         }
     }
     $this->_params['invoiceID'] = $this->get('invoiceID');
     $this->set('params', $this->_params);
 }
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 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');
     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;
             }
         }
     }
     // Make the contributionPageID avilable to the template
     $this->assign('contributionPageID', $this->_id);
     $this->assign('isShare', CRM_Utils_Array::value('is_share', $this->_values));
     $this->assign('isConfirmEnabled', CRM_Utils_Array::value('is_confirm_enabled', $this->_values));
     // make sure we have right permission to edit this user
     $csContactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE, $this->_userID);
     $reset = CRM_Utils_Request::retrieve('reset', 'Boolean', CRM_Core_DAO::$_nullObject);
     $mainDisplay = CRM_Utils_Request::retrieve('_qf_Main_display', 'Boolean', CRM_Core_DAO::$_nullObject);
     if ($csContactID != $this->_userID) {
         if (CRM_Contact_BAO_Contact_Permission::validateChecksumContact($csContactID, $this)) {
             $session = CRM_Core_Session::singleton();
             $session->set('userID', $csContactID);
             $this->_userID = $csContactID;
         }
     }
     if ($reset) {
         $this->assign('reset', $reset);
     }
     if ($mainDisplay) {
         $this->assign('mainDisplay', $mainDisplay);
     }
     $this->_onbehalf = FALSE;
     if (CRM_Utils_Array::value('is_for_organization', $this->_values)) {
         $urlParams = "&id={$this->_id}&qfKey={$this->controller->_key}";
         $this->assign('urlParams', $urlParams);
         $this->_onbehalf = CRM_Utils_Array::value('onbehalf', $_GET);
         CRM_Contribute_Form_Contribution_OnBehalfOf::preProcess($this);
         if (CRM_Utils_Array::value('hidden_onbehalf_profile', $_POST) && (CRM_Utils_Array::value('is_for_organization', $_POST) || CRM_Utils_Array::value('is_for_organization', $this->_values) == 2)) {
             CRM_Contribute_Form_Contribution_OnBehalfOf::buildQuickForm($this);
         }
     }
     if (CRM_Utils_Array::value('id', $this->_pcpInfo) && CRM_Utils_Array::value('intro_text', $this->_pcpInfo)) {
         $this->assign('intro_text', $this->_pcpInfo['intro_text']);
     } elseif (CRM_Utils_Array::value('intro_text', $this->_values)) {
         $this->assign('intro_text', $this->_values['intro_text']);
     }
     $qParams = "reset=1&amp;id={$this->_id}";
     if ($pcpId = CRM_Utils_Array::value('pcp_id', $this->_pcpInfo)) {
         $qParams .= "&amp;pcpId={$pcpId}";
     }
     $this->assign('qParams', $qParams);
     if (CRM_Utils_Array::value('footer_text', $this->_values)) {
         $this->assign('footer_text', $this->_values['footer_text']);
     }
     //CRM-5001
     if (CRM_Utils_Array::value('is_for_organization', $this->_values)) {
         $msg = ts('Mixed profile not allowed for on behalf of registration/sign up.');
         if ($preID = CRM_Utils_Array::value('custom_pre_id', $this->_values)) {
             $preProfile = CRM_Core_BAO_UFGroup::profileGroups($preID);
             foreach (array('Individual', 'Organization', 'Household') as $contactType) {
                 if (in_array($contactType, $preProfile) && (in_array('Membership', $preProfile) || in_array('Contribution', $preProfile))) {
                     CRM_Core_Error::fatal($msg);
                 }
             }
         }
         if ($postID = CRM_Utils_Array::value('custom_post_id', $this->_values)) {
             $postProfile = CRM_Core_BAO_UFGroup::profileGroups($postID);
             foreach (array('Individual', 'Organization', 'Household') as $contactType) {
                 if (in_array($contactType, $postProfile) && (in_array('Membership', $postProfile) || in_array('Contribution', $postProfile))) {
                     CRM_Core_Error::fatal($msg);
                 }
             }
         }
     }
     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 
  */
 public function preProcess()
 {
     parent::preProcess();
     // make sure we have right permission to edit this user
     $csContactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, false, $this->_userID);
     $reset = CRM_Utils_Request::retrieve('reset', 'Boolean', CRM_Core_DAO::$_nullObject);
     $mainDisplay = CRM_Utils_Request::retrieve('_qf_Main_display', 'Boolean', CRM_Core_DAO::$_nullObject);
     require_once 'CRM/Contact/BAO/Contact.php';
     if ($csContactID != $this->_userID) {
         require_once 'CRM/Contact/BAO/Contact/Permission.php';
         if (CRM_Contact_BAO_Contact_Permission::validateChecksumContact($csContactID, $this)) {
             $session = CRM_Core_Session::singleton();
             $session->set('userID', $csContactID);
             $this->_userID = $csContactID;
         }
     }
     if ($reset) {
         $this->assign('reset', $reset);
     }
     if ($mainDisplay) {
         $this->assign('mainDisplay', $mainDisplay);
     }
     $this->_onbehalf = false;
     if (CRM_Utils_Array::value('is_for_organization', $this->_values)) {
         $urlParams = "&id={$this->_id}&qfKey={$this->controller->_key}";
         $this->assign('urlParams', $urlParams);
         $this->_onbehalf = CRM_Utils_Array::value('onbehalf', $_GET);
         require_once 'CRM/Contribute/Form/Contribution/OnBehalfOf.php';
         CRM_Contribute_Form_Contribution_OnBehalfOf::preProcess($this);
         if (CRM_Utils_Array::value('hidden_onbehalf_profile', $_POST) && CRM_Utils_Array::value('is_for_organization', $_POST)) {
             CRM_Contribute_Form_Contribution_OnBehalfOf::buildQuickForm($this);
         }
     }
     if (CRM_Utils_Array::value('id', $this->_pcpInfo) && CRM_Utils_Array::value('intro_text', $this->_pcpInfo)) {
         $this->assign('intro_text', $this->_pcpInfo['intro_text']);
     } else {
         if (CRM_Utils_Array::value('intro_text', $this->_values)) {
             $this->assign('intro_text', $this->_values['intro_text']);
         }
     }
     if (CRM_Utils_Array::value('footer_text', $this->_values)) {
         $this->assign('footer_text', $this->_values['footer_text']);
     }
     //CRM-5001
     if ($this->_values['is_for_organization']) {
         $msg = ts('Mixed profile not allowed for on behalf of registration/sign up.');
         require_once 'CRM/Core/BAO/UFGroup.php';
         if ($preID = CRM_Utils_Array::value('custom_pre_id', $this->_values)) {
             $preProfile = CRM_Core_BAO_UFGroup::profileGroups($preID);
             foreach (array('Individual', 'Organization', 'Household') as $contactType) {
                 if (in_array($contactType, $preProfile) && (in_array('Membership', $preProfile) || in_array('Contribution', $preProfile))) {
                     CRM_Core_Error::fatal($msg);
                 }
             }
         }
         if ($postID = CRM_Utils_Array::value('custom_post_id', $this->_values)) {
             $postProfile = CRM_Core_BAO_UFGroup::profileGroups($postID);
             foreach (array('Individual', 'Organization', 'Household') as $contactType) {
                 if (in_array($contactType, $postProfile) && (in_array('Membership', $postProfile) || in_array('Contribution', $postProfile))) {
                     CRM_Core_Error::fatal($msg);
                 }
             }
         }
     }
 }