Пример #1
0
 /**
  * Check if User have access to the given project
  *
  * @param User $user
  * @return bool
  */
 public function checkUserAccess(User $user)
 {
     $access = false;
     $projectCompanies = $this->getCompanies();
     foreach ($projectCompanies as $company) {
         foreach ($company->getUsers() as $companyUser) {
             if ($companyUser->getId() == $user->getId()) {
                 return true;
             }
         }
     }
     return $access;
 }
Пример #2
0
 /**
  * Check if given user have access to the company
  *
  * @param User $user
  * @return bool
  */
 public function checkUserAccess(User $user)
 {
     $access = false;
     foreach ($this->users as $companyUser) {
         if ($companyUser->getId() == $user->getId()) {
             return true;
         }
     }
     return $access;
 }
 /**
  * Get all companies attached to the given user
  *
  * @param User $user
  * @param null $limit
  * @return array
  */
 public function findUserCompanies(User $user, $limit = null)
 {
     $companies = $this->createQueryBuilder('c')->select('c')->join('c.users', 'u')->where('u = :user')->setParameter('user', $user->getId())->setMaxResults($limit)->getQuery()->getResult();
     return $companies;
 }
 public function findUserRoleInCompany(Company $company, User $user)
 {
     $result = $this->createQueryBuilder('ar')->where('ar.type = :company_type')->join('ar.company', 'c')->andWhere('c = :company')->join('ar.users', 'u')->andWhere('u = :users')->setParameter('company_type', AccessRole::TYPE_COMPANY)->setParameter('company', $company->getId())->setParameter('users', $user->getId())->getQuery()->getResult();
     return $result;
 }