This repository was archived by the owner on Dec 7, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreat_multimedia.php
More file actions
222 lines (211 loc) · 7.71 KB
/
creat_multimedia.php
File metadata and controls
222 lines (211 loc) · 7.71 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<?php
require_once 'autoload.php';
// Check for accses
User::CheckLogin();
$Multimedia = new Youtube();
$access = User::getSessionAccses();
if (!$Multimedia->hasAccsesToModify($access)) {
header("Location: accses_denied.php");
}
// Update
if (isset($_GET["id"])) {
if ($Multimedia->read($_GET["id"])) {
$Data = array(
"Youtubelink" => $Multimedia->getyoutubeURLString(),
"title_en" => $Multimedia->getTitleEnglish(),
"description_en" => $Multimedia->getDescriptionEnglish(),
"title_ar" => $Multimedia->getTitleArabic(),
"description_ar" => $Multimedia->getDescriptionArabic()
);
} else {
header("Location: 404.php");
exit;
}
}
if (valAllNotnull()) {
// setting the data
$iscorrect = array(
"Youtubelink" => (bool) $Multimedia->setyoutubeID($_POST["Youtubelink"]),
"title_en" => (bool) $Multimedia->setTitleEnglish($_POST["title_en"]),
"description_en" => (bool) $Multimedia->setDescriptionEnglish($_POST["description_en"]),
"title_ar" => (bool) $Multimedia->setTitleArabic($_POST["title_ar"]),
"description_ar" => (bool) $Multimedia->setDescriptionEnglish($_POST["description_ar"]));
// set the publish or aprove or creat
$Multimedia->setDisplayFromSession($access);
$passed = FALSE;
// check if the imput is valid
if (Validation::valAll($iscorrect)) {
if (isset($_GET["id"])) {
$passed = (bool) $Multimedia->update();
if ($passed) {
$x = new Updates;
$x->setEditorID(User::getSessionUserID());
$x->setTargetType(Updates::TARGET_TYPE_YOUTUBE);
$x->setTargetID($Multimedia->getId());
$x->setMessageType(Updates::MESSAGE_TYPE_UPDATE);
$x->create();
$y = new Notification;
$y->setUserID($Multimedia->getWriterID());
$y->setSource(Notification::SOURCE_MULTIMEDIA);
$y->setsourceID($Multimedia->getId());
$y->setMessage("Multimedia was updated by ".User::getSessionUserFullName());
$y->create();
}
} else {
$Multimedia->setWriterID(User::getSessionUserID());
$passed = (bool) $Multimedia->create();
}
}
// check if every thing went right
if ($passed) {
header("Location: multimedia.php?id=" . $Multimedia->getId());
exit;
} else {
$Data = array(
"Youtubelink" => $_POST["Youtubelink"],
"title_en" => $_POST["title_en"],
"description_en" => $_POST["description_en"],
"title_ar" => $_POST["title_ar"],
"description_ar" => $_POST["description_ar"]
);
}
}
function valAllNotnull() {
return
isset($_POST["Youtubelink"]) &&
isset($_POST["title_en"]) &&
isset($_POST["description_en"]) &&
isset($_POST["title_ar"]) &&
isset($_POST["description_ar"]);
}
?><!DOCTYPE html>
<html lang="en">
<head>
<title>ACU Times | Creat Multimedia</title>
<?php require_once("header.php"); ?>
<script src="js/Validate.js"></script>
</head>
<body>
<?php include ("navbar.php"); ?>
<div class="container">
<h3>
<ul class="nav nav-pills">
<li role="presentation" ><a href="creat_article.php"> Article </a></li>
<li role="presentation"><a href="creat_poll.php"> Poll </a></li>
<li role="presentation" class="active"><a> Multimedia </a></li>
<li role="presentation"><a href="creat_gallery.php"> Gallery </a></li>
</ul>
</h3>
<br><br>
<form class="form-horizontal" role="form" method="post" action="creat_multimedia.php<?php if (isset($_GET["id"])) echo "?id=" . $_GET["id"] ?>">
<!-- #################################################################### YoutubeUrl #################################################################### -->
<div class="form-group">
<label class="control-label col-sm-2" for="Youtubelink">Youtube Url:</label>
<div class="controls col-sm-10">
<input type="text"
class="form-control"
placeholder="paste the youtube vedio link here "
name="Youtubelink"
id="Youtubelink"
maxlength="256"
required
onBlur="valYouTube(this)"
value="<?php echo @$Data["Youtubelink"] ?>">
<span class="help-block"><ul>
<?php PrintHTML::validation("Youtubelink", @$iscorrect["Youtubelink"], "Invalid Input") ?>
</ul></span> </div>
</div>
<div id="en">
<h3 class="text-center text-primary">English</h3>
<hr>
<!-- #################################################################### Title-EN #################################################################### -->
<div class="form-group">
<label class="control-label col-sm-2" for="title_en">Title :</label>
<div class="controls col-sm-10">
<input type="text"
name="title_en"
id="title_en"
value="<?php echo @$Data["title_en"]; ?>"
placeholder="Enter title in English"
class="form-control"
onBlur="valTitle(this)"
maxlength="128"
required
autocomplete="on">
<span class="help-block">
<ul>
<?php PrintHTML::validation("title_en", @$iscorrect["title_en"], "Invalid Input") ?>
</ul>
</span></div>
</div>
<!-- #################################################################### Breif-EN #################################################################### -->
<div class="form-group">
<label class="control-label col-sm-2" for="description_en">Description :</label>
<div class="controls col-sm-10">
<input type="text"
name="description_en"
id="description_en"
value="<?php echo @$Data["description_en"]; ?>"
placeholder="Enter 1 line description of the video in english"
class="form-control"
onBlur="valDescription(this)"
maxlength="256"
required
autocomplete="on">
<span class="help-block">
<ul>
<?php PrintHTML::validation("description_en", @$iscorrect["description_en"], "Invalid Input") ?>
</ul>
</span></div>
</div>
</div>
<div id="ar">
<h3 class="text-center text-primary">Arabic</h3>
<hr>
<!-- #################################################################### Title-AR #################################################################### -->
<div class="form-group">
<label class="control-label col-sm-2" for="title_ar">Title :</label>
<div class="controls col-sm-10">
<input type="text"
name="title_ar"
id="title_ar"
value="<?php echo @$Data["title_ar"]; ?>"
placeholder="Enter title in arabic"
class="form-control"
onBlur="valTitle(this)"
maxlength="128"
required
autocomplete="on">
<span class="help-block">
<ul>
<?php PrintHTML::validation("title_ar", @$iscorrect["title_ar"], "Invalid Input") ?>
</ul>
</span></div>
</div>
<!-- #################################################################### Breif-AR #################################################################### -->
<div class="form-group">
<label class="control-label col-sm-2" for="description_ar">Description :</label>
<div class="controls col-sm-10">
<input type="text"
name="description_ar"
id="description_ar"
value="<?php echo @$_POST["description_ar"]; ?>"
placeholder="Enter 1 line description of the video in arabic"
class="form-control"
onBlur="valDescription(this)"
maxlength="256"
required
autocomplete="on">
<span class="help-block">
<ul>
<?php PrintHTML::validation("description_ar", @$iscorrect["description_ar"], "Invalid Input") ?>
</ul>
</span></div>
</div>
</div>
<button type="submit" class="btn btn-primary pull-right">Submit</button>
</form>
</div>
<?php include ("footer.php"); ?>
</body>
</html>