Merge branch 'kevin-prototype' into 'master'
Fixed posts on group pages. See merge request !156
This commit was merged in pull request #160.
This commit is contained in:
@@ -11,6 +11,12 @@ function selectGroupByName($name) {
|
||||
`description`,
|
||||
`picture`,
|
||||
`status`,
|
||||
(
|
||||
SELECT `role`
|
||||
FROM `group_member`
|
||||
WHERE `group_member`.`groupID` = `group_page`.`groupID` AND
|
||||
`userID` = :userID
|
||||
) AS `role`,
|
||||
COUNT(`group_member`.`groupID`) as `members`
|
||||
FROM
|
||||
`group_page`
|
||||
@@ -22,13 +28,36 @@ function selectGroupByName($name) {
|
||||
name LIKE :name
|
||||
");
|
||||
|
||||
$stmt->bindParam(':name', $name);
|
||||
$stmt->bindParam(':name', $name, PDO::PARAM_STR);
|
||||
$stmt->bindParam(':userID', $_SESSION["userID"], PDO::PARAM_INT);
|
||||
if (!$stmt->execute()) {
|
||||
return False;
|
||||
}
|
||||
return $stmt->fetch();
|
||||
}
|
||||
|
||||
function selectGroupRole(int $groupID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
`role`
|
||||
FROM
|
||||
`group_member`
|
||||
WHERE
|
||||
`groupID` = :groupID AND
|
||||
`userID` = :userID
|
||||
");
|
||||
|
||||
$stmt->bindParam(':groupID', $groupID, PDO::PARAM_INT);
|
||||
$stmt->bindParam(':userID', $_SESSION["userID"], PDO::PARAM_INT);
|
||||
if(!$stmt->execute()) {
|
||||
return False;
|
||||
}
|
||||
if($stmt->rowCount() == 0) {
|
||||
return "none";
|
||||
}
|
||||
return $stmt->fetch()["role"];
|
||||
}
|
||||
|
||||
function selectGroupMembers(int $groupID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
|
||||
@@ -107,48 +107,6 @@ 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 select20UsersFromN($n) {
|
||||
$q = prepareQuery("
|
||||
SELECT
|
||||
|
||||
Reference in New Issue
Block a user