CRM-21660 Remove use of deprecated function on mapping_type
authoreileen <emcnaughton@wikimedia.org>
Mon, 15 Jan 2018 23:22:41 +0000 (12:22 +1300)
committereileen <emcnaughton@wikimedia.org>
Mon, 15 Jan 2018 23:23:09 +0000 (12:23 +1300)
CRM/Activity/Import/Form/MapField.php
CRM/Contact/BAO/Group.php
CRM/Contact/Form/Task/SaveSearch.php
CRM/Contribute/Import/Form/MapField.php
CRM/Custom/Import/Form/MapField.php
CRM/Event/Import/Form/MapField.php
CRM/Export/Form/Select.php
CRM/Member/Import/Form/MapField.php

index 752e4a96078e2a56ead38787793e9115d0161286..488970061ad8963e6c4ce8b90e1e73fa6dde2891 100644 (file)
@@ -339,8 +339,7 @@ class CRM_Activity_Import_Form_MapField extends CRM_Import_Form_MapField {
         $errors['saveMappingName'] = ts('Name is required to save Import Mapping');
       }
       else {
-        $mappingTypeId = CRM_Core_OptionGroup::getValue('mapping_type', 'Import Activity', 'name');
-        if (CRM_Core_BAO_Mapping::checkMapping($nameField, $mappingTypeId)) {
+        if (CRM_Core_BAO_Mapping::checkMapping($nameField, CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Mapping', 'mapping_type_id', 'Import Activity'))) {
           $errors['saveMappingName'] = ts('Duplicate Import Mapping Name');
         }
       }
@@ -441,10 +440,7 @@ class CRM_Activity_Import_Form_MapField extends CRM_Import_Form_MapField {
       $mappingParams = array(
         'name' => $params['saveMappingName'],
         'description' => $params['saveMappingDesc'],
-        'mapping_type_id' => CRM_Core_OptionGroup::getValue('mapping_type',
-          'Import Activity',
-          'name'
-        ),
+        'mapping_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Mapping', 'mapping_type_id', 'Import Activity'),
       );
       $saveMapping = CRM_Core_BAO_Mapping::add($mappingParams);
 
index d513ba2605317ace6aca4809a62cffef82253526..9aa7704fb6f60ac09ef36e07925b13c74dfbd4d1 100644 (file)
@@ -673,10 +673,7 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group {
       if (!$ssId) {
         //save record in mapping table
         $mappingParams = array(
-          'mapping_type_id' => CRM_Core_OptionGroup::getValue('mapping_type',
-            'Search Builder',
-            'name'
-          ),
+          'mapping_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Mapping', 'mapping_type_id', 'Search Builder'),
         );
         $mapping = CRM_Core_BAO_Mapping::add($mappingParams);
         $mappingId = $mapping->id;
@@ -731,10 +728,7 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group {
         'id' => $mappingId,
         'name' => CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $smartGroupId, 'name', 'id'),
         'description' => CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $smartGroupId, 'description', 'id'),
-        'mapping_type_id' => CRM_Core_OptionGroup::getValue('mapping_type',
-          'Search Builder',
-          'name'
-        ),
+        'mapping_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Mapping', 'mapping_type_id', 'Search Builder'),
       );
       CRM_Core_BAO_Mapping::add($mappingParams);
     }
index bff3f0d1291db27d8e81bd1acc4cec3cfc52aeba..54be7e0d025fe4ec1a906ea8e4289ada33ee7bf8 100644 (file)
@@ -158,10 +158,7 @@ class CRM_Contact_Form_Task_SaveSearch extends CRM_Contact_Form_Task {
       if (!$this->_id) {
         //save record in mapping table
         $mappingParams = array(
-          'mapping_type_id' => CRM_Core_OptionGroup::getValue('mapping_type',
-            'Search Builder',
-            'name'
-          ),
+          'mapping_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Mapping', 'mapping_type_id', 'Search Builder'),
         );
         $mapping = CRM_Core_BAO_Mapping::add($mappingParams);
         $mappingId = $mapping->id;
@@ -240,10 +237,7 @@ class CRM_Contact_Form_Task_SaveSearch extends CRM_Contact_Form_Task {
         'id' => $mappingId,
         'name' => CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $group->id, 'name', 'id'),
         'description' => CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $group->id, 'description', 'id'),
-        'mapping_type_id' => CRM_Core_OptionGroup::getValue('mapping_type',
-          'Search Builder',
-          'name'
-        ),
+        'mapping_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Mapping', 'mapping_type_id', 'Search Builder'),
       );
       CRM_Core_BAO_Mapping::add($mappingParams);
     }
index 8421712d4d211ba6f336164433134470c53fce22..d9c6de574d9f878eb33b1f89ed2c7edd84af1423 100644 (file)
@@ -421,8 +421,7 @@ class CRM_Contribute_Import_Form_MapField extends CRM_Import_Form_MapField {
         $errors['saveMappingName'] = ts('Name is required to save Import Mapping');
       }
       else {
-        $mappingTypeId = CRM_Core_OptionGroup::getValue('mapping_type', 'Import Contribution', 'name');
-        if (CRM_Core_BAO_Mapping::checkMapping($nameField, $mappingTypeId)) {
+        if (CRM_Core_BAO_Mapping::checkMapping($nameField, CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Mapping', 'mapping_type_id', 'Import Contribution'))) {
           $errors['saveMappingName'] = ts('Duplicate Import Contribution Mapping Name');
         }
       }
@@ -526,10 +525,7 @@ class CRM_Contribute_Import_Form_MapField extends CRM_Import_Form_MapField {
       $mappingParams = array(
         'name' => $params['saveMappingName'],
         'description' => $params['saveMappingDesc'],
-        'mapping_type_id' => CRM_Core_OptionGroup::getValue('mapping_type',
-          'Import Contribution',
-          'name'
-        ),
+        'mapping_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Mapping', 'mapping_type_id', 'Import Contribution'),
       );
       $saveMapping = CRM_Core_BAO_Mapping::add($mappingParams);
 
index d68aa95a367baed8c427ac1771894a263b642709..abc0138c04e8bb10bed411764c3a53abfa8b4745 100644 (file)
@@ -88,8 +88,7 @@ class CRM_Custom_Import_Form_MapField extends CRM_Contact_Import_Form_MapField {
         $errors['saveMappingName'] = ts('Name is required to save Import Mapping');
       }
       else {
-        $mappingTypeId = CRM_Core_OptionGroup::getValue('mapping_type', 'Import Multi value custom data', 'name');
-        if (CRM_Core_BAO_Mapping::checkMapping($nameField, $mappingTypeId)) {
+        if (CRM_Core_BAO_Mapping::checkMapping($nameField, CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Mapping', 'mapping_type_id', 'Import Multi value custom data'))) {
           $errors['saveMappingName'] = ts('Duplicate ' . $self->_mappingType . 'Mapping Name');
         }
       }
@@ -187,10 +186,7 @@ class CRM_Custom_Import_Form_MapField extends CRM_Contact_Import_Form_MapField {
       $mappingParams = array(
         'name' => $params['saveMappingName'],
         'description' => $params['saveMappingDesc'],
-        'mapping_type_id' => CRM_Core_OptionGroup::getValue('mapping_type',
-          $this->_mappingType,
-          'name'
-        ),
+        'mapping_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Mapping', 'mapping_type_id', $this->_mappingType),
       );
       $saveMapping = CRM_Core_BAO_Mapping::add($mappingParams);
 
index 2f634202706316f2b1caffa90490037c78c23936..0751cbe0a60dc30a3e8be6eee9b87e8fb56f70cd 100644 (file)
@@ -362,8 +362,7 @@ class CRM_Event_Import_Form_MapField extends CRM_Import_Form_MapField {
         $errors['saveMappingName'] = ts('Name is required to save Import Mapping');
       }
       else {
-        $mappingTypeId = CRM_Core_OptionGroup::getValue('mapping_type', 'Import Participant', 'name');
-        if (CRM_Core_BAO_Mapping::checkMapping($nameField, $mappingTypeId)) {
+        if (CRM_Core_BAO_Mapping::checkMapping($nameField, CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Mapping', 'mapping_type_id', 'Import Participant'))) {
           $errors['saveMappingName'] = ts('Duplicate Import Participant Mapping Name');
         }
       }
@@ -461,10 +460,7 @@ class CRM_Event_Import_Form_MapField extends CRM_Import_Form_MapField {
       $mappingParams = array(
         'name' => $params['saveMappingName'],
         'description' => $params['saveMappingDesc'],
-        'mapping_type_id' => CRM_Core_OptionGroup::getValue('mapping_type',
-          'Import Participant',
-          'name'
-        ),
+        'mapping_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Mapping', 'mapping_type_id', 'Import Participant'),
       );
       $saveMapping = CRM_Core_BAO_Mapping::add($mappingParams);
 
index fdf563e372f82863aa833f0d6ce4c45109665aa6..e5ee25856fc602f3327d9c300acb8a5f6975a31a 100644 (file)
@@ -471,8 +471,7 @@ FROM   {$this->_componentTable}
         break;
     }
 
-    $mappingTypeId = CRM_Core_OptionGroup::getValue('mapping_type', $exportType, 'name');
-    $this->set('mappingTypeId', $mappingTypeId);
+    $this->set('mappingTypeId', CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Mapping', 'mapping_type_id', $exportType));
 
     $mappings = CRM_Core_BAO_Mapping::getMappings($exportType);
     if (!empty($mappings)) {
index bfab1fdddeca6ec20bd85a2e7c01fdf84456cc58..a48eb207002979b196d36ae2de61786cec939370 100644 (file)
@@ -383,9 +383,7 @@ class CRM_Member_Import_Form_MapField extends CRM_Import_Form_MapField {
         $errors['saveMappingName'] = ts('Name is required to save Import Mapping');
       }
       else {
-        $mappingTypeId = CRM_Core_OptionGroup::getValue('mapping_type', 'Import Membership', 'name');
-
-        if (CRM_Core_BAO_Mapping::checkMapping($nameField, $mappingTypeId)) {
+        if (CRM_Core_BAO_Mapping::checkMapping($nameField, CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Mapping', 'mapping_type_id', 'Import Membership'))) {
           $errors['saveMappingName'] = ts('Duplicate Import Membership Mapping Name');
         }
       }
@@ -487,10 +485,7 @@ class CRM_Member_Import_Form_MapField extends CRM_Import_Form_MapField {
       $mappingParams = array(
         'name' => $params['saveMappingName'],
         'description' => $params['saveMappingDesc'],
-        'mapping_type_id' => CRM_Core_OptionGroup::getValue('mapping_type',
-          'Import Membership',
-          'name'
-        ),
+        'mapping_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Mapping', 'mapping_type_id', 'Import Membership'),
       );
       $saveMapping = CRM_Core_BAO_Mapping::add($mappingParams);