From: monishdeb Date: Mon, 20 Jul 2015 19:25:24 +0000 (+0530) Subject: migrating to profileContact and optimization X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e63910c5bbb47f77336bb120e6083f313dfec7ad;p=civicrm-core.git migrating to profileContact and optimization Conflicts: CRM/Contribute/Form/Contribution/Confirm.php --- diff --git a/CRM/Contact/Form/ProfileContact.php b/CRM/Contact/Form/ProfileContact.php index 61f3ed48b0..59b9d279fd 100644 --- a/CRM/Contact/Form/ProfileContact.php +++ b/CRM/Contact/Form/ProfileContact.php @@ -58,6 +58,7 @@ class CRM_Contact_Form_ProfileContact { if ($module == 'soft_credit') { $form->_honoreeProfileId = $ufJoin->uf_group_id; + $form->_honor_block_is_active = $ufJoin->is_active; if (!$form->_honoreeProfileId || !CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $form->_honoreeProfileId, 'is_active') @@ -78,7 +79,8 @@ class CRM_Contact_Form_ProfileContact { } else { $form->_onbehalf = FALSE; - $params = CRM_Contribute_BAO_ContributionPage::formatMultilingualOnBehalfParams($ufJoin->module_data, TRUE); + $params = CRM_Contribute_BAO_ContributionPage::formatModuleData($ufJoin->module_data, TRUE, 'on_behalf'); + $form->_values = array_merge($params, $form->_values); if (CRM_Utils_Array::value('is_for_organization', $params)) { if ($params['is_for_organization'] == 2) { $form->_onBehalfRequired = TRUE; @@ -92,16 +94,16 @@ class CRM_Contact_Form_ProfileContact { !empty($_POST['is_for_organization']) ) { $form->_onbehalf = TRUE; - $form->_profileId = $ufJoin->uf_group_id; + $form->_onBehalfProfileId = $ufJoin->uf_group_id; - if (!$form->_profileId || - !CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $form->_profileId, 'is_active') + if (!$form->_onBehalfProfileId || + !CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $form->_onBehalfProfileId, 'is_active') ) { CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of an organization and the selected onbehalf profile is either disabled or not found.')); } $requiredProfileFields = array('organization_name', 'email'); - $validProfile = CRM_Core_BAO_UFGroup::checkValidProfile($form->_profileId, $requiredProfileFields); + $validProfile = CRM_Core_BAO_UFGroup::checkValidProfile($form->_onBehalfProfileId, $requiredProfileFields); if (!$validProfile) { CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of an organization and the required fields of the selected onbehalf profile are disabled.')); } @@ -110,7 +112,7 @@ class CRM_Contact_Form_ProfileContact { $member = CRM_Member_BAO_Membership::getMembershipBlock($form->_id); if (empty($member['is_active'])) { $msg = ts('Mixed profile not allowed for on behalf of registration/sign up.'); - $onBehalfProfile = CRM_Core_BAO_UFGroup::profileGroups($form->_profileId); + $onBehalfProfile = CRM_Core_BAO_UFGroup::profileGroups($form->_onBehalfProfileId); foreach (array( 'Individual', 'Organization', @@ -143,7 +145,7 @@ class CRM_Contact_Form_ProfileContact { } } - $form->assign('profileId', $form->_profileId); + $form->assign('profileId', $form->_onBehalfProfileId); $form->assign('mode', $form->_mode); if ($contactID) { @@ -260,8 +262,8 @@ class CRM_Contact_Form_ProfileContact { } public static function buildOnBehalfBlock(&$form) { - $form->assign('fieldSetTitle', ts('Organization Details')); $form->assign('buildOnBehalfForm', TRUE); + $form->assign('fieldSetTitle', ts('Organization Details')); $contactID = $form->_contactID; @@ -296,7 +298,7 @@ class CRM_Contact_Form_ProfileContact { } $prefix = 'onbehalf'; - $profileFields = CRM_Core_BAO_UFGroup::getFields($form->_profileId, FALSE, CRM_Core_Action::VIEW, NULL, + $profileFields = CRM_Core_BAO_UFGroup::getFields($form->_onBehalfProfileId, FALSE, CRM_Core_Action::VIEW, NULL, NULL, FALSE, NULL, FALSE, NULL, CRM_Core_Permission::CREATE, NULL ); @@ -323,6 +325,6 @@ class CRM_Contact_Form_ProfileContact { } $form->assign('onBehalfOfFields', $profileFields); - $form->addElement('hidden', 'hidden_onbehalf_profile', 1); + $form->addElement('hidden', 'onbehalf_profile_id', $form->_onBehalfProfileId); } } diff --git a/CRM/Contribute/BAO/ContributionPage.php b/CRM/Contribute/BAO/ContributionPage.php index 46f7aa088c..f45d0ae761 100644 --- a/CRM/Contribute/BAO/ContributionPage.php +++ b/CRM/Contribute/BAO/ContributionPage.php @@ -770,145 +770,100 @@ LEFT JOIN civicrm_premiums ON ( civicrm_premiums.entity_id = civicrm } /** - * Get or Set multilingually affected honor params for processing module_data or setting default values. + * Get or Set honor/on_behalf params for processing module_data or setting default values. * - * @param string $params : + * @param array $params : * @param bool $setDefault : If yes then returns array to used for setting default value afterward + * @param string $module : processing module_data for which module? e.g. soft_credit, on_behalf * * @return array|string */ - public static function formatMultilingualHonorParams($params, $setDefault = FALSE) { + public static function formatModuleData($params, $setDefault = FALSE, $module) { $config = CRM_Core_Config::singleton(); - $sctJson = $sctJsonDecode = NULL; + $json = $jsonDecode = NULL; $domain = new CRM_Core_DAO_Domain(); $domain->find(TRUE); + $moduleDataFormat = array( + 'soft_credit' => array( + 'soft_credit_types', + 'multilingual' => array( + 'honor_block_title', + 'honor_block_text' + ), + ), + 'on_behalf' => array( + 'is_for_organization', + 'multilingual' => array( + 'for_organization' + ), + ), + ); + //When we are fetching the honor params respecting both multi and mono lingual state //and setting it to default param of Contribution Page's Main and Setting form if ($setDefault) { - $sctJsonDecode = json_decode($params); - $sctJsonDecode = (array) $sctJsonDecode->soft_credit; - if (!$domain->locales && !empty($sctJsonDecode['default'])) { + $jsonDecode = json_decode($params); + $jsonDecode = (array) $jsonDecode->$module; + if (!$domain->locales && !empty($jsonDecode['default'])) { //monolingual state - $sctJsonDecode += (array) $sctJsonDecode['default']; + $jsonDecode += (array) $jsonDecode['default']; + unset($jsonDecode['default']); } - elseif (!empty($sctJsonDecode[$config->lcMessages])) { + elseif (!empty($jsonDecode[$config->lcMessages])) { //multilingual state - foreach ($sctJsonDecode[$config->lcMessages] as $column => $value) { - $sctJsonDecode[$column] = $value; + foreach ($jsonDecode[$config->lcMessages] as $column => $value) { + $jsonDecode[$column] = $value; } - unset($sctJsonDecode[$config->lcMessages]); + unset($jsonDecode[$config->lcMessages]); } - return $sctJsonDecode; + return $jsonDecode; } //check and handle multilingual honoree params if (!$domain->locales) { //if in singlelingual state simply return the array format - $sctJson = json_encode( - array( - 'soft_credit' => array( - 'soft_credit_types' => $params['soft_credit_types'], - 'default' => array( - 'honor_block_title' => $params['honor_block_title'], - 'honor_block_text' => $params['honor_block_text'], - ), - ), - ) - ); + $json = array($module => NULL); + foreach ($moduleDataFormat[$module] as $key => $attribute) { + if ($key === 'multilingual') { + $json[$module]['default'] = array(); + foreach ($attribute as $attr) { + $json[$module]['default'][$attr] = $params[$attr]; + } + } + else { + $json[$module][$attribute] = $params[$attribute]; + } + } + $json = json_encode($json); } else { //if in multilingual state then retrieve the module_data against this contribution and //merge with earlier module_data json data to current so not to lose earlier multilingual module_data information - $sctJson = array( - 'soft_credit' => array( - 'soft_credit_types' => $params['soft_credit_types'], - $config->lcMessages => array( - 'honor_block_title' => $params['honor_block_title'], - 'honor_block_text' => $params['honor_block_text'], - ), - ), - ); - - $ufJoinDAO = new CRM_Core_DAO_UFJoin(); - $ufJoinDAO->module = 'soft_credit'; - $ufJoinDAO->entity_id = $params['id']; - $ufJoinDAO->find(TRUE); - $jsonData = json_decode($ufJoinDAO->module_data); - if ($jsonData) { - $sctJson['soft_credit'] = array_merge((array) $jsonData->soft_credit, $sctJson['soft_credit']); - } - $sctJson = json_encode($sctJson); - } - return $sctJson; - } - - /** - * Get or Set multilingually affected on behalf params for processing module_data or setting default values. - * - * @param string $params : - * @param bool $setDefault : If yes then returns array to used for setting default value afterward - * - * @return array|string - */ - public static function formatMultilingualOnBehalfParams($params, $setDefault = FALSE) { - $config = CRM_Core_Config::singleton(); - $onBehalfJson = $onBehalfJsonDecode = NULL; - $domain = new CRM_Core_DAO_Domain(); - $domain->find(TRUE); - - if ($setDefault) { - $onBehalfJsonDecode = json_decode($params); - $onBehalfJsonDecode = (array) $onBehalfJsonDecode->on_behalf; - if (!$domain->locales && !empty($onBehalfJsonDecode['default'])) { - //monolingual state - $onBehalfJsonDecode += (array) $onBehalfJsonDecode['default']; - } - elseif (!empty($onBehalfJsonDecode[$config->lcMessages])) { - //multilingual state - foreach ($sctJsonDecode[$config->lcMessages] as $column => $value) { - $onBehalfJsonDecode[$column] = $value; + $json = array($module => NULL); + foreach ($moduleDataFormat[$module] as $key => $attribute) { + if ($key === 'multilingual') { + $json[$module][$config->lcMessages] = array(); + foreach ($attribute as $attr) { + $json[$module][$config->lcMessages][$attr] = $params[$attr]; + } + } + else { + $json[$module][$attribute] = $params[$attribute]; } - unset($onBehalfJsonDecode[$config->lcMessages]); } - return $onBehalfJsonDecode; - } - - //check and handle multilingual honoree params - if (!$domain->locales) { - //if in singlelingual state simply return the array format - $onBehalfJson = json_encode( - array( - 'on_behalf' => array( - 'is_for_organization' => $params['is_for_organization'], - 'default' => array( - 'for_organization' => $params['for_organization'], - ), - ), - ) - ); - } - else { - $onBehalfJson = array( - 'on_behalf' => array( - 'is_for_organization' => $params['is_for_organization'], - $config->lcMessages => array( - 'for_organization' => $params['for_organization'], - ), - ), - ); $ufJoinDAO = new CRM_Core_DAO_UFJoin(); - $ufJoinDAO->module = 'on_behalf'; + $ufJoinDAO->module = $module; $ufJoinDAO->entity_id = $params['id']; $ufJoinDAO->find(TRUE); $jsonData = json_decode($ufJoinDAO->module_data); if ($jsonData) { - $onBehalfJson['on_behalf'] = array_merge((array) $jsonData->on_behalf, $onBehalfJson['on_behalf']); + $json[$module] = array_merge((array) $jsonData->$module, $json[$module]); } - $onBehalfJson = json_encode($onBehalfJson); + $json = json_encode($json); } - return $onBehalfJson; + return $json; } /** diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 4d727c42ac..a148a96e6d 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -228,7 +228,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $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['onbehalf_profile_id'])) { // CRM-15182 if (empty($this->_params['org_option']) && empty($this->_params['organization_id'])) { if (!empty($this->_params['onbehalfof_id'])) { @@ -467,15 +467,9 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr } $this->buildCustom($this->_values['custom_pre_id'], 'customPre', TRUE); $this->buildCustom($this->_values['custom_post_id'], 'customPost', TRUE); + CRM_Core_Error::debug( '$params', $params ); - if (!empty($params['hidden_onbehalf_profile'])) { - $ufJoinParams = array( - 'module' => 'onBehalf', - 'entity_table' => 'civicrm_contribution_page', - 'entity_id' => $this->_id, - ); - $OnBehalfProfile = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams); - $profileId = $OnBehalfProfile[0]; + if (!empty($params['onbehalf_profile_id'])) { $fieldTypes = array('Contact', 'Organization'); $contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization'); @@ -487,7 +481,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $fieldTypes = array_merge($fieldTypes, array('Contribution')); } - $this->buildCustom($profileId, 'onbehalfProfile', TRUE, 'onbehalf', $fieldTypes); + $this->buildCustom($params['onbehalf_profile_id'], 'onbehalfProfile', TRUE, 'onbehalf', $fieldTypes); } $this->_separateMembershipPayment = $this->get('separateMembershipPayment'); diff --git a/CRM/Contribute/Form/Contribution/OnBehalfOf.php b/CRM/Contribute/Form/Contribution/OnBehalfOf.php deleted file mode 100644 index 7a87c60884..0000000000 --- a/CRM/Contribute/Form/Contribution/OnBehalfOf.php +++ /dev/null @@ -1,178 +0,0 @@ -_contactID; - - $ufJoinParams = array( - 'module' => 'onBehalf', - 'entity_table' => 'civicrm_contribution_page', - 'entity_id' => $form->_id, - ); - $profileId = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams); - $form->_profileId = $profileId[0]; - - if (!$form->_profileId || - !CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $form->_profileId, 'is_active') - ) { - CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of an organization and the selected onbehalf profile is either disabled or not found.')); - } - - $requiredProfileFields = array('organization_name', 'email'); - $validProfile = CRM_Core_BAO_UFGroup::checkValidProfile($form->_profileId, $requiredProfileFields); - if (!$validProfile) { - CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of an organization and the required fields of the selected onbehalf profile are disabled.')); - } - - $form->assign('profileId', $form->_profileId); - $form->assign('mode', $form->_mode); - - if ($contactID) { - $form->_employers = CRM_Contact_BAO_Relationship::getPermissionedEmployer($contactID); - - if (!empty($form->_membershipContactID) && $contactID != $form->_membershipContactID) { - // renewal case - membership being renewed may or may not be for organization - if (!empty($form->_employers) && array_key_exists($form->_membershipContactID, $form->_employers)) { - // if _membershipContactID belongs to employers list, we can say: - $form->_relatedOrganizationFound = TRUE; - } - } - elseif (!empty($form->_employers)) { - // not a renewal case and _employers list is not empty - $form->_relatedOrganizationFound = TRUE; - } - - if ($form->_relatedOrganizationFound) { - // Related org url - pass checksum if needed - $args = array('cid' => ''); - if (!empty($_GET['cs'])) { - $args = array( - 'uid' => $form->_contactID, - 'cs' => $_GET['cs'], - 'cid' => '', - ); - } - $locDataURL = CRM_Utils_System::url('civicrm/ajax/permlocation', $args, FALSE, NULL, FALSE); - $form->assign('locDataURL', $locDataURL); - - if (!empty($form->_submitValues['onbehalf'])) { - if (!empty($form->_submitValues['onbehalfof_id'])) { - $form->assign('submittedOnBehalf', $form->_submitValues['onbehalfof_id']); - } - $form->assign('submittedOnBehalfInfo', json_encode($form->_submitValues['onbehalf'])); - } - } - - if ($form->_values['is_for_organization'] != 2) { - $form->assign('relatedOrganizationFound', $form->_relatedOrganizationFound); - } - else { - $form->assign('onBehalfRequired', $form->_onBehalfRequired); - } - - if (count($form->_employers) == 1) { - foreach ($form->_employers as $id => $value) { - $form->_organizationName = $value['name']; - $orgId = $id; - } - $form->assign('orgId', $orgId); - $form->assign('organizationName', $form->_organizationName); - } - } - } - - /** - * Build form for related contacts / on behalf of organization. - * - * @param CRM_Core_Form $form - * - */ - public static function buildQuickForm(&$form) { - $form->assign('fieldSetTitle', ts('Organization Details')); - $form->assign('buildOnBehalfForm', TRUE); - - $contactID = $form->_contactID; - - if ($contactID && count($form->_employers) >= 1) { - $form->add('text', 'organization_id', ts('Select an existing related Organization OR enter a new one')); - - $form->add('select', 'onbehalfof_id', '', CRM_Utils_Array::collect('name', $form->_employers)); - - $orgOptions = array( - 0 => ts('Select an existing organization'), - 1 => ts('Enter a new organization'), - ); - - $form->addRadio('org_option', ts('options'), $orgOptions); - $form->setDefaults(array('org_option' => 0)); - $form->add('checkbox', 'mode', ''); - } - - $profileFields = CRM_Core_BAO_UFGroup::getFields($form->_profileId, FALSE, CRM_Core_Action::VIEW, NULL, - NULL, FALSE, NULL, FALSE, NULL, - CRM_Core_Permission::CREATE, NULL - ); - $fieldTypes = array('Contact', 'Organization'); - $contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization'); - $fieldTypes = array_merge($fieldTypes, $contactSubType); - - if (is_array($form->_membershipBlock) && !empty($form->_membershipBlock)) { - $fieldTypes = array_merge($fieldTypes, array('Membership')); - } - else { - $fieldTypes = array_merge($fieldTypes, array('Contribution')); - } - - foreach ($profileFields as $name => $field) { - if (in_array($field['field_type'], $fieldTypes)) { - list($prefixName, $index) = CRM_Utils_System::explode('-', $name, 2); - if (in_array($prefixName, array('organization_name', 'email')) && empty($field['is_required'])) { - $field['is_required'] = 1; - } - - CRM_Core_BAO_UFGroup::buildProfile($form, $field, NULL, NULL, FALSE, 'onbehalf'); - } - } - - $form->assign('onBehalfOfFields', $profileFields); - $form->addElement('hidden', 'hidden_onbehalf_profile', 1); - } - -} diff --git a/CRM/Contribute/Form/Contribution/ThankYou.php b/CRM/Contribute/Form/Contribution/ThankYou.php index abe880aef8..ff71a7bdaa 100644 --- a/CRM/Contribute/Form/Contribution/ThankYou.php +++ b/CRM/Contribute/Form/Contribution/ThankYou.php @@ -186,15 +186,7 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont $this->buildCustom($this->_values['custom_pre_id'], 'customPre', TRUE); $this->buildCustom($this->_values['custom_post_id'], 'customPost', TRUE); - if (!empty($params['hidden_onbehalf_profile'])) { - $ufJoinParams = array( - 'module' => 'onBehalf', - 'entity_table' => 'civicrm_contribution_page', - 'entity_id' => $this->_id, - ); - $OnBehalfProfile = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams); - $profileId = $OnBehalfProfile[0]; - + if (!empty($params['onbehalf_profile_id'])) { $fieldTypes = array('Contact', 'Organization'); $contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization'); $fieldTypes = array_merge($fieldTypes, $contactSubType); @@ -205,7 +197,7 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont $fieldTypes = array_merge($fieldTypes, array('Contribution')); } - $this->buildCustom($profileId, 'onbehalfProfile', TRUE, 'onbehalf', $fieldTypes); + $this->buildCustom($params['onbehalf_profile_id'], 'onbehalfProfile', TRUE, 'onbehalf', $fieldTypes); } $this->assign('trxn_id', diff --git a/CRM/Contribute/Form/ContributionBase.php b/CRM/Contribute/Form/ContributionBase.php index 7be232c3c0..e4db6f63fc 100644 --- a/CRM/Contribute/Form/ContributionBase.php +++ b/CRM/Contribute/Form/ContributionBase.php @@ -539,7 +539,7 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { $this->assign('address', CRM_Utils_Address::format($addressFields)); - if (!empty($this->_params['hidden_onbehalf_profile'])) { + if (!empty($this->_params['onbehalf_profile_id'])) { $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']); diff --git a/CRM/Contribute/Form/ContributionPage/Settings.php b/CRM/Contribute/Form/ContributionPage/Settings.php index eec20aa160..cfd5552701 100644 --- a/CRM/Contribute/Form/ContributionPage/Settings.php +++ b/CRM/Contribute/Form/ContributionPage/Settings.php @@ -58,15 +58,14 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_ $ufJoinDAO->module = $module; $ufJoinDAO->entity_id = $this->_id; if ($ufJoinDAO->find(TRUE)) { + $jsonData = CRM_Contribute_BAO_ContributionPage::formatModuleData($ufJoinDAO->module_data, TRUE, $module); if ($module == 'soft_credit') { $defaults['honoree_profile'] = $ufJoinDAO->uf_group_id; - $jsonData = CRM_Contribute_BAO_ContributionPage::formatMultilingualHonorParams($ufJoinDAO->module_data, TRUE); $defaults = array_merge($defaults, $jsonData); $defaults['honor_block_is_active'] = $ufJoinDAO->is_active; } else { $defaults['onbehalf_profile_id'] = $ufJoinDAO->uf_group_id; - $jsonData = CRM_Contribute_BAO_ContributionPage::formatMultilingualOnBehalfParams($ufJoinDAO->module_data, TRUE); $defaults = array_merge($defaults, $jsonData); $defaults['is_organization'] = $ufJoinDAO->is_active; } @@ -362,11 +361,11 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_ $ufJoinParam['is_active'] = 1; if ($index == 'honor_block_is_active') { $ufJoinParam['uf_group_id'] = $params['honoree_profile']; - $ufJoinParam['module_data'] = CRM_Contribute_BAO_ContributionPage::formatMultilingualHonorParams($params); + $ufJoinParam['module_data'] = CRM_Contribute_BAO_ContributionPage::formatModuleData($params, FALSE, 'soft_credit'); } else { $ufJoinParam['uf_group_id'] = $params['onbehalf_profile_id']; - $ufJoinParam['module_data'] = CRM_Contribute_BAO_ContributionPage::formatMultilingualOnBehalfParams($params); + $ufJoinParam['module_data'] = CRM_Contribute_BAO_ContributionPage::formatModuleData($params, FALSE, 'on_behalf'); } CRM_Core_BAO_UFJoin::create($ufJoinParam); } diff --git a/CRM/Contribute/Form/SoftCredit.php b/CRM/Contribute/Form/SoftCredit.php index 7561df91bb..a24a5dc343 100644 --- a/CRM/Contribute/Form/SoftCredit.php +++ b/CRM/Contribute/Form/SoftCredit.php @@ -74,7 +74,7 @@ class CRM_Contribute_Form_SoftCredit { $ufJoinDAO->module = 'soft_credit'; $ufJoinDAO->entity_id = $form->_id; if ($ufJoinDAO->find(TRUE)) { - $jsonData = CRM_Contribute_BAO_ContributionPage::formatMultilingualHonorParams($ufJoinDAO->module_data, TRUE); + $jsonData = CRM_Contribute_BAO_ContributionPage::formatModuleData($ufJoinDAO->module_data, TRUE, 'soft_credit'); if ($jsonData) { foreach (array('honor_block_title', 'honor_block_text') as $name) { $form->assign($name, $jsonData[$name]); diff --git a/templates/CRM/Contribute/Form/Contribution/Main.tpl b/templates/CRM/Contribute/Form/Contribution/Main.tpl index 8fb97b9582..cb6642f865 100644 --- a/templates/CRM/Contribute/Form/Contribution/Main.tpl +++ b/templates/CRM/Contribute/Form/Contribution/Main.tpl @@ -25,7 +25,7 @@ *} {* Callback snippet: On-behalf profile *} {if $snippet and !empty($isOnBehalfCallback)} - {* include file="CRM/Contribute/Form/Contribution/OnBehalfOf.tpl" context="front-end" *} + {include file="CRM/Contribute/Form/Contribution/OnBehalfOf.tpl" context="front-end"} {else} {literal} @@ -171,9 +171,7 @@ {/if} {if $is_for_organization} -
- {include file="CRM/UF/Form/Block.tpl" fields=$onBehalfOfFields mode=8 prefix='onbehalf'} -
+ {include file="CRM/Contribute/Form/Contribution/OnBehalfOf.tpl"} {/if} {* User account registration option. Displays if enabled for one of the profiles on this page. *} diff --git a/templates/CRM/Contribute/Form/Contribution/OnBehalfOf.tpl b/templates/CRM/Contribute/Form/Contribution/OnBehalfOf.tpl index c12da8f421..e58bb75ac3 100644 --- a/templates/CRM/Contribute/Form/Contribution/OnBehalfOf.tpl +++ b/templates/CRM/Contribute/Form/Contribution/OnBehalfOf.tpl @@ -31,112 +31,26 @@ *} {if $buildOnBehalfForm or $onBehalfRequired} -
-{$fieldSetTitle} - {if ( $relatedOrganizationFound or $onBehalfRequired ) and !$organizationName} -
-
- {$form.org_option.html} + {if !empty($context)} +
+ {$fieldSetTitle} + {if ( $relatedOrganizationFound or $onBehalfRequired ) and !$organizationName and $form.org_option.html} +
+
+ {$form.org_option.html} +
-
- {/if} - -
- {foreach from=$onBehalfOfFields item=onBehaldField key=fieldName} - {if $onBehalfOfFields.$fieldName.skipDisplay} - {continue} - {/if} - {if $onBehalfOfFields.$fieldName.field_type eq "Formatting"} - {$onBehalfOfFields.$fieldName.help_pre} - {continue} {/if} -
- {if $onBehalfOfFields.$fieldName.help_pre} -   {$onBehalfOfFields.$fieldName.help_pre} - {/if} + {/if} +
+ {include file="CRM/UF/Form/Block.tpl" fields=$onBehalfOfFields mode=8 prefix='onbehalf'} +
- {if ( $fieldName eq 'organization_name' ) and $organizationName} -
{$form.onbehalf.$fieldName.label}
-
- {$form.onbehalf.$fieldName.html|crmAddClass:big} - - ( {ts}Enter a new organization{/ts} ) - -
- {ts}Organization details have been prefilled for you. If this is not the organization you want to use, click "Enter a new organization" above.{/ts} -
- {if $onBehalfOfFields.$fieldName.help_post} - {$onBehalfOfFields.$fieldName.help_post} - {/if} -
- {else} - {if $onBehalfOfFields.$fieldName.options_per_line} -
{$form.onbehalf.$fieldName.label}
-
- {assign var="count" value="1"} - {strip} - - - {* sort by fails for option per line. Added a variable to iterate through the element array*} - {assign var="index" value="1"} - {foreach name=outer key=key item=item from=$form.onbehalf.$fieldName} - {if $index < 10} - {assign var="index" value=`$index+1`} - {else} - - {if $count == $onBehalfOfFields.$fieldName.options_per_line} - - - {assign var="count" value="1"} - {else} - {assign var="count" value=`$count+1`} - {/if} - {/if} - {/foreach} - -
{$form.onbehalf.$fieldName.$key.html}
- {/strip} - {if $onBehalfOfFields.$fieldName.help_post} - {$onBehalfOfFields.$fieldName.help_post} - {/if} -
- {else} -
{$form.onbehalf.$fieldName.label}
-
- {if $fieldName eq 'organization_name' and !empty($form.onbehalfof_id)} - {$form.onbehalfof_id.html} - {/if} - {$form.onbehalf.$fieldName.html} - {if !empty($onBehalfOfFields.$fieldName.html_type) && $onBehalfOfFields.$fieldName.html_type eq 'Autocomplete-Select'} - {assign var=elementName value=onbehalf[$fieldName]} - {if $onBehalfOfFields.$fieldName.data_type eq 'ContactReference'} - {include file="CRM/Custom/Form/ContactReference.tpl" element_name = $elementName} - {/if} - {/if} - {if $onBehalfOfFields.$fieldName.name|substr:0:5 eq 'phone'} - {assign var="phone_ext_field" value=$onBehalfOfFields.$fieldName.name|replace:'phone':'phone_ext'} - {if $form.onbehalf.$phone_ext_field.html} -  {$form.onbehalf.$phone_ext_field.html} - {/if} - {/if} - {if $onBehalfOfFields.$fieldName.data_type eq 'Date'} - {assign var=elementName value=onbehalf[$fieldName]} - {include file="CRM/common/jcalendar.tpl" elementName=$elementName elementId=onbehalf_$fieldName} - {/if} - {if $onBehalfOfFields.$fieldName.help_post} -
{$onBehalfOfFields.$fieldName.help_post} - {/if} -
- {/if} - {/if} -
-
- {/foreach} -
-
{$form.mode.html}
-
+
{$form.mode.html}
+ {if !empty($context)} + + {/if} {/if} -{if empty($snippet)} {literal} -{/if} diff --git a/templates/CRM/UF/Form/Block.tpl b/templates/CRM/UF/Form/Block.tpl index fc2f1ace08..8608391965 100644 --- a/templates/CRM/UF/Form/Block.tpl +++ b/templates/CRM/UF/Form/Block.tpl @@ -132,7 +132,21 @@  {$form.$phone_ext_field.html} {/if} {else} - {if $prefix}{$form.$prefix.$n.html}{else}{$form.$n.html}{/if} + {if $prefix} + {if $n eq 'organization_name'} + {if !empty($form.onbehalfof_id)} + {$form.onbehalfof_id.html} + {/if} + {if $organizationName} + + ( {ts}Enter a new organization{/ts} ) + + {/if} + {/if} + {$form.$prefix.$n.html} + {else} + {$form.$n.html} + {/if} {/if} {*CRM-4564*}