Handle upgrade logic
authormonishdeb <monish.deb@webaccessglobal.com>
Tue, 21 Jul 2015 06:30:15 +0000 (12:00 +0530)
committermonishdeb <monish.deb@webaccessglobal.com>
Thu, 10 Sep 2015 08:24:30 +0000 (13:54 +0530)
CRM/Contribute/Form/Contribution/Confirm.php
CRM/Upgrade/Incremental/php/FourSeven.php
CRM/Upgrade/Incremental/sql/4.7.alpha1.mysql.tpl

index a148a96e6d64d292bcff8ec6f9b82179ee0e1ea7..3d031f008072209db49c22c775ccc6bcbe4c766b 100644 (file)
@@ -467,7 +467,6 @@ 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['onbehalf_profile_id'])) {
 
index 0c043289a5743cd55ee3959c901455772e73e780..710854ac16909ca9202b48652771c19b43bcf6c5 100644 (file)
@@ -102,6 +102,8 @@ class CRM_Upgrade_Incremental_php_FourSeven extends CRM_Upgrade_Incremental_Base
   public function upgrade_4_7_alpha1($rev) {
     $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev);
     $this->addTask(ts('Add Getting Started dashlet to %1: SQL', array(1 => $rev)), 'addGettingStartedDashlet', $rev);
+    $this->addTask(ts('Migrate \'on behalf of\' information to module_data'), 'migrateOnBehalfOfInfo');
+    $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'task_4_7_x_runSql', $rev);
   }
 
   /**
@@ -143,4 +145,58 @@ FROM `civicrm_dashboard_contact` WHERE 1 GROUP BY contact_id";
     return TRUE;
   }
 
+  /**
+   * Migrate on-behalf information to uf_join.module_data as on-behalf columns will be dropped
+   * on DB upgrade
+   *
+   * @param CRM_Queue_TaskContext $ctx
+   *
+   * @return bool
+   *   TRUE for success
+   */
+  public static function migrateOnBehalfOfInfo(CRM_Queue_TaskContext $ctx) {
+
+    $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);
+
+    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(
+              $locale => array(
+                'for_organization' => $dao->$for_organization,
+              ),
+            );
+          }
+        }
+        else {
+          $onBehalfParams['on_behalf'] += array(
+            'default' => array(
+              'for_organization' => $dao->for_organization,
+            ),
+          );
+        }
+        $ufJoinParam = array(
+          'id' => $dao->join_id,
+          'module' => 'on_behalf',
+          'module_data' => json_encode($onBehalfParams),
+        );
+        CRM_Core_BAO_UFJoin::create($ufJoinParam);
+      }
+    }
+
+    return TRUE;
+  }
 }
index 6e83b5981e8362d77d1796dc7de3c4d4be2118a5..0797764857f19ec0b18fe6146d1d24d8a02a73d4 100644 (file)
@@ -88,7 +88,6 @@ CREATE TABLE IF NOT EXISTS `civicrm_status_pref` (
 -- CRM-17005
 UPDATE civicrm_country SET name = 'PALESTINIAN TERRITORY' WHERE name = 'PALESTINIAN TERRITORY, OCCUPIED';
 
-
 -- CRM-17145 update Activity detail data type
 ALTER TABLE `civicrm_activity` CHANGE `details` `details` LONGTEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'Details about the activity (agenda, notes, etc).';
 
@@ -166,3 +165,13 @@ INSERT INTO
    (@option_group_id_date_filter, '{ts escape="sql"}Next Quarter{/ts}', 'next.quarter', 'next.quarter', NULL, NULL, NULL,57, NULL, 0, 0, 1, NULL, NULL),
    (@option_group_id_date_filter, '{ts escape="sql"}Next Fiscal Year{/ts}', 'next.fiscal_year', 'next.fiscal_year', NULL, NULL, NULL,58, NULL, 0, 0, 1, NULL, NULL),
    (@option_group_id_date_filter, '{ts escape="sql"}Next Year{/ts}', 'next.year', 'next.year', NULL, NULL, NULL,59, NULL, 0, 0, 1, NULL, NULL);
+
+-- CRM-16873
+{if $multilingual}
+  {foreach from=$locales item=loc}
+     ALTER TABLE civicrm_contribution_page DROP for_organization_{$loc};
+  {/foreach}
+{else}
+     ALTER TABLE civicrm_contribution_page DROP for_organization;
+{/if}
+ALTER TABLE civicrm_contribution_page DROP is_for_organization;