Awight has submitted this change and it was merged.

Change subject: Revert commits on wrong branch
......................................................................


Revert commits on wrong branch

Revert "T99836 Civi46: change contributionType to financialType"

This reverts commit bb07ec231879f1b6cf5de1c723d15c6ddaec8fa9.

Revert "T99836 Civi46 : change submodule version to 4.6.9"

This reverts commit df37a842daf64dbe42f61d01d79f4936dee2083c.

Revert "T99836 Civi46 magic var for weight from api call"

This reverts commit 543255cc2be72deedab3c0d759540db82bc312b6.

Revert "T99836 Civi46 remove call to psuedoconstnat:ContributionType"

This reverts commit 20fa24d6daf7b2e03e271325cef81417857651a6.

Revert "T99836 Civi46 remove call to pseudoconstant:locationType"

This reverts commit fc81f03bbc3b7022908e742c9242fc5ffc56acab.

Revert "T99836 remove code to add prevnext indexes"

This reverts commit 0495eab80b2819b903c5a22f1c0eb29cacfaf05e.

Revert "T99836 add option value for tag_used for upgrading installs too."

This reverts commit d1f85adec46962b4bc24351533d4fc1de2e32322.

Revert "T99836 CiviCRM 4.6 : add otion value for tag_used_for on install"

This reverts commit df748bf5b4a283138b4d69f9c0cc93602e35732d.

Change-Id: I24306f8378ca681d4d436c0b62305609f1cbab09
---
M civicrm
M sites/all/modules/wmf_civicrm/bootstrap.inc
M sites/all/modules/wmf_civicrm/wmf_civicrm.install
M sites/all/modules/wmf_civicrm/wmf_civicrm.module
4 files changed, 57 insertions(+), 101 deletions(-)

Approvals:
  Awight: Verified; Looks good to me, approved



diff --git a/civicrm b/civicrm
index 0e31ff7..dbeff64 160000
--- a/civicrm
+++ b/civicrm
-Subproject commit 0e31ff753a9e05a63d92c08ea97db9f201ea795e
+Subproject commit dbeff641f99bfa73fd820e20ccd61ebb822a5d25
diff --git a/sites/all/modules/wmf_civicrm/bootstrap.inc 
b/sites/all/modules/wmf_civicrm/bootstrap.inc
index 14ebf15..03f5eb0 100644
--- a/sites/all/modules/wmf_civicrm/bootstrap.inc
+++ b/sites/all/modules/wmf_civicrm/bootstrap.inc
@@ -34,9 +34,6 @@
  *
  * @param array $financial_types
  *
- * @return array
- *   Financial types in th DB.
- *
  * @throws \CiviCRM_API3_Exception
  */
 function wmf_civicrm_create_financial_types($financial_types)
@@ -47,118 +44,69 @@
     $missingTypes = array_diff($financial_types, 
$existingFinancialTypes['values']);
     foreach ($missingTypes  as $type)
     {
-        $result = civicrm_api3('FinancialType', 'create', array(
+        civicrm_api3('FinancialType', 'create', array(
           'is_active' => 1,
           'is_deductible' => 1,
           'accounting_code' => strtoupper($type),
           'name' => $type,
         ));
-        $existingFinancialTypes[$result['id']] = $type;
     }
-    return $existingFinancialTypes;
 }
 
-/**
- * Create option values in CiviCRM.
- *
- * For more control use the option_values_detailed function below.
- *
- * NB - encapsulated the detailed create function has a slight performance
- * cost since group is resolved potentially multiple times - but this
- * function seems like a rarely run function.
- *
- * @param string $group_name
- * @param array $values
- */
 function wmf_civicrm_create_option_values( $group_name, $values )
-{
-    foreach ($values as $value) {
-        wmf_civicrm_create_option_values_detailed($group_name, array(
-            $value => array(
-                'name' => $value,
-        )));
-    }
-}
-
-/**
- * Create option values in CiviCRM with details.
- *
- * The previous other of this only permits a flat array. This allows a more
- * nuanced option value create.
- *
- * This checks for an existing option value first.
- *
- * @param string $group_name
- * @param array $values
- */
-function wmf_civicrm_create_option_values_detailed($group_name, $values)
 {
     $api = wmf_civicrm_bootstrap_civi();
 
     $api->OptionGroup->Get(array(
-      'name' => $group_name,
+        'name' => $group_name,
     ));
     $result = $api->values();
     $option_group = array_pop($result);
-    foreach ($values as $key => $value)
+    foreach ($values as $value)
     {
-        $params = array_merge(array(
-          'option_group_id' => $option_group->id,
-          'name' => $key,
-          'label' => $key,
-          'is_active' => 1,
-        ), $value);
-
         $api->OptionValue->Get(array(
-          'option_group_id' => $option_group->id,
-          'name' => $params['name'],
+            'option_group_id' => $option_group->id,
+            'name' => $value,
         ));
 
         $result = $api->values();
         if (empty($result))
         {
-            $api->OptionValue->Create(array_merge(array(
-              'option_group_id' => $option_group->id,
-              'name' => $key,
-              'label' => $key,
-              'is_active' => 1,
-            )), $value);
+            $api->OptionValue->Create(array(
+                'option_group_id' => $option_group->id,
+                'name' => $value,
+                'label' => $value,
+                'is_active' => 1,
+            ));
         }
     }
 }
 
-/**
- * Ensure that a location type exists for every item in the array.
- *
- * @param array $financial_types
- *
- * @throws \CiviCRM_API3_Exception
- */
 function wmf_civicrm_create_location_types($location_types, $update_existing = 
FALSE)
 {
-    $existingTypes = civicrm_api3('Address', 'getoptions', array(
-      'field' => 'location_type_id',
-    ));
-    if (!$update_existing) {
-        $location_types = array_diff($location_types, 
$existingTypes['values']);
-    }
     foreach ($location_types as $name => $display_name)
     {
-        $params = array(
-            'name' => $name,
-            'display_name' => $display_name,
-            'is_active' => 1,
+        $location_type_id = CRM_Utils_Array::key(
+            $name,
+            CRM_Contribute_PseudoConstant::locationType()
         );
-        if ($update_existing) {
-            $params['id'] = array_search($display_name,  
$existingTypes['values']);
+
+        if (!$location_type_id || $update_existing == TRUE)
+        {
+            $params = array(
+                'name' => $name,
+                'display_name' => $display_name,
+                'is_active' => 1,
+            );
+            if ($location_type_id && $update_existing == TRUE)
+            {
+                $params['id'] = $location_type_id;
+            }
+            wmf_civicrm_add_location_type($params);
         }
-        civicrm_api3('LocationType', 'create', $params);
     }
 }
 
-/**
- * @deprecated
- */
 function wmf_civicrm_add_location_type($params)
 {
     $locationType = new CRM_Core_DAO_LocationType();
diff --git a/sites/all/modules/wmf_civicrm/wmf_civicrm.install 
b/sites/all/modules/wmf_civicrm/wmf_civicrm.install
index bc3f57a..2e07ff0 100644
--- a/sites/all/modules/wmf_civicrm/wmf_civicrm.install
+++ b/sites/all/modules/wmf_civicrm/wmf_civicrm.install
@@ -99,6 +99,7 @@
                 'option_group_id' => $option_group_id,
                 'label' => ts( $value ),
                 'value' => $value,
+                'weight' => 'next',
             ) );
             if ( !$success ) {
                 throw new Exception( $api->errorMsg() );
@@ -851,10 +852,6 @@
 {
     $ret = array();
     $api = wmf_civicrm_bootstrap_civi();
-    wmf_civicrm_create_option_values_detailed('tag_used_for', array(
-        'Contributions' => array('value' => 'civicrm_contribution'),
-    ));
-
     $success = $api->Tag->get(array(
         'name' => 'RecurringRestarted',
         'used_for' => 'civicrm_contribution',
@@ -1196,13 +1193,17 @@
 }
 
 /**
- * Add indexes to the civicrm_prevnext_cache table.
- *
- * In CiviCRM 4.6 these are in core.
+ * Add indexes to the civicrm_prevnext_cache table
  */
 function wmf_civicrm_update_7025()
 {
+    $dbs = wmf_civicrm_get_dbs();
+    $dbs->push('civicrm');
 
+    db_query("alter table civicrm_prevnext_cache
+            add index entity_id1 (entity_id1),
+            add index entity_id2 (entity_id2),
+            add index cacheKey (cacheKey)");
 }
 
 /**
@@ -1341,10 +1342,28 @@
  * Add more custom fields that already exist on production
  */
 function wmf_civicrm_update_7031() {
+    $warnings = array();
 
     $api = wmf_civicrm_bootstrap_civi();
-    $financialTypes = wmf_civicrm_create_financial_types(array('Stock'));
-    $stockContributionTypeId = array_search('Stock', $financialTypes);
+
+    // No API available yet.
+    $existingTypes = array_flip( 
CRM_Contribute_PseudoConstant::contributionType() );
+    if ( array_key_exists( 'Stock', $existingTypes ) ) {
+        $stockContributionTypeId = $existingTypes['Stock'];
+    } else {
+        $params = array(
+            'accounting_code' => 'STOCK',
+            'is_active' => 1,
+            'is_deductible' => 1,
+            'name' => 'Stock',
+        );
+        $ids = array();
+        $stockContributionType = CRM_Contribute_BAO_ContributionType::add( 
$params, $ids );
+        if ( is_a( $stockContributionType, 'CRM_Core_Error' ) ) {
+            throw new Exception( $stockContributionType->getMessages() );
+        }
+        $stockContributionTypeId = $stockContributionType->id;
+    }
 
     $success = $api->CustomGroup->get(array(
         'name' => 'Stock_Information',
@@ -1426,17 +1445,6 @@
  * Add "Trilogy" payment instrument.
  */
 function wmf_civicrm_update_7034() {
-    wmf_civicrm_bootstrap_civi();
-    wmf_civicrm_create_option_values( 'payment_instrument', array('Trilogy') );
-    return array();
-}
-
-/**
- * Add option value 'tag_used_for' for civicrm_contribution.
- *
- * This might exist as it had to be added to update 7022 so check first.d
- */
-function wmf_civicrm_update_7035() {
     wmf_civicrm_bootstrap_civi();
     wmf_civicrm_create_option_values( 'payment_instrument', array('Trilogy') );
     return array();
diff --git a/sites/all/modules/wmf_civicrm/wmf_civicrm.module 
b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
index 9d2ad15..6a49470 100644
--- a/sites/all/modules/wmf_civicrm/wmf_civicrm.module
+++ b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
@@ -457,7 +457,7 @@
         case 'contribution_type_id':
             //fixme: This is probably the upside-down way to do it. Really 
ought to go through the API.
             //
-            $result = CRM_Financial_BAO_FinancialType::retrieve($params, 
$dummy);
+            $result = CRM_Contribute_BAO_ContributionType::retrieve($params, 
$dummy);
             if (!is_null($result)){
                 $civi_ids[$type][$name] = $result->id;
                 watchdog('wmf_civicrm', "Found id for contribution_type $name: 
" . $civi_ids[$type][$name]);
@@ -469,7 +469,7 @@
                 $params['accounting_code'] = strtoupper($name);
                 $params['is_deductible'] = 1;
                 $params['is_active'] = 1;
-                $result = CRM_Financial_BAO_FinancialType::add($params, 
$dummy);
+                $result = CRM_Contribute_BAO_ContributionType::add($params, 
$dummy);
                 $civi_ids[$type][$name] = $result->id;
                 watchdog('wmf_civicrm', "New id for contribution_type $name :" 
. $civi_ids[$type][$name]);
             }

-- 
To view, visit https://gerrit.wikimedia.org/r/240287
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I24306f8378ca681d4d436c0b62305609f1cbab09
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to