-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateMedia.php
114 lines (98 loc) · 3.82 KB
/
updateMedia.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
session_start();
include "navbar.php"; ?>
<?php
require_once 'Buisness/dbConfig.php';
require_once 'Buisness/Quiz.cls.php';
require_once 'Buisness/Subject.cls.php';
require_once 'Buisness/Course.cls.php';
require_once 'Buisness/Content.cls.php';
require_once 'Buisness/Media.cls.php';
$media = new Media();
$media->setId($_GET["id"]);
$media = $media->findById($connectionId);
?>
<script>
function displayValue(obj){
document.getElementById("path").innerHTML = obj.value;
$("#browse").removeClass("required");
}
function validateCreation(){
if (document.getElementById("path").innerHTML == "" ){
$("#browse").addClass("required");
$("#browse").focus();
return false;
}
}
$( document ).ready(function() {
document.getElementById("path").innerHTML = "<?php echo trim($media->getName() ." - " . $media->getPath());?>";
document.getElementById("mediaName").value = "<?php echo trim($media->getName());?>";
var flag = "<?php if(isset($_GET['flag'])){echo trim($_GET['flag']);}else{echo 'true';}?>";
if (flag == "false"){
alert("Invalid Media Type");
}
});
</script>
<form method = 'post' action = 'updatingMedia.php' enctype = 'multipart/form-data'>
<div class="container-fluid">
<div class="row">
<div class="col-sm-12 text-center">
<div>
<h2>Add Media</h2>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-4">
</div>
<div class="col-sm-4">
<div>
<div style="word-wrap: break-word;">
<span id="path"></span>
</div>
<label id="browse" class="btn btn-basic form-control" style="background-color: grey; color: white;">
Browse Media <input type="file" style="display: none;" name="media" onchange="displayValue(this)" accept=".mp4,.webm,.ogg,.mp3,.wav,.ogg,.gif,.jpg,.png,.svg">
</label>
</div>
<div class="form-group">
<label>Name:</label>
<input type="text" class="form-control" id="mediaName" placeholder="Enter media name" name="mediaName" required="required"/>
</div>
<div class="form-group">
<label>Content:</label>
<select name="content" required="required" class="form-control">
<?php
$content = new Content();
$course = new Course();
$courses = $course->findAll($connectionId);
$subject = new Subject();
$subjects = $subject->findAll($connectionId);
$contents = $content->findAll($connectionId);
foreach ($courses as $courseElement){
if($courseElement->getMemberId() == $_SESSION["id"]){
foreach ($subjects as $subjectElement){
if ($subjectElement->getCourseId() == $courseElement->getId()){
foreach ($contents as $contentElement){
if($contentElement->getSubjectId() == $subjectElement->getId()){
echo "<option value='".$contentElement->getId()." ".(($contentElement->getId() == $media->getContentId())?'selected="selected"':'')."'>".$contentElement->getName()."</option>";
}
}
}
}
}
}
?>
</select>
</div>
<div class="text-center">
<button type="submit" class="btn btn-primary" id="submit" name="id" value="<?php echo $_GET["id"];?>" onclick="return validateCreation()">Update</button>
</div>
<div class="text-center">
<p style="color: red;">* Note: Uploaded files will not be deleted from your computer.</p>
</div>
</div>
<div class="col-sm-4">
</div>
</div>
</div>
</form>