-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_watchlist.php
73 lines (67 loc) · 2.37 KB
/
user_watchlist.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<html>
<head>
<title>My Watchlist</title>
<?php include_once 'header.php'; ?>
</head>
<body>
<section id="head-bar">
<?php include_once 'navbar.php'; ?>
</section>
<div class="container">
<h1>My Watchlist</h1>
<?php
if(isset($_SESSION['authenticated_user'])) {
require_once 'watchlist.php';
require_once 'mediapost.php';
$watchlist = new Watchlist();
$post = new MediaPost();
if($_SERVER['REQUEST_METHOD'] === 'POST'){
if(!empty($_POST['title'])){
$media_id = $post->getMediaIdByTitle($_POST['title']);
$watchlist->storeListMedia($_SESSION['authenticated_user'], $media_id);
}
}
else if($_SERVER['REQUEST_METHOD'] === 'GET') {
if (!empty($_GET['remove_media'])) {
$media_id = $_GET['remove_media'];
$watchlist->removeMediaFromWatchlist($_SESSION['authenticated_user'], $media_id);
}
}
$list_items = $watchlist->getWatchlistForUser($_SESSION['authenticated_user']);
if ($list_items) {
while ($list_item = $list_items->fetch_object()) {
echo '<div class="well"><div class="page-header"><h3>';
$media = $post->getMediaById($list_item->media);
echo $media->title;
echo "</h3>";
echo "<a class='btn btn-danger btn-sm' href='user_watchlist.php?remove_media=";
echo $media->id;
echo "'>Remove from Watchlist</a>";
echo "</div></div>";
}
}
if($list_items->num_rows === 0){
?>
<div class="well">
<div class="page-header">
<h3>No Items in Watchlist</h3>
</div>
</div>
<?php
}
?>
<a href="add_to_watchlist.php" class="btn btn-success">Add to Watchlist</a>
<?php
}
else{
?>
<div class="page-header">
<span><strong>You must <a href="signin.php">sign in </a>to view this content</strong></span>
</div>
<?php
}
?>
</div>
</body>
</html>