public function canSeeProject($project) { $ret = $this->isAdmin() || $project->visibility == 'public' ? true : false; if (!$ret && ($this->isEditor() || $this->isGuest())) { // check if the user has the right to see the project $queryBuilder = new Phalcon\Mvc\Model\Query\Builder(); $queryBuilder->from('UsersProjects'); $queryBuilder->columns('id'); $queryBuilder->where('user_id = :userId: AND project_id = :projectId:', array('userId' => $this->id, 'projectId' => $projectId)); if (count($queryBuilder->getQuery()->execute()) > 0) { $ret = true; } } return $ret; }