jenkins-bot has submitted this change and it was merged.

Change subject: Fix direct_mail field check
......................................................................


Fix direct_mail field check

A patch at the beginning on Nov had accidentally caused this to start checking 
on the option_group, transposing title for name and
all campaigns were being dropped.

Bug: T121284
Change-Id: Ibcfdd06a8e9d8b099880461e87d9ef8c0de4889b
---
M sites/all/modules/wmf_civicrm/wmf_civicrm.module
1 file changed, 21 insertions(+), 3 deletions(-)

Approvals:
  Awight: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/sites/all/modules/wmf_civicrm/wmf_civicrm.module 
b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
index 10fa419..c5f2851 100644
--- a/sites/all/modules/wmf_civicrm/wmf_civicrm.module
+++ b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
@@ -6,14 +6,15 @@
 /**
  * return a map of option value (id) => option name
  */
-function civicrm_api_option_group($group_name, $key = null)
+function civicrm_api_option_group($group_name, $key = null, $force = FALSE)
 {
        static $cached_group = array();
-       if (!array_key_exists($group_name, $cached_group))
+       if (!array_key_exists($group_name, $cached_group) || $force)
        {
                $api = civicrm_api_classapi();
                $api->OptionValue->Get(array(
                        'option_group_name' => $group_name,
+                       'options' => array('limit' => 0),
                ));
                $cached_group[$group_name] = array();
                $option_values = $api->values();
@@ -1500,7 +1501,7 @@
             $msg['direct_mail_appeal'] = "Mediander";
             break;
         default:
-            $values = civicrm_api_option_group( 'Appeal' );
+            $values = civicrm_api_option_group( 
wmf_civicrm_get_direct_mail_field_option_name() );
             if ( in_array( $msg['utm_campaign'], $values ) ) {
                 $msg['direct_mail_appeal'] = $msg['utm_campaign'];
             }
@@ -1532,6 +1533,23 @@
 }
 
 /**
+ * Get the name value for the option group for direct mail.
+ *
+ * The option group for the direct mail field has been given a distinctive 
title but
+ * the name (which is the unique one) is distinctly historical.
+ *
+ * This name is included (as per below) in the install script so this function 
exists mostly
+ * to document it as such a wierd name is guaranteed to get people worried 
about avoiding
+ * hard-coding. The more appealing title 'Appeal' cannot be guaranteed to be 
unique.
+ *
+ * @throws \CiviCRM_API3_Exception
+ */
+function wmf_civicrm_get_direct_mail_field_option_name()
+{
+    return 'appeal_20080709183729';
+}
+
+/**
  * Insert the tag record
  *
  * Serves as a standard way for message processors to handle tag

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ibcfdd06a8e9d8b099880461e87d9ef8c0de4889b
Gerrit-PatchSet: 3
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Eileen <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Cdentinger <[email protected]>
Gerrit-Reviewer: Eileen <[email protected]>
Gerrit-Reviewer: Ejegg <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to