added alert box when emptpy posting
This commit is contained in:
@@ -12,36 +12,39 @@ if (isset($_SESSION["userID"]) &&
|
|||||||
getRoleByID($_SESSION["userID"]) != 'frozen' &&
|
getRoleByID($_SESSION["userID"]) != 'frozen' &&
|
||||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||||
|
|
||||||
if (empty($_POST["title"]) or
|
if (empty($_SESSION["userID"])) {
|
||||||
empty($_POST["content"]) or
|
|
||||||
empty($_SESSION["userID"])
|
|
||||||
) {
|
|
||||||
header('HTTP/1.1 500 Non enough arguments');
|
header('HTTP/1.1 500 Non enough arguments');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($_POST["group"])) {
|
if (empty(test_input($_POST["title"])) or
|
||||||
// User Post
|
empty(test_input($_POST["content"]))
|
||||||
makePost(
|
) {
|
||||||
$_SESSION["userID"],
|
echo "empty";
|
||||||
null,
|
|
||||||
test_input($_POST["title"]),
|
|
||||||
test_input($_POST["content"])
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
// Group Post
|
if (empty($_POST["group"])) {
|
||||||
|
// User Post
|
||||||
|
makePost(
|
||||||
|
$_SESSION["userID"],
|
||||||
|
null,
|
||||||
|
test_input($_POST["title"]),
|
||||||
|
test_input($_POST["content"])
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// Group Post
|
||||||
|
|
||||||
// Check if the user is an admin or mod of the group.
|
// Check if the user is an admin or mod of the group.
|
||||||
if (!in_array(selectGroupRole($_POST["group"]), array('mod', 'admin'))) {
|
if (!in_array(selectGroupRole($_POST["group"]), array('mod', 'admin'))) {
|
||||||
header('HTTP/1.1 500 Non enough rights');
|
header('HTTP/1.1 500 Non enough rights');
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
makePost(
|
||||||
|
$_SESSION["userID"],
|
||||||
|
$_POST["group"],
|
||||||
|
test_input($_POST["title"]),
|
||||||
|
test_input($_POST["content"])
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
makePost(
|
|
||||||
$_SESSION["userID"],
|
|
||||||
$_POST["group"],
|
|
||||||
test_input($_POST["title"]),
|
|
||||||
test_input($_POST["content"])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
echo "frozen";
|
echo "frozen";
|
||||||
|
|||||||
@@ -31,14 +31,28 @@ function postPost() {
|
|||||||
$.post("API/postPost.php", { title: title,
|
$.post("API/postPost.php", { title: title,
|
||||||
content : content,
|
content : content,
|
||||||
group : groupID })
|
group : groupID })
|
||||||
.done(function() {
|
.done(function(data) {
|
||||||
masonry(masonryMode);
|
if (data == "empty") {
|
||||||
|
$('#alertbox').show();
|
||||||
|
$('#alerttext').html("Geen titel of inhoud; vul a.u.b. in.");
|
||||||
|
window.scrollTo(0,0);
|
||||||
|
} else {
|
||||||
|
$('#alertbox').hide();
|
||||||
|
masonry(masonryMode);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$.post("API/postPost.php", { title: title,
|
$.post("API/postPost.php", { title: title,
|
||||||
content : content })
|
content : content })
|
||||||
.done(function() {
|
.done(function(data) {
|
||||||
masonry(masonryMode);
|
if (data == "empty") {
|
||||||
|
$('#alertbox').show();
|
||||||
|
$('#alerttext').html("Geen titel of inhoud; vul a.u.b. in.");
|
||||||
|
window.scrollTo(0,0);
|
||||||
|
} else {
|
||||||
|
$('#alertbox').hide();
|
||||||
|
masonry(masonryMode);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,9 +167,6 @@ function loadMorePosts(uID, gID, offset, limit) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(uID, gID, offset, limit);
|
|
||||||
|
|
||||||
|
|
||||||
$.post("API/getPosts.php", { usr : uID,
|
$.post("API/getPosts.php", { usr : uID,
|
||||||
grp : gID,
|
grp : gID,
|
||||||
offset : offset,
|
offset : offset,
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ function deletePost(postID) {
|
|||||||
alert("Je account is bevroren, dus je kan geen posts verwijderen. Contacteer een admin als je denkt dat dit onjuist is.");
|
alert("Je account is bevroren, dus je kan geen posts verwijderen. Contacteer een admin als je denkt dat dit onjuist is.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
noposts = false;
|
||||||
|
postAmount = 0;
|
||||||
closeModal();
|
closeModal();
|
||||||
masonry(masonryMode);
|
masonry(masonryMode);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
/* New */
|
/* New */
|
||||||
|
|
||||||
|
.alertbox {
|
||||||
|
display: none;
|
||||||
|
background-color: firebrick;
|
||||||
|
}
|
||||||
|
|
||||||
.user-box {
|
.user-box {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
<div class="content">
|
<div class="content">
|
||||||
|
<div class='platform alertbox' id="alertbox">
|
||||||
|
<span id="alerttext"></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="user-box">
|
<div class="user-box">
|
||||||
<img class="profile-picture main-picture <?= $user["onlinestatus"] ?>" src="<?= $user["profilepicture"] ?>"><br />
|
<img class="profile-picture main-picture <?= $user["onlinestatus"] ?>" src="<?= $user["profilepicture"] ?>"><br />
|
||||||
<div class="platform">
|
<div class="platform">
|
||||||
|
|||||||
Reference in New Issue
Block a user