示例#1
1
 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;
 }
示例#2
0
 public function checkInAccount(User $user, Entity $entity)
 {
     $accountIdList = $user->getLinkMultipleIdList('accounts');
     if (count($accountIdList)) {
         if (in_array($entity->id, $accountIdList)) {
             return true;
         }
     }
     return false;
 }
示例#3
0
 public function checkIsOwnContact(User $user, Entity $entity)
 {
     $contactId = $user->get('contactId');
     if ($contactId) {
         if ($entity->id === $contactId) {
             return true;
         }
     }
     return false;
 }
示例#4
0
 public function checkReadOnlyContact(User $user, $scope)
 {
     if ($user->isAdmin()) {
         return false;
     }
     $data = $this->getTable($user)->getScopeData($scope);
     return $this->getImplementation($scope)->checkReadOnlyContact($user, $data);
 }
示例#5
0
 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;
 }
示例#6
0
 public function getScopeForbiddenFieldList(User $user, $scope, $action = 'read', $thresholdLevel = 'no')
 {
     if ($user->isAdmin()) {
         return [];
     }
     return $this->getTable($user)->getScopeForbiddenFieldList($scope, $action, $thresholdLevel);
 }
示例#7
0
 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);
 }
示例#8
0
 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;
 }
示例#9
0
 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;
 }
示例#10
0
 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;
 }