-
-
Notifications
You must be signed in to change notification settings - Fork 827
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2372 from kurund/CRM-13981
CRM-13981, Migrate "In Honor of" to Soft Credits
- 6.0.0
- 5.82.1
- 5.82.0
- 5.81.2
- 5.81.1
- 5.81.0
- 5.80.3
- 5.80.2
- 5.80.1
- 5.80.0
- 5.79.2
- 5.79.1
- 5.79.0
- 5.78.4
- 5.78.3
- 5.78.2
- 5.78.1
- 5.78.0
- 5.77.1
- 5.77.0
- 5.76.3
- 5.76.2
- 5.76.1
- 5.76.0
- 5.75.2
- 5.75.1
- 5.75.0
- 5.74.5
- 5.74.4
- 5.74.3
- 5.74.2
- 5.74.1
- 5.74.0
- 5.73.4
- 5.73.3
- 5.73.2
- 5.73.1
- 5.73.0
- 5.72.3
- 5.72.2
- 5.72.1
- 5.72.0
- 5.71.2
- 5.71.1
- 5.71.0
- 5.70.2
- 5.70.1
- 5.70.0
- 5.69.5
- 5.69.4
- 5.69.3
- 5.69.2
- 5.69.1
- 5.69.0
- 5.68.1
- 5.68.0
- 5.67.3
- 5.67.2
- 5.67.1
- 5.67.0
- 5.66.2
- 5.66.1
- 5.66.0
- 5.65.2
- 5.65.1
- 5.65.0
- 5.64.4
- 5.64.3
- 5.64.2
- 5.64.1
- 5.64.0
- 5.63.3
- 5.63.2
- 5.63.1
- 5.63.0
- 5.62.1
- 5.62.0
- 5.61.4
- 5.61.3
- 5.61.2
- 5.61.1
- 5.61.0
- 5.60.0
- 5.59.4
- 5.59.3
- 5.59.2
- 5.59.1
- 5.59.0
- 5.58.1
- 5.58.0
- 5.57.3
- 5.57.2
- 5.57.1
- 5.57.0
- 5.56.2
- 5.56.1
- 5.56.0
- 5.55.2
- 5.55.1
- 5.55.0
- 5.54.2
- 5.54.1
- 5.54.0
- 5.53.0
- 5.52.3
- 5.52.2
- 5.52.1
- 5.52.0
- 5.51.3
- 5.51.2
- 5.51.1
- 5.51.0
- 5.50.4
- 5.50.3
- 5.50.2
- 5.50.1
- 5.50.0
- 5.49.5
- 5.49.4
- 5.49.3
- 5.49.2
- 5.49.1
- 5.49.0
- 5.48.2
- 5.48.1
- 5.48.0
- 5.47.4
- 5.47.3
- 5.47.2
- 5.47.1
- 5.47.0
- 5.46.3
- 5.46.2
- 5.46.1
- 5.46.0
- 5.45.3
- 5.45.2
- 5.45.1
- 5.45.0
- 5.44.0
- 5.43.2
- 5.43.1
- 5.43.0
- 5.42.1
- 5.42.0
- 5.41.2
- 5.41.1
- 5.41.0
- 5.40.4
- 5.40.3
- 5.40.2
- 5.40.1
- 5.40.0
- 5.39.1
- 5.39.0
- 5.38.1
- 5.38.0
- 5.37.2
- 5.37.1
- 5.37.0
- 5.36.1
- 5.36.0
- 5.35.2
- 5.35.1
- 5.35.0
- 5.34.0
- 5.33.2
- 5.33.1
- 5.33.0
- 5.32.2
- 5.32.1
- 5.32.0
- 5.31.1
- 5.31.0
- 5.30.1
- 5.30.0
- 5.29.1
- 5.29.0
- 5.28.4
- 5.28.3
- 5.28.2
- 5.28.1
- 5.28.0
- 5.27.4
- 5.27.3
- 5.27.2
- 5.27.1
- 5.27.0
- 5.26.2
- 5.26.1
- 5.26.0
- 5.25.0
- 5.24.6
- 5.24.5
- 5.24.4
- 5.24.3
- 5.24.2
- 5.24.1
- 5.24.0
- 5.23.4
- 5.23.3
- 5.23.2
- 5.23.1
- 5.23.0
- 5.22.1
- 5.22.0
- 5.21.2
- 5.21.1
- 5.21.0
- 5.20.3
- 5.20.2
- 5.20.1
- 5.20.0
- 5.19.4
- 5.19.3
- 5.19.2
- 5.19.1
- 5.19.0
- 5.18.4
- 5.18.3
- 5.18.2
- 5.18.1
- 5.18.0
- 5.17.5
- 5.17.4
- 5.17.3
- 5.17.2
- 5.17.1
- 5.17.0
- 5.16.4
- 5.16.3
- 5.16.2
- 5.16.1
- 5.16.0
- 5.15.2
- 5.15.1
- 5.15.0
- 5.14.2
- 5.14.1
- 5.14.0
- 5.13.5
- 5.13.4
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.5
- 4.6.4
- 4.6.3
- 4.6.2
- 4.6.1
- 4.6.0
- 4.6.beta5
- 4.6.beta4
- 4.6.beta3
- 4.6.beta2
- 4.6.beta1
- 4.6.alpha7
- 4.6.alpha6
- 4.6.alpha5
- 4.6.alpha4
- 4.6.alpha3
- 4.6.alpha2
- 4.6.alpha1
- 4.5.8
- 4.5.7
- 4.5.6
- 4.5.5
- 4.5.4
- 4.5.3
- 4.5.2
- 4.5.1
- 4.5.0
- 4.5.beta9
- 4.5.beta8
- 4.5.beta7
- 4.5.beta6
- 4.5.beta5
- 4.5.beta4
- 4.5.beta3
- 4.5.beta2
- 4.5.beta1
- 4.5.alpha2
- 4.5.alpha1
Showing
43 changed files
with
792 additions
and
966 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
<?php | ||
/* | ||
+--------------------------------------------------------------------+ | ||
| CiviCRM version 4.4 | | ||
+--------------------------------------------------------------------+ | ||
| Copyright CiviCRM LLC (c) 2004-2013 | | ||
+--------------------------------------------------------------------+ | ||
| This file is a part of CiviCRM. | | ||
| | | ||
| CiviCRM is free software; you can copy, modify, and distribute it | | ||
| under the terms of the GNU Affero General Public License | | ||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | ||
| | | ||
| CiviCRM is distributed in the hope that it will be useful, but | | ||
| WITHOUT ANY WARRANTY; without even the implied warranty of | | ||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | ||
| See the GNU Affero General Public License for more details. | | ||
| | | ||
| You should have received a copy of the GNU Affero General Public | | ||
| License and the CiviCRM Licensing Exception along | | ||
| with this program; if not, contact CiviCRM LLC | | ||
| at info[AT]civicrm[DOT]org. If you have questions about the | | ||
| GNU Affero General Public License or the licensing of CiviCRM, | | ||
| see the CiviCRM license FAQ at http://civicrm.org/licensing | | ||
+--------------------------------------------------------------------+ | ||
*/ | ||
|
||
/** | ||
* | ||
* @package CRM | ||
* @copyright CiviCRM LLC (c) 2004-2013 | ||
* $Id$ | ||
* | ||
*/ | ||
class CRM_Contact_Form_ProfileContact { | ||
|
||
protected $_mode; | ||
|
||
/** | ||
* Function to set variables up before form is built | ||
* | ||
* @return void | ||
* @access public | ||
*/ | ||
static function preProcess(&$form) { | ||
$session = CRM_Core_Session::singleton(); | ||
$contactID = $session->get('userID'); | ||
|
||
$ufJoinParams = array( | ||
'module' => 'soft_credit', | ||
'entity_table' => 'civicrm_contribution_page', | ||
'entity_id' => $form->_id, | ||
); | ||
$profileId = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams); | ||
$form->_honoreeProfileId = $profileId[0]; | ||
|
||
if (!$form->_honoreeProfileId || | ||
!CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $form->_honoreeProfileId, 'is_active') | ||
) { | ||
CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of honoree and the selected honoree profile is either disabled or not found.')); | ||
} | ||
|
||
$profileContactType = CRM_Core_BAO_UFGroup::getContactType($form->_honoreeProfileId); | ||
$requiredProfileFields = array( | ||
'Individual' => array('first_name', 'last_name'), | ||
'Organization' => array('organization_name', 'email'), | ||
'Household' => array('household_name', 'email') | ||
); | ||
$validProfile = CRM_Core_BAO_UFGroup::checkValidProfile($form->_honoreeProfileId, $requiredProfileFields[$profileContactType]); | ||
if (!$validProfile) { | ||
CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of honoree and the required fields of the selected honoree profile are disabled or doesn\'t exist.')); | ||
} | ||
} | ||
|
||
/** | ||
* Function to build form for honoree contact / on behalf of organization. | ||
* | ||
* @param $form object invoking Object | ||
* @param $contactType string contact type | ||
* @param $title string fieldset title | ||
* | ||
* @static | ||
*/ | ||
static function buildQuickForm(&$form) { | ||
$ufGroup = new CRM_Core_DAO_UFGroup(); | ||
$ufGroup->id = $form->_honoreeProfileId; | ||
if (!$ufGroup->find(TRUE)) { | ||
CRM_Core_Error::fatal(ts('Chosen honoree profile is for this contribution is disabled')); | ||
} | ||
|
||
$prefix = 'honor'; | ||
$honoreeProfileFields = CRM_Core_BAO_UFGroup::getFields($form->_honoreeProfileId, FALSE, NULL, | ||
NULL, NULL, | ||
FALSE, NULL, | ||
TRUE, NULL, | ||
CRM_Core_Permission::CREATE | ||
); | ||
$form->addElement('hidden', 'honoree_profile_id', $form->_honoreeProfileId); | ||
$form->assign('honoreeProfileFields', $honoreeProfileFields); | ||
|
||
// add the form elements | ||
foreach ($honoreeProfileFields as $name => $field) { | ||
// If soft credit type is not chosen then make omit requiredness from honoree profile fields | ||
if (count($form->_submitValues) && | ||
!CRM_Utils_Array::value('soft_credit_type_id', $form->_submitValues) && | ||
CRM_Utils_Array::value('is_required', $field) | ||
) { | ||
$field['is_required'] = FALSE; | ||
} | ||
CRM_Core_BAO_UFGroup::buildProfile($form, $field, CRM_Profile_Form::MODE_CREATE, NULL, FALSE, FALSE, NULL, $prefix); | ||
} | ||
} | ||
|
||
static function postProcess($form) { | ||
$params = $form->_params; | ||
$values = $form->_values; | ||
if ($form->get('honor_block_is_active') && CRM_Utils_Array::value('soft_credit_type_id', $params)) { | ||
$honorId = null; | ||
|
||
//check if there is any duplicate contact | ||
$profileContactType = CRM_Core_BAO_UFGroup::getContactType($params['honoree_profile_id']); | ||
$dedupeParams = CRM_Dedupe_Finder::formatParams($params['honor'], $profileContactType); | ||
$dedupeParams['check_permission'] = FALSE; | ||
$ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, $profileContactType); | ||
if(count($ids)) { | ||
$honorId = CRM_Utils_Array::value(0, $ids); | ||
} | ||
|
||
$honorId = CRM_Contact_BAO_Contact::createProfileContact( | ||
$params['honor'], CRM_Core_DAO::$_nullArray, | ||
$honorId, NULL, | ||
$params['honoree_profile_id'] | ||
); | ||
$softParams = array(); | ||
$softParams['contribution_id'] = $form->_contributionID; | ||
$softParams['contact_id'] = $honorId; | ||
$softParams['soft_credit_type_id'] = $params['soft_credit_type_id']; | ||
$contribution = new CRM_Contribute_DAO_Contribution(); | ||
$contribution->id = $form->_contributionID; | ||
$contribution->find(); | ||
while ($contribution->fetch()) { | ||
$softParams['currency'] = $contribution->currency; | ||
$softParams['amount'] = $contribution->total_amount; | ||
} | ||
CRM_Contribute_BAO_ContributionSoft::add($softParams); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.