Made small changes to posts, added amount of comments and niet slechts

This commit is contained in:
K. Nobel
2017-01-26 16:09:18 +01:00
parent e75df42bd8
commit 59fc65e27a
2 changed files with 24 additions and 13 deletions

View File

@@ -70,9 +70,7 @@ function masonry(mode) {
$form.append($("<input value=\"Plaats!\" type=\"submit\">"));
columns[0][1].append($postInput);
$postInput.on("load", function() {
columns[0][0] = $postInput.height() + margin;
});
columns[0][0] = $postInput.height() + margin;
}
/*
@@ -99,11 +97,12 @@ function masonry(mode) {
/*
* Rearange the objects.
*/
jQuery.each(posts, function() {
$.each(posts, function() {
$post = $("<div class=\"post platform\" onclick=\"requestPost(\'"+this['postID']+"\')\">");
$post.append($("<h2>").html(this["title"]));
$post.append($("<p>").html(this["content"]));
$post.append($("<p class=\"subscript\">").text(this["nicetime"]));
$post.append($("<p class=\"subscript\">").text("comments: " + this["comments"] + ", niet slechts: " + this["niet_slechts"]));
shortestColumn = getShortestColumn(columns);
shortestColumn[1].append($post);

View File

@@ -105,24 +105,36 @@ function selectAllUserGroups($userID) {
function selectAllUserPosts($userID) {
$stmt = $GLOBALS["db"]->prepare("
SELECT
`postID`,
`author`,
`post`.`postID`,
`post`.`author`,
`title`,
CASE LENGTH(`content`) >= 150 AND `content` NOT LIKE '<img%'
CASE LENGTH(`post`.`content`) >= 150 AND `post`.`content` NOT LIKE '<img%'
WHEN TRUE THEN
CONCAT(LEFT(`content`, 150), '...')
CONCAT(LEFT(`post`.`content`, 150), '...')
WHEN FALSE THEN
`content`
`post`.`content`
END
AS `content`,
`creationdate`
AS `content`,
`post`.`creationdate`,
COUNT(`commentID`) AS `comments`,
COUNT(`niet_slecht`.`postID`) AS `niet_slechts`
FROM
`post`
LEFT JOIN
`niet_slecht`
ON
`post`.`postID` = `niet_slecht`.`postID`
LEFT JOIN
`comment`
ON
`post`.`postID` = `comment`.`postID`
WHERE
`author` = :userID AND
`post`.`author` = :userID AND
`groupID` IS NULL
GROUP BY
`post`.`postID`
ORDER BY
`creationdate` DESC
`post`.`creationdate` DESC
");
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);