CRM-14181, add callback function, so that enums are accessible via api etc
authorkurund <kurund@civicrm.org>
Tue, 11 Feb 2014 22:45:13 +0000 (14:45 -0800)
committerkurund <kurund@civicrm.org>
Tue, 11 Feb 2014 22:45:13 +0000 (14:45 -0800)
----------------------------------------
* CRM-14181: migrate enums to varchar in schema for all tables
  http://issues.civicrm.org/jira/browse/CRM-14181

16 files changed:
CRM/Contribute/Form/ManagePremiums.php
CRM/Core/SelectValues.php
xml/schema/ACL/ACL.xml
xml/schema/Campaign/CampaignGroup.xml
xml/schema/Contact/ACLContactCache.xml
xml/schema/Contact/Contact.xml
xml/schema/Contact/Group.xml
xml/schema/Contact/GroupContact.xml
xml/schema/Contact/RelationshipType.xml
xml/schema/Contact/SubscriptionHistory.xml
xml/schema/Contribute/ContributionRecur.xml
xml/schema/Contribute/Product.xml
xml/schema/Core/ActionSchedule.xml
xml/schema/Core/CustomField.xml
xml/schema/Core/CustomGroup.xml
xml/schema/Core/Extension.xml

index 6e7abf2aaf6a48ff2106a920b070f24fec54e35b..ae906ea0a02a159b8fecdf28aa8e219599041ef4 100644 (file)
@@ -164,12 +164,11 @@ class CRM_Contribute_Form_ManagePremiums extends CRM_Contribute_Form {
 
     $this->add('text', 'fixed_period_start_day', ts('Fixed Period Start Day'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'fixed_period_start_day'));
 
-
-    $this->add('Select', 'duration_unit', ts('Duration Unit'), array('' => '- select period -', 'day' => 'Day', 'week' => 'Week', 'month' => 'Month', 'year' => 'Year'));
+    $this->add('Select', 'duration_unit', ts('Duration Unit'), array('' => '- select period -') + CRM_Core_SelectValues::getPremiumUnits());
 
     $this->add('text', 'duration_interval', ts('Duration'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'duration_interval'));
 
-    $this->add('Select', 'frequency_unit', ts('Frequency Unit'), array('' => '- select period -', 'day' => 'Day', 'week' => 'Week', 'month' => 'Month', 'year' => 'Year'));
+    $this->add('Select', 'frequency_unit', ts('Frequency Unit'), array('' => '- select period -') + CRM_Core_SelectValues::getPremiumUnits());
 
     $this->add('text', 'frequency_interval', ts('Frequency'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'frequency_interval'));
 
index 36127993dda7055af39b17d191855c8803f9d0a5..8b45c63f8b21af2dd4e0b5ccb44709c8282550f4 100644 (file)
@@ -134,8 +134,8 @@ class CRM_Core_SelectValues {
     if (!$periodType) {
       $periodType = array(
         '' => ts('- select -'),
-        'rolling' => ts('rolling'),
-        'fixed' => ts('fixed'),
+        'rolling' => ts('Rolling'),
+        'fixed' => ts('Fixed'),
       );
     }
     return $periodType;
@@ -881,5 +881,53 @@ class CRM_Core_SelectValues {
     }
     return $dedupeRuleTypes;
   }
+
+  /**
+   * campaign group types
+   */
+  static function getCampaignGroupTypes() {
+    static $campaignGroupTypes = NULL;
+    if (!$campaignGroupTypes) {
+      $campaignGroupTypes = array(
+        'Include' => ts('Include'),
+        'Exclude' => ts('Exclude'),
+      );
+    }
+    return $campaignGroupTypes;
+  }
+
+  /**
+   * subscription history method
+   */
+  static function getSubscriptionHistoryMethods() {
+    static $subscriptionHistoryMethods = NULL;
+    if (!$subscriptionHistoryMethods) {
+      $subscriptionHistoryMethods = array(
+        'Admin' => ts('Admin'),
+        'Email' => ts('Email'),
+        'Web' => ts('Web'),
+        'API' => ts('API'),
+      );
+    }
+
+    return $subscriptionHistoryMethods;
+  }
+
+  /**
+   * premium units
+   */
+  static function getPremiumUnits() {
+    static $premiumUnits = NULL;
+    if (!$premiumUnits) {
+      $premiumUnits = array(
+        'day' => ts('Day'),
+        'week' => ts('Week'),
+        'month' => ts('Month'),
+        'year' => ts('Year'),
+      );
+    }
+
+    return $premiumUnits;
+  }
 }
 
index fc00731c7e75e6b572f6fee939627a4d9b966722..046d75fa200125dd2e61f21d0cf951890b1a52b2 100644 (file)
@@ -65,6 +65,9 @@
         <length>8</length>
         <required>true</required>
         <comment>What operation does this ACL entry control?</comment>
+        <pseudoconstant>
+          <callback>CRM_ACL_BAO_ACL::operation()</callback>
+        </pseudoconstant>
         <html>
           <type>Select</type>
         </html>
index 907b3d381ebb51a24c2bbd34d87ea2e00ec9d670..49d5817168784c7f211bb106a9ca51cb0946b04a 100644 (file)
@@ -44,6 +44,9 @@
     <length>8</length>
     <default>NULL</default>
     <comment>Type of Group.</comment>
+    <pseudoconstant>
+      <callback>CRM_Core_SelectValues::getCampaignGroupTypes()</callback>
+    </pseudoconstant>
     <html>
       <type>Select</type>
     </html>
index a09df70e21391efdf9afc201d6891afed623d993..5a6150f38368fc86f6b09412595a5a903dae5d90 100644 (file)
@@ -50,6 +50,9 @@
       <length>8</length>
       <required>true</required>
       <comment>What operation does this user have permission on?</comment>
+      <pseudoconstant>
+        <callback>CRM_ACL_BAO_ACL::operation()</callback>
+      </pseudoconstant>
       <add>1.6</add>
       <html>
         <type>Select</type>
index de9c87503bb88fff71ebeac6bba1ea0a1e107aaf..4b76895a39cc09dc1dc9a31898633bc1dec21748 100644 (file)
        <headerPattern>/^p(ref\w*\s)?m(ail\s)?f(orm\w*)$/i</headerPattern>
        <comment>What is the preferred mode of sending an email.</comment>
        <add>1.1</add>
+       <pseudoconstant>
+         <callback>CRM_Core_SelectValues::pmf()</callback>
+       </pseudoconstant>
        <html>
          <type>Select</type>
        </html>
index 1934d644aa37a7b5da39663466616e13e9e9029d..444b6a61789b3ee7edc656ffa788fc6efee71b1b 100644 (file)
@@ -84,6 +84,9 @@
        <title>Group Visibility Setting</title>
        <default>'User and User Admin Only'</default>
        <comment>In what context(s) is this field visible.</comment>
+       <pseudoconstant>
+         <callback>CRM_Core_SelectValues::ufVisibility(true)</callback>
+       </pseudoconstant>
        <add>1.2</add>
        <html>
          <type>Select</type>
index 76d7e607983c24fb17539cb92ca1a2b8aa854a0c..837f820b5a5eed521da7a33712cb58f3738819d3 100644 (file)
@@ -63,6 +63,9 @@
        <length>8</length>
        <title>Group Contact Status</title>
        <comment>status of contact relative to membership in group</comment>
+       <pseudoconstant>
+         <callback>CRM_Core_SelectValues::groupContactStatus()</callback>
+       </pseudoconstant>
        <add>1.1</add>
        <html>
          <type>Select</type>
index c805b517cea6bb895bfdf7b8e78ff184534066dd..c9e3e1937b005b72b1755f39c6279b68cebd8068 100644 (file)
@@ -65,6 +65,9 @@
        <type>varchar</type>
        <length>12</length>
        <comment>If defined, contact_a in a relationship of this type must be a specific contact_type.</comment>
+       <pseudoconstant>
+         <callback>CRM_Contact_BAO_ContactType::getSelectElements()</callback>
+       </pseudoconstant>
        <add>1.1</add>
        <html>
          <type>Select</type>
@@ -76,6 +79,9 @@
        <type>varchar</type>
        <length>12</length>
        <comment>If defined, contact_b in a relationship of this type must be a specific contact_type.</comment>
+       <pseudoconstant>
+         <callback>CRM_Contact_BAO_ContactType::getSelectElements()</callback>
+       </pseudoconstant>
        <add>1.1</add>
        <html>
         <type>Select</type>
index aff77bd8549fcf72cec7be5c05840663d78206b9..bfcb7a257da07d063bbcd4f7d05ad38940639bc6 100644 (file)
@@ -65,6 +65,9 @@
         <type>varchar</type>
         <length>8</length>
         <comment>How the (un)subscription was triggered</comment>
+        <pseudoconstant>
+          <callback>CRM_Core_SelectValues::getSubscriptionHistoryMethods()</callback>
+        </pseudoconstant>
        <add>1.1</add>
        <html>
          <type>Select</type>
@@ -75,6 +78,9 @@
         <type>varchar</type>
         <length>8</length>
         <comment>The state of the contact within the group</comment>
+        <pseudoconstant>
+          <callback>CRM_Core_SelectValues::groupContactStatus()</callback>
+        </pseudoconstant>
        <add>1.1</add>
     </field>
     <field>
index b08c5fa1515e775fa9156a06709a83290d6e8277..65fec6ff6784fcf29e7fb4d7c41e0a64d0f350f7 100644 (file)
     <length>8</length>
     <default>'month'</default>
     <comment>Time units for recurrence of payment.</comment>
+    <pseudoconstant>
+      <optionGroupName>recur_frequency_units</optionGroupName>
+      <keyColumn>name</keyColumn>
+    </pseudoconstant>
     <add>1.6</add>
     <html>
       <type>Select</type>
index 4bf3d1f095ec0d1c04950d31aae9d004965b2b89..2761dc6b4a199edcf2d708256083e53abcf086bd 100644 (file)
       <default>'rolling'</default>
       <comment>Rolling means we set start/end based on current day, fixed means we set start/end for current year or month
 (e.g. 1 year + fixed -> we would set start/end for 1/1/06 thru 12/31/06 for any premium chosen in 2006) </comment>
+      <pseudoconstant>
+        <callback>CRM_Core_SelectValues::periodType()</callback>
+      </pseudoconstant>
       <add>1.4</add>
       <html>
         <type>Select</type>
       <type>varchar</type>
       <length>8</length>
       <default>'year'</default>
+      <pseudoconstant>
+        <callback>CRM_Core_SelectValues::getPremiumUnits()</callback>
+      </pseudoconstant>
       <add>1.4</add>
       <html>
         <type>Select</type>
       <length>8</length>
       <default>'month'</default>
       <comment>Frequency unit and interval allow option to store actual delivery frequency for a subscription or service.</comment>
+      <pseudoconstant>
+        <callback>CRM_Core_SelectValues::getPremiumUnits()</callback>
+      </pseudoconstant>
       <add>1.4</add>
       <html>
         <type>Select</type>
index 2688420f12ec53dfa8a82b2332dd24ebfb961bc8..0afc6c27fb9e0a438a8a44bf30fd4fbc44e6b611 100644 (file)
        <type>varchar</type>
        <length>8</length>
        <comment>Time units for reminder.</comment>
+       <pseudoconstant>
+         <optionGroupName>recur_frequency_units</optionGroupName>
+         <keyColumn>name</keyColumn>
+       </pseudoconstant>
        <add>3.4</add>
        <html>
          <type>Select</type>
        <type>varchar</type>
        <length>8</length>
        <comment>Time units for repetition of reminder.</comment>
+       <pseudoconstant>
+         <optionGroupName>recur_frequency_units</optionGroupName>
+         <keyColumn>name</keyColumn>
+       </pseudoconstant>
        <add>3.4</add>
        <html>
          <type>Select</type>
        <type>varchar</type>
        <length>8</length>
        <comment>Time units till repetition of reminder.</comment>
+       <pseudoconstant>
+         <optionGroupName>recur_frequency_units</optionGroupName>
+         <keyColumn>name</keyColumn>
+       </pseudoconstant>
        <add>3.4</add>
        <html>
          <type>Select</type>
index 0de4d036a12f7dd81569149cc1ea100402f6c488..3efb5c00c1b33ef54efe1036fc29ff6699218261 100644 (file)
@@ -62,6 +62,9 @@
      <length>16</length>
      <required>true</required>
      <comment>Controls location of data storage in extended_data table.</comment>
+     <pseudoconstant>
+       <callback>CRM_Core_BAO_CustomField::dataType()</callback>
+     </pseudoconstant>
      <add>1.1</add>
      <html>
        <type>Select</type>
@@ -73,6 +76,9 @@
      <length>32</length>
      <required>true</required>
      <comment>HTML types plus several built-in extended types.</comment>
+     <pseudoconstant>
+       <callback>CRM_Core_BAO_CustomField::dataToHtml()</callback>
+     </pseudoconstant>
      <add>1.1</add>
   </field>
   <field>
index 0318cb6555e3608c809756a7e861bcbbf89072f1..9eae8821929f224f2b51621cddba964c7817d1bd 100644 (file)
@@ -70,6 +70,9 @@
      <type>varchar</type>
      <length>8</length>
      <comment>Visual relationship between this form and its parent.</comment>
+     <pseudoconstant>
+       <callback>CRM_Core_SelectValues::customGroupStyle()</callback>
+     </pseudoconstant>
        <add>1.1</add>
        <html>
          <type>Select</type>
index 632bb5c232d1c46ebf45d9d91e53c2573c5392b4..da3fac0a7cd820ff6a1d1e6c690405d1f319f5b4 100644 (file)
@@ -24,6 +24,9 @@
     <length>8</length>
     <required>true</required>
     <comment></comment>
+    <pseudoconstant>
+      <callback>CRM_Core_SelectValues::pmf()</callback>
+    </pseudoconstant>
     <add>4.2</add>
     <html>
       <type>Select</type>