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
19 * This class contains the functions that are called using AJAX (jQuery)
21 class CRM_Group_Page_AJAX
{
26 public static function getGroupList() {
28 if (isset($params['parent_id'])) {
29 // requesting child groups for a given parent
32 $groups = CRM_Contact_BAO_Group
::getGroupListSelector($params);
38 'created_by' => 'String',
39 'group_type' => 'String',
40 'visibility' => 'String',
41 'component_mode' => 'String',
42 'status' => 'Integer',
43 'parentsOnly' => 'Integer',
44 'showOrgInfo' => 'Boolean',
45 // Ignore 'parent_id' as that case is handled above
47 $params = CRM_Core_Page_AJAX
::defaultSortAndPagerParams();
48 $params +
= CRM_Core_Page_AJAX
::validateParams($requiredParams, $optionalParams);
51 $groups = CRM_Contact_BAO_Group
::getGroupListSelector($params);
53 // if no groups found with parent-child hierarchy and logged in user say can view child groups only (an ACL case),
54 // go ahead with flat hierarchy, CRM-12225
56 $groupsAccessible = CRM_Core_PseudoConstant
::group();
57 $parentsOnly = $params['parentsOnly'] ??
NULL;
58 if (!empty($groupsAccessible) && $parentsOnly) {
59 // recompute group list with flat hierarchy
60 $params['parentsOnly'] = 0;
61 $groups = CRM_Contact_BAO_Group
::getGroupListSelector($params);
66 CRM_Utils_JSON
::output($groups);