diff --git a/CRM/Contact/BAO/RelationshipCache.php b/CRM/Contact/BAO/RelationshipCache.php index f771072f09c6..54906ee2e917 100644 --- a/CRM/Contact/BAO/RelationshipCache.php +++ b/CRM/Contact/BAO/RelationshipCache.php @@ -155,4 +155,18 @@ public static function createInsertUpdateQueries() { return $queries; } + /** + * @return array + */ + public function addSelectWhereClause() { + // Permission for this entity depends on access to the two related contacts. + $contactClause = CRM_Utils_SQL::mergeSubquery('Contact'); + $clauses = [ + 'near_contact_id' => $contactClause, + 'far_contact_id' => $contactClause, + ]; + CRM_Utils_Hook::selectWhereClause($this, $clauses); + return $clauses; + } + } diff --git a/CRM/Core/Permission.php b/CRM/Core/Permission.php index 921e59549fd7..0ae7e331637d 100644 --- a/CRM/Core/Permission.php +++ b/CRM/Core/Permission.php @@ -1052,6 +1052,11 @@ public static function getEntityActionPermissions() { 'edit all contacts', ], ]; + // Readonly relationship_cache table + $permissions['relationship_cache'] = [ + // get is managed by BAO::addSelectWhereClause + 'get' => [], + ]; // CRM-17741 - Permissions for RelationshipType. $permissions['relationship_type'] = [