-
Notifications
You must be signed in to change notification settings - Fork 0
/
review_process.php
59 lines (38 loc) · 1.44 KB
/
review_process.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
require_once("config/globals.php");
require_once("config/db.php");
require_once("models/Game.php");
require_once("models/Review.php");
require_once("models/Message.php");
require_once("dao/UserDAO.php");
require_once("dao/GameDAO.php");
require_once("dao/ReviewDAO.php");
$message = new Message($BASE_URL);
$userDao = new UserDAO($conn, $BASE_URL);
$gameDao = new GameDAO($conn, $BASE_URL);
$reviewDao = new ReviewDAO($conn, $BASE_URL);
$type = filter_input(INPUT_POST, "type");
$userData = $userDao->verifyToken();
if($type === "create") {
$rating = filter_input(INPUT_POST, "rating");
$review = filter_input(INPUT_POST, "review");
$games_id = filter_input(INPUT_POST, "games_id");
$users_id = $userData->id;
$reviewObject = new Review();
$gameData = $gameDao->findById($games_id);
if($gameData) {
if(!empty($rating) && !empty($review) && !empty($games_id)) {
$reviewObject->rating = $rating;
$reviewObject->review = $review;
$reviewObject->games_id = $games_id;
$reviewObject->users_id = $users_id;
$reviewDao->create($reviewObject);
} else {
$message->setMessage("Você precisa inserir a nota e o comentário!", "error", "back");
}
} else {
$message->setMessage("Informações inválidas!", "error", "index.php");
}
} else {
$message->setMessage("Informações inválidas!", "error", "index.php");
}