dev/core/#152 - Remove AdvMulti-Select custom field type
authorColeman Watts <coleman@civicrm.org>
Wed, 30 May 2018 23:10:37 +0000 (19:10 -0400)
committerColeman Watts <coleman@civicrm.org>
Wed, 30 May 2018 23:10:37 +0000 (19:10 -0400)
19 files changed:
CRM/Contact/Import/Parser/Contact.php
CRM/Core/BAO/CustomField.php
CRM/Core/BAO/CustomGroup.php
CRM/Core/BAO/CustomOption.php
CRM/Core/BAO/UFGroup.php
CRM/Core/Page/AJAX/Location.php
CRM/Core/SelectValues.php
CRM/Custom/Form/ChangeFieldType.php
CRM/Custom/Form/Field.php
CRM/Custom/Form/Option.php
CRM/Dedupe/Merger.php
CRM/Member/Import/Parser/Membership.php
CRM/Upgrade/Incremental/sql/5.3.alpha1.mysql.tpl
CRM/Utils/DeprecatedUtils.php
api/v3/CustomField.php
templates/CRM/Custom/Form/ChangeFieldType.tpl
templates/CRM/Custom/Form/Field.tpl
tests/phpunit/WebTest/Import/AddressImportTest.php
tests/phpunit/api/v3/CustomValueTest.php

index a04f15928e0e7b258c88d254f97e77cfc491ccaa..420cb70de2397e9ae851a0e36b2e6f59b25baea7 100644 (file)
@@ -1246,7 +1246,6 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser {
           $htmlType = array(
             'CheckBox',
             'Multi-Select',
-            'AdvMulti-Select',
             'Select',
             'Radio',
             'Multi-Select State/Province',
@@ -1260,7 +1259,7 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser {
           }
 
           // check for values for custom fields for checkboxes and multiselect
-          if ($customFields[$customFieldID]['html_type'] == 'CheckBox' || $customFields[$customFieldID]['html_type'] == 'AdvMulti-Select' || $customFields[$customFieldID]['html_type'] == 'Multi-Select') {
+          if ($customFields[$customFieldID]['html_type'] == 'CheckBox' || $customFields[$customFieldID]['html_type'] == 'Multi-Select') {
             $value = trim($value);
             $value = str_replace('|', ',', $value);
             $mulValues = explode(',', $value);
index ce816c53d1e44db8e74e9fa851551850ecf25120..06e8bc0ae7df152626d5888673c5bfe655d95beb 100644 (file)
@@ -99,7 +99,6 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
           'Radio' => 'Radio',
           'CheckBox' => 'CheckBox',
           'Multi-Select' => 'Multi-Select',
-          'AdvMulti-Select' => 'AdvMulti-Select',
           'Autocomplete-Select' => 'Autocomplete-Select',
         ),
         array('Text' => 'Text', 'Select' => 'Select', 'Radio' => 'Radio'),
@@ -167,7 +166,6 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
         break;
 
       case 'CheckBox':
-      case 'AdvMulti-Select':
       case 'Multi-Select':
         if (isset($params['default_checkbox_option'])) {
           $tempArray = array_keys($params['default_checkbox_option']);
@@ -819,7 +817,6 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
       'Multi-Select State/Province',
       'Select Country',
       'Multi-Select Country',
-      'AdvMulti-Select',
       'CheckBox',
       'Radio',
     )));
@@ -828,7 +825,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
       $options = $field->getOptions($search ? 'search' : 'create');
 
       // Consolidate widget types to simplify the below switch statement
-      if ($search || ($widget !== 'AdvMulti-Select' && strpos($widget, 'Select') !== FALSE)) {
+      if ($search || (strpos($widget, 'Select') !== FALSE)) {
         $widget = 'Select';
       }
 
@@ -970,27 +967,6 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
         }
         break;
 
-      case 'AdvMulti-Select':
-        $element = $qf->addElement(
-          'advmultiselect',
-          $elementName,
-          $label, $options,
-          array(
-            'size' => 5,
-            'style' => '',
-            'class' => 'advmultiselect',
-            'data-crm-custom' => $dataCrmCustomVal,
-          )
-        );
-
-        $element->setButtonAttributes('add', array('value' => ts('Add >>')));
-        $element->setButtonAttributes('remove', array('value' => ts('<< Remove')));
-
-        if ($useRequired && !$search) {
-          $qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required');
-        }
-        break;
-
       case 'CheckBox':
         $check = array();
         foreach ($options as $v => $l) {
@@ -1204,7 +1180,6 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
       case 'Select Country':
       case 'Select State/Province':
       case 'CheckBox':
-      case 'AdvMulti-Select':
       case 'Multi-Select':
       case 'Multi-Select State/Province':
       case 'Multi-Select Country':
@@ -1373,7 +1348,6 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
     }
     switch ($customField->html_type) {
       case 'CheckBox':
-      case 'AdvMulti-Select':
       case 'Multi-Select':
         $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldId, FALSE);
         $defaults[$elementName] = array();
@@ -1385,9 +1359,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
             if ($customField->html_type == 'CheckBox') {
               $defaults[$elementName][$val['value']] = 1;
             }
-            elseif ($customField->html_type == 'Multi-Select' ||
-              $customField->html_type == 'AdvMulti-Select'
-            ) {
+            elseif ($customField->html_type == 'Multi-Select') {
               $defaults[$elementName][$val['value']] = $val['value'];
             }
           }
@@ -1597,9 +1569,7 @@ SELECT id
       }
     }
 
-    if ($customFields[$customFieldId]['html_type'] == 'Multi-Select' ||
-      $customFields[$customFieldId]['html_type'] == 'AdvMulti-Select'
-    ) {
+    if ($customFields[$customFieldId]['html_type'] == 'Multi-Select') {
       if ($value) {
         $value = CRM_Utils_Array::implodePadded($value);
       }
@@ -1609,7 +1579,6 @@ SELECT id
     }
 
     if (($customFields[$customFieldId]['html_type'] == 'Multi-Select' ||
-        $customFields[$customFieldId]['html_type'] == 'AdvMulti-Select' ||
         $customFields[$customFieldId]['html_type'] == 'CheckBox'
       ) &&
       $customFields[$customFieldId]['data_type'] == 'String' &&
index 282bc2e7db7f9088e20b01987a0f840984f637f8..a60def47e9e1a51808a2374640f8b74dea7347bd 100644 (file)
@@ -1386,7 +1386,6 @@ ORDER BY civicrm_custom_group.weight,
 
         switch ($field['html_type']) {
           case 'Multi-Select':
-          case 'AdvMulti-Select':
           case 'CheckBox':
             $defaults[$elementName] = array();
             $customOption = CRM_Core_BAO_CustomOption::getCustomOption($field['id'], $inactiveNeeded);
@@ -1506,7 +1505,6 @@ ORDER BY civicrm_custom_group.weight,
         //added Multi-Select option in the below if-statement
         if ($field['html_type'] == 'CheckBox' ||
           $field['html_type'] == 'Radio' ||
-          $field['html_type'] == 'AdvMulti-Select' ||
           $field['html_type'] == 'Multi-Select'
         ) {
           $groupTree[$groupID]['fields'][$fieldId]['customValue']['data'] = 'NULL';
@@ -1542,10 +1540,6 @@ ORDER BY civicrm_custom_group.weight,
             }
             break;
 
-          //added for Advanced Multi-Select
-
-          case 'AdvMulti-Select':
-            //added for Multi-Select
           case 'Multi-Select':
             if (!empty($v)) {
               $groupTree[$groupID]['fields'][$fieldId]['customValue']['data'] = CRM_Core_DAO::VALUE_SEPARATOR
@@ -1663,7 +1657,6 @@ ORDER BY civicrm_custom_group.weight,
     $htmlType = array(
       'CheckBox',
       'Multi-Select',
-      'AdvMulti-Select',
       'Select',
       'Radio',
     );
@@ -1684,7 +1677,6 @@ ORDER BY civicrm_custom_group.weight,
             $valid = CRM_Core_BAO_CustomValue::typecheck($field['data_type'], $value);
           }
           if ($field['html_type'] == 'CheckBox' ||
-            $field['html_type'] == 'AdvMulti-Select' ||
             $field['html_type'] == 'Multi-Select'
           ) {
             $value = str_replace("|", ",", $value);
index 6f52aa034b8558add55c828f5654085f883d383c..3fc2bf6942c8a05c2657854e2215209baa41d0da 100644 (file)
@@ -155,7 +155,7 @@ class CRM_Core_BAO_CustomOption {
         $action -= CRM_Core_Action::DELETE;
       }
 
-      if (in_array($field->html_type, array('CheckBox', 'AdvMulti-Select', 'Multi-Select'))) {
+      if (in_array($field->html_type, ['CheckBox', 'Multi-Select'])) {
         if (isset($defVal) && in_array($dao->value, $defVal)) {
           $options[$dao->id]['is_default'] = '<img src="' . $config->resourceBase . 'i/check.gif" />';
         }
@@ -291,7 +291,6 @@ WHERE  id = %2";
           );
           break;
 
-        case 'AdvMulti-Select':
         case 'Multi-Select':
         case 'CheckBox':
           $oldString = CRM_Core_DAO::VALUE_SEPARATOR . $oldValue . CRM_Core_DAO::VALUE_SEPARATOR;
index 02055aa760955eb70ea5aa6210cb3d042a524763..722fc4b9dfc6d05a8d8fce2ccc4c5902d788a8f1 100644 (file)
@@ -1321,7 +1321,6 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
           elseif (in_array($htmlType, array(
             'CheckBox',
             'Multi-Select',
-            'AdvMulti-Select',
             'Multi-Select State/Province',
             'Multi-Select Country',
           ))) {
@@ -2388,7 +2387,6 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
             switch ($customFields[$customFieldId]['html_type']) {
               case 'Multi-Select State/Province':
               case 'Multi-Select Country':
-              case 'AdvMulti-Select':
               case 'Multi-Select':
                 $v = explode(CRM_Core_DAO::VALUE_SEPARATOR, $details[$name]);
                 foreach ($v as $item) {
index 96b5df2d1ac5d9f2b8e9038f7b67e098424fd09f..5749c923e62c14dc3f53471dd528f78523a60cdf 100644 (file)
@@ -171,7 +171,7 @@ class CRM_Core_Page_AJAX_Location {
               $elements["onbehalf_{$key}"]['value'][$k] = $v;
             }
           }
-          elseif (strstr($htmlType, 'Multi-Select') && $htmlType != 'AdvMulti-Select') {
+          elseif (strstr($htmlType, 'Multi-Select')) {
             $elements["onbehalf_{$key}"]['type'] = 'Multi-Select';
             $elements["onbehalf_{$key}"]['value'] = array_values($defaults[$key]);
           }
index 73d92562d0f61cdaae7eb8265944c21316c1a47b..6f4ed3c8b41a7fa85f5fd79128d9a0ad6d09dbfd 100644 (file)
@@ -203,7 +203,6 @@ class CRM_Core_SelectValues {
       'RichTextEditor' => ts('Rich Text Editor'),
       'Autocomplete-Select' => ts('Autocomplete-Select'),
       'Multi-Select' => ts('Multi-Select'),
-      'AdvMulti-Select' => ts('AdvMulti-Select'),
       'Link' => ts('Link'),
       'ContactReference' => ts('Autocomplete-Select'),
     );
index 9fbc7bc571d665bef79b2e9c9671047fcd640f7b..1b05717e2f180a00d42e6603c632773b6ddbad26 100644 (file)
@@ -155,7 +155,6 @@ class CRM_Custom_Form_ChangeFieldType extends CRM_Core_Form {
     $mutliValueOps = array(
       'CheckBox',
       'Multi-Select',
-      'AdvMulti-Select',
     );
 
     $srcHtmlType = $this->_values['html_type'];
@@ -220,7 +219,6 @@ class CRM_Custom_Form_ChangeFieldType extends CRM_Core_Form {
     $mutliValueOps = array(
       'CheckBox' => 'CheckBox',
       'Multi-Select' => 'Multi-Select',
-      'AdvMulti-Select' => 'AdvMulti-Select',
     );
 
     switch ($dataType) {
index ab82214a85fc21d8aa12ea50712e5a32f4bcc18e..5326a2ff108e7a8a207d8a47f4a220652d00e7ae 100644 (file)
@@ -135,7 +135,6 @@ class CRM_Custom_Form_Field extends CRM_Core_Form {
           'Radio' => ts('Radio'),
           'CheckBox' => ts('CheckBox'),
           'Multi-Select' => ts('Multi-Select'),
-          'AdvMulti-Select' => ts('Adv Multi-Select (obsolete)'),
           'Autocomplete-Select' => ts('Autocomplete-Select'),
         ),
         array(
@@ -708,7 +707,7 @@ SELECT count(*)
     if (isset($fields['data_type'][1])) {
       $dataField = $fields['data_type'][1];
     }
-    $optionFields = array('Select', 'Multi-Select', 'CheckBox', 'Radio', 'AdvMulti-Select');
+    $optionFields = array('Select', 'Multi-Select', 'CheckBox', 'Radio');
 
     if (isset($fields['option_type']) && $fields['option_type'] == 1) {
       //capture duplicate Custom option values
index b861c7f3447202c8b959ae206ad90f4076258d30..96a45c00891f62ab0635590bbe484ae63519fee2 100644 (file)
@@ -115,7 +115,6 @@ class CRM_Custom_Form_Option extends CRM_Core_Form {
 
       if ($fieldDefaults['html_type'] == 'CheckBox'
         || $fieldDefaults['html_type'] == 'Multi-Select'
-        || $fieldDefaults['html_type'] == 'AdvMulti-Select'
       ) {
         if (!empty($fieldDefaults['default_value'])) {
           $defaultCheckValues = explode(CRM_Core_DAO::VALUE_SEPARATOR,
@@ -434,7 +433,6 @@ SELECT count(*)
       $customField->find(TRUE) &&
       (
         $customField->html_type == 'CheckBox' ||
-        $customField->html_type == 'AdvMulti-Select' ||
         $customField->html_type == 'Multi-Select'
       )
     ) {
index e5229c7d3e652772b4e1ec2475255c2b7362bb72..86b3ff03120dd0122c12b9548a029cecdb924213 100644 (file)
@@ -1633,7 +1633,6 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
             break;
 
           case 'CheckBox':
-          case 'AdvMulti-Select':
           case 'Multi-Select':
           case 'Multi-Select Country':
           case 'Multi-Select State/Province':
@@ -1667,7 +1666,6 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
                   if (in_array($htmlType, array(
                     'CheckBox',
                     'Multi-Select',
-                    'AdvMulti-Select',
                   ))) {
                     $submitted[$key] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR,
                         $mergeValue
index 0e03811cb26a6439b141183190d5e2b08358dfd7..195d14b802d3b804e9f2cbfcd71f249a39dc91c9 100644 (file)
@@ -658,7 +658,7 @@ class CRM_Member_Import_Parser_Membership extends CRM_Member_Import_Parser {
       if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
         $values[$key] = $value;
         $type = $customFields[$customFieldID]['html_type'];
-        if ($type == 'CheckBox' || $type == 'Multi-Select' || $type == 'AdvMulti-Select') {
+        if ($type == 'CheckBox' || $type == 'Multi-Select') {
           $mulValues = explode(',', $value);
           $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE);
           $values[$key] = array();
index 520a37a29c1a8f9ab73eef088719b2cbf9fa3915..cb1a7511c19e4bc99b830234a59fb01c2576da11 100644 (file)
@@ -13,3 +13,6 @@ ALTER TABLE civicrm_custom_field ALTER column is_active SET DEFAULT 1;
 SET @UKCountryId = (SELECT id FROM civicrm_country cc WHERE cc.name = 'United Kingdom');
 INSERT INTO civicrm_state_province (country_id, abbreviation, name)
 VALUES (@UKCountryId, 'MON', 'Monmouthshire');
+
+{* dev/core/#152 *}
+UPDATE `civicrm_custom_field` set `html_type` = "Multi-Select" WHERE `html_type` = "AdvMulti-Select";
index 81b4924978db7fed72e1f5d97bca862a160ad86e..00afe4332eb26b1734ec8ab6ba27b2f9ba78b884 100644 (file)
@@ -863,7 +863,6 @@ function _civicrm_api3_deprecated_add_formatted_param(&$values, &$params) {
           $htmlType = CRM_Utils_Array::value('html_type', $customFields[$customFieldID]);
           switch ($htmlType) {
             case 'CheckBox':
-            case 'AdvMulti-Select':
             case 'Multi-Select':
               if ($val) {
                 $mulValues = explode(',', $val);
index 43f2ce2afd40a1744903892749535629e150a6f4..32ef50f8c0b733c9aeb29018688d4c7917d2ed52 100644 (file)
@@ -243,7 +243,7 @@ SELECT count(*)
   }
 
   if (in_array($htmlType, array(
-    'Select', 'Multi-Select', 'CheckBox', 'Radio', 'AdvMulti-Select')) &&
+    'Select', 'Multi-Select', 'CheckBox', 'Radio')) &&
     !isset($errors[$fieldName])
   ) {
     $options = CRM_Core_OptionGroup::valuesByID($fieldDetails['option_group_id']);
index a2a90253cd595722380f50e3f6d4407445857976..3977814ef20b41c3b0c7edb8685757baf75dad31 100644 (file)
@@ -45,7 +45,7 @@
   function checkCustomDataField( ) {
     var srcHtmlType = '{/literal}{$srcHtmlType}{literal}';
     var singleValOps = ['Text', 'Select', 'Radio', 'Autocomplete-Select'];
-    var multiValOps  = ['CheckBox', 'Multi-Select', 'AdvMulti-Select'];
+    var multiValOps  = ['CheckBox', 'Multi-Select'];
     var dstHtmlType = cj('#dst_html_type').val( );
     if ( !dstHtmlType ) {
       return true;
index 8517a9236d7a45037f228240bbfb69c9e5cdbaf4..32723fd6b3692d612baa92c5503d687cf3658d4a 100644 (file)
 <script type="text/javascript">
   CRM.$(function($) {
     var $form = $('form.{/literal}{$form.formClass}{literal}'),
-      deprecatedNotice,
       dataTypes = {/literal}{$dataTypeKeys|@json_encode}{literal};
 
-    function deprecatedWidgets() {
-      deprecatedNotice && deprecatedNotice.close && deprecatedNotice.close();
-      switch ($('#data_type_1', $form).val()) {
-        case 'AdvMulti-Select':
-          deprecatedNotice = CRM.alert({/literal}'{ts escape="js"}The old "Advance Multi-Select" widget is being phased out and will be removed in a future version of CiviCRM. "Multi-Select" is the recommended substitute.{/ts}', '{ts escape="js"}Obsolete widget{/ts}'{literal}, 'alert', {expires: 0});
-          break;
-      }
-    }
-    $('#data_type_1', $form).each(deprecatedWidgets).change(deprecatedWidgets);
-
     function showSearchRange() {
       var htmlType = $("[name='data_type[1]']", $form).val(),
        dataType = dataTypes[$("[name='data_type[0]']", $form).val()];
index 9c271f16fe5acdd1959ebcea23a09ef2d3b780c2..8137c19b0be74742ec4424551e03c3f8e802eaa5 100644 (file)
@@ -201,12 +201,6 @@ class WebTest_Import_AddressImportTest extends ImportCiviSeleniumTestCase {
     $customField6 = 'Customfield_alp_multiselect' . substr(sha1(rand()), 0, 4);
     $customFieldId6 = $this->_createMultipleValueCustomField($customField6, 'Multi-Select');
 
-    // create custom field - "alphanumeric advmultiselect"
-    $this->click("newCustomField");
-    $this->waitForElementPresent('_qf_Field_done-bottom');
-    $customField7 = 'Customfield_alp_advmultiselect' . substr(sha1(rand()), 0, 4);
-    $customFieldId7 = $this->_createMultipleValueCustomField($customField7, 'AdvMulti-Select');
-
     // create custom field - "alphanumeric autocompleteselect"
     $this->click("newCustomField");
     $this->waitForElementPresent('_qf_Field_done-bottom');
@@ -253,7 +247,6 @@ class WebTest_Import_AddressImportTest extends ImportCiviSeleniumTestCase {
         "custom_{$customFieldId4}" => "$customField4 :: $customGroupTitle",
         "custom_{$customFieldId5}" => "$customField5 :: $customGroupTitle",
         "custom_{$customFieldId6}" => "$customField6 :: $customGroupTitle",
-        "custom_{$customFieldId7}" => "$customField7 :: $customGroupTitle",
         "custom_{$customFieldId8}" => "$customField8 :: $customGroupTitle",
         "custom_{$customFieldId1}" => "$customField1 :: $customGroupTitle",
         "custom_{$customFieldId2}" => "$customField2 :: $customGroupTitle",
@@ -267,7 +260,6 @@ class WebTest_Import_AddressImportTest extends ImportCiviSeleniumTestCase {
           "custom_{$customFieldId4}" => "label1",
           "custom_{$customFieldId5}" => "label1",
           "custom_{$customFieldId6}" => "label1",
-          "custom_{$customFieldId7}" => "label1",
           "custom_{$customFieldId8}" => "label1",
           "custom_{$customFieldId1}" => 1,
           "custom_{$customFieldId2}" => 12345,
@@ -281,7 +273,6 @@ class WebTest_Import_AddressImportTest extends ImportCiviSeleniumTestCase {
         $customField4 => 'label1',
         $customField5 => 'label1',
         $customField6 => 'label1',
-        $customField7 => 'label1',
         $customField8 => 'label1',
         $customField1 => '1',
         $customField2 => '12345',
index 791eea0344ce105e80b9c8380bc3252d70b8d11e..58e90c48423a5b468bc4d24b7812bb683f531d28 100644 (file)
@@ -109,7 +109,7 @@ class api_v3_CustomValueTest extends CiviUnitTestCase {
     $customFieldDataType = CRM_Core_BAO_CustomField::dataType();
     $dataToHtmlTypes = CRM_Core_BAO_CustomField::dataToHtml();
     $count = 0;
-    $optionSupportingHTMLTypes = array('Select', 'Radio', 'CheckBox', 'AdvMulti-Select', 'Autocomplete-Select', 'Multi-Select');
+    $optionSupportingHTMLTypes = array('Select', 'Radio', 'CheckBox', 'Autocomplete-Select', 'Multi-Select');
 
     foreach ($customFieldDataType as $dataType => $label) {
       switch ($dataType) {