From d3e92c887f3094c86dc6998e174a0199e17f87dc Mon Sep 17 00:00:00 2001 From: monishdeb Date: Wed, 23 Sep 2015 19:39:16 +0530 Subject: [PATCH] CRM-16873: OnBehalf fix for multilingual ---------------------------------------- * CRM-16873: Migrating OnBehalf to ProfileContact https://issues.civicrm.org/jira/browse/CRM-16873 --- CRM/Upgrade/Incremental/php/FourSeven.php | 27 ++++++++++++++----- .../Form/ContributionPage/Settings.tpl | 2 +- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/CRM/Upgrade/Incremental/php/FourSeven.php b/CRM/Upgrade/Incremental/php/FourSeven.php index 8eca09799e..d4006bc1c6 100644 --- a/CRM/Upgrade/Incremental/php/FourSeven.php +++ b/CRM/Upgrade/Incremental/php/FourSeven.php @@ -231,23 +231,35 @@ FROM `civicrm_dashboard_contact` WHERE 1 GROUP BY contact_id"; * TRUE for success */ public static function migrateOnBehalfOfInfo(CRM_Queue_TaskContext $ctx) { + $domain = new CRM_Core_DAO_Domain(); + $domain->find(TRUE); + // fetch onBehalf entry in UFJoin table $ufGroupDAO = new CRM_Core_DAO_UFJoin(); $ufGroupDAO->module = 'OnBehalf'; $ufGroupDAO->find(TRUE); - $query = "SELECT cp.*, uj.id as join_id - FROM civicrm_contribution_page cp - INNER JOIN civicrm_uf_join uj ON uj.entity_id = cp.id AND uj.module = 'OnBehalf'"; - $dao = CRM_Core_DAO::executeQuery($query); + $forOrgColums = array(); + if ($domain->locales) { + $locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales); + foreach ($locales as $locale) { + $forOrgColums[] = "for_organization_{$locale}"; + } + } + else { + $forOrgColums[] = "for_organization"; + } + + $query = " + SELECT " . implode(", ", $forOrgColums) . ", uj.id as join_id, uj.uf_group_id as uf_group_id + FROM civicrm_contribution_page cp + INNER JOIN civicrm_uf_join uj ON uj.entity_id = cp.id AND uj.module = 'OnBehalf'"; + $dao = CRM_Core_DAO::executeQuery($query, array(), TRUE, NULL, FALSE, FALSE); if ($dao->N) { - $domain = new CRM_Core_DAO_Domain(); - $domain->find(TRUE); while ($dao->fetch()) { $onBehalfParams['on_behalf'] = array('is_for_organization' => $dao->is_for_organization); if ($domain->locales) { - $locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales); foreach ($locales as $locale) { $for_organization = "for_organization_{$locale}"; $onBehalfParams['on_behalf'] += array( @@ -267,6 +279,7 @@ FROM `civicrm_dashboard_contact` WHERE 1 GROUP BY contact_id"; $ufJoinParam = array( 'id' => $dao->join_id, 'module' => 'on_behalf', + 'uf_group_id' => $dao->uf_group_id, 'module_data' => json_encode($onBehalfParams), ); CRM_Core_BAO_UFJoin::create($ufJoinParam); diff --git a/templates/CRM/Contribute/Form/ContributionPage/Settings.tpl b/templates/CRM/Contribute/Form/ContributionPage/Settings.tpl index a964450b9f..ce13b74b16 100644 --- a/templates/CRM/Contribute/Form/ContributionPage/Settings.tpl +++ b/templates/CRM/Contribute/Form/ContributionPage/Settings.tpl @@ -68,7 +68,7 @@ {/if} - {$form.for_organization.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_contribution_page' field='for_organization' id=$contributionPageID}{/if} + {$form.for_organization.label} {$form.for_organization.html}
{ts}Text displayed next to the checkbox on the contribution form.{/ts} -- 2.25.1