<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.4 |
+ | CiviCRM version 4.5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
* $Id$
*
*/
/**
- * This class generates form components for processing a ontribution
+ * This class generates form components for processing a contribution
*
*/
class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form {
/**
- * the id of the contribution page that we are proceessing
+ * the id of the contribution page that we are processsing
*
* @var int
* @public
*/
public $_membershipBlock = NULL;
+ /**
+ * Does this form support a separate membership payment
+ * @var bool
+ */
+ protected $_separateMembershipPayment;
/**
* the default values for the form
*
* @var array
* @public
*/
- public $_fields;
+ public $_fields = array();
/**
* The billing location id for this contribiution page
public $_action;
+ /**
+ * Is honor block is enabled for this contribution?
+ *
+ * @var boolean
+ * @protected
+ */
+ public $_honor_block_is_active = FALSE;
+
+ /**
+ * Contribution mode e.g express for payment express, notify for off-site + notification back to CiviCRM
+ * @var string
+ */
+ public $_contributeMode;
+
+ /**
+ * contribution page supports memberships
+ * @var boolean
+ */
+ public $_useForMember;
/**
* Function to set variables up before form is built
*
// this was used prior to the cleverer this_>getContactID - unsure now
$this->_userID = $session->get('userID');
+ //Check if honor block is enabled for current contribution
+ $ufJoinParams = array(
+ 'module' => 'soft_credit',
+ 'entity_table' => 'civicrm_contribution_page',
+ 'entity_id' => $this->_id,
+ );
+ $ufJoin = new CRM_Core_DAO_UFJoin();
+ $ufJoin->copyValues($ufJoinParams);
+ $ufJoin->find(TRUE);
+ $this->_honor_block_is_active = $ufJoin->is_active;
+
$this->_contactID = $this->_membershipContactID = $this->getContactID();
$this->_mid = NULL;
if ($this->_contactID) {
CRM_Contribute_BAO_ContributionPage::setValues($this->_id, $this->_values);
// check if form is active
- if (!CRM_Utils_Array::value('is_active', $this->_values)) {
+ if (empty($this->_values['is_active'])) {
// form is inactive, die a fatal death
CRM_Core_Error::fatal(ts('The page you requested is currently unavailable.'));
}
//FIXME: to support multiple payment processors
if ($isMonetary &&
- (!$isPayLater || CRM_Utils_Array::value('payment_processor', $this->_values))
+ (!$isPayLater || !empty($this->_values['payment_processor']))
) {
$ppID = CRM_Utils_Array::value('payment_processor', $this->_values);
if (!$ppID) {
// this avoids getting E_NOTICE errors in php
$setNullFields = array(
'amount_block_is_active',
- 'honor_block_is_active',
'is_allow_other_amount',
'footer_text',
);
}
//set pledge block if block id is set
- if (CRM_Utils_Array::value('pledge_block_id', $this->_values)) {
+ if (!empty($this->_values['pledge_block_id'])) {
$this->assign('pledgeBlock', TRUE);
}
*/
function assignToTemplate() {
$name = CRM_Utils_Array::value('billing_first_name', $this->_params);
- if (CRM_Utils_Array::value('billing_middle_name', $this->_params)) {
+ if (!empty($this->_params['billing_middle_name'])) {
$name .= " {$this->_params['billing_middle_name']}";
}
$name .= ' ' . CRM_Utils_Array::value('billing_last_name', $this->_params);
);
$config = CRM_Core_Config::singleton();
- if (isset($this->_values['is_recur']) &&
- CRM_Utils_Array::value('is_recur', $this->_paymentProcessor)
- ) {
+ if (isset($this->_values['is_recur']) && !empty($this->_paymentProcessor['is_recur'])) {
$this->assign('is_recur_enabled', 1);
$vars = array_merge($vars, array(
'is_recur', 'frequency_interval', 'frequency_unit',
$this->assign('address', CRM_Utils_Address::format($addressFields));
- if (CRM_Utils_Array::value('hidden_onbehalf_profile', $this->_params)) {
+ if (!empty($this->_params['hidden_onbehalf_profile'])) {
$this->assign('onBehalfName', $this->_params['organization_name']);
$locTypeId = array_keys($this->_params['onbehalf_location']['email']);
$this->assign('onBehalfEmail', $this->_params['onbehalf_location']['email'][$locTypeId[0]]['email']);
if ($this->_amount > 0.0) {
$assignCCInfo = TRUE;
}
- elseif (CRM_Utils_array::value('selectMembership', $this->_params)) {
+ elseif (!empty($this->_params['selectMembership'])) {
$memFee = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_params['selectMembership'], 'minimum_fee');
if ($memFee > 0.0) {
$assignCCInfo = TRUE;
/**
* Function to add the custom fields
*
- * @return None
+ * @param $id
+ * @param $name
+ * @param bool $viewOnly
+ * @param null $profileContactType
+ * @param null $fieldTypes
+ *
+ * @return void
* @access public
*/
- function buildCustom($id, $name, $viewOnly = FALSE, $onBehalf = FALSE, $fieldTypes = NULL) {
- $stateCountryMap = array();
-
+ function buildCustom($id, $name, $viewOnly = FALSE, $profileContactType = NULL, $fieldTypes = NULL) {
if ($id) {
$contactID = $this->getContactID();
if ($fields) {
// unset any email-* fields since we already collect it, CRM-2888
foreach (array_keys($fields) as $fieldName) {
- if (substr($fieldName, 0, 6) == 'email-') {
+ if (substr($fieldName, 0, 6) == 'email-' && $profileContactType != 'honor') {
unset($fields[$fieldName]);
}
}
continue;
}
- list($prefixName, $index) = CRM_Utils_System::explode('-', $key, 2);
- if ($prefixName == 'state_province' || $prefixName == 'country' || $prefixName == 'county') {
- if (!array_key_exists($index, $stateCountryMap)) {
- $stateCountryMap[$index] = array();
+ if ($profileContactType) {
+ //Since we are showing honoree name separately so we are removing it from honoree profile just for display
+ $honoreeNamefields = array('prefix_id', 'first_name', 'last_name', 'suffix_id', 'organization_name', 'household_name');
+ if ($profileContactType == 'honor' && in_array($field['name'], $honoreeNamefields)) {
+ unset($fields[$field['name']]);
+ continue;
}
- $stateCountryMap[$index][$prefixName] = $key;
- }
-
- if ($onBehalf) {
if (!empty($fieldTypes) && in_array($field['field_type'], $fieldTypes)) {
CRM_Core_BAO_UFGroup::buildProfile(
$this,
$field,
CRM_Profile_Form::MODE_CREATE,
$contactID,
- TRUE
+ TRUE,
+ $profileContactType
);
- $this->_fields['onbehalf'][$key] = $field;
+ $this->_fields[$profileContactType][$key] = $field;
}
else {
unset($fields[$key]);
$this->assign($name, $fields);
- CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap);
-
if ($addCaptcha && !$viewOnly) {
$captcha = CRM_Utils_ReCAPTCHA::singleton();
$captcha->add($this);
}
}
+ /**
+ * Check template file exists
+ * @param null $suffix
+ *
+ * @return null|string
+ */
function checkTemplateFileExists($suffix = NULL) {
if ($this->_id) {
$templateFile = "CRM/Contribute/Form/Contribution/{$this->_id}/{$this->_name}.{$suffix}tpl";
return NULL;
}
+ /**
+ * Use the form name to create the tpl file name
+ *
+ * @return string
+ * @access public
+ */
+ /**
+ * @return string
+ */
function getTemplateFileName() {
$fileName = $this->checkTemplateFileExists();
return $fileName ? $fileName : parent::getTemplateFileName();
}
+ /**
+ * Default extra tpl file basically just replaces .tpl with .extra.tpl
+ * i.e. we dont override
+ *
+ * @return string
+ * @access public
+ */
+ /**
+ * @return string
+ */
function overrideExtraTemplateFileName() {
$fileName = $this->checkTemplateFileExists('extra.');
return $fileName ? $fileName : parent::overrideExtraTemplateFileName();
*
* @access public
*
- * @return None
+ * @return void
*/
public function authenticatePledgeUser() {
//get the userChecksum and contact id