$current++; } } } //It might be that the project is in draft and is not returned by the browse and so it is not //present in the session lists if (!$project) { $project = Project::getProjectById($project_id, false, PDO::FETCH_ASSOC, true); } $my_id = Users::getMyId(); if ($project['state'] == 'draft' && !($project['mentor_id'] == $my_id || $project['owner_id'] == $my_id || Users::isAdmin() || Groups::isAssociate(_PROJECT_OBJ, $project_id))) { jsonBadResult(t('You cannot view this proposal. It is in draft state.')); return; } if (Users::isSuperVisor()) { $project['rate'] = Project::getRating($project_id, $my_id); } else { $project['rate'] = -2; if (Users::isStudent()) { $table = tableName('student_favourite'); $favourite = db_select($table)->fields($table)->condition('pid', $project_id)->condition('uid', $my_id)->execute()->rowCount(); $project['favourite'] = $favourite != 0; //Count the views of the students $result = db_update(tableName('project'))->condition('pid', $project_id)->fields(array('views' => $project['views'] + 1))->execute(); } } jsonGoodResult($project); } catch (Exception $e) { jsonBadResult(t('Could not get details of project') . (_DEBUG ? $e->getMessage() : "")); } } else {