modified masonry and posts, masonry is now reusable on group pages.

This commit is contained in:
K. Nobel
2017-01-30 15:28:54 +01:00
parent f3df682af5
commit 1acad8e765
7 changed files with 101 additions and 50 deletions

View File

@@ -1,10 +1,11 @@
<?php
require("connect.php");
require_once("connect.php");
function selectGroupByName($name) {
$stmt = prepareQuery("
SELECT
`group_page`.`groupID`,
`group_page`.`groupID`,
`name`,
`description`,

View File

@@ -1,5 +1,51 @@
<?php
require_once("connect.php");
function selectAllPosts($userID, $groupID) {
$stmt = prepareQuery("
SELECT
`post`.`postID`,
`post`.`author`,
`title`,
CASE LENGTH(`post`.`content`) >= 150 AND `post`.`content` NOT LIKE '<img%'
WHEN TRUE THEN
CONCAT(LEFT(`post`.`content`, 150), '...')
WHEN FALSE THEN
`post`.`content`
END
AS `content`,
`post`.`creationdate`,
COUNT(DISTINCT `commentID`) AS `comments`,
COUNT(DISTINCT `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
`post`.`author` = :userID AND
`groupID` IS NULL OR
`groupID` = :groupID
GROUP BY
`post`.`postID`
ORDER BY
`post`.`creationdate` DESC
");
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
$stmt->bindParam(':groupID', $groupID , PDO::PARAM_INT);
if(!$stmt->execute()) {
return False;
}
return $stmt;
}
function selectPostById($postID) {
$stmt = prepareQuery("
SELECT

View File

@@ -103,47 +103,47 @@ function selectAllUserGroups($userID) {
return $stmt;
}
function selectAllUserPosts($userID) {
$stmt = prepareQuery("
SELECT
`post`.`postID`,
`post`.`author`,
`title`,
CASE LENGTH(`post`.`content`) >= 150 AND `post`.`content` NOT LIKE '<img%'
WHEN TRUE THEN
CONCAT(LEFT(`post`.`content`, 150), '...')
WHEN FALSE THEN
`post`.`content`
END
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
`post`.`author` = :userID AND
`groupID` IS NULL
GROUP BY
`post`.`postID`
ORDER BY
`post`.`creationdate` DESC
");
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
if(!$stmt->execute()) {
return False;
}
return $stmt;
}
//function selectAllUserPosts($userID) {
// $stmt = prepareQuery("
// SELECT
// `post`.`postID`,
// `post`.`author`,
// `title`,
// CASE LENGTH(`post`.`content`) >= 150 AND `post`.`content` NOT LIKE '<img%'
// WHEN TRUE THEN
// CONCAT(LEFT(`post`.`content`, 150), '...')
// WHEN FALSE THEN
// `post`.`content`
// END
// 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
// `post`.`author` = :userID AND
// `groupID` IS NULL
// GROUP BY
// `post`.`postID`
// ORDER BY
// `post`.`creationdate` DESC
// ");
//
// $stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
// if(!$stmt->execute()) {
// return False;
// }
// return $stmt;
//}
function select20UsersFromN($n) {
$q = prepareQuery("