diff --git a/website/public/API/loadChatNotifications.php b/website/public/API/loadChatNotifications.php index baceabc..8ef0aa5 100644 --- a/website/public/API/loadChatNotifications.php +++ b/website/public/API/loadChatNotifications.php @@ -6,6 +6,7 @@ require_once ("../../queries/connect.php"); require_once ("../../queries/private_message.php"); require_once("../../queries/user.php"); +// Check if the user is allowed to load them. if (isset($_SESSION["userID"]) && getRoleByID($_SESSION["userID"]) != 'banned') { echo selectAllUnreadChat(); diff --git a/website/public/API/loadFriendRequest.php b/website/public/API/loadFriendRequest.php index 91a1cc7..7eca6a8 100644 --- a/website/public/API/loadFriendRequest.php +++ b/website/public/API/loadFriendRequest.php @@ -6,6 +6,7 @@ require_once ("../../queries/connect.php"); require_once ("../../queries/friendship.php"); require_once ("../../queries/user.php"); +// Check if the user is allowed to load them. if (isset($_SESSION["userID"]) && getRoleByID($_SESSION["userID"]) != 'frozen' && getRoleByID($_SESSION["userID"]) != 'banned') { diff --git a/website/public/API/loadFriends.php b/website/public/API/loadFriends.php index b59b34c..13a25d8 100644 --- a/website/public/API/loadFriends.php +++ b/website/public/API/loadFriends.php @@ -7,9 +7,11 @@ require_once ("../../queries/checkInput.php"); require_once ("../../queries/friendship.php"); require_once("../../queries/user.php"); +// Check if the user is allowed to load them. if (isset($_SESSION["userID"]) && getRoleByID($_SESSION["userID"]) != 'banned') { if (isset($_SESSION["userID"])) { + // Echo the limited or unlimited users. if (isset($_POST["limit"])) { echo selectLimitedFriends($_SESSION["userID"], (int)test_input($_POST["limit"])); } else if (isset($_GET["limit"])) { diff --git a/website/public/API/loadGroups.php b/website/public/API/loadGroups.php index 3c562b1..5bbc111 100644 --- a/website/public/API/loadGroups.php +++ b/website/public/API/loadGroups.php @@ -8,8 +8,10 @@ require_once ("../../queries/group_member.php"); require_once("../../queries/user.php"); +// Check if the user is allowed to load them. if (isset($_SESSION["userID"]) && getRoleByID($_SESSION["userID"]) != 'banned') { + // Echo the limited or unlimited groups. if (isset($_POST["limit"])) { echo selectLimitedGroupsFromUser($_SESSION["userID"], (int)test_input($_POST["limit"])); } else { diff --git a/website/public/API/loadMessages.php b/website/public/API/loadMessages.php index d78d058..d1a7e15 100644 --- a/website/public/API/loadMessages.php +++ b/website/public/API/loadMessages.php @@ -8,8 +8,10 @@ require_once("../../queries/checkInput.php"); require_once("../../queries/friendship.php"); require_once("../../queries/user.php"); +// Check if the user is allowed to get the messages. if (isset($_SESSION["userID"]) && getRoleByID($_SESSION["userID"]) != 'banned') { + // Check if the users wants new messages or old ones, and give the right one back. if (isset($_POST["lastID"]) && $_POST["lastID"] != "") { setLastVisited(test_input($_POST["destination"])); echo getNewChatMessages(test_input($_POST["lastID"]), test_input($_POST["destination"])); diff --git a/website/public/API/sendMessage.php b/website/public/API/sendMessage.php index 2d0b092..c6e3231 100644 --- a/website/public/API/sendMessage.php +++ b/website/public/API/sendMessage.php @@ -6,12 +6,15 @@ require_once("../../queries/private_message.php"); require_once("../../queries/checkInput.php"); require_once("../../queries/user.php"); +// Check if the user is allowed to send a message. if (isset($_SESSION["userID"]) && getRoleByID($_SESSION["userID"]) != 'frozen' && getRoleByID($_SESSION["userID"]) != 'banned') { if (!empty(test_input($_POST["destination"])) && !empty(test_input($_POST["content"])) ) { + // Send the message. + // Returns false when it didn't succeed sending the message. if (sendMessage(test_input($_POST["destination"]), test_input($_POST["content"]))) { echo 1; } else { diff --git a/website/public/bits/friend-item.php b/website/public/bits/friend-item.php index 40bc8a8..181f9b6 100644 --- a/website/public/bits/friend-item.php +++ b/website/public/bits/friend-item.php @@ -4,6 +4,7 @@ session_start(); include_once ("../../queries/friendship.php"); +// Initialize variables to given or default values. if (isset($_POST["action"])) { $action = $_POST["action"]; } else { @@ -18,6 +19,8 @@ if (isset($_POST["actionType"])) { $friends = json_decode($_POST["friends"]); + +// Foreach friend, return them as list item. foreach($friends as $i => $friend) { $friendshipStatus = getFriendshipStatus($friend->userID); ?> @@ -48,6 +51,7 @@ foreach($friends as $i => $friend) { 1) { if ($friendshipStatus == 2) { $denyName = "Annuleer"; diff --git a/website/public/bits/group-item.php b/website/public/bits/group-item.php index 92eccfc..dbe799d 100644 --- a/website/public/bits/group-item.php +++ b/website/public/bits/group-item.php @@ -6,6 +6,7 @@ include_once ("../../queries/group_member.php"); $groups = json_decode($_POST["groups"]); +// Add each group as list item. foreach($groups as $i => $group) { ?>
  • diff --git a/website/public/js/chat.js b/website/public/js/chat.js index 6a027c8..3f28c81 100644 --- a/website/public/js/chat.js +++ b/website/public/js/chat.js @@ -9,13 +9,17 @@ $(document).ready(function() { $(".chat-field").hide(); }); +// This function loads the new messages and runs the addMessages function to show them. function loadMessages() { + // If the function is not running elsewhere, run it here. if (!gettingMessages) { gettingMessages = true; + // Get the messages. $.post( "API/loadMessages.php", $("#lastIDForm").serialize() ).done(function (data) { + // Post the messages in the chat. if (data && data != "[]") { messages = JSON.parse(data); addMessages(messages); @@ -28,7 +32,7 @@ function loadMessages() { } } - +// Send a message to a friend of the user. function sendMessage() { $.post( "API/sendMessage.php", @@ -37,42 +41,54 @@ function sendMessage() { if (response == "frozen") { alert("Je account is bevroren, dus je kan niet chat berichten versturen. Contacteer een admin als je denkt dat dit onjuist is."); } + // Load messages if the message has been send, so it shows in the chat. + loadMessages(); }); $("#newContent").val(""); - loadMessages(); } +// Add messages to the chat. function addMessages(messages) { var messagesText = ""; + + // Loop over all the messages. for(var i in messages) { - // Initialize message variables + // Initialize message variables. var thisDate = new Date(messages[i].creationdate.replace(/ /,"T")); var thisTime = thisDate.getHours() + ":" + thisDate.getMinutes(); var type; thisDate.setHours(0,0,0,0); + // See where the message has been send from, so it shows on the right side. if (messages[i].destination == $(".destinationID").val()) { type = "chat-message-self"; } else { type = "chat-message-other"; } + + // If it is the first message, open the message box and maybe add a year. if (i == 0) { + if (thisDate.getTime() > previousDate.getTime()) { + messagesText += '\ +
    \ +
    \ + ' + days[thisDate.getDay()] + " " + thisDate.getDate() + " " + months[thisDate.getMonth()] + " " + thisDate.getFullYear() + '\ +
    \ +
    '; + } previousDate = thisDate; - messagesText += '\ -
    \ -
    \ - ' + days[thisDate.getDay()] + " " + thisDate.getDate() + " " + months[thisDate.getMonth()] + " " + thisDate.getFullYear() + '\ -
    \ -
    '; messagesText += '
    '; + // If it is not the first message, and has a different date/time/type then the previous message, } else if (type != previousType || thisTime != previousTime || thisDate.getTime() > previousDate.getTime()) { + // Close the previous message. messagesText += '
    \ ' + thisTime + '\
    '; previousTime = thisTime; previousType = type; + // If the date is different, add a new date. if (thisDate > previousDate) { previousDate = thisDate; messagesText += '\ @@ -83,8 +99,11 @@ function addMessages(messages) { '; } + // Open the new message. messagesText += '
    '; } + + // Add the content of the message in the new box. messagesText += fancyText(messages[i].content) + "
    "; } @@ -93,11 +112,14 @@ function addMessages(messages) { ' + thisTime + '\
    '; + // Add all the new created messaged to the chat. $("#chat-history").append(messagesText); + // Scroll down, so the user can see the new messages. $("#chat-history").scrollTop($("#chat-history")[0].scrollHeight - $('#chat-history')[0].clientHeight); } +// Switch to a different user. function switchUser(userID) { previousDate = new Date("1970-01-01 00:00:00"); $(".chat-field").show(); @@ -108,6 +130,7 @@ function switchUser(userID) { $("#friend-item-" + userID).addClass("active-friend-chat"); } +// Insert a message in the chat, this is used when it is empty. function sayEmpty() { $("#chat-history").html("Probeer ook eens foto's en video's te sturen"); } \ No newline at end of file diff --git a/website/public/js/main.js b/website/public/js/main.js index 7741406..b6ab703 100644 --- a/website/public/js/main.js +++ b/website/public/js/main.js @@ -14,14 +14,14 @@ function fancyText(text) { return ""; + ""; } // Add ogg video's else if (link.match(/(https?:\/\/.[^ ]*\.(?:ogg))/ig)) { return ""; + ""; } // Add youtube video's else if (link.match(/(https?:\/\/.(www.)?youtube|youtu.be)*watch/ig)) { @@ -38,6 +38,8 @@ function fancyText(text) { return text; } +// This function gets the value of a cookie when given a key. +// If didn“t find any compatible cookie, it returns false. function getCookie(key) { cookies = document.cookie.split("; "); for (var i in cookies) { @@ -49,6 +51,7 @@ function getCookie(key) { return false; } +// Edit the friendship status of two users. function editFriendship(userID, value) { $.post("API/editFriendship.php", { usr: userID, action: value }) .done(function() { @@ -57,6 +60,8 @@ function editFriendship(userID, value) { }); } +// Show the given friends in the given list. +// The friends are giving in JSON, and the list is giving with a hashtag. function showFriends(friends, list) { if(friends && friends != "[]") { $(list).load("bits/friend-item.php", { @@ -69,6 +74,8 @@ function showFriends(friends, list) { } } +// Show the given friends in the given list. +// This function supports more options given as parameters. This adds extra functionality. function showFriendsPlus(friends, list, limit, action, actionType) { if(friends && friends != "[]") { $(list).load("bits/friend-item.php", { @@ -84,6 +91,7 @@ function showFriendsPlus(friends, list, limit, action, actionType) { } } +// Show the given groups in the given list. function showGroups(groups, list) { if(groups && groups != "[]") { $(list).load("bits/group-item.php", { diff --git a/website/public/js/search.js b/website/public/js/search.js index f7c4bbe..affe758 100644 --- a/website/public/js/search.js +++ b/website/public/js/search.js @@ -2,6 +2,7 @@ $(window).on('load', function () { pageNumber(); }); +// Search for the users and put them in the user list. function searchUsers() { $.post( "API/searchUsers.php", @@ -13,6 +14,7 @@ function searchUsers() { }); } +// Search for the groups and put them in the group list. function searchGroups() { $.post( "API/searchGroups.php", @@ -24,6 +26,7 @@ function searchGroups() { }); } +// Get the page numbers and return them in the select. function pageNumber() { var input = input2 = $('#search-form').serialize(); $.post( diff --git a/website/public/styles/main.css b/website/public/styles/main.css index 94fdea9..650a30f 100644 --- a/website/public/styles/main.css +++ b/website/public/styles/main.css @@ -102,7 +102,6 @@ p { .group-picture { border-radius: 5px; - border: none; } .item-box, .item-box-full-width { @@ -117,7 +116,7 @@ p { @media only screen and (max-width: 1400px) { .item-box { - width: calc(100% - 50px); + width: calc(100% - 50px)!important; } } @@ -291,19 +290,6 @@ div[data-title]:hover:after { vertical-align: middle; } -::-webkit-scrollbar { - width: 5px; - height: 5px; -} -::-webkit-scrollbar-track { - background: none; -} -::-webkit-scrollbar-thumb { - -webkit-border-radius: 20px; - border-radius: 20px; - background: #4CAF50; -} - @media only screen and (max-width: 1080px) { body { font-size: 28px!important; diff --git a/website/public/styles/profile.css b/website/public/styles/profile.css index 2370da8..146a4fa 100644 --- a/website/public/styles/profile.css +++ b/website/public/styles/profile.css @@ -11,7 +11,7 @@ display: inline-block; } -.friend-button-container { +.friend-button-container, .group-button-container { position: relative; float: right; width: 200px; @@ -62,7 +62,6 @@ .group-picture { border: none; - margin-bottom: 0; margin-right: 15px; } diff --git a/website/public/styles/settings.css b/website/public/styles/settings.css index 933e7fd..6a2c2f2 100644 --- a/website/public/styles/settings.css +++ b/website/public/styles/settings.css @@ -32,6 +32,11 @@ text-align: right; } +.settings-password, .settings-email { + width: calc(50% - 60px); + display: inline-flex; +} + .settings-password label, .settings-email label { text-align: left; } diff --git a/website/queries/friendship.php b/website/queries/friendship.php index a16d859..e1a8c53 100644 --- a/website/queries/friendship.php +++ b/website/queries/friendship.php @@ -10,8 +10,8 @@ function selectLimitedFriends($userID, $limit) { $stmt = prepareQuery(" SELECT `userID`, - `username`, - LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `fullname`, + LEFT(`username`, 12) as `username`, + LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`, IFNULL( `profilepicture`, '../img/avatar-standard.png' @@ -50,8 +50,8 @@ function selectAllFriends($userID) { $stmt = prepareQuery(" SELECT `userID`, - `username`, - LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `fullname`, + LEFT(`username`, 12) as `username`, + LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`, IFNULL( `profilepicture`, '../img/avatar-standard.png' @@ -85,8 +85,8 @@ function selectAllFriendRequests() { $stmt = prepareQuery(" SELECT `userID`, - `username`, - LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `fullname`, + LEFT(`username`, 12) as `username`, + LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`, IFNULL( `profilepicture`, '../img/avatar-standard.png' @@ -235,8 +235,9 @@ function searchSomeFriends($n, $m, $search) { $stmt = prepareQuery(" SELECT `userID`, - `username`, - LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `fullname`, + + LEFT(`username`, 12) as `username`, + LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`, IFNULL( `profilepicture`, '../img/avatar-standard.png' diff --git a/website/queries/private_message.php b/website/queries/private_message.php index 4ac04a7..3b88563 100644 --- a/website/queries/private_message.php +++ b/website/queries/private_message.php @@ -95,7 +95,7 @@ function getNewChatMessages($lastID, $destination) { function selectAllUnreadChat() { $stmt = prepareQuery(" SELECT - LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) AS `fullname`, + LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`, `user`.`userID`, IFNULL( `profilepicture`, diff --git a/website/queries/user.php b/website/queries/user.php index f7d8abe..b0fb47b 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -52,6 +52,10 @@ function selectUser($me, $other) { `username`, `birthdate`, `location`, + `showBday`, + `showEmail`, + `showProfile`, + `email`, IFNULL( `profilepicture`, '../img/avatar-standard.png' @@ -351,12 +355,12 @@ function searchSomeUsers($n, $m, $search) { $stmt = prepareQuery(" SELECT `userID`, - `username`, + LEFT(`username`, 12) as `username`, IFNULL( `profilepicture`, '../img/avatar-standard.png' ) AS profilepicture, - LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `fullname`, + LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`, CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE) WHEN TRUE THEN 'online' WHEN FALSE THEN 'offline' diff --git a/website/views/group.php b/website/views/group.php index c12b552..d192123 100644 --- a/website/views/group.php +++ b/website/views/group.php @@ -1,12 +1,17 @@
    -
    - -
    -

    -

    - +
    + ">
    +
    +
    + +
    +
    +
    +

    + +
    +
    -

    Leden ()

    diff --git a/website/views/head.php b/website/views/head.php index 284abb4..c4d13a5 100644 --- a/website/views/head.php +++ b/website/views/head.php @@ -1,4 +1,8 @@ - + + + + + MyHyvesbook+ diff --git a/website/views/notification-center.php b/website/views/notification-center.php index 7bd03ea..f6f4a03 100644 --- a/website/views/notification-center.php +++ b/website/views/notification-center.php @@ -14,7 +14,7 @@ echo ""; } ?> - +

    diff --git a/website/views/profile.php b/website/views/profile.php index 2bb117f..e8aa8c9 100644 --- a/website/views/profile.php +++ b/website/views/profile.php @@ -29,7 +29,12 @@

    Informatie

      +
    • Leeftijd: jaar
    • + + +
    • Email:
    • +
    • Locatie:
    • Lid sinds:
    diff --git a/website/views/settings-view.php b/website/views/settings-view.php index f72e243..cf5317f 100644 --- a/website/views/settings-view.php +++ b/website/views/settings-view.php @@ -17,6 +17,7 @@ $settings = getSettings(); " @@ -27,6 +28,7 @@ $settings = getSettings(); " > @@ -36,6 +38,7 @@ $settings = getSettings(); " > @@ -194,6 +197,7 @@ $settings = getSettings(); " disabled > @@ -202,6 +206,7 @@ $settings = getSettings(); @@ -211,14 +216,16 @@ $settings = getSettings();
  • + value="email"> + Verander Email +