public function canEditProject($projectId, $project = null) { $ret = $this->isAdmin() ? true : false; if (!$ret && $this->isEditor()) { // check if the user has the right to edit 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)); $queryBuilder->inWhere('privilege', ['admin', 'editor']); if (count($queryBuilder->getQuery()->execute()) > 0) { $ret = true; } } return $ret; }