/** * 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&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']); } //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); } } } } }
/** * 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&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']); } //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); } } } } }