public function checkEntityRead(User $user, Entity $entity, $data) { if ($user->isAdmin()) { return true; } if ($entity->get('parentId') && $entity->get('parentType')) { $parent = $this->getEntityManager()->getEntity($entity->get('parentType'), $entity->get('parentId')); if ($parent) { if ($parent->getEntityType() === 'Note') { if ($parent->get('parentId') && $parent->get('parentType')) { $parentOfParent = $this->getEntityManager()->getEntity($parent->get('parentType'), $parent->get('parentId')); if ($this->getAclManager()->checkEntity($user, $parentOfParent)) { return true; } } else { return true; } } else { if ($this->getAclManager()->checkEntity($user, $parent)) { return true; } } } } else { return true; } if ($this->checkEntity($user, $entity, $data, 'read')) { return true; } return false; }
public function checkInAccount(User $user, Entity $entity) { $accountIdList = $user->getLinkMultipleIdList('accounts'); if (count($accountIdList)) { if (in_array($entity->id, $accountIdList)) { return true; } } return false; }
public function checkIsOwnContact(User $user, Entity $entity) { $contactId = $user->get('contactId'); if ($contactId) { if ($entity->id === $contactId) { return true; } } return false; }
public function checkReadOnlyContact(User $user, $scope) { if ($user->isAdmin()) { return false; } $data = $this->getTable($user)->getScopeData($scope); return $this->getImplementation($scope)->checkReadOnlyContact($user, $data); }
public function checkEntityDelete(User $user, Entity $entity, $data) { if ($user->isAdmin()) { return true; } if ($this->checkEntity($user, $entity, $data, 'delete')) { return true; } if (is_object($data)) { if ($data->edit !== 'no') { if ($entity->has('createdById') && $entity->get('createdById') == $user->id) { if (!$entity->has('assignedUserId')) { return true; } else { if (!$entity->get('assignedUserId')) { return true; } if ($entity->get('assignedUserId') == $entity->get('createdById')) { return true; } } } } } return false; }
public function getScopeForbiddenFieldList(User $user, $scope, $action = 'read', $thresholdLevel = 'no') { if ($user->isAdmin()) { return []; } return $this->getTable($user)->getScopeForbiddenFieldList($scope, $action, $thresholdLevel); }
public function checkScope(User $user, $scope, $action = null, $isOwner = null, $inTeam = null, $entity = null) { if ($user->isAdmin()) { return true; } $data = $this->getTable($user)->getScopeData($scope); return $this->getImplementation($scope)->checkScope($user, $data, $scope, $action, $isOwner, $inTeam, $entity); }
public function checkIsOwnContact(User $user, Entity $entity) { $contactId = $user->get('contactId'); if ($contactId) { if ($entity->hasAttribute('contactId')) { if ($entity->get('contactId') === $contactId) { return true; } } if ($entity->hasRelation('contacts')) { $repository = $this->getEntityManager()->getRepository($entity->getEntityType()); if ($repository->isRelated($entity, 'contacts', $contactId)) { return true; } } if ($entity->hasAttribute('parentId') && $entity->hasRelation('parent')) { if ($entity->get('parentType') === 'Contact') { if ($entity->get('parentId') === $contactId) { return true; } } } } return false; }
public function checkUser(User $user, $permission, User $entity) { if ($user->isAdmin()) { return true; } if ($this->get($user, $permission) === 'no') { if ($entity->id !== $user->id) { return false; } } else { if ($this->get($user, $permission) === 'team') { if ($entity->id != $user->id) { $teamIdList1 = $user->getTeamIdList(); $teamIdList2 = $entity->getTeamIdList(); $inTeam = false; foreach ($teamIdList1 as $id) { if (in_array($id, $teamIdList2)) { $inTeam = true; break; } } if (!$inTeam) { return false; } } } } return true; }
public function checkInTeam(User $user, Entity $entity) { $userTeamIds = $user->get('teamsIds'); if (!$entity->hasRelation('teams') || !$entity->hasField('teamsIds')) { return false; } if (!$entity->has('teamsIds')) { $entity->loadLinkMultipleField('teams'); } $teamIds = $entity->get('teamsIds'); if (empty($teamIds)) { return false; } foreach ($userTeamIds as $id) { if (in_array($id, $teamIds)) { return true; } } return false; }