diff --git a/website/public/API/edit_friendship.php b/website/public/API/edit_friendship.php deleted file mode 100644 index 52aacf5..0000000 --- a/website/public/API/edit_friendship.php +++ /dev/null @@ -1,31 +0,0 @@ - $friend) { $friendshipStatus = getFriendshipStatus($friend->userID); - - if ($limit != 0 && $i >= $limit) - $extra = "extra-friend-item"; - else - $extra = ""; ?>
  • @@ -60,15 +49,13 @@ foreach($friends as $i => $friend) {
    1) { + if ($friendshipStatus == 2) { + $denyName = "Annuleer"; + } else { + $denyName = "Weiger"; + } ?> -
    - - +
    @@ -76,11 +63,19 @@ foreach($friends as $i => $friend) { onclick="editFriendship('userID ?>', 'accept')" class='accept-notification' value='1'> - + Accepteer + +
    $friend) { $limit) { - ?> -
  • - Meer vrienden... -
  • - diff --git a/website/public/bits/group-item.php b/website/public/bits/group-item.php index 0a5831c..92eccfc 100644 --- a/website/public/bits/group-item.php +++ b/website/public/bits/group-item.php @@ -22,17 +22,3 @@ foreach($groups as $i => $group) { -
  • -
    - - - -
    -
  • diff --git a/website/public/js/header.js b/website/public/js/header.js index 8d91d95..9889bdb 100644 --- a/website/public/js/header.js +++ b/website/public/js/header.js @@ -1,25 +1,19 @@ $(document).ready(function() { - $("#own-profile-picture").click(function() { - if($("#notification-center").css('right') == "-256px") { - $(".content").animate({ - marginRight: "256px" - }, 500); - $(".chat-right").animate({ - width: $(".chat-right").width() - 266 - }, 500); - $("#notification-center").animate({ - right: "0px" - }, 500); + + // Toggle menu + $("#own-profile-picture, #open-notifications").click(function() { + if ($("#notification-center").css('right') == "-256px") { + // Make the menu visible and move the content to the left. + $("#chat-history").width("calc(100% - 587px)"); + $(".modal").width("calc(100% - 512px)"); + $(".content").css("margin-right", "256px"); + $("#notification-center").css("right", "0px"); } else { - $(".chat-right").animate({ - width: $(".chat-right").width() + 266 - }, 500); - $(".content").animate({ - marginRight: "0px" - }, 500); - $("#notification-center").animate({ - right: "-256px" - }, 500); + // Make the menu invisible and move the content to the right. + $("#chat-history").width("calc(100% - 331px)"); + $(".modal").width("calc(100% - 256px)"); + $(".content").css("margin-right", "0px"); + $("#notification-center").css("right", "-256px"); } }); }); diff --git a/website/public/js/menu.js b/website/public/js/menu.js index 8329cde..d15d678 100644 --- a/website/public/js/menu.js +++ b/website/public/js/menu.js @@ -1,49 +1,28 @@ +var menuFriendsData; +var menuGroupsData; +var notificationMessagesData; +var notificationRequestsData; + $(document).ready(function() { - // Show more friends/users - - // Show more friends - // $("#more-friends-click").click(function() { - // // Show only friends - // $("#groups-menu-section").slideUp(); - // $("#friends-menu-section li").show(); - // - // // Change buttons - // $("#more-friends-click").hide(); - // $("#menu-back").show(); - // }); - // - // // Show more groups - // $("#more-groups-click").click(function() { - // // Show only groups - // $("#friends-menu-section").slideUp(); - // $("#groups-menu-section li").show(); - // - // // Change buttons - // $("#more-groups-click").hide(); - // $("#menu-back").show(); - // }); - - // // Go back - // $("#menu-back").click(function() { - // // Show overview of friends and groups - // $("#friends-menu-section").slideDown(); - // $("#groups-menu-section").slideDown(); - // $(".extra-menu-items").hide(); - // - // // Change buttons - // $("#menu-back").hide(); - // $("#more-groups-click").show(); - // $("#more-friends-click").show(); - // }); - loadMenuFriends(5); loadNotificationFriends(); loadUnreadMessages(); loadMenuGroups(); + setInterval(updateMenus, 3000); }); +// Update the menu and notification items. +function updateMenus() { + loadMenuFriends(5); + loadNotificationFriends(); + loadUnreadMessages(); + loadMenuGroups(); +} + + +// Get, every 3 seconds, the friends and insert them in the menu. function loadMenuFriends(limit) { $.post( "API/loadFriends.php", @@ -51,16 +30,18 @@ function loadMenuFriends(limit) { limit: 5 } ).done(function(data) { - if (showFriends(data, "#menu-friends-list", 5, "profile.php", "GET", limit)) { - $("#friends-menu-section").show(); - } else { - $("#friends-menu-section").hide(); + if (menuFriendsData != data) { + menuFriendsData = data; + if (showFriends(data, "#menu-friends-list", 5, "profile.php", "GET", limit)) { + $("#friends-menu-section").show(); + } else { + $("#friends-menu-section").hide(); + } } }); - - setTimeout(loadMenuFriends, 3000, limit); } +// Get, every 3 seconds, the groups and insert them in the menu. function loadMenuGroups() { $.post( "API/loadGroups.php", @@ -68,41 +49,45 @@ function loadMenuGroups() { limit: 5 } ).done(function(data) { - if (showGroups(data, "#menu-groups-list")) { - $("#groups-menu-section").show(); - } else { - $("#groups-menu-section").hide(); + if (menuGroupsData != data) { + menuGroupsData = data; + if (showGroups(data, "#menu-groups-list")) { + $("#groups-menu-section").show(); + } else { + $("#groups-menu-section").hide(); + } } }); - - setTimeout(loadMenuGroups, 3000); } +// Get, every 3 seconds, the friends requests and insert them in the notification center. function loadNotificationFriends() { $.post( "API/loadFriendRequest.php" ).done(function(data) { - if (showFriendsPlus(data, "#friend-requests-list", 5, "profile.php", "GET")) { - $("#friend-request-section").show(); - } else { - $("#friend-request-section").hide(); + if (notificationRequestsData != data) { + notificationRequestsData = data; + if (showFriendsPlus(data, "#friend-requests-list", 5, "profile.php", "GET")) { + $("#friend-request-section").show(); + } else { + $("#friend-request-section").hide(); + } } }); - - setTimeout(loadNotificationFriends, 3000); } +// Get, every 3 seconds, the unread messages and insert them in the notification center. function loadUnreadMessages() { $.post( "API/loadChatNotifications.php" ).done(function(data) { - if (showFriendsPlus(data, "#unread-chat-list", 5, "chat.php", "GET")) { - console.log(data); - $("#unread-messages-section").show(); - } else { - $("#unread-messages-section").hide(); + if (notificationMessagesData != data) { + notificationMessagesData = data; + if (showFriendsPlus(data, "#unread-chat-list", 5, "chat.php", "GET")) { + $("#unread-messages-section").show(); + } else { + $("#unread-messages-section").hide(); + } } }); - - setTimeout(loadUnreadMessages, 3000); } \ No newline at end of file diff --git a/website/public/js/notifications.js b/website/public/js/notifications.js deleted file mode 100644 index d78d167..0000000 --- a/website/public/js/notifications.js +++ /dev/null @@ -1,43 +0,0 @@ -// function showChatNotifications(notifications) { -// $("#unreadChatlist").html(""); -// for (i in notifications) { -// $("#unreadChatlist").append(" \ -//
  • \ -//
    \ -// \ -//
    \ -//
  • \ -// "); -// } -// } -// -// function loadNotifications() { -// $.post( -// "API/loadChatNotifications.php" -// ).done(function(data) { -// if (data && data != "[]") { -// $("#unread-messages-section").show(); -// showChatNotifications(JSON.parse(data)); -// } else { -// $("#unread-messages-section").hide(); -// } -// }); -// -// setTimeout(loadNotifications, 10000); -// } -// $(document).ready(function() { -// loadNotifications(); -// }); - - - diff --git a/website/public/js/search.js b/website/public/js/search.js new file mode 100644 index 0000000..b3c322a --- /dev/null +++ b/website/public/js/search.js @@ -0,0 +1,33 @@ +function searchUsers(n, m) { + $.post( + "API/searchUsers.php", + { + n: n, + m: m, + search: $("#search-input").val(), + filter: $("#search-filter").val() + } + ).done(function(data) { + console.log(data); + if (!showFriends(data, "#search-users-list", 0, "profile.php", "GET")) { + $("#search-users-list").text("Niemand gevonden"); + } + }); +} + +function searchGroups(n, m) { + $.post( + "API/searchGroups.php", + { + n: n, + m: m, + search: $("#search-input").val(), + filter: $("#search-filter").val() + } + ).done(function(data) { + console.log(data); + if (!showGroups(data, "#search-groups-list")) { + $("#search-groups-list").text("Geen groepen gevonden"); + } + }); +} \ No newline at end of file diff --git a/website/public/search.php b/website/public/search.php index 6cfadd8..fbb0bc2 100644 --- a/website/public/search.php +++ b/website/public/search.php @@ -9,6 +9,8 @@ + + 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()); } \ No newline at end of file diff --git a/website/queries/group_member.php b/website/queries/group_member.php index a188494..cba339f 100644 --- a/website/queries/group_member.php +++ b/website/queries/group_member.php @@ -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()); +} diff --git a/website/queries/group_page.php b/website/queries/group_page.php index 9a3461d..f3de045 100644 --- a/website/queries/group_page.php +++ b/website/queries/group_page.php @@ -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) { diff --git a/website/queries/private_message.php b/website/queries/private_message.php index e708541..fecea2b 100644 --- a/website/queries/private_message.php +++ b/website/queries/private_message.php @@ -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 diff --git a/website/queries/user.php b/website/queries/user.php index cb4525d..4a7ee57 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -318,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 @@ -347,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) { diff --git a/website/views/header.php b/website/views/header.php index 5349a72..9d2aa56 100644 --- a/website/views/header.php +++ b/website/views/header.php @@ -12,7 +12,6 @@ $userinfo = getHeaderInfo(); -

    - Groepen + Top groepen

    +
    + +
    \ No newline at end of file diff --git a/website/views/notification-center.php b/website/views/notification-center.php index 8c01217..ee5622e 100644 --- a/website/views/notification-center.php +++ b/website/views/notification-center.php @@ -7,7 +7,7 @@

    - Vriendchapsverzoeken + Verzoeken