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

CRM/Admin/Form/Job.php
CRM/Core/SelectValues.php
xml/schema/Core/Extension.xml
xml/schema/Core/Job.xml

index 17f090e8f6f572f330cb3c87e4808b303353cf59..5a18932bc26c4888c5bf72f64e74bc34dbc07d74 100644 (file)
@@ -94,10 +94,7 @@ class CRM_Admin_Form_Job extends CRM_Admin_Form {
       $attributes['api_action'], TRUE
     );
 
-    $this->add('select', 'run_frequency', ts('Run frequency'),
-      array('Daily' => ts('Daily'), 'Hourly' => ts('Hourly'), 'Always' => ts('Every time cron job is run'))
-    );
-
+    $this->add('select', 'run_frequency', ts('Run frequency'), CRM_Core_SelectValues::getJobFrequency());
 
     $this->add('textarea', 'parameters', ts('Command parameters'),
       "cols=50 rows=6"
index 8b45c63f8b21af2dd4e0b5ccb44709c8282550f4..acb99a20eb2ef1cd485e04077f5759e38ae4c25e 100644 (file)
@@ -929,5 +929,39 @@ class CRM_Core_SelectValues {
 
     return $premiumUnits;
   }
+
+  /**
+   * extension types
+   */
+  static function getExtensionTypes() {
+    static $extensionTypes = NULL;
+    if (!$extensionTypes) {
+      $extensionTypes = array(
+        'payment' => ts('Payment'),
+        'search' => ts('Search'),
+        'report' => ts('Report'),
+        'module' => ts('Module'),
+        'sms' => ts('SMS'),
+      );
+    }
+
+    return $extensionTypes;
+  }
+
+  /**
+   * job frequency
+   */
+  static function getJobFrequency() {
+    static $jobFrequency = NULL;
+    if (!$jobFrequency) {
+      $jobFrequency = array(
+        'Daily' => ts('Daily'),
+        'Hourly' => ts('Hourly'),
+        'Always' => ts('Every time cron job is run'),
+      );
+    }
+
+    return $jobFrequency;
+  }
 }
 
index da3fac0a7cd820ff6a1d1e6c690405d1f319f5b4..3d1abc48176160642b2c37a03c6cc5b8ff46e190 100644 (file)
@@ -25,7 +25,7 @@
     <required>true</required>
     <comment></comment>
     <pseudoconstant>
-      <callback>CRM_Core_SelectValues::pmf()</callback>
+      <callback>CRM_Core_SelectValues::getExtensionTypes()</callback>
     </pseudoconstant>
     <add>4.2</add>
     <html>
index b86bdff9e80b5664c91a9a599e989096a0b59970..fcf89f856fbcfaf21918e8167451564da75d3dd2 100644 (file)
@@ -37,6 +37,9 @@
        <length>8</length>
        <default>"Daily"</default>
        <comment>Scheduled job run frequency.</comment>
+       <pseudoconstant>
+         <callback>CRM_Core_SelectValues::getJobFrequency()</callback>
+       </pseudoconstant>
        <add>4.1</add>
        <html>
          <type>Select</type>