-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.php
44 lines (35 loc) · 1.24 KB
/
api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
require ('DAO/ActivityDAO.php');
$method = $_SERVER['REQUEST_METHOD'];
$result = Array();
$status = "200";
if($method == 'GET'){
if(isset($_GET['id'])){
$a = ActivityDAO::get($_GET['id']);
if($a->getId() != null) {
$u = ActivityDAO::getUser($a->getSpeaker());
$speaker = ['id' => $u->getId(), 'name' => $u->getName(),'surname' => $u->getSurname(),'email' => $u->getEmail(), 'photo' => $u->getPhoto()];
$activity = ['id' => $a->getId(), 'speaker' => $speaker,'title' => $a->getTitle(), 'description' => $a->getDescription(), 'type' => $a->getType(), 'duration' =>$a->getDuration(), 'vacancies' => $a->getVacancies(), 'visible' => $a->isVisible()];
$result = ['activity' => $activity];
}else{
$result = ["ACTIVITY_NOT_FOUND"];
$status = "404";
}
}else{
$activities = ActivityDAO::getAll();
if($activities != null){
//$u = ActivityDAO::getUser($a->getSpeaker());
$result = $activities;
}else{
$result = ['NO_RESULTS_FOUND'];
}
}
}
else if($method == 'POST') {
//$u = UserDAO::save($_POST['user']);
//$result = ['users' => $_POST['name'] ];
}
else if($method == 'DELETE'){
}
$arr = ['result' => $result, 'method' => $method, 'status' => $status ];
die(json_encode($arr));