'String', 'created_by' => 'String', 'group_type' => 'String', 'visibility' => 'String', 'component_mode' => 'String', 'status' => 'Integer', 'parentsOnly' => 'Integer', 'showOrgInfo' => 'Boolean', // Ignore 'parent_id' as that case is handled above ]; $params = CRM_Core_Page_AJAX::defaultSortAndPagerParams(); $params += CRM_Core_Page_AJAX::validateParams($requiredParams, $optionalParams); // get group list $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); // if no groups found with parent-child hierarchy and logged in user say can view child groups only (an ACL case), // go ahead with flat hierarchy, CRM-12225 if (empty($groups)) { $groupsAccessible = CRM_Core_PseudoConstant::group(); $parentsOnly = $params['parentsOnly'] ?? NULL; if (!empty($groupsAccessible) && $parentsOnly) { // recompute group list with flat hierarchy $params['parentsOnly'] = 0; $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); } } } CRM_Utils_JSON::output($groups); } }