Merge branch 'master' into 'marijn-settings'

# Conflicts:
#   website/views/menu.php
This commit is contained in:
Marijn Jansen
2017-01-24 14:02:19 +01:00
21 changed files with 345 additions and 291 deletions

View File

@@ -21,8 +21,8 @@ function selectAllFriends($userID) {
`friendship`.`user2ID` = `user`.`userID` OR
`friendship`.`user2ID` = :userID AND
`friendship`.`user1ID` = `user`.`userID`) AND
`role` != 5 AND
`status` = 1
`user`.`role` != 'banned' AND
`friendship`.`status` = 'confirmed'
");
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
@@ -52,8 +52,8 @@ function selectAllFriendRequests() {
`friendship`.`user2ID` = `user`.`userID` OR
`friendship`.`user2ID` = :userID AND
`friendship`.`user1ID` = `user`.`userID`) AND
`role` != 5 AND
`status` = 0
`user`.`role` != 5 AND
`friendship`.`status` = 'requested'
");
$stmt->bindParam(':userID', $_SESSION["userID"], PDO::PARAM_INT);

View File

@@ -1,7 +1,7 @@
<?php
function selectAllGroupsFromUser($userID) {
return $GLOBALS["db"]->query("
$stmt = $GLOBALS["db"]->prepare("
SELECT
`group_page`.`name`,
`group_page`.`picture`
@@ -10,8 +10,13 @@ function selectAllGroupsFromUser($userID) {
INNER JOIN
`group_member`
WHERE
`group_member`.`userID` = $userID AND
`group_member`.`userID` = :userID AND
`group_member`.`groupID` = `group_page`.`groupID` AND
`group_page`.`status` != 0
`group_page`.`status` != 'hidden'
");
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
$stmt->execute();
return $stmt;
}

View File

@@ -194,4 +194,22 @@ function searchSomeGroups($n, $m, $search) {
$stmt->execute();
return $stmt;
}
function countSomeGroups($search) {
$stmt = $GLOBALS["db"]->prepare("
SELECT
COUNT(*)
FROM
`group_page`
WHERE
`name` LIKE :keyword
ORDER BY
`name`
");
$search = "%$search%";
$stmt->bindParam(':keyword', $search);
$stmt->execute();
return $stmt;
}
?>

View File

@@ -273,7 +273,8 @@ function selectRandomNotFriendUser($userID) {
return $stmt->fetch();
}
function searchSomeUsers($n, $m, $search) {
function searchSomeUsers($n, $m, $search)
{
$stmt = $GLOBALS["db"]->prepare("
SELECT
`username`,
@@ -301,3 +302,25 @@ function searchSomeUsers($n, $m, $search) {
$stmt->execute();
return $stmt;
}
function countSomeUsers($search) {
$q = $GLOBALS["db"]->prepare("
SELECT
COUNT(*)
FROM
`user`
WHERE
`username` LIKE :keyword OR
`fname` LIKE :keyword OR
`lname` LIKE :keyword
ORDER BY
`fname`,
`lname`,
`username`
");
$search = "%$search%";
$q->bindParam(':keyword', $search);
$q->execute();
return $q;
}