CRM-16873: OnBehalf fix for multilingual
authormonishdeb <monish.deb@webaccessglobal.com>
Wed, 23 Sep 2015 14:09:16 +0000 (19:39 +0530)
committermonishdeb <monish.deb@webaccessglobal.com>
Wed, 23 Sep 2015 14:09:16 +0000 (19:39 +0530)
----------------------------------------
* CRM-16873: Migrating OnBehalf to ProfileContact
  https://issues.civicrm.org/jira/browse/CRM-16873

CRM/Upgrade/Incremental/php/FourSeven.php
templates/CRM/Contribute/Form/ContributionPage/Settings.tpl

index 8eca09799e51dec3d9002eaa908acbfd10021286..d4006bc1c6a46171270fbe73683130c4ce73bb5c 100644 (file)
@@ -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);
index a964450b9f5f33820639df8b10653ee2bbc168ad..ce13b74b16cd8241b001ab92956446710df5e8ff 100644 (file)
@@ -68,7 +68,7 @@
               </tr>
             {/if}
             <tr id="for_org_text" class="crm-contribution-contributionpage-settings-form-block-for_organization">
-                <td class="label">{$form.for_organization.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_contribution_page' field='for_organization' id=$contributionPageID}{/if}</td>
+                <td class="label">{$form.for_organization.label}</td>
                 <td>{$form.for_organization.html}<br />
                     <span class="description">{ts}Text displayed next to the checkbox on the contribution form.{/ts}</span>
                 </td>