3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
20 * This class contains the functions that are called using AJAX (jQuery)
22 class CRM_Group_Page_AJAX
{
27 public static function getGroupList() {
29 if (isset($params['parent_id'])) {
30 // requesting child groups for a given parent
33 $groups = CRM_Contact_BAO_Group
::getGroupListSelector($params);
39 'created_by' => 'String',
40 'group_type' => 'String',
41 'visibility' => 'String',
42 'component_mode' => 'String',
43 'status' => 'Integer',
44 'parentsOnly' => 'Integer',
45 'showOrgInfo' => 'Boolean',
46 // Ignore 'parent_id' as that case is handled above
48 $params = CRM_Core_Page_AJAX
::defaultSortAndPagerParams();
49 $params +
= CRM_Core_Page_AJAX
::validateParams($requiredParams, $optionalParams);
52 $groups = CRM_Contact_BAO_Group
::getGroupListSelector($params);
54 // if no groups found with parent-child hierarchy and logged in user say can view child groups only (an ACL case),
55 // go ahead with flat hierarchy, CRM-12225
57 $groupsAccessible = CRM_Core_PseudoConstant
::group();
58 $parentsOnly = $params['parentsOnly'] ??
NULL;
59 if (!empty($groupsAccessible) && $parentsOnly) {
60 // recompute group list with flat hierarchy
61 $params['parentsOnly'] = 0;
62 $groups = CRM_Contact_BAO_Group
::getGroupListSelector($params);
67 if (!empty($_GET['is_unit_test'])) {
71 CRM_Utils_JSON
::output($groups);