GetProjectsAction.class.php 811 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. class GetProjectsAction implements IAction {
  3. public function execute() {
  4. if(!Authorize::isLoggedIn()) {
  5. return array("error" => "Access not authorized");
  6. }
  7. $database = SqliteDatabase::getSingleton();
  8. $clientId = $_SESSION['client_id'];
  9. $sql = "SELECT rowid AS project_id, * FROM projects WHERE project_id IN (SELECT project_id FROM account_projects WHERE account_id = ".$clientId.");";
  10. if(Authorize::hasPermission()) {
  11. //admin can see all projects
  12. $sql = "SELECT rowid AS project_id, * FROM projects;";
  13. }
  14. $projects = $database->queryArray($sql);
  15. foreach($projects as $index => $project) {
  16. if($project['bucket'] == "ccld-public-test") {
  17. $projects[$index]['cdn_url'] = "https://d39u220yzhs1cm.cloudfront.net";
  18. }
  19. }
  20. return array("projects" => $projects);
  21. }
  22. }