12345678910111213141516171819202122232425262728 |
- <?php
- class GetProjectsAction implements IAction {
- public function execute() {
- if(!Authorize::isLoggedIn()) {
- return array("error" => "Access not authorized");
- }
- $database = SqliteDatabase::getSingleton();
- $clientId = $_SESSION['client_id'];
- $sql = "SELECT rowid AS project_id, * FROM projects WHERE project_id IN (SELECT project_id FROM account_projects WHERE account_id = ".$clientId.");";
-
- if(Authorize::hasPermission()) {
- //admin can see all projects
- $sql = "SELECT rowid AS project_id, * FROM projects;";
- }
- $projects = $database->queryArray($sql);
- foreach($projects as $index => $project) {
- if($project['bucket'] == "ccld-public-test") {
- $projects[$index]['cdn_url'] = "https://d39u220yzhs1cm.cloudfront.net";
- }
- }
- return array("projects" => $projects);
- }
- }
|