From e204d358e4731240a45193a0af8d88af8c3bdc70 Mon Sep 17 00:00:00 2001 From: kurund Date: Wed, 12 Feb 2014 21:06:41 -0800 Subject: [PATCH] CRM-14181, add callback function, so that enums are accessible via api etc ---------------------------------------- * CRM-14181: migrate enums to varchar in schema for all tables http://issues.civicrm.org/jira/browse/CRM-14181 --- CRM/Core/BAO/Mapping.php | 17 +------- CRM/Core/SelectValues.php | 64 +++++++++++++++++++++++++++++ xml/schema/Core/MappingField.xml | 3 ++ xml/schema/Core/UFField.xml | 3 ++ xml/schema/Core/UFGroup.xml | 3 ++ xml/schema/Core/WordReplacement.xml | 3 ++ 6 files changed, 77 insertions(+), 16 deletions(-) diff --git a/CRM/Core/BAO/Mapping.php b/CRM/Core/BAO/Mapping.php index 12d8e74d85..6c4a576b63 100644 --- a/CRM/Core/BAO/Mapping.php +++ b/CRM/Core/BAO/Mapping.php @@ -850,22 +850,7 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { if ($mappingType == 'Search Builder') { //CRM -2292, restricted array set - $operatorArray = array( - '' => ts('-operator-'), - '=' => '=', - '!=' => '≠', - '>' => '>', - '<' => '<', - '>=' => '≥', - '<=' => '≤', - 'IN' => ts('In'), - 'LIKE' => ts('Like'), - 'RLIKE' => ts('Regex'), - 'IS EMPTY' => ts('Is Empty'), - 'IS NOT EMPTY' => ts('Not Empty'), - 'IS NULL' => ts('Is Null'), - 'IS NOT NULL' => ts('Not Null'), - ); + $operatorArray = array('' => ts('-operator-')) + CRM_Core_SelectValues::getSearchBuilderOperators(); $form->add('select', "operator[$x][$i]", '', $operatorArray); $form->add('text', "value[$x][$i]", ''); diff --git a/CRM/Core/SelectValues.php b/CRM/Core/SelectValues.php index acb99a20eb..3c1edc26fb 100644 --- a/CRM/Core/SelectValues.php +++ b/CRM/Core/SelectValues.php @@ -963,5 +963,69 @@ class CRM_Core_SelectValues { return $jobFrequency; } + + /** + * Search builder operators + */ + static function getSearchBuilderOperators() { + static $searchBuilderOperators = NULL; + if (!$searchBuilderOperators) { + $searchBuilderOperators = array( + '=' => '=', + '!=' => '≠', + '>' => '>', + '<' => '<', + '>=' => '≥', + '<=' => '≤', + 'IN' => ts('In'), + 'LIKE' => ts('Like'), + 'RLIKE' => ts('Regex'), + 'IS EMPTY' => ts('Is Empty'), + 'IS NOT EMPTY' => ts('Not Empty'), + 'IS NULL' => ts('Is Null'), + 'IS NOT NULL' => ts('Not Null'), + ); + } + + return $searchBuilderOperators; + } + + /** + * profile group types + * + * @static + */ + static function getProfileGroupType() { + static $profileGroupType = NULL; + if (!$profileGroupType) { + $profileGroupType = array( + 'Activity' => ts('Activities'), + 'Contribution' => ts('Contributions'), + 'Membership' => ts('Memberships'), + 'Participant' => ts('Participants'), + ); + $contactTypes = self::contactType(); + $contactTypes = !empty($contactTypes) ? array('Contact' => 'Contacts') + $contactTypes : array(); + $profileGroupType = array_merge($contactTypes, $profileGroupType ); + } + return $profileGroupType; + } + + + /** + * word replacement match type + */ + static function getWordReplacementMatchType() { + static $wordReplacementMatchType = NULL; + if (!$wordReplacementMatchType) { + $wordReplacementMatchType = array( + 'exactMatch' => ts('Exact Match'), + 'wildcardMatch' => ts('Wildcard Match'), + ); + } + + return $jobFrequency; + } + } diff --git a/xml/schema/Core/MappingField.xml b/xml/schema/Core/MappingField.xml index f679d844fd..3cefbc8e93 100644 --- a/xml/schema/Core/MappingField.xml +++ b/xml/schema/Core/MappingField.xml @@ -141,6 +141,9 @@ 16 enum SQL WHERE operator for search-builder mapping fields (search criteria). + + CRM_Core_SelectValues::getSearchBuilderOperators() + 1.5 Select diff --git a/xml/schema/Core/UFField.xml b/xml/schema/Core/UFField.xml index ac7e5abc18..582b1dcdb6 100644 --- a/xml/schema/Core/UFField.xml +++ b/xml/schema/Core/UFField.xml @@ -113,6 +113,9 @@ 32 'User and User Admin Only' In what context(s) is this field visible. + + CRM_Core_SelectValues::ufVisibility() + 1.1 Select diff --git a/xml/schema/Core/UFGroup.xml b/xml/schema/Core/UFGroup.xml index 19db8bf789..7ae8901c60 100644 --- a/xml/schema/Core/UFGroup.xml +++ b/xml/schema/Core/UFGroup.xml @@ -31,6 +31,9 @@ 255 true This column will store a comma separated list of the type(s) of profile fields. + + CRM_Core_SelectValues::getProfileGroupType() + 2.1 diff --git a/xml/schema/Core/WordReplacement.xml b/xml/schema/Core/WordReplacement.xml index 012c51adaf..5a16a83953 100644 --- a/xml/schema/Core/WordReplacement.xml +++ b/xml/schema/Core/WordReplacement.xml @@ -53,6 +53,9 @@ varchar 16 "wildcardMatch" + + CRM_Core_SelectValues::getWordReplacementMatchType() + 4.4 Select -- 2.25.1