Merge branch 'kevin-prototype' into 'master'

Kevin prototype

See merge request !143
This commit was merged in pull request #147.
This commit is contained in:
Lars van Hijfte
2017-01-27 16:13:32 +01:00
5 changed files with 98 additions and 45 deletions

View File

@@ -1,5 +1,58 @@
<?php
require("connect.php");
function selectGroupByName($name) {
$stmt = $GLOBALS["db"]->prepare("
SELECT
`group_page`.`groupID`,
`name`,
`description`,
`picture`,
`status`,
COUNT(`group_member`.`groupID`) as `members`
FROM
`group_page`
LEFT JOIN
`group_member`
ON
`group_page`.`groupID` = `group_member`.`groupID`
WHERE
name LIKE :name
");
$stmt->bindParam(':name', $name);
if (!$stmt->execute()) {
return False;
}
return $stmt->fetch();
}
function selectGroupMembers(int $groupID) {
$stmt = $GLOBALS["db"]->prepare("
SELECT
`username`,
`fname`,
`lname`,
`profilepicture`
FROM
`group_member`
LEFT JOIN
`user`
ON
`group_member`.`userID` = `user`.`userID`
WHERE
`groupID` = :groupID
LIMIT 20
");
$stmt->bindParam(':groupID', $groupID);
if (!$stmt->execute()) {
return False;
}
return $stmt->fetchAll();
}
function selectGroupById($groupID) {
$q = $GLOBALS["db"]->prepare("
SELECT

View File

@@ -106,24 +106,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);