Merge branch 'master' into hendrik-testing

This commit is contained in:
Hendrik
2017-01-26 15:33:08 +01:00
32 changed files with 472 additions and 391 deletions

View File

@@ -94,7 +94,7 @@ function selectAllFriendRequests() {
`friendship`.`user2ID` = `user`.`userID` OR
`friendship`.`user2ID` = :userID AND
`friendship`.`user1ID` = `user`.`userID`) AND
`user`.`role` != 5 AND
`user`.`role` != 'banned' AND
`friendship`.`status` = 'requested'
");
@@ -217,4 +217,47 @@ function setLastVisited($friend) {
$stmt->execute();
return $stmt;
}
function searchSomeFriends($n, $m, $search) {
$stmt = $GLOBALS["db"]->prepare("
SELECT
`userID`,
`username`,
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `fullname`,
IFNULL(
`profilepicture`,
'../img/avatar-standard.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
`user`.`role` != 'banned' AND
`friendship`.`status` = 'confirmed') AND
(`username` LIKE :keyword OR
`fname` LIKE :keyword OR
`lname` LIKE :keyword)
ORDER BY
`fname`,
`lname`,
`username`
LIMIT
:n, :m
");
$search = "%$search%";
$stmt->bindParam(':keyword', $search);
$stmt->bindParam(':userID', $_SESSION["userID"], PDO::PARAM_INT);
$stmt->bindParam(':n', $n, PDO::PARAM_INT);
$stmt->bindParam(':m', $m, PDO::PARAM_INT);
$stmt->execute();
return json_encode($stmt->fetchAll());
}

View File

@@ -27,3 +27,30 @@ function selectLimitedGroupsFromUser($userID, $limit) {
return json_encode($stmt->fetchAll());
}
function searchSomeOwnGroups($n, $m, $search) {
$stmt = $GLOBALS["db"]->prepare("
SELECT
`group_page`.`name`,
`group_page`.`picture`
FROM
`group_page`
INNER JOIN
`group_member`
WHERE
`group_member`.`userID` = :userID AND
`group_member`.`groupID` = `group_page`.`groupID` AND
`group_page`.`status` != 'hidden' AND
`name` LIKE :keyword
LIMIT
:n, :m
");
$search = "%$search%";
$stmt->bindParam(':keyword', $search);
$stmt->bindParam(':userID', $_SESSION["userID"], PDO::PARAM_INT);
$stmt->bindParam(':n', $n, PDO::PARAM_INT);
$stmt->bindParam(':m', $m, PDO::PARAM_INT);
$stmt->execute();
return json_encode($stmt->fetchAll());
}

View File

@@ -192,7 +192,7 @@ function searchSomeGroups($n, $m, $search) {
$stmt->bindParam(':n', $n, PDO::PARAM_INT);
$stmt->bindParam(':m', $m, PDO::PARAM_INT);
$stmt->execute();
return $stmt;
return json_encode($stmt->fetchAll());
}
function countSomeGroups($search) {

View File

@@ -76,7 +76,7 @@ function makePost($userID, $groupID, $title, $content) {
}
function makeComment($postID, $userID, $content) {
$stmt = $_GLOBAL["db"]->prepare("
$stmt = $GLOBALS["db"]->prepare("
INSERT INTO
`comment` (
`postID`,

View File

@@ -83,7 +83,7 @@ function selectAllUnreadChat() {
`user`.`userID`,
IFNULL(
`profilepicture`,
'../img/notbad.jpg'
'../img/avatar-standard.png'
) AS profilepicture,
LEFT(`private_message`.`content`, 15) as `content`
FROM

View File

@@ -126,7 +126,9 @@ function selectAllUserPosts($userID) {
");
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
$stmt->execute();
if(!$stmt->execute()) {
return False;
}
return $stmt;
}
@@ -316,17 +318,16 @@ function selectRandomNotFriendUser($userID) {
return $stmt->fetch();
}
function searchSomeUsers($n, $m, $search)
{
function searchSomeUsers($n, $m, $search) {
$stmt = $GLOBALS["db"]->prepare("
SELECT
`userID`,
`username`,
IFNULL(
`profilepicture`,
'../img/notbad.jpg'
'../img/avatar-standard.png'
) AS profilepicture,
`fname`,
`lname`
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `fullname`
FROM
`user`
WHERE
@@ -345,8 +346,10 @@ function searchSomeUsers($n, $m, $search)
$stmt->bindParam(':keyword', $search);
$stmt->bindParam(':n', $n, PDO::PARAM_INT);
$stmt->bindParam(':m', $m, PDO::PARAM_INT);
$stmt->execute();
return $stmt;
return json_encode($stmt->fetchAll());
}
function countSomeUsers($search) {