Merge branch 'master' into lars

This commit is contained in:
Lars van Hijfte
2017-01-31 14:27:50 +01:00
9 changed files with 297 additions and 170 deletions

View File

@@ -3,15 +3,52 @@
session_start();
require_once("../../queries/post.php");
require_once("../../queries/group_page.php");
require_once("../../queries/connect.php");
require_once("../../queries/checkInput.php");
if (empty($_POST['newpost-title'])) {
} else {
makePost($_SESSION['userID'],
null,
test_input($_POST['newpost-title']),
test_input($_POST['newpost-content']));
if (empty($_POST["title"]) or
empty($_POST["content"]) or
empty($_SESSION["userID"])) {
header('HTTP/1.1 500 Non enough arguments');
}
header("Location: ../profile.php");
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;
}
makePost(
$_SESSION["userID"],
$_POST["group"],
test_input($_POST["title"]),
test_input($_POST["content"])
);
}
//if (empty($_POST['newpost-title'])) {
//} else {
// makePost($_SESSION['userID'],
// null,
// test_input($_POST['newpost-title']),
// test_input($_POST['newpost-content']));
//}
//
//header("Location: ../profile.php");

View File

@@ -34,6 +34,9 @@ include("../views/group.php");
include("../views/footer.php");
$masonry_mode = 0;
if ($group["role"] == "mod" OR $group["role"] == "admin") {
$masonry_mode = 2;
}
?>
<script src="js/masonry.js"></script>

View File

@@ -23,6 +23,28 @@ function requestPost(postID) {
});
}
function postPost() {
title = $("input.newpost[name='title']").val();
content = $("textarea.newpost[name='content']").val();
if (masonryMode == 2) {
$.post("API/postPost.php", { title: title,
content : content,
group : groupID })
.done(function() {
masonry(masonryMode);
});
} else {
$.post("API/postPost.php", { title: title,
content : content })
.done(function() {
masonry(masonryMode);
});
}
}
$(window).on("load", function() {
$(".modal-close").click(function () {
$(".modal").hide();
@@ -33,11 +55,15 @@ $(window).on("load", function() {
});
var masonryMode = 0;
var windowWidth = $(window).width();
$(window).resize(function() {
clearTimeout(window.resizedFinished);
window.resizeFinished = setTimeout(function() {
masonry(masonryMode);
if ($(window).width() != windowWidth) {
windowWidth = $(window).width();
masonry(masonryMode);
}
}, 250);
});
@@ -60,13 +86,17 @@ function masonry(mode) {
columns[i] = [0, $column];
}
if(mode == 1) {
if(mode > 0) {
$postInput = $("<div class=\"post platform\">");
$form = $("<form action=\"API/postPost.php\" method=\"post\">");
$form = $("<form class=\"newpost\" action=\"API/postPost.php\" method=\"post\" onsubmit=\"postPost(); return false;\">");
$postInput.append($form);
$form.append($("<input class=\"newpost\" name=\"newpost-title\" placeholder=\"Titel\" type=\"text\">"));
$form.append($("<textarea class=\"newpost\" name=\"newpost-content\" placeholder=\"Schrijf een berichtje...\">"));
if(mode == 2) {
$form.append($("<input class=\"newpost\" type=\"hidden\" name=\"group\" value=\"" + groupID + "\">"));
}
$form.append($("<input class=\"newpost\" name=\"title\" placeholder=\"Titel\" type=\"text\">"));
$form.append($("<textarea class=\"newpost\" name=\"content\" placeholder=\"Schrijf een berichtje...\">"));
$form.append($("<input value=\"Plaats!\" type=\"submit\">"));
columns[0][1].append($postInput);