- /**
- * Get all ACLs granted to a contact through all group memberships.
- *
- * @param int $contact_id
- * The contact's ID.
- * @param bool $aclRoles
- * Include ACL Roles?.
- *
- * @return array
- * Assoc array of ACL rules
- * @throws \CRM_Core_Exception
- */
- protected static function getGroupACLs($contact_id, $aclRoles = FALSE) {
- $contact_id = CRM_Utils_Type::escape($contact_id, 'Integer');
-
- $results = [];
-
- if ($contact_id) {
- $query = "
-SELECT acl.*
- FROM civicrm_acl acl
- INNER JOIN civicrm_group_contact group_contact
- ON acl.entity_id = group_contact.group_id
- WHERE acl.entity_table = 'civicrm_group'
- AND group_contact.contact_id = $contact_id
- AND group_contact.status = 'Added'";
-
- $rule = CRM_Core_DAO::executeQuery($query);
-
- while ($rule->fetch()) {
- $results[$rule->id] = $rule->toArray();
- }
- }
-
- if ($aclRoles) {
- $results += self::getGroupACLRoles($contact_id);
- }
-
- return $results;
- }
-