示例#1
0
 public function isPermittedTeams(Entity $entity)
 {
     $assignmentPermission = $this->getAcl()->get('assignmentPermission');
     if (empty($assignmentPermission) || $assignmentPermission === true || !in_array($assignmentPermission, ['team', 'no'])) {
         return true;
     }
     if (!$entity->hasAttribute('teamsIds')) {
         return true;
     }
     $teamIds = $entity->get('teamsIds');
     if (empty($teamIds)) {
         return true;
     }
     $newIds = [];
     if (!$entity->isNew()) {
         $existingIds = [];
         foreach ($entity->get('teams') as $team) {
             $existingIds[] = $team->id;
         }
         foreach ($teamIds as $id) {
             if (!in_array($id, $existingIds)) {
                 $newIds[] = $id;
             }
         }
     } else {
         $newIds = $teamIds;
     }
     if (empty($newIds)) {
         return true;
     }
     $userTeamIds = $this->getUser()->get('teamsIds');
     foreach ($newIds as $id) {
         if (!in_array($id, $userTeamIds)) {
             return false;
         }
     }
     return true;
 }
示例#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;
 }
示例#3
0
 public function checkInTeam(User $user, Entity $entity)
 {
     $userTeamIdList = $user->getLinkMultipleIdList('teams');
     if (!$entity->hasRelation('teams') || !$entity->hasAttribute('teamsIds')) {
         return false;
     }
     $entityTeamIdList = $entity->getLinkMultipleIdList('teams');
     if (empty($entityTeamIdList)) {
         return false;
     }
     foreach ($userTeamIdList as $id) {
         if (in_array($id, $entityTeamIdList)) {
             return true;
         }
     }
     return false;
 }
示例#4
0
文件: RDB.php 项目: disearth/espocrm
 protected function handlePhoneNumberSave(Entity $entity)
 {
     if ($entity->hasRelation('phoneNumbers') && $entity->hasAttribute('phoneNumber')) {
         $emailAddressRepository = $this->getEntityManager()->getRepository('PhoneNumber')->storeEntityPhoneNumber($entity);
     }
 }