diff --git a/website/public/API/postPost.php b/website/public/API/postPost.php index b1c6649..241bda6 100644 --- a/website/public/API/postPost.php +++ b/website/public/API/postPost.php @@ -12,36 +12,39 @@ if (isset($_SESSION["userID"]) && getRoleByID($_SESSION["userID"]) != 'frozen' && getRoleByID($_SESSION["userID"]) != 'banned') { - if (empty($_POST["title"]) or - empty($_POST["content"]) or - empty($_SESSION["userID"]) - ) { + if (empty($_SESSION["userID"])) { header('HTTP/1.1 500 Non enough arguments'); } - if (empty($_POST["group"])) { - // User Post - makePost( - $_SESSION["userID"], - null, - test_input($_POST["title"]), - test_input($_POST["content"]) - ); + if (empty(test_input($_POST["title"])) or + empty(test_input($_POST["content"])) + ) { + echo "empty"; } 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. - if (!in_array(selectGroupRole($_POST["group"]), array('mod', 'admin'))) { - header('HTTP/1.1 500 Non enough rights'); - return; + // Check if the user is an admin or mod of the group. + if (!in_array(selectGroupRole($_POST["group"]), array('mod', 'admin'))) { + header('HTTP/1.1 500 Non enough rights'); + 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 { echo "frozen"; diff --git a/website/public/js/masonry.js b/website/public/js/masonry.js index 4f638c2..d0d2074 100644 --- a/website/public/js/masonry.js +++ b/website/public/js/masonry.js @@ -31,14 +31,28 @@ function postPost() { $.post("API/postPost.php", { title: title, content : content, group : groupID }) - .done(function() { - masonry(masonryMode); + .done(function(data) { + 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 { $.post("API/postPost.php", { title: title, content : content }) - .done(function() { - masonry(masonryMode); + .done(function(data) { + 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; } - console.log(uID, gID, offset, limit); - - $.post("API/getPosts.php", { usr : uID, grp : gID, offset : offset, diff --git a/website/public/js/post.js b/website/public/js/post.js index f176950..7c73793 100644 --- a/website/public/js/post.js +++ b/website/public/js/post.js @@ -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."); } }); + noposts = false; + postAmount = 0; closeModal(); masonry(masonryMode); diff --git a/website/public/styles/profile.css b/website/public/styles/profile.css index 1bacafa..27d2bdd 100644 --- a/website/public/styles/profile.css +++ b/website/public/styles/profile.css @@ -1,5 +1,10 @@ /* New */ +.alertbox { + display: none; + background-color: firebrick; +} + .user-box { text-align: center; } diff --git a/website/views/profile.php b/website/views/profile.php index 2bb117f..120dae4 100644 --- a/website/views/profile.php +++ b/website/views/profile.php @@ -1,4 +1,8 @@
+
+ +
+
" src="">