Merge branch 'kevin-prototype' into 'master'
Kevin prototype See merge request !62
This commit was merged in pull request #66.
This commit is contained in:
@@ -1,26 +1,30 @@
|
||||
<?php
|
||||
require("connect.php");
|
||||
|
||||
function selectAllFriends($db, $userID) {
|
||||
return $db->query("
|
||||
SELECT
|
||||
`user`.`userID`,
|
||||
`user`.`username`,
|
||||
`user`.`profilepicture`,
|
||||
`user`.`onlinestatus`,
|
||||
`user`.`role`
|
||||
FROM
|
||||
`user`
|
||||
INNER JOIN
|
||||
`friendship`
|
||||
WHERE
|
||||
`friendship`.`user1ID` = $userID AND
|
||||
`friendship`.`user2ID` = `user`.`userID` OR
|
||||
`friendship`.`user2ID` = $userID AND
|
||||
`friendship`.`user1ID` = `user`.`userID` AND
|
||||
`user`.`role` != 3
|
||||
$stmt = $db->prepare("
|
||||
SELECT
|
||||
`username`,
|
||||
IFNULL(
|
||||
`profilepicture`,
|
||||
'img/notbad.png'
|
||||
) AS profilepicture,
|
||||
`onlinestatus`,
|
||||
`role`
|
||||
FROM
|
||||
`user`
|
||||
INNER JOIN
|
||||
`friendship`
|
||||
WHERE
|
||||
(`friendship`.`user1ID` = :userID AND
|
||||
`friendship`.`user2ID` = `user`.`userID` OR
|
||||
`friendship`.`user2ID` = :userID AND
|
||||
`friendship`.`user1ID` = `user`.`userID`) AND
|
||||
`role` != 5 AND
|
||||
`status` = 1
|
||||
");
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
return $stmt;
|
||||
}
|
||||
@@ -1,4 +1,90 @@
|
||||
<?php
|
||||
require("connect.php");
|
||||
|
||||
function getUserID($db, $username) {
|
||||
$stmt = $db->prepare("
|
||||
SELECT
|
||||
`userID`
|
||||
FROM
|
||||
`user`
|
||||
WHERE
|
||||
LOWER(`username`) = LOWER(:username)
|
||||
");
|
||||
|
||||
$stmt->bindParam(':username', $username, PDO::PARAM_STR);
|
||||
$stmt->execute();
|
||||
return $stmt->fetch()["userID"];
|
||||
}
|
||||
|
||||
function selectUser($db, $userID) {
|
||||
$stmt = $db->prepare("
|
||||
SELECT
|
||||
`username`,
|
||||
IFNULL(
|
||||
`profilepicture`,
|
||||
'img/notbad.png'
|
||||
) AS profilepicture,
|
||||
`bio`,
|
||||
`role`,
|
||||
`onlinestatus`,
|
||||
`loggedin`,
|
||||
`fname`,
|
||||
`lname`
|
||||
FROM
|
||||
`user`
|
||||
WHERE
|
||||
`userID` = :userID
|
||||
");
|
||||
|
||||
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
return $stmt->fetch();
|
||||
}
|
||||
|
||||
function selectAllUserGroups($db, $userID) {
|
||||
$stmt = $db->prepare("
|
||||
SELECT
|
||||
`group_page`.`groupID`,
|
||||
`name`,
|
||||
`picture`,
|
||||
`userID`
|
||||
FROM
|
||||
`group_page`
|
||||
INNER JOIN
|
||||
`group_member`
|
||||
ON
|
||||
`group_page`.`groupID` = `group_member`.`groupID`
|
||||
WHERE
|
||||
`userID` = :userID AND
|
||||
`role` = 1
|
||||
");
|
||||
|
||||
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
function selectAllUserPosts($db, $userID) {
|
||||
$stmt = $db->prepare("
|
||||
SELECT
|
||||
`postID`,
|
||||
`author`,
|
||||
`title`,
|
||||
`content`,
|
||||
`creationdate`
|
||||
FROM
|
||||
`post`
|
||||
WHERE
|
||||
`author` = :userID AND
|
||||
`groupID` IS NULL
|
||||
ORDER BY
|
||||
`creationdate` DESC
|
||||
");
|
||||
|
||||
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
function select20UsersFromN($db, $n) {
|
||||
return $db->query("
|
||||
|
||||
Reference in New Issue
Block a user