Beispiel #1
0
 public function checkIsOwnContact(User $user, Entity $entity)
 {
     $contactId = $user->get('contactId');
     if ($contactId) {
         if ($entity->id === $contactId) {
             return true;
         }
     }
     return false;
 }
Beispiel #2
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;
 }
Beispiel #3
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;
 }