Custom Team ACL - based off parent team

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kyle
    Senior Member
    • May 2020
    • 143

    Custom Team ACL - based off parent team

    I am having some trouble working out how to use the orm to generate the correct query for access control. Any help would be appreciated.


    I have a parent entity that has the team relationship on it.
    This entity is linked to a child using a 'hasChildren' link

    I want the child records to use the parent records team to determine team access.


    I have added a "onlyTeam" select def but cant work out how to build the query.

    What I have so far

    PHP Code:
        public function apply(QueryBuilder $queryBuilder): void
        {
            $queryBuilder->distinct();
            $queryBuilder->leftJoin('parent', 'parentRecord');
            $queryBuilder->leftJoin(
                'teams', 'teamsAccess',
                [
                    'parentRecord.id:'=> '???'
                ]
            );
    
            $orGroup = [
                'teamsAccess.id' => $this->user->getTeamIdList()
            ];
            $orGroup['parentRecord.assignedUserId'] = $this->user->id;
            $orGroup['createdById'] = $this->user->id;
            $orGroup['parentRecord.createdById'] = $this->user->id;
            $queryBuilder->where([
                'OR' => $orGroup,
            ]);
        } 
    
    Last edited by Kyle; 01-27-2022, 04:27 AM.
  • Kyle
    Senior Member
    • May 2020
    • 143

    #2
    This was not possible with a parent link.
    I had to change the link type and then could join through to the teams

    Comment

    Working...