/** * Function to process the form * * @access public * * @return None */ public function beginPostProcess(&$form, &$params) { if ($form->_context == 'caseActivity') { return; } // set the contact, when contact is selected if (isset($params['contact_select_id']) && CRM_utils_Array::value(1, $params['contact_select_id'])) { $params['contact_id'] = $params['contact_select_id'][1]; $form->_currentlyViewedContactId = $params['contact_id']; } elseif ($form->_allowMultiClient && $form->_context != 'case') { $clients = explode(',', $params['contact'][1]); $form->_currentlyViewedContactId = $clients[0]; } // for open case start date should be set to current date $params['start_date'] = CRM_Utils_Date::processDate($params['start_date'], $params['start_date_time']); $caseStatus = CRM_Case_PseudoConstant::caseStatus('name'); // for resolved case the end date should set to now if ($params['status_id'] == array_search('Closed', $caseStatus)) { $params['end_date'] = $params['now']; } // rename activity_location param to the correct column name for activity DAO $params['location'] = CRM_Utils_Array::value('activity_location', $params); }
/** * 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, $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 auto renew checkbox is set, initiate a open-ended recurring membership if (CRM_Utils_Array::value('selectMembership', $this->_params) && CRM_utils_Array::value('is_recur', $this->_paymentProcessor) && CRM_Utils_Array::value('auto_renew', $this->_params) && !CRM_utils_Array::value('is_recur', $this->_params) && !CRM_Utils_Array::value('frequency_interval', $this->_params)) { // FIXME: set interval and unit based on selected membership type $this->_params['is_recur'] = $this->_values['is_recur'] = 1; $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) { $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); }