Merge pull request #5101 from agh1/context-abbrev
authorcolemanw <coleman@civicrm.org>
Tue, 10 Feb 2015 14:25:46 +0000 (09:25 -0500)
committercolemanw <coleman@civicrm.org>
Tue, 10 Feb 2015 14:25:46 +0000 (09:25 -0500)
CRM-15919 Address getoptions alternative: "abbreviate" context

CRM/Core/DAO.php
CRM/Core/PseudoConstant.php

index d4edfff9b30ac3979129907a564c442ca4f8294d..f551fb448c926205269ee427e5308ece3c125323 100644 (file)
@@ -2208,6 +2208,7 @@ SELECT contact_id
       'create' => "Options are filtered appropriately for the object being created/updated. Labels are translated.",
       'search' => "Searchable options are returned. Labels are translated.",
       'validate' => "All options are returned, even if they are disabled. Machine names are used in place of labels.",
+      'abbreviate' => "Active options are returned, and labels are replaced with abbreviations.",
     );
     // Validation: enforce uniformity of this param
     if ($context !== NULL && !isset($contexts[$context])) {
index 99e52169fe2a781c96c27673da180f4ae516a220..91ba2e6fc24fe7b70ed8ef440ea9296435180cfb 100644 (file)
@@ -284,6 +284,20 @@ class CRM_Core_PseudoConstant {
         'labelColumn' => CRM_Utils_Array::value('labelColumn', $pseudoconstant),
       );
 
+      if ($context == 'abbreviate') {
+        switch ($fieldName) {
+          case 'state_province_id':
+            $params['labelColumn'] = 'abbreviation';
+            break;
+
+          case 'country_id':
+            $params['labelColumn'] = 'iso_code';
+            break;
+
+          default:
+        }
+      }
+
       // Fetch option group from option_value table
       if (!empty($pseudoconstant['optionGroupName'])) {
         if ($context == 'validate') {