revert PR 13958
authordemeritcowboy <demeritcowboy@hotmail.com>
Sat, 18 Jul 2020 15:17:31 +0000 (11:17 -0400)
committerdemeritcowboy <demeritcowboy@hotmail.com>
Sat, 18 Jul 2020 15:17:31 +0000 (11:17 -0400)
CRM/Contact/BAO/Group.php
CRM/Contact/Form/Contact.php
CRM/Contact/Form/Edit/TagsAndGroups.php
CRM/Contact/Form/GroupContact.php
CRM/Contact/Form/Search/Basic.php
CRM/Contact/Form/Search/Criteria.php
ang/crmMailing/Recipients.js
tests/phpunit/CRM/Contact/Page/View/UserDashboard/GroupContactTest.php

index e232f46087a2f849423449ba57b7cf55ab69d346..aac84aa42428df1d79e3e88b9dc00ab1fdaa3733 100644 (file)
@@ -1055,7 +1055,7 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group {
     $groups = [];
     $args = [1 => [$groupIdString, 'String']];
     $query = "
-SELECT id, title, description, visibility, parents, saved_search_id
+SELECT id, title, description, visibility, parents
 FROM   civicrm_group
 WHERE  id IN $groupIdString
 ";
@@ -1081,7 +1081,7 @@ WHERE  id IN $groupIdString
         $parent = self::filterActiveGroups($parentArray);
         $tree[$parent][] = [
           'id' => $dao->id,
-          'title' => empty($dao->saved_search_id) ? $dao->title : '* ' . $dao->title,
+          'title' => $dao->title,
           'visibility' => $dao->visibility,
           'description' => $dao->description,
         ];
@@ -1089,7 +1089,7 @@ WHERE  id IN $groupIdString
       else {
         $roots[] = [
           'id' => $dao->id,
-          'title' => empty($dao->saved_search_id) ? $dao->title : '* ' . $dao->title,
+          'title' => $dao->title,
           'visibility' => $dao->visibility,
           'description' => $dao->description,
         ];
@@ -1123,12 +1123,11 @@ WHERE  id IN $groupIdString
       $hierarchy[$group['id']] = $spaces . $group['title'];
     }
     else {
-      $hierarchy[] = array(
-        'id' => $group['id'],
-        'text' => $spaces . $group['title'],
+      $hierarchy[$group['id']] = [
+        'title' => $spaces . $group['title'],
         'description' => $group['description'],
         'visibility' => $group['visibility'],
-      );
+      ];
     }
 
     // For performance reasons we use a for loop rather than a foreach.
index 229c3f3c84e9fcb100bb1074b6a475c9893a3f14..20d115f28dc13cf80f63db8ee3e9ad4cc337b40c 100644 (file)
@@ -869,9 +869,8 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form {
       $params['preferred_communication_method'] = 'null';
     }
 
-    $group = CRM_Utils_Array::value('group', $params);
-    if (!empty($group)) {
-      $group = is_array($group) ? $group : explode(',', $group);
+    $group = $params['group'] ?? NULL;
+    if (!empty($group) && is_array($group)) {
       unset($params['group']);
       foreach ($group as $key => $value) {
         $params['group'][$value] = 1;
index b4a82118df377e0e7ecb2f1db2c5d8ea22664754..c7d26927153d85cfc8fcd67ed6e781367edfe2a4 100644 (file)
@@ -102,7 +102,7 @@ class CRM_Contact_Form_Edit_TagsAndGroups {
           }
 
           if ($groupElementType == 'select') {
-            $groupsOptions[$id] = $group;
+            $groupsOptions[$id] = $group['title'];
           }
           else {
             $form->_tagGroup[$fName][$id]['description'] = $group['description'];
@@ -111,8 +111,8 @@ class CRM_Contact_Form_Edit_TagsAndGroups {
         }
 
         if ($groupElementType == 'select' && !empty($groupsOptions)) {
-          $form->add('select2', $fName, $groupName, $groupsOptions, FALSE,
-            ['placeholder' => '- select -', 'multiple' => TRUE, 'class' => 'twenty']
+          $form->add('select', $fName, $groupName, $groupsOptions, FALSE,
+            ['id' => $fName, 'multiple' => 'multiple', 'class' => 'crm-select2 twenty']
           );
           $form->assign('groupCount', count($groupsOptions));
         }
index 79d4c29c1d62152fe31b0f2528d47a1f0662253b..b2e326e960f7804911438c660f7011240a1378e1 100644 (file)
@@ -73,7 +73,7 @@ class CRM_Contact_Form_GroupContact extends CRM_Core_Form {
         if ($onlyPublicGroups && $group['visibility'] == 'User and User Admin Only') {
           continue;
         }
-        $allGroups[$group['id']] = $group;
+        $allGroups[$id] = $group;
       }
     }
     else {
index c1e84382319ffdfe400087c705c29717c939118d..1b6ae423fa4d2849eb439a8fc4690e12dd7a4172 100644 (file)
@@ -49,14 +49,13 @@ class CRM_Contact_Form_Search_Basic extends CRM_Contact_Form_Search {
 
     // add select for groups
     // Get hierarchical listing of groups, respecting ACLs for CRM-16836.
-    $groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($this->_group, NULL, '&nbsp;&nbsp;');
+    $groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($this->_group, NULL, '&nbsp;&nbsp;', TRUE);
     if (!empty($searchOptions['groups'])) {
       $this->addField('group', [
         'entity' => 'group_contact',
         'label' => ts('in'),
         'placeholder' => ts('- any group -'),
         'options' => $groupHierarchy,
-        'type' => 'Select2',
       ]);
     }
 
index c9a822e66f853de0cbef39c03726a9d696cc0b79..dbfb6ebe6a34b161d590b87de9a518cbb33d9223 100644 (file)
@@ -42,10 +42,10 @@ class CRM_Contact_Form_Search_Criteria {
       // multiselect for groups
       if ($form->_group) {
         // Arrange groups into hierarchical listing (child groups follow their parents and have indentation spacing in title)
-        $groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($form->_group, NULL, '&nbsp;&nbsp;');
+        $groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($form->_group, NULL, '&nbsp;&nbsp;', TRUE);
 
-        $form->add('select2', 'group', ts('Groups'), $groupHierarchy, FALSE,
-          ['placeholder' => ts('- select -'), 'multiple' => TRUE, 'class' => 'twenty']
+        $form->add('select', 'group', ts('Groups'), $groupHierarchy, FALSE,
+          ['id' => 'group', 'multiple' => 'multiple', 'class' => 'crm-select2']
         );
         $groupOptions = CRM_Core_BAO_OptionValue::getOptionValuesAssocArrayFromName('group_type');
         $form->add('select', 'group_type', ts('Group Types'), $groupOptions, FALSE,
index 1867e9582f70e061087b1cb2afc0c46f58c61554..55677813f7af1f6e4819d526d0258ae73f3b4ae9 100644 (file)
@@ -95,7 +95,6 @@
           }
           var option = convertValueToObj(item.id);
           var icon = (option.entity_type === 'civicrm_mailing') ? 'fa-envelope' : 'fa-users';
-          var smartGroupMarker = item.is_smart ? '* ' : '';
           var spanClass = (option.mode == 'exclude') ? 'crmMailing-exclude' : 'crmMailing-include';
           if (option.entity_type != 'civicrm_mailing' && isMandatory(option.entity_id)) {
             spanClass = 'crmMailing-mandatory';
               mids.push(0);
             }
 
-            CRM.api3('Group', 'getlist', { params: { id: { IN: gids }, options: { limit: 0 } }, extra: ["is_hidden"] }).then(
+            CRM.api3('Group', 'getlist', { params: { id: { IN: gids }, options: { limit: 0 } }, extra: ["is_hidden"] } ).then(
               function(glist) {
                 CRM.api3('Mailing', 'getlist', { params: { id: { IN: mids }, options: { limit: 0 } } }).then(
                   function(mlist) {
 
                     $(glist.values).each(function (idx, group) {
                       var key = group.id + ' civicrm_group include';
-
                       groupNames.push({id: parseInt(group.id), title: group.label, is_hidden: group.extra.is_hidden});
                       if (values.indexOf(key) >= 0) {
                         datamap.push({id: key, text: group.label});
               if('civicrm_mailing' === rcpAjaxState.entity) {
                 params["api.MailingRecipients.getcount"] = {};
               }
-              else if ('civicrm_group' === rcpAjaxState.entity) {
-                params.extra = ["saved_search_id"];
-              }
 
               return params;
             },
                                text: obj.label } : '';
                   }
                   else {
-                    return {   id: obj.id + ' ' + rcpAjaxState.entity + ' ' + rcpAjaxState.type, text: obj.label,
-                              is_smart: (!_.isEmpty(obj.extra.saved_search_id)) };
+                    return {   id: obj.id + ' ' + rcpAjaxState.entity + ' ' + rcpAjaxState.type,
+                               text: obj.label };
                   }
                 })
               };
index 8876fccf800cc00e550942eb949a4455c94b9398..a88e0774a6f63fd8c94e08a95b38dd80e4aaae80 100644 (file)
@@ -177,7 +177,7 @@ class CRM_Contact_Page_View_UserDashboard_GroupContactTest extends CiviUnitTestC
     $group_id_field_html = $form['group_id']['html'];
     $this->assertContains($publicSmartGroupTitle, $group_id_field_html, "Group '$publicSmartGroupTitle' should be in listed available groups, but is not.");
     $this->assertContains($publicStdGroupTitle, $group_id_field_html, "Group '$publicStdGroupTitle' should be in listed available groups, but is not.");
-    $this->assertNotContains('* ' . $adminSmartGroupTitle, $group_id_field_html, "Group '$adminSmartGroupTitle' should not be in listed available groups, but is.");
+    $this->assertNotContains($adminSmartGroupTitle, $group_id_field_html, "Group '$adminSmartGroupTitle' should not be in listed available groups, but is.");
     $this->assertNotContains($adminStdGroupTitle, $group_id_field_html, "Group '$adminStdGroupTitle' should not be in listed available groups, but is.");
 
     // Add current user to the test groups.
@@ -199,9 +199,9 @@ class CRM_Contact_Page_View_UserDashboard_GroupContactTest extends CiviUnitTestC
 
     $form = CRM_Core_Smarty::singleton()->get_template_vars('form');
     $group_id_field_html = $form['group_id']['html'];
-    $this->assertNotContains('* ' . $publicSmartGroupTitle, $group_id_field_html, "Group '$publicSmartGroupTitle' should not be in listed available groups, but is.");
+    $this->assertNotContains($publicSmartGroupTitle, $group_id_field_html, "Group '$publicSmartGroupTitle' should not be in listed available groups, but is.");
     $this->assertNotContains($publicStdGroupTitle, $group_id_field_html, "Group '$publicStdGroupTitle' should not be in listed available groups, but is.");
-    $this->assertNotContains('* ' . $adminSmartGroupTitle, $group_id_field_html, "Group '$adminSmartGroupTitle' should not be in listed available groups, but is.");
+    $this->assertNotContains($adminSmartGroupTitle, $group_id_field_html, "Group '$adminSmartGroupTitle' should not be in listed available groups, but is.");
     $this->assertNotContains($adminStdGroupTitle, $group_id_field_html, "Group '$adminStdGroupTitle' should not be in listed available groups, but is.");
   }