Skip to content

Commit

Permalink
RelationshipCache - Set 'get' permissions to be the same as for 'Rela…
Browse files Browse the repository at this point in the history
…tionship' entity

This gives lesser-permissioned users access to the RelationshipCache entity, for Search Kit.
  • Loading branch information
colemanw committed Jun 3, 2022
1 parent 24f0a1c commit 962e14b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
14 changes: 14 additions & 0 deletions CRM/Contact/BAO/RelationshipCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}
5 changes: 5 additions & 0 deletions CRM/Core/Permission.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] = [
Expand Down

0 comments on commit 962e14b

Please sign in to comment.