CRM-14181 fixes, deleted addDisplayEnums() and code fixes
authorkurund <kurund@civicrm.org>
Sun, 9 Feb 2014 09:09:55 +0000 (01:09 -0800)
committerkurund <kurund@civicrm.org>
Sun, 9 Feb 2014 09:09:55 +0000 (01:09 -0800)
----------------------------------------
* CRM-14181: migrate enums to varchar in schema for all tables
  http://issues.civicrm.org/jira/browse/CRM-14181

CRM/Admin/Form/RelationshipType.php
CRM/Contact/BAO/Contact.php
CRM/Contact/Form/DedupeRules.php
CRM/Contact/Page/DedupeRules.php
CRM/Core/Page/Basic.php
CRM/Core/SelectValues.php
CRM/Custom/Page/Group.php
CRM/UF/Page/Field.php
xml/templates/dao.tpl

index 76d627e0f4dcef7a570c6a2c06ca00bbb7d448af..7dbd708b2ec200801952fce71c8be6ad0c90cc47 100644 (file)
@@ -74,8 +74,6 @@ class CRM_Admin_Form_RelationshipType extends CRM_Admin_Form {
       CRM_Core_DAO::getAttribute('CRM_Contact_DAO_RelationshipType', 'description')
     );
 
-
-
     $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements();
 
     // add select for contact type
index fafe395c9a32d47670f6a0a9739c145c6db20b7e..90fefe0c9eb96b5f7a73b8764a8015863fbceab0 100644 (file)
@@ -2381,7 +2381,8 @@ AND       civicrm_openid.is_primary = 1";
       $values['preferred_communication_method'] = $preffComm;
       $values['preferred_communication_method_display'] = CRM_Utils_Array::value('preferred_communication_method_display', $temp);
 
-      CRM_Contact_DAO_Contact::addDisplayEnums($values);
+      $preferredMailingFormat = CRM_Core_SelectValues::pmf();
+      $values['preferred_mail_format'] = $preferredMailingFormat[$contact->preferred_mail_format];
 
       // get preferred languages
       if (!empty($contact->preferred_language)) {
index 85e21738aac402eec249aa4d7bc9595eb423f9ab..15b4014c7a43feb42bd8133136d891d3cb181dd8 100644 (file)
@@ -56,7 +56,7 @@ class CRM_Contact_Form_DedupeRules extends CRM_Admin_Form {
       CRM_Utils_System::permissionDenied();
       CRM_Utils_System::civiExit();
     }
-    $this->_options = array(ts('Unsupervised'), ts('Supervised'), ts('General'));
+    $this->_options = CRM_Core_SelectValues::getDedupeRuleTypes();
     $this->_rgid = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0);
     $this->_contactType = CRM_Utils_Request::retrieve('contact_type', 'String', $this, FALSE, 0);
     if ($this->_rgid) {
@@ -188,16 +188,16 @@ class CRM_Contact_Form_DedupeRules extends CRM_Admin_Form {
     $values = $this->exportValues();
 
     //FIXME: Handle logic to replace is_default column by usage
-    $used = CRM_Utils_Array::value('used', $values, FALSE);
     // reset used column to General (since there can only
     // be one 'Supervised' or 'Unsupervised' rule)
-    if ($this->_options[$used] != 'General') {
+    if ($values['used'] != 'General') {
       $query = "
 UPDATE civicrm_dedupe_rule_group
    SET used = 'General'
  WHERE contact_type = %1
    AND used = %2";
-      $queryParams = array(1 => array($this->_contactType, 'String'),
+      $queryParams = array(
+        1 => array($this->_contactType, 'String'),
         2 => array($this->_options[$used], 'String'),
       );
 
@@ -211,7 +211,7 @@ UPDATE civicrm_dedupe_rule_group
 
     $rgDao->title        = $values['title'];
     $rgDao->is_reserved  = CRM_Utils_Array::value('is_reserved', $values, FALSE);
-    $rgDao->used         = $this->_options[$values['used']];
+    $rgDao->used         = $values['used'];
     $rgDao->contact_type = $this->_contactType;
     $rgDao->threshold    = $values['threshold'];
     $rgDao->save();
index 4ea6369a924f33ba1f2cdd6390c24e3df48ef9c2..629d992367e2b9e76287f4250410c471bb3f41b1 100644 (file)
@@ -148,6 +148,7 @@ class CRM_Contact_Page_DedupeRules extends CRM_Core_Page_Basic {
     $dao->orderBy('contact_type,used ASC');
     $dao->find();
 
+    $dedupeRuleTypes = CRM_Core_SelectValues::getDedupeRuleTypes();
     while ($dao->fetch()) {
       $ruleGroups[$dao->contact_type][$dao->id] = array();
       CRM_Core_DAO::storeValues($dao, $ruleGroups[$dao->contact_type][$dao->id]);
@@ -174,9 +175,9 @@ class CRM_Contact_Page_DedupeRules extends CRM_Core_Page_Basic {
         'DedupeRule',
         $dao->id
       );
-      CRM_Dedupe_DAO_RuleGroup::addDisplayEnums($ruleGroups[$dao->contact_type][$dao->id]);
-    }
 
+      $ruleGroups[$dao->contact_type][$dao->id]['used_display'] = $dedupeRuleTypes[$ruleGroups[$dao->contact_type][$dao->id]['used']];
+    }
     $this->assign('brows', $ruleGroups);
   }
 
index 65c76846234f30f3083983d126708aa50ee1ad88..bce480ba86e2133608ff74abf1772f665cab4843 100644 (file)
@@ -242,6 +242,7 @@ abstract class CRM_Core_Page_Basic extends CRM_Core_Page {
     }
 
 
+    $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements();
     // find all objects
     $object->find();
     while ($object->fetch()) {
@@ -257,7 +258,10 @@ abstract class CRM_Core_Page_Basic extends CRM_Core_Page {
           $values[$object->id] = array();
           CRM_Core_DAO::storeValues($object, $values[$object->id]);
 
-          CRM_Contact_DAO_RelationshipType::addDisplayEnums($values[$object->id]);
+          if (is_a($object, 'CRM_Contact_DAO_RelationshipType')) {
+            $values[$object->id]['contact_type_a_display'] = $contactTypes[$values[$object->id]['contact_type_a']];
+            $values[$object->id]['contact_type_b_display'] = $contactTypes[$values[$object->id]['contact_type_b']];
+          }
 
           // populate action links
           $this->action($object, $action, $values[$object->id], $links, $permission);
index 6c4ddbd2f295af8314680c356dc2f7ef36dbb29d..36127993dda7055af39b17d191855c8803f9d0a5 100644 (file)
@@ -866,5 +866,20 @@ class CRM_Core_SelectValues {
     }
     return $barcodeTypes;
   }
+
+  /**
+   * dedupe rule types
+   */
+  static function getDedupeRuleTypes() {
+    static $dedupeRuleTypes = NULL;
+    if (!$dedupeRuleTypes) {
+      $dedupeRuleTypes = array(
+        'Unsupervised' => ts('Unsupervised'),
+        'Supervised' => ts('Supervised'),
+        'General' => ts('General'),
+      );
+    }
+    return $dedupeRuleTypes;
+  }
 }
 
index b26cea535d3ae55d0c4c84ec4f248f7bfcc8927f..b1874f37dcc3d7ac25605075e484f5db515dac32 100644 (file)
@@ -235,8 +235,9 @@ class CRM_Custom_Page_Group extends CRM_Core_Page {
     }
 
     $customGroupExtends = CRM_Core_SelectValues::customGroupExtends();
+    $customGroupStyle = CRM_Core_SelectValues::customGroupStyle();
     foreach ($customGroup as $key => $array) {
-      CRM_Core_DAO_CustomGroup::addDisplayEnums($customGroup[$key]);
+      $customGroup[$key]['style_display'] = $customGroupStyle[$customGroup[$key]['style']];
       $customGroup[$key]['extends_display'] = $customGroupExtends[$customGroup[$key]['extends']];
     }
 
index 37b67017989d1d63b5aec946e999acb8806ae242..f1fa6bd3efdc3172d5212aaed16824e6f8800748 100644 (file)
@@ -143,11 +143,12 @@ class CRM_UF_Page_Field extends CRM_Core_Page {
     $select['group'] = ts('Group(s)');
     $select['tag'] = ts('Tag(s)');
 
+    $visibility = CRM_Core_SelectValues::ufVisibility();
     while ($ufFieldBAO->fetch()) {
       $ufField[$ufFieldBAO->id] = array();
       $phoneType = $locType = '';
       CRM_Core_DAO::storeValues($ufFieldBAO, $ufField[$ufFieldBAO->id]);
-      CRM_Core_DAO_UFField::addDisplayEnums($ufField[$ufFieldBAO->id]);
+      $ufField[$ufFieldBAO->id]['visibility_display'] = $visibility[$ufFieldBAO->visibility];
 
       $ufField[$ufFieldBAO->id]['label'] = $ufFieldBAO->label;
 
index 1f3240c29ecc90a612db424e3af4291f412396a3..3d4d29e3dd5cc9981873e6eb8fdfff0d9cc1c37b 100644 (file)
@@ -357,24 +357,6 @@ class {$table.className} extends CRM_Core_DAO {ldelim}
           return self::$_export;
       {rdelim}
 
-{if $table.hasEnum}
-
-    /**
-     * adds $value['foo_display'] for each $value['foo'] enum from {$table.name}
-     *
-     * @param array $values (reference)  the array up for enhancing
-     * @return void
-     */
-    static function addDisplayEnums(&$values) {ldelim}
-        $enumFields =& {$table.className}::getEnums();
-        foreach ($enumFields as $enum) {ldelim}
-            if (isset($values[$enum])) {ldelim}
-                $values[$enum.'_display'] = {$table.className}::tsEnum($enum, $values[$enum]);
-            {rdelim}
-        {rdelim}
-    {rdelim}
-{/if}
-
 {rdelim}