Hendrik testing #208
@@ -3,10 +3,10 @@ session_start();
|
||||
|
||||
require_once "../../queries/post.php";
|
||||
require_once "../../queries/user.php";
|
||||
|
||||
if (isset($_SESSION["userID"]) and
|
||||
getRoleByID($_SESSION["userID"]) != 'frozen' and
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
if (!isset($_SESSION["userID"])) {
|
||||
echo "logged out";
|
||||
} else if (getRoleByID($_SESSION["userID"]) != 'frozen' and
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
|
||||
if (empty($_POST["postID"]) or empty($_SESSION["userID"])) {
|
||||
header('HTTP/1.1 500 Non enough arguments');
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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') {
|
||||
|
||||
@@ -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"])) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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"]));
|
||||
|
||||
@@ -7,10 +7,10 @@ require_once("../../queries/connect.php");
|
||||
require_once("../../queries/checkInput.php");
|
||||
require_once("../../queries/user.php");
|
||||
|
||||
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
getRoleByID($_SESSION["userID"]) != 'frozen' &&
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
if (!isset($_SESSION["userID"])) {
|
||||
echo "logged out";
|
||||
} else if (getRoleByID($_SESSION["userID"]) != 'frozen' &&
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
if ($_POST['button'] == 'reaction') {
|
||||
if (empty($_POST['newcomment-content'])) {
|
||||
echo 0;
|
||||
|
||||
@@ -8,40 +8,44 @@ require_once("../../queries/connect.php");
|
||||
require_once("../../queries/checkInput.php");
|
||||
require_once("../../queries/user.php");
|
||||
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
getRoleByID($_SESSION["userID"]) != 'frozen' &&
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
if (!isset($_SESSION["userID"])) {
|
||||
echo "logged out";
|
||||
} else if (getRoleByID($_SESSION["userID"]) != 'frozen' &&
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
|
||||
if (empty($_POST["title"]) or
|
||||
empty($_POST["content"]) or
|
||||
empty($_SESSION["userID"])
|
||||
) {
|
||||
if (empty($_SESSION["userID"])) {
|
||||
header('HTTP/1.1 500 Non enough arguments');
|
||||
}
|
||||
|
||||
if (empty($_POST["group"])) {
|
||||
// User Post
|
||||
makePost(
|
||||
$_SESSION["userID"],
|
||||
null,
|
||||
test_input($_POST["title"]),
|
||||
test_input($_POST["content"])
|
||||
);
|
||||
if (empty(test_input($_POST["title"])) or
|
||||
empty(test_input($_POST["content"]))
|
||||
) {
|
||||
echo "empty";
|
||||
} else {
|
||||
// Group Post
|
||||
if (empty($_POST["group"])) {
|
||||
// User Post
|
||||
makePost(
|
||||
$_SESSION["userID"],
|
||||
null,
|
||||
test_input($_POST["title"]),
|
||||
test_input($_POST["content"])
|
||||
);
|
||||
} else {
|
||||
// Group Post
|
||||
|
||||
// Check if the user is an admin or mod of the group.
|
||||
if (!in_array(selectGroupRole($_POST["group"]), array('mod', 'admin'))) {
|
||||
header('HTTP/1.1 500 Non enough rights');
|
||||
return;
|
||||
// Check if the user is an admin or mod of the group.
|
||||
if (!in_array(selectGroupRole($_POST["group"]), array('mod', 'admin'))) {
|
||||
header('HTTP/1.1 500 Non enough rights');
|
||||
return;
|
||||
}
|
||||
|
||||
makePost(
|
||||
$_SESSION["userID"],
|
||||
$_POST["group"],
|
||||
test_input($_POST["title"]),
|
||||
test_input($_POST["content"])
|
||||
);
|
||||
}
|
||||
|
||||
makePost(
|
||||
$_SESSION["userID"],
|
||||
$_POST["group"],
|
||||
test_input($_POST["title"]),
|
||||
test_input($_POST["content"])
|
||||
);
|
||||
}
|
||||
} else {
|
||||
echo "frozen";
|
||||
|
||||
@@ -6,11 +6,11 @@ require_once ("../../queries/connect.php");
|
||||
require_once ("../../queries/checkInput.php");
|
||||
require_once ("../../queries/user.php");
|
||||
require_once ("../../queries/group_page.php");
|
||||
require_once ("../../queries/friendship.php");
|
||||
require_once ("../../queries/group_member.php");
|
||||
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
|
||||
$user_perpage = $group_perpage = 20;
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {$user_perpage = $group_perpage = 20;
|
||||
|
||||
$user_currentpage = $group_currentpage = 1;
|
||||
if (isset($_POST['user-pageselect'])) {
|
||||
@@ -28,20 +28,26 @@ if (isset($_SESSION["userID"]) &&
|
||||
$search = test_input($_POST['search']);
|
||||
}
|
||||
|
||||
$user_count = countSomeUsers($search)->fetchColumn();
|
||||
$group_count = countSomeGroups($search)->fetchColumn();
|
||||
|
||||
$filter = "all";
|
||||
if (isset($_POST['filter'])) {
|
||||
$filter = test_input($_POST['filter']);
|
||||
}
|
||||
|
||||
if ($filter == "all") {
|
||||
$user_count = countSomeUsers($search)->fetchColumn();
|
||||
$group_count = countSomeGroups($search)->fetchColumn();
|
||||
} else {
|
||||
$user_count = countSomeFriends($search);
|
||||
$group_count = countSomeOwnGroups($search);
|
||||
}
|
||||
|
||||
|
||||
$option = "user";
|
||||
if (isset($_POST['option'])) {
|
||||
$option = test_input($_POST['option']);
|
||||
}
|
||||
|
||||
include("../../views/searchPageNumber.php");
|
||||
include ("../../views/searchPageNumber.php");
|
||||
} else {
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
}
|
||||
@@ -6,12 +6,16 @@ require_once("../../queries/private_message.php");
|
||||
require_once("../../queries/checkInput.php");
|
||||
require_once("../../queries/user.php");
|
||||
|
||||
if (isset($_SESSION["userID"]) &&
|
||||
getRoleByID($_SESSION["userID"]) != 'frozen' &&
|
||||
getRoleByID($_SESSION["userID"]) != 'banned') {
|
||||
// Check if the user is allowed to send a message.
|
||||
if (!isset($_SESSION["userID"])) {
|
||||
echo "logged out";
|
||||
} else if (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 {
|
||||
|
||||
@@ -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);
|
||||
?>
|
||||
@@ -38,7 +41,7 @@ foreach($friends as $i => $friend) {
|
||||
<?= $friend->fullname ?><br/>
|
||||
<span style='color: #666'><?php
|
||||
if (isset($friend->username)) {
|
||||
echo $friend->username;
|
||||
echo $friend->usernameshort;
|
||||
} else if (isset($friend->content)) {
|
||||
echo $friend->content;
|
||||
}
|
||||
@@ -48,6 +51,7 @@ foreach($friends as $i => $friend) {
|
||||
</button>
|
||||
</form>
|
||||
<?php
|
||||
// Add friendship options if possible.
|
||||
if ($friendshipStatus > 1) {
|
||||
if ($friendshipStatus == 2) {
|
||||
$denyName = "Annuleer";
|
||||
|
||||
@@ -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) {
|
||||
?>
|
||||
<li class='group-item'>
|
||||
|
||||
8
website/public/bits/niet-slecht.php
Normal file
8
website/public/bits/niet-slecht.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
if (isset($_GET["groupname"])) {
|
||||
$url = "https://myhyvesbookplus.nl/~lars/group.php?groupname=" . $_GET["groupname"];
|
||||
} else {
|
||||
$url = "https://myhyvesbookplus.nl/";
|
||||
}
|
||||
?>
|
||||
<a href="<?= $url ?>" target='_blank'><img style="width: 100%; height: auto;" src="../external/nietslecht_button.png" alt='\"Niet slecht\" ons op MyHyvesbook+' /></a>
|
||||
36
website/public/createGroup.php
Normal file
36
website/public/createGroup.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
require_once "../queries/createGroup.php";
|
||||
require_once "../queries/connect.php";
|
||||
require_once "../queries/alerts.php"?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<?php include("../views/head.php"); ?>
|
||||
<style>
|
||||
@import url("styles/settings.css");
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
/*
|
||||
* This view adds the main layout over the screen.
|
||||
* Header and menu.
|
||||
*/
|
||||
include("../views/main.php");
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
try {
|
||||
createGroup();
|
||||
} catch (AlertMessage $e) {
|
||||
|
||||
}
|
||||
$groupname = $_POST["groupName"];
|
||||
header("location: group.php?groupname=$groupname");
|
||||
}
|
||||
/* Add your view files here. */
|
||||
include("../views/createGroup.php");
|
||||
|
||||
/* This adds the footer. */
|
||||
include("../views/footer.php");
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
@@ -13,13 +13,15 @@
|
||||
|
||||
include_once("../queries/group_page.php");
|
||||
|
||||
$group = selectGroupByName($_GET["groupname"]);
|
||||
$members = selectGroupMembers(2);
|
||||
if(!$group = selectGroupByName($_GET["groupname"])) {
|
||||
header("HTTP/1.0 404 Not Found");
|
||||
header("Location: error/404.php");
|
||||
die();
|
||||
}
|
||||
|
||||
|
||||
$members = selectGroupMembers($group["groupID"]);
|
||||
|
||||
?>
|
||||
<script>alert("<?= $members[0] ?>");</script>
|
||||
<script>alert("<?= $members[1] ?>");</script>
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This view adds the main layout over the screen.
|
||||
|
||||
61
website/public/groupAdmin.php
Normal file
61
website/public/groupAdmin.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
require_once "../queries/picture.php";
|
||||
require_once "../queries/groupAdmin.php";
|
||||
require_once "../queries/alerts.php";
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<?php include("../views/head.php"); ?>
|
||||
<style>
|
||||
/*Insert own stylesheet here ;)*/
|
||||
@import url("styles/settings.css");
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
/*
|
||||
* This view adds the main layout over the screen.
|
||||
* Header and menu.
|
||||
*/
|
||||
include("../views/main.php");
|
||||
$alertClass;
|
||||
$alertMessage;
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
try {
|
||||
switch ($_POST["form"]) {
|
||||
case "group":
|
||||
updateGroupSettings($_POST["groupID"]);
|
||||
break;
|
||||
case "picture":
|
||||
if (checkGroupAdmin($_POST["groupID"], $_SESSION["userID"])) {
|
||||
updateAvatar($_POST["groupID"]);
|
||||
}
|
||||
break;
|
||||
case "mod":
|
||||
if (!array_key_exists("userID", $_POST)) {
|
||||
throw new AngryAlert("Geen gebruiker geselecteerd.");
|
||||
}
|
||||
upgradeUser($_POST["groupID"], $_POST["userID"], "mod");
|
||||
break;
|
||||
case "admin":
|
||||
if (!array_key_exists("userID", $_POST)) {
|
||||
throw new AngryAlert("Geen gebruiker geselecteerd.");
|
||||
}
|
||||
upgradeUser($_POST["groupID"], $_POST["userID"], "admin");
|
||||
break;
|
||||
}
|
||||
} catch (AlertMessage $w) {
|
||||
$alertClass = $w->getClass();
|
||||
$alertMessage = $w->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/* Add your view files here. */
|
||||
include("../views/groupAdmin.php");
|
||||
|
||||
/* This adds the footer. */
|
||||
include("../views/footer.php");
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
@@ -9,18 +9,25 @@ $(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);
|
||||
$("#lastID").val(messages[messages.length - 1].messageID);
|
||||
}
|
||||
|
||||
loadUnreadMessages();
|
||||
|
||||
gettingMessages = false;
|
||||
});
|
||||
} else {
|
||||
@@ -28,7 +35,7 @@ function loadMessages() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Send a message to a friend of the user.
|
||||
function sendMessage() {
|
||||
$.post(
|
||||
"API/sendMessage.php",
|
||||
@@ -36,43 +43,59 @@ function sendMessage() {
|
||||
).done(function(response) {
|
||||
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.");
|
||||
} else if (response == "logged out") {
|
||||
window.location.href = "login.php?url=" + window.location.pathname;
|
||||
}
|
||||
// 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 thisTime = thisDate.getHours() + ":" + ('0' + thisDate.getMinutes()).slice(-2);
|
||||
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 += '\
|
||||
<div class="day-message"> \
|
||||
<div class="day-message-content">\
|
||||
' + days[thisDate.getDay()] + " " + thisDate.getDate() + " " + months[thisDate.getMonth()] + " " + thisDate.getFullYear() + '\
|
||||
</div> \
|
||||
</div>';
|
||||
}
|
||||
previousDate = thisDate;
|
||||
messagesText += '\
|
||||
<div class="day-message"> \
|
||||
<div class="day-message-content">\
|
||||
' + days[thisDate.getDay()] + " " + thisDate.getDate() + " " + months[thisDate.getMonth()] + " " + thisDate.getFullYear() + '\
|
||||
</div> \
|
||||
</div>';
|
||||
previousTime = thisTime;
|
||||
previousType = type;
|
||||
messagesText += '<div class="chat-message"><div class="' + type + '">';
|
||||
// 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 += '<div class="chat-time">\
|
||||
' + thisTime + '\
|
||||
</div></div></div>';
|
||||
|
||||
previousTime = thisTime;
|
||||
previousType = type;
|
||||
// If the date is different, add a new date.
|
||||
if (thisDate > previousDate) {
|
||||
previousDate = thisDate;
|
||||
messagesText += '\
|
||||
@@ -83,8 +106,11 @@ function addMessages(messages) {
|
||||
</div>';
|
||||
}
|
||||
|
||||
// Open the new message.
|
||||
messagesText += '<div class="chat-message"><div class="' + type + '">';
|
||||
}
|
||||
|
||||
// Add the content of the message in the new box.
|
||||
messagesText += fancyText(messages[i].content) + "<br />";
|
||||
}
|
||||
|
||||
@@ -93,11 +119,14 @@ function addMessages(messages) {
|
||||
' + thisTime + '\
|
||||
</div></div></div>';
|
||||
|
||||
// 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 +137,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");
|
||||
}
|
||||
@@ -19,24 +19,24 @@ function placeFriendButtons() {
|
||||
case "0":
|
||||
value1 = "request";
|
||||
class1 = "green";
|
||||
text1 = "Bevriend";
|
||||
icon1 = "fa-handshake-o";
|
||||
text1 = "Word vrienden";
|
||||
icon1 = "fa-user-plus";
|
||||
break;
|
||||
case "1":
|
||||
value1 = userID;
|
||||
class1 = "green";
|
||||
text1 = "Chat";
|
||||
icon1 = "fa-comment-o";
|
||||
icon1 = "fa-comment";
|
||||
value2 = "delete";
|
||||
class2 = "red";
|
||||
text2 = "Verwijder";
|
||||
icon2 = "fa-times";
|
||||
text2 = "Ontvriend";
|
||||
icon2 = "fa-user-times";
|
||||
break;
|
||||
case "2":
|
||||
value1 = "delete";
|
||||
class1 = "red";
|
||||
text1 = "Trek verzoek in";
|
||||
icon1 = "fa-cross";
|
||||
icon1 = "fa-times";
|
||||
break;
|
||||
case "3":
|
||||
value1 = "accept";
|
||||
@@ -51,16 +51,18 @@ function placeFriendButtons() {
|
||||
}
|
||||
|
||||
$buttonContainer.append(
|
||||
"<button class='"+ class1 +" friend-button' value='"+ value1 +"'>" +
|
||||
"<i class='fa "+ icon1 +"'></i> " + text1 +
|
||||
"</button>");
|
||||
"<div><button class='"+ class1 +" fancy-button friend-button' value='"+ value1 +"'>" +
|
||||
"<span>"+ text1 +"</span>" +
|
||||
"<i class='fa fa-fw "+ icon1 +"'></i> " +
|
||||
"</button></div>");
|
||||
$buttonContainer.append(
|
||||
"<button class='"+ class2 +" friend-button' value='"+ value2 +"'>" +
|
||||
"<i class='fa "+ icon2 +"'></i> " + text2 +
|
||||
"</button>");
|
||||
"<div><button class='"+ class2 +" fancy-button friend-button' value='"+ value2 +"'>" +
|
||||
"<span>"+ text2 +"</span>" +
|
||||
"<i class='fa fa-fw "+ icon2 +"'></i> " +
|
||||
"</button></div>");
|
||||
|
||||
|
||||
$buttonContainer.children().click(function() {
|
||||
$buttonContainer.find("button").click(function() {
|
||||
if (isNaN(this.value))
|
||||
editFriendship(userID, this.value);
|
||||
else if (this.value != "")
|
||||
|
||||
@@ -3,31 +3,41 @@ function placeGroupButtons() {
|
||||
.done(function(data) {
|
||||
var $buttonContainer = $("div.group-button-container");
|
||||
|
||||
if(data == 'none') {
|
||||
if (data == 'none') {
|
||||
$buttonContainer.append(
|
||||
"<button class='green group-button' value='request'>" +
|
||||
"<i class='fa fa-plus'></i> Voeg toe" +
|
||||
"<button class='green group-button fancy-button' value='request'>" +
|
||||
"<span>Treed toe</span><i class='fa fa-plus'></i>" +
|
||||
"</button>");
|
||||
} else if(data == 'request') {
|
||||
} else if (data == 'request') {
|
||||
$buttonContainer.append(
|
||||
"<button class='red group-button' value='none'>" +
|
||||
"<i class='fa fa-times'></i> Trek verzoek in" +
|
||||
"<button class='red group-button fancy-button' value='none'>" +
|
||||
"<span>Trek verzoek in</span><i class='fa fa-times'></i>" +
|
||||
"</button>");
|
||||
} else if (data == 'admin') {
|
||||
$buttonContainer.append(
|
||||
"<button class='group-button fancy-button' value='admin'>" +
|
||||
"<span>Instellingen</span><i class='fa fa-cogs'></i>" +
|
||||
"</button>"
|
||||
);
|
||||
} else {
|
||||
$buttonContainer.append(
|
||||
"<button class='red group-button' value='none'>" +
|
||||
"<i class='fa fa-times'></i> Verlaat groep" +
|
||||
"<button class='red group-button fancy-button' value='none'>" +
|
||||
"<span>Verlaat groep</span><i class='fa fa-sign-out'></i>" +
|
||||
"</button>");
|
||||
}
|
||||
|
||||
$buttonContainer.children().click(function() {
|
||||
$.post("API/editMembership.php", { grp: groupID, role: this.value })
|
||||
.done(function() {
|
||||
$buttonContainer.children().remove();
|
||||
placeGroupButtons();
|
||||
updateMenus();
|
||||
}).fail(function() {
|
||||
});
|
||||
if (this.value == 'admin') {
|
||||
window.location.href='groupAdmin.php?groupID=' + groupID;
|
||||
} else {
|
||||
$.post("API/editMembership.php", {grp: groupID, role: this.value})
|
||||
.done(function () {
|
||||
$buttonContainer.children().remove();
|
||||
placeGroupButtons();
|
||||
updateMenus();
|
||||
}).fail(function () {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -3,8 +3,7 @@ var months = ["januari", "februari", "maart", "april", "mei", "juni", "juli", "a
|
||||
|
||||
function fancyText(text) {
|
||||
// Add links, images, gifs and (youtube) video's.
|
||||
var regex = /(https?:\/\/.[^ <>"]*)/ig;
|
||||
text = text.replace(regex, function(link) {
|
||||
text = text.replace(/(https?:\/\/.[^ \n<>"]*)/ig, function(link) {
|
||||
// Add images
|
||||
if (link.match(/(https?:\/\/.[^ ]*\.(?:png|jpg|jpeg|gif))/ig)) {
|
||||
return "<img alt='" + link + "' src='" + link + "' />";
|
||||
@@ -14,14 +13,14 @@ function fancyText(text) {
|
||||
return "<video width='100%'>" +
|
||||
"<source src='"+ link +"' type='video/mp4'>" +
|
||||
"<b>Je browser ondersteund geen video</b>" +
|
||||
"</video><button class='gray' onclick='$(this).prev().get(0).play();'>Speel af</button>";
|
||||
"</video><button class='gray' onclick='$(this).prev().get(0).play();'><i class='fa fa-play'></i></button>";
|
||||
}
|
||||
// Add ogg video's
|
||||
else if (link.match(/(https?:\/\/.[^ ]*\.(?:ogg))/ig)) {
|
||||
return "<video width='100%'>" +
|
||||
"<source src='"+ link +"' type='video/ogg'>" +
|
||||
"<b>Je browser ondersteund geen video</b>" +
|
||||
"</video><button onclick='$(this).prev().get(0).play();'>Speel af</button>";
|
||||
"</video><button class='gray' onclick='$(this).prev().get(0).play();'><i class='fa fa-play'></i></button>";
|
||||
}
|
||||
// Add youtube video's
|
||||
else if (link.match(/(https?:\/\/.(www.)?youtube|youtu.be)*watch/ig)) {
|
||||
@@ -31,13 +30,15 @@ function fancyText(text) {
|
||||
}
|
||||
// Add links
|
||||
else {
|
||||
return "<a href='" + link + "'>" + link + "</a>";
|
||||
return "<a href='" + link + "' target='_blank'>" + link + "</a>";
|
||||
}
|
||||
});
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
// This function gets the value of a cookie when given a key.
|
||||
// If it didn´t find any compatible cookie, it returns false.
|
||||
function getCookie(key) {
|
||||
cookies = document.cookie.split("; ");
|
||||
for (var i in cookies) {
|
||||
@@ -49,6 +50,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 +59,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 +73,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 +90,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", {
|
||||
|
||||
@@ -26,19 +26,41 @@ function requestPost(postID) {
|
||||
function postPost() {
|
||||
title = $("input.newpost[name='title']").val();
|
||||
content = $("textarea.newpost[name='content']").val();
|
||||
|
||||
console.log(masonryMode);
|
||||
if (masonryMode == 2) {
|
||||
$.post("API/postPost.php", { title: title,
|
||||
content : content,
|
||||
group : groupID })
|
||||
.done(function() {
|
||||
masonry(masonryMode);
|
||||
.done(function(data) {
|
||||
if (data == "empty") {
|
||||
$('#alertbox').show();
|
||||
$('#alerttext').html("Geen titel of inhoud; vul a.u.b. in.");
|
||||
window.scrollTo(0,0);
|
||||
} else if (data == "logged out") {
|
||||
window.location.href = "login.php?url=" + window.location.pathname;
|
||||
} else if (data == "frozen") {
|
||||
alert("Je account is bevroren, dus je kan geen posts plaatsen. Contacteer een admin als je denkt dat dit onjuist is.");
|
||||
} else {
|
||||
$('#alertbox').hide();
|
||||
masonry(masonryMode);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$.post("API/postPost.php", { title: title,
|
||||
content : content })
|
||||
.done(function() {
|
||||
masonry(masonryMode);
|
||||
.done(function(data) {
|
||||
if (data == "empty") {
|
||||
$('#alertbox').show();
|
||||
$('#alerttext').html("Geen titel of inhoud; vul a.u.b. in.");
|
||||
window.scrollTo(0,0);
|
||||
} else if (data == "logged out") {
|
||||
window.location.href = "login.php?url=" + window.location.pathname;
|
||||
} else if (data == "frozen") {
|
||||
alert("Je account is bevroren, dus je kan geen posts plaatsen. Contacteer een admin als je denkt dat dit onjuist is.");
|
||||
} else {
|
||||
$('#alertbox').hide();
|
||||
masonry(masonryMode);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -98,6 +120,10 @@ function masonry(mode) {
|
||||
masonryMode = mode;
|
||||
$container.children().remove();
|
||||
|
||||
// reinit posts
|
||||
noposts = false;
|
||||
postAmount = 0;
|
||||
|
||||
/*
|
||||
* Initialise columns.
|
||||
*/
|
||||
@@ -120,7 +146,7 @@ function masonry(mode) {
|
||||
|
||||
$form.append($("<input class=\"newpost\" name=\"title\" placeholder=\"Titel\" type=\"text\">"));
|
||||
$form.append($("<textarea class=\"newpost\" name=\"content\" placeholder=\"Schrijf een berichtje...\" maxlength='1000'></textarea><span></span>"));
|
||||
$form.append($("<input value=\"Plaats!\" type=\"submit\">"));
|
||||
$form.append($("<button type=\"submit\"><i class='fa fa-sticky-note-o'></i> Plaats!</button>"));
|
||||
columns[0][1].append($postInput);
|
||||
|
||||
columns[0][0] = $postInput.height() + margin;
|
||||
@@ -153,9 +179,6 @@ function loadMorePosts(uID, gID, offset, limit) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(uID, gID, offset, limit);
|
||||
|
||||
|
||||
$.post("API/getPosts.php", { usr : uID,
|
||||
grp : gID,
|
||||
offset : offset,
|
||||
|
||||
@@ -8,6 +8,8 @@ function postComment(buttonValue) {
|
||||
).done(function (response) {
|
||||
if (response == "frozen") {
|
||||
alert("Je account is bevroren, dus je kan geen comments plaatsen of \"niet slechten\". Contacteer een admin als je denkt dat dit onjuist is.");
|
||||
} else if (response == "logged out") {
|
||||
window.location.href = "login.php?url=" + window.location.pathname;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -30,6 +32,8 @@ function deletePost(postID) {
|
||||
).done(function (response) {
|
||||
if (response == "frozen") {
|
||||
alert("Je account is bevroren, dus je kan geen posts verwijderen. Contacteer een admin als je denkt dat dit onjuist is.");
|
||||
} else if (response == "logged out") {
|
||||
window.location.href = "login.php?url=" + window.location.pathname;
|
||||
}
|
||||
});
|
||||
closeModal();
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -25,9 +25,15 @@ if(empty($_GET["username"])) {
|
||||
$userID = getUserID($_GET["username"]);
|
||||
}
|
||||
|
||||
$user = selectUser($_SESSION["userID"], $userID);
|
||||
if(!$user = selectUser($_SESSION["userID"], $userID)) {
|
||||
header("HTTP/1.0 404 Not Found");
|
||||
header("Location: error/404.php");
|
||||
die();
|
||||
}
|
||||
|
||||
$profile_friends = selectAllFriends($userID);
|
||||
$profile_groups = selectAllUserGroups($userID);
|
||||
$showProfile = $user["showProfile"] || ($user["status"] == 'confirmed') || $_SESSION["userID"] == $userID;
|
||||
|
||||
|
||||
if ($userID == $_SESSION["userID"]) {
|
||||
|
||||
@@ -18,7 +18,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
try {
|
||||
switch ($_POST["form"]) {
|
||||
case "profile":
|
||||
updateSettings();
|
||||
checkUpdateSettings();
|
||||
break;
|
||||
case "password":
|
||||
changePassword();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,8 +256,6 @@ div[data-title]:hover:after {
|
||||
top: 150%;
|
||||
z-index: 200;
|
||||
white-space: nowrap;
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
|
||||
background-color: #333;
|
||||
@@ -291,19 +288,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;
|
||||
|
||||
@@ -48,6 +48,10 @@
|
||||
width: 90%;
|
||||
}
|
||||
|
||||
.post-content a {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.commentfield {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
@@ -87,17 +91,5 @@
|
||||
|
||||
.deleteButton {
|
||||
background-color: firebrick;
|
||||
|
||||
}
|
||||
|
||||
.deleteButton i {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.deleteButton:hover span {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.deleteButton span {
|
||||
display: none;
|
||||
float: right;
|
||||
}
|
||||
@@ -1,5 +1,14 @@
|
||||
/* New */
|
||||
|
||||
.alertbox {
|
||||
display: none;
|
||||
background-color: firebrick;
|
||||
}
|
||||
|
||||
.alerttext {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.user-box {
|
||||
text-align: center;
|
||||
}
|
||||
@@ -11,21 +20,29 @@
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.friend-button-container {
|
||||
.friend-button-container, .group-button-container {
|
||||
position: relative;
|
||||
float: right;
|
||||
width: 200px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.friend-button-container div, .status-buttons-container div {
|
||||
width: 200px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.friend-button-container button, .status-buttons-container button, .group-button-container button {
|
||||
display: block;
|
||||
float: right;
|
||||
|
||||
margin: 7px 0;
|
||||
width: 200px;
|
||||
|
||||
font-size: 18px;
|
||||
}
|
||||
.status-buttons-container button {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.group-button-container button {
|
||||
float: right;
|
||||
@@ -62,10 +79,24 @@
|
||||
|
||||
.group-picture {
|
||||
border: none;
|
||||
margin-bottom: 0;
|
||||
margin-right: 15px;
|
||||
}
|
||||
|
||||
.fancy-button span {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.fancy-button:hover {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.fancy-button i {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.fancy-button:hover span {
|
||||
display: inline-block;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
/* Old */
|
||||
|
||||
@@ -90,6 +121,10 @@ div.posts div.post {
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
div.posts div.post a {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
div.posts div.post:hover {
|
||||
box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
|
||||
}
|
||||
@@ -108,7 +143,7 @@ div.posts .post form input, div.posts .post form textarea {
|
||||
width: calc(100% - 15px);
|
||||
}
|
||||
|
||||
div.posts .post form input[type="submit"] {
|
||||
div.posts .post form input[type="submit"], .post button{
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
37
website/queries/createGroup.php
Normal file
37
website/queries/createGroup.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
require_once "../queries/checkInput.php";
|
||||
require_once "../queries/picture.php";
|
||||
require_once "../queries/alerts.php";
|
||||
function createGroup()
|
||||
{
|
||||
$createGroup = prepareQuery("
|
||||
INSERT INTO
|
||||
`group_page` (`name`, `description`)
|
||||
VALUES (:name, :description);
|
||||
");
|
||||
$createGroup->bindValue(':name', test_input($_POST["groupName"]), PDO::PARAM_STR);
|
||||
$createGroup->bindValue(':description', test_input($_POST["bio"]));
|
||||
$createGroup->execute();
|
||||
|
||||
$getGroupID = prepareQuery("
|
||||
SELECT
|
||||
`groupID`
|
||||
FROM
|
||||
`group_page`
|
||||
WHERE
|
||||
`name` LIKE :name");
|
||||
$getGroupID->bindValue(':name', test_input($_POST["groupName"]), PDO::PARAM_STR);
|
||||
$getGroupID->execute();
|
||||
$groupID = $getGroupID->fetch()["groupID"];
|
||||
|
||||
$makeUserAdmin = prepareQuery("
|
||||
INSERT INTO
|
||||
`group_member` (userID, groupID, role)
|
||||
VALUES (:userID, :groupID, 'admin')
|
||||
");
|
||||
$makeUserAdmin->bindValue(":userID", $_SESSION["userID"]);
|
||||
$makeUserAdmin->bindValue("groupID", $groupID);
|
||||
$makeUserAdmin->execute();
|
||||
|
||||
updateAvatar($groupID);
|
||||
}
|
||||
@@ -10,13 +10,14 @@ function selectLimitedFriends($userID, $limit) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
`userID`,
|
||||
LEFT(`username`, 12) as `usernameshort`,
|
||||
`username`,
|
||||
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `fullname`,
|
||||
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`,
|
||||
IFNULL(
|
||||
`profilepicture`,
|
||||
'../img/avatar-standard.png'
|
||||
) AS profilepicture,
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
|
||||
WHEN TRUE THEN 'online'
|
||||
WHEN FALSE THEN 'offline'
|
||||
END AS `onlinestatus`,
|
||||
@@ -50,13 +51,14 @@ function selectAllFriends($userID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
`userID`,
|
||||
LEFT(`username`, 12) as `usernameshort`,
|
||||
`username`,
|
||||
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `fullname`,
|
||||
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`,
|
||||
IFNULL(
|
||||
`profilepicture`,
|
||||
'../img/avatar-standard.png'
|
||||
) AS profilepicture,
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
|
||||
WHEN TRUE THEN 'online'
|
||||
WHEN FALSE THEN 'offline'
|
||||
END AS `onlinestatus`,
|
||||
@@ -85,13 +87,14 @@ function selectAllFriendRequests() {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
`userID`,
|
||||
LEFT(`username`, 12) as `usernameshort`,
|
||||
`username`,
|
||||
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `fullname`,
|
||||
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`,
|
||||
IFNULL(
|
||||
`profilepicture`,
|
||||
'../img/avatar-standard.png'
|
||||
) AS profilepicture,
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
|
||||
WHEN TRUE THEN 'online'
|
||||
WHEN FALSE THEN 'offline'
|
||||
END AS `onlinestatus`,
|
||||
@@ -235,13 +238,14 @@ function searchSomeFriends($n, $m, $search) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
`userID`,
|
||||
LEFT(`username`, 12) as `usernameshort`,
|
||||
`username`,
|
||||
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `fullname`,
|
||||
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`,
|
||||
IFNULL(
|
||||
`profilepicture`,
|
||||
'../img/avatar-standard.png'
|
||||
) AS profilepicture,
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
|
||||
WHEN TRUE THEN 'online'
|
||||
WHEN FALSE THEN 'offline'
|
||||
END AS `onlinestatus`,
|
||||
@@ -276,3 +280,34 @@ function searchSomeFriends($n, $m, $search) {
|
||||
$stmt->execute();
|
||||
return json_encode($stmt->fetchAll());
|
||||
}
|
||||
|
||||
function countSomeFriends($search) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
COUNT(*)
|
||||
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`
|
||||
");
|
||||
|
||||
$search = "%$search%";
|
||||
$stmt->bindParam(':keyword', $search);
|
||||
$stmt->bindParam(':userID', $_SESSION["userID"], PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
return $stmt->fetchColumn();
|
||||
}
|
||||
109
website/queries/groupAdmin.php
Normal file
109
website/queries/groupAdmin.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
function getGroupSettings(int $groupID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
`name`,
|
||||
`picture`,
|
||||
`description`
|
||||
FROM
|
||||
`group_page`
|
||||
WHERE
|
||||
`groupID` = :groupID
|
||||
");
|
||||
$stmt->bindParam(":groupID", $groupID);
|
||||
$stmt->execute();
|
||||
return $stmt->fetch();
|
||||
}
|
||||
|
||||
function updateGroupSettings(int $groupID)
|
||||
{
|
||||
if (!checkGroupAdmin($groupID, $_SESSION["userID"])) {
|
||||
throw new AngryAlert("Je hebt geen rechten in deze groep");
|
||||
}
|
||||
$stmt = prepareQuery("
|
||||
UPDATE
|
||||
`group_page`
|
||||
SET
|
||||
`name` = :name,
|
||||
`description` = :bio
|
||||
WHERE
|
||||
`groupID` = :groupID
|
||||
");
|
||||
$stmt->bindValue(":bio", test_input($_POST["bio"]));
|
||||
$stmt->bindValue(":name", test_input($_POST["name"]));
|
||||
$stmt->bindValue(":groupID", test_input($_POST["groupID"]));
|
||||
$stmt->execute();
|
||||
if ($stmt->rowCount()) {
|
||||
throw new HappyAlert("Groep aangepast!");
|
||||
} else {
|
||||
throw new AngryAlert("Er is iets mis gegaan");
|
||||
}
|
||||
}
|
||||
|
||||
function checkGroupAdmin(int $groupID, int $userID) : bool {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
`role`
|
||||
FROM
|
||||
`group_member`
|
||||
WHERE
|
||||
`groupID` = :groupID AND
|
||||
`userID` = :userID
|
||||
");
|
||||
$stmt->bindValue(":userID", $userID);
|
||||
$stmt->bindValue(":groupID", $groupID);
|
||||
$stmt->execute();
|
||||
if (!$stmt->rowCount()) {
|
||||
return false;
|
||||
}
|
||||
$role = $stmt->fetch()["role"];
|
||||
return ($role == "admin");
|
||||
}
|
||||
|
||||
function getAllGroupMembers(int $groupID) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
`username`,
|
||||
`user`.`userID`,
|
||||
CONCAT(`fname`, ' ', `lname`) AS `fullname`,
|
||||
`group_member`.`role`
|
||||
FROM
|
||||
`group_member`
|
||||
LEFT JOIN
|
||||
`user`
|
||||
ON
|
||||
`group_member`.`userID` = `user`.`userID`
|
||||
WHERE
|
||||
`groupID` = :groupID AND `group_member`.`role` = 'member'
|
||||
");
|
||||
|
||||
$stmt->bindParam(':groupID', $groupID);
|
||||
if (!$stmt->execute()) {
|
||||
return False;
|
||||
}
|
||||
return $stmt->fetchAll();
|
||||
}
|
||||
|
||||
function upgradeUser(int $groupID, int $userID, string $role) {
|
||||
if (!checkGroupAdmin($groupID, $_SESSION["userID"])) {
|
||||
throw new AngryAlert("Geen toestemming om te wijzigen");
|
||||
}
|
||||
|
||||
$stmt = prepareQuery("
|
||||
UPDATE
|
||||
`group_member`
|
||||
SET
|
||||
`role` = :role
|
||||
WHERE
|
||||
`userID` = :userID AND `groupID` = :groupID
|
||||
");
|
||||
$stmt->bindValue(":groupID", $groupID);
|
||||
$stmt->bindValue(":userID", $userID);
|
||||
$stmt->bindValue(":role", $role);
|
||||
$stmt->execute();
|
||||
if ($stmt->rowCount()) {
|
||||
throw new HappyAlert("Permissie aangepast!");
|
||||
} else {
|
||||
throw new AngryAlert("Er is iets mis gegaan");
|
||||
}
|
||||
}
|
||||
@@ -55,6 +55,29 @@ function searchSomeOwnGroups($n, $m, $search) {
|
||||
return json_encode($stmt->fetchAll());
|
||||
}
|
||||
|
||||
function countSomeOwnGroups($search) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
COUNT(*)
|
||||
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
|
||||
");
|
||||
|
||||
$search = "%$search%";
|
||||
$stmt->bindParam(':keyword', $search);
|
||||
$stmt->bindParam(':userID', $_SESSION["userID"], PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
|
||||
return $stmt->fetchColumn();
|
||||
}
|
||||
|
||||
function addMember($groupID, $userID, $role) {
|
||||
$stmt = prepareQuery("
|
||||
INSERT INTO
|
||||
|
||||
@@ -33,7 +33,12 @@ function selectGroupByName($name) {
|
||||
if (!$stmt->execute()) {
|
||||
return False;
|
||||
}
|
||||
return $stmt->fetch();
|
||||
$row = $stmt->fetch();
|
||||
if($row["groupID"] == null) {
|
||||
return False;
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
function selectGroupRole(int $groupID) {
|
||||
@@ -81,7 +86,10 @@ function selectGroupMembers(int $groupID) {
|
||||
`username`,
|
||||
`fname`,
|
||||
`lname`,
|
||||
`profilepicture`
|
||||
IFNULL(
|
||||
`profilepicture`,
|
||||
'../img/avatar-standard.png'
|
||||
) AS profilepicture
|
||||
FROM
|
||||
`group_member`
|
||||
LEFT JOIN
|
||||
|
||||
@@ -6,7 +6,10 @@
|
||||
* @throws AngryAlert
|
||||
* @throws HappyAlert
|
||||
*/
|
||||
function updateAvatar(bool $group = false) {
|
||||
function updateAvatar(int $group = 0) {
|
||||
if (!array_key_exists("pp", $_FILES)) {
|
||||
throw new AngryAlert("Geen afbeelding meegegeven!");
|
||||
}
|
||||
$publicDir = "/var/www/html/public/";
|
||||
$tmpImg = $_FILES["pp"]["tmp_name"];
|
||||
$avatarDir = $group ? "uploads/groupavatar/" : "uploads/profilepictures/";
|
||||
@@ -16,17 +19,17 @@ function updateAvatar(bool $group = false) {
|
||||
if ($_FILES["pp"]["size"] > 4000000) {
|
||||
throw new AngryAlert("Bestand is te groot, maximaal 4MB toegestaan.");
|
||||
}
|
||||
$relativePath = $avatarDir . $_SESSION["userID"] . "_avatar.gif";
|
||||
$group ? removeOldGroupAvatar($_POST["groupID"]) : removeOldUserAvatar();
|
||||
$relativePath = $group ? $avatarDir . $group . "_avatar.gif" : $avatarDir . $_SESSION["userID"] . "_avatar.gif";
|
||||
$group ? removeOldGroupAvatar($group) : removeOldUserAvatar();
|
||||
move_uploaded_file($tmpImg, $publicDir . $relativePath);
|
||||
} else {
|
||||
$relativePath = $avatarDir . $_SESSION["userID"] . "_avatar.png";
|
||||
$relativePath = $group ? $avatarDir . $group . "_avatar.png": $avatarDir . $_SESSION["userID"] . "_avatar.png";
|
||||
$scaledImg = scaleAvatar($tmpImg);
|
||||
$group ? removeOldGroupAvatar($_POST["groupID"]) : removeOldUserAvatar();
|
||||
$group ? removeOldGroupAvatar($group) : removeOldUserAvatar();
|
||||
imagepng($scaledImg, $publicDir . $relativePath);
|
||||
}
|
||||
|
||||
$group ? setGroupAvatarToDatabase("../" . $relativePath, $_POST["groupID"]) : setUserAvatarToDatabase("../" . $relativePath);
|
||||
$group ? setGroupAvatarToDatabase("../" . $relativePath, $group) : setUserAvatarToDatabase("../" . $relativePath);
|
||||
throw new HappyAlert("Profielfoto veranderd.");
|
||||
}
|
||||
|
||||
|
||||
@@ -6,18 +6,23 @@ function getOldChatMessages($user2ID) {
|
||||
if (getFriendshipStatus($user2ID) == 1) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
*
|
||||
*
|
||||
FROM
|
||||
`private_message`
|
||||
WHERE
|
||||
`origin` = :user1 AND
|
||||
`destination` = :user2 OR
|
||||
`origin` = :user2 AND
|
||||
`destination` = :user1
|
||||
(SELECT
|
||||
*
|
||||
FROM
|
||||
`private_message`
|
||||
WHERE
|
||||
`origin` = :user1 AND
|
||||
`destination` = :user2 OR
|
||||
`origin` = :user2 AND
|
||||
`destination` = :user1
|
||||
ORDER BY
|
||||
`messageID` DESC
|
||||
LIMIT
|
||||
100) sub
|
||||
ORDER BY
|
||||
`creationdate` ASC
|
||||
LIMIT
|
||||
100
|
||||
`messageID` ASC
|
||||
");
|
||||
|
||||
$stmt->bindParam(":user1", $user1ID);
|
||||
@@ -76,7 +81,7 @@ function getNewChatMessages($lastID, $destination) {
|
||||
`destination` = :user1) AND
|
||||
`messageID` > :lastID
|
||||
ORDER BY
|
||||
`creationdate` ASC
|
||||
`messageID` ASC
|
||||
");
|
||||
|
||||
$stmt->bindParam(':user1', $_SESSION["userID"]);
|
||||
@@ -95,7 +100,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`,
|
||||
|
||||
@@ -50,6 +50,15 @@ function getPasswordHash() {
|
||||
return $stmt->fetch();
|
||||
}
|
||||
|
||||
function checkUpdateSettings() {
|
||||
if (empty(test_input($_POST['fname'])) || empty(test_input($_POST['lname']))) {
|
||||
throw new AngryAlert("Geen voornaam of achternaam.");
|
||||
return;
|
||||
}
|
||||
|
||||
updateSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the setting from post.
|
||||
* @throws HappyAlert
|
||||
@@ -139,6 +148,10 @@ function doChangePassword() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the users email if it is valid.
|
||||
* @throws AngryAlert
|
||||
*/
|
||||
function changeEmail() {
|
||||
|
||||
if (test_input($_POST["email"]) == test_input($_POST["email-confirm"])) {
|
||||
@@ -155,6 +168,11 @@ function changeEmail() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if an emailadres is available in the database.
|
||||
* @param $email
|
||||
* @throws AngryAlert
|
||||
*/
|
||||
function emailIsAvailableInDatabase($email) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
@@ -172,6 +190,12 @@ function emailIsAvailableInDatabase($email) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the actual changing of an email-adress.
|
||||
* @param $email
|
||||
* @throws AngryAlert
|
||||
* @throws HappyAlert
|
||||
*/
|
||||
function doChangeEmail($email) {
|
||||
$stmt = prepareQuery("
|
||||
UPDATE
|
||||
|
||||
@@ -52,19 +52,27 @@ function selectUser($me, $other) {
|
||||
`username`,
|
||||
`birthdate`,
|
||||
`location`,
|
||||
`showBday`,
|
||||
`showEmail`,
|
||||
`showProfile`,
|
||||
`email`,
|
||||
IFNULL(
|
||||
`profilepicture`,
|
||||
'../img/avatar-standard.png'
|
||||
) AS profilepicture,
|
||||
`bio`,
|
||||
`user`.`creationdate`,
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
|
||||
WHEN TRUE THEN 'online'
|
||||
WHEN FALSE THEN 'offline'
|
||||
END AS `onlinestatus`,
|
||||
`role`,
|
||||
`fname`,
|
||||
`lname`,
|
||||
`showBday`,
|
||||
`showEmail`,
|
||||
`showProfile`,
|
||||
`status`,
|
||||
CASE `status` IS NULL
|
||||
WHEN TRUE THEN 0
|
||||
WHEN FALSE THEN
|
||||
@@ -93,7 +101,9 @@ function selectUser($me, $other) {
|
||||
|
||||
$stmt->bindParam(':me', $me, PDO::PARAM_INT);
|
||||
$stmt->bindParam(':other', $other, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
if(!$stmt->execute() || $stmt->rowCount() == 0) {
|
||||
return False;
|
||||
}
|
||||
return $stmt->fetch();
|
||||
}
|
||||
|
||||
@@ -112,7 +122,7 @@ function selectAllUserGroups($userID) {
|
||||
`group_page`.`groupID` = `group_member`.`groupID`
|
||||
WHERE
|
||||
`userID` = :userID AND
|
||||
`role` = 'member'
|
||||
`role` IN ('member', 'mod', 'admin')
|
||||
");
|
||||
|
||||
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
|
||||
@@ -127,7 +137,7 @@ function select20UsersFromN($n) {
|
||||
`username`,
|
||||
`role`,
|
||||
`bancomment`,
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
|
||||
WHEN TRUE THEN 'online'
|
||||
WHEN FALSE THEN 'offline'
|
||||
END AS `onlinestatus`
|
||||
@@ -152,7 +162,7 @@ function search20UsersFromN($n, $keyword) {
|
||||
`username`,
|
||||
`role`,
|
||||
`bancomment`,
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
|
||||
WHEN TRUE THEN 'online'
|
||||
WHEN FALSE THEN 'offline'
|
||||
END AS `onlinestatus`
|
||||
@@ -180,7 +190,7 @@ function search20UsersFromNByStatus($n, $keyword, $status) {
|
||||
`username`,
|
||||
`role`,
|
||||
`bancomment`,
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
|
||||
WHEN TRUE THEN 'online'
|
||||
WHEN FALSE THEN 'offline'
|
||||
END AS `onlinestatus`
|
||||
@@ -214,7 +224,7 @@ function searchSomeUsersByStatus($n, $m, $search, $status) {
|
||||
`username`,
|
||||
`role`,
|
||||
`bancomment`,
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
|
||||
WHEN TRUE THEN 'online'
|
||||
WHEN FALSE THEN 'offline'
|
||||
END AS `onlinestatus`
|
||||
@@ -351,13 +361,14 @@ function searchSomeUsers($n, $m, $search) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
`userID`,
|
||||
LEFT(`username`, 12) as `usernameshort`,
|
||||
`username`,
|
||||
IFNULL(
|
||||
`profilepicture`,
|
||||
'../img/avatar-standard.png'
|
||||
) AS profilepicture,
|
||||
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 15) as `fullname`,
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
|
||||
LEFT(CONCAT(`user`.`fname`, ' ', `user`.`lname`), 12) as `fullname`,
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 5 MINUTE)
|
||||
WHEN TRUE THEN 'online'
|
||||
WHEN FALSE THEN 'offline'
|
||||
END AS `onlinestatus`
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<tr>
|
||||
<th><input class="table-checkbox" type="checkbox" id="checkall" name="checkall" onchange="checkAll(this)"></th>
|
||||
<th class="table-username">Gebruikersnaam</th>
|
||||
<th class="table-username">Groepsnaam</th>
|
||||
<th class="table-status">Status</th>
|
||||
<th class="table-comment">Aantekening</th>
|
||||
<th class="table-comment">Beschrijving</th>
|
||||
<th class="table-action">Actie</th>
|
||||
</tr>
|
||||
|
||||
@@ -33,9 +33,9 @@ while ($group = $q->fetch(PDO::FETCH_ASSOC)) {
|
||||
<form class='admin-groupaction'
|
||||
onsubmit=\"adminUpdate(this); return false;\">
|
||||
<select class='action' name='actions'>
|
||||
<option value='hidden'>Hidden</option>
|
||||
<option value='public'>Public</option>
|
||||
<option value='membersonly'>Members</option>
|
||||
<option value='hidden'>Verborgen</option>
|
||||
<option value='public'>Publiek</option>
|
||||
<option value='membersonly'>Alleen Leden</option>
|
||||
</select>
|
||||
<input type='hidden' name='groupID' value='$groupID'>
|
||||
<input type='submit' value='Confirm'>
|
||||
|
||||
@@ -55,7 +55,8 @@ while($user = $q->fetch(PDO::FETCH_ASSOC)) {
|
||||
OR $user['role'] == 'owner'))) {
|
||||
echo "<option value='frozen'>Bevries</option>
|
||||
<option value='banned'>Ban</option>
|
||||
<option value='user'>Activeer</option>";
|
||||
<option value='user'>Activeer</option>
|
||||
<option value='unconfirmed'>Ongevalideerd</option>";
|
||||
|
||||
if ($userinfo == 'owner') {
|
||||
echo "<option value='admin'>Admin</option>
|
||||
|
||||
@@ -67,13 +67,13 @@ if (isset($_GET["groupstatus"])) {
|
||||
id="frozen"
|
||||
value="frozen"
|
||||
<?php if (in_array("frozen", $status)) echo "checked";?>>
|
||||
<label for="frozen">Gefrozen</label><br>
|
||||
<label for="frozen">Bevroren</label><br>
|
||||
<input type="checkbox"
|
||||
name="status[]"
|
||||
id="banned"
|
||||
value="banned"
|
||||
<?php if (in_array("banned", $status)) echo "checked";?>>
|
||||
<label for="banned">Gebant</label><br>
|
||||
<label for="banned">Verbannen</label><br>
|
||||
<input type="checkbox"
|
||||
name="status[]"
|
||||
id="admin"
|
||||
@@ -91,7 +91,7 @@ if (isset($_GET["groupstatus"])) {
|
||||
id="owner"
|
||||
value="owner"
|
||||
<?php if (in_array("owner", $status)) echo "checked";?>>
|
||||
<label for="owner">Owner</label>
|
||||
<label for="owner">Eigenaar</label>
|
||||
</div>
|
||||
|
||||
<div id="admin-groupfilter">
|
||||
@@ -122,6 +122,7 @@ if (isset($_GET["groupstatus"])) {
|
||||
<button type="submit" name="batchactions" id="freeze" value="frozen">Bevries</button>
|
||||
<button type="submit" name="batchactions" id="ban" value="banned">Ban</button>
|
||||
<button type="submit" name="batchactions" id="restore" value="user">Activeer</button>
|
||||
<button type="submit" name="batchactions" id="unconfirm" value="unconfirmed">Maak Ongevalideerd</button>
|
||||
<?php
|
||||
if ($userinfo == 'owner') {
|
||||
echo "<button type=\"submit\"
|
||||
@@ -131,7 +132,7 @@ if (isset($_GET["groupstatus"])) {
|
||||
<button type=\"submit\"
|
||||
name=\"batchactions\"
|
||||
id=\"owner\"
|
||||
value=\"owner\">Maak Owner</button>";
|
||||
value=\"owner\">Maak Eigenaar</button>";
|
||||
}
|
||||
?>
|
||||
</form>
|
||||
@@ -139,9 +140,9 @@ if (isset($_GET["groupstatus"])) {
|
||||
onsubmit="adminUpdate(this); return false;">
|
||||
|
||||
<input type="hidden" name="groupbatchactions" id="groupbatchinput">
|
||||
<button type="submit" name="batchactions" id="hide" value="hidden">Hide</button>
|
||||
<button type="submit" name="batchactions" id="ban" value="public">Public</button>
|
||||
<button type="submit" name="batchactions" id="members" value="membersonly">Members</button>
|
||||
<button type="submit" name="batchactions" id="hide" value="hidden">Verborgen</button>
|
||||
<button type="submit" name="batchactions" id="ban" value="public">Publiek</button>
|
||||
<button type="submit" name="batchactions" id="members" value="membersonly">Alleen Leden</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
42
website/views/createGroup.php
Normal file
42
website/views/createGroup.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
?>
|
||||
|
||||
<div class="content">
|
||||
<div class="createGroup">
|
||||
<form class="platform settings" method="post" action="createGroup.php" enctype="multipart/form-data">
|
||||
<h5>Maak een groep!</h5>
|
||||
<ul>
|
||||
<li>
|
||||
<label for="groupName">Groepsnaam</label>
|
||||
<input type="text"
|
||||
name="groupName"
|
||||
id="groupName"
|
||||
maxlength="63"
|
||||
placeholder="Groepsnaam"
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<label for="bio">Bio</label>
|
||||
<textarea name="bio"
|
||||
rows="5"
|
||||
title="bio"
|
||||
id="bio"
|
||||
maxlength="1000"
|
||||
></textarea>
|
||||
</li>
|
||||
<li>
|
||||
<label>Selecteer foto</label>
|
||||
<input type="file"
|
||||
name="pp"
|
||||
accept="image/*"
|
||||
size="4000000"
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<label></label>
|
||||
<button type="submit">Maak Groep</button>
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,12 +1,17 @@
|
||||
<div class="content">
|
||||
<div class="profile-box platform">
|
||||
<img class="left main-picture group-picture" src="<?= $group['picture'] ?>">
|
||||
<div class="group-button-container"></div>
|
||||
<h1 class="profile-username"><?= $group['name'] ?></h1>
|
||||
<p><?= $group['description'] ?></p>
|
||||
|
||||
<div class="user-box">
|
||||
<img alt="<?= $group["name"] ?>" class="group-picture main-picture" src="<?= $group["picture"] ?>"><br />
|
||||
<div class="platform">
|
||||
<div class="status-buttons-container">
|
||||
<button disabled class="gray"><?= $group["status"] ?></button>
|
||||
</div>
|
||||
<div class="group-button-container"></div>
|
||||
<div class="profile-info">
|
||||
<h2><?= $group["name"]?></h2>
|
||||
<?= $group["description"] ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="item-box-full-width platform">
|
||||
<h2>Leden (<?= $group['members'] ?>)</h2>
|
||||
<p>
|
||||
@@ -22,6 +27,10 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div class="noposts platform">
|
||||
<p>Geen posts meer!</p>
|
||||
</div>
|
||||
|
||||
<div class="modal">
|
||||
<div class="modal-content platform">
|
||||
<div class="modal-close">
|
||||
|
||||
126
website/views/groupAdmin.php
Normal file
126
website/views/groupAdmin.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
require_once "../queries/connect.php";
|
||||
require_once "../queries/groupAdmin.php";
|
||||
require_once "../queries/checkInput.php";
|
||||
$groupinfo = getGroupSettings($_GET["groupID"]);
|
||||
?>
|
||||
<div class="content">
|
||||
<div class="settings">
|
||||
<?php if ($_SERVER["REQUEST_METHOD"] == "POST"): ?>
|
||||
<div class='platform settings-message <?=$alertClass?>'>
|
||||
<?=$alertMessage?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="platform">
|
||||
<ul>
|
||||
<li>
|
||||
<label></label>
|
||||
<a href="group.php?groupname=<?=$groupinfo["name"]?>">
|
||||
<button class="fa fa-chevron-left"> Terug naar de groep</button>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<form class="platform" method="post">
|
||||
<h5>Groep Instellingen</h5>
|
||||
<input type="hidden" name="groupID" value="<?=$_GET["groupID"]?>">
|
||||
<ul>
|
||||
<li>
|
||||
<label for="name">Groepsnaam</label>
|
||||
<input type="text"
|
||||
name="name"
|
||||
id="name"
|
||||
maxlength="63"
|
||||
placeholder="Groepsnaam"
|
||||
title="Groepsnaam"
|
||||
value="<?=$groupinfo["name"]?>"
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<label for="bio">Bio</label>
|
||||
<textarea name="bio"
|
||||
rows="5"
|
||||
title="bio"
|
||||
id="bio"
|
||||
maxlength="1000"
|
||||
><?=$groupinfo["description"]?></textarea>
|
||||
<label></label>
|
||||
</li>
|
||||
<li>
|
||||
<label></label>
|
||||
<button type="submit"
|
||||
name="form"
|
||||
value="group"
|
||||
class="fa fa-save"
|
||||
> Opslaan</button>
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
<form class="platform" method="post" enctype="multipart/form-data">
|
||||
<h5>Verander groepsafbeelding.</h5>
|
||||
<input type="hidden" name="groupID" value="<?=$_GET["groupID"]?>">
|
||||
<ul>
|
||||
<li>
|
||||
<label>Huidige profielfoto</label>
|
||||
<img src="<?=$groupinfo["picture"]?>"
|
||||
class="group-picture"
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<label>Selecteer foto</label>
|
||||
<input type="file"
|
||||
name="pp"
|
||||
accept="image/*"
|
||||
size="4000000"
|
||||
required
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<label></label>
|
||||
<button type="submit"
|
||||
name="form"
|
||||
value="picture"
|
||||
class="fa fa-picture-o"
|
||||
> Verander profielfoto</button>
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
<form class="platform" method="post">
|
||||
<h5>Voeg een admin/mod toe</h5>
|
||||
<ul>
|
||||
<il>
|
||||
<input name="groupID" value="<?=$_GET["groupID"]?>" type="hidden">
|
||||
<label>Selecteer gebruiker</label>
|
||||
<select name="userID">
|
||||
<option disabled selected>Geen gebruiker geselecteerd:</option>
|
||||
<?php
|
||||
$groupMembers = getAllGroupMembers($_GET["groupID"]);
|
||||
foreach ($groupMembers as $groupMember) {?>
|
||||
<option value="<?=$groupMember["userID"]?>">
|
||||
<?=$groupMember["fullname"]?> (<?=$groupMember["username"]?>)
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<button name="form"
|
||||
value="admin"
|
||||
>
|
||||
Maak Admin
|
||||
</button>
|
||||
<button name="form"
|
||||
value="mod"
|
||||
>
|
||||
Maak Moderator
|
||||
</button>
|
||||
</il>
|
||||
</ul>
|
||||
</form>
|
||||
<div class="platform">
|
||||
<ul>
|
||||
<li>
|
||||
<label></label>
|
||||
<a href="group.php?groupname=<?=$groupinfo["name"]?>"><button class="fa fa-chevron-left"> Terug naar de groep</button></a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,4 +1,7 @@
|
||||
<meta charset="utf-8">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="description" content="MyHyvesbook+ is het sociaal medium voor alle coole mensen. Stap nu over van facebook op het gloednieuwe en betere sociaal medium.">
|
||||
<meta name="keywords" content="MyHyvesbookPlus,Myhyvesbook+,sociaal,media">
|
||||
<meta name="author" content="MyHyvesbookplus corporation">
|
||||
<title>MyHyvesbook+</title>
|
||||
<!-- Add your javascript files here. -->
|
||||
<script src="js/jquery.js"></script>
|
||||
@@ -23,8 +26,8 @@ require_once ("../queries/user.php");
|
||||
|
||||
session_start();
|
||||
|
||||
if(!isset($_SESSION["userID"])){
|
||||
header("location:login.php");
|
||||
if(!isset($_SESSION["userID"])) {
|
||||
header("location:login.php?url=" . "$_SERVER[REQUEST_URI]");
|
||||
} else {
|
||||
updateLastActivity();
|
||||
}
|
||||
|
||||
@@ -23,9 +23,9 @@ $userinfo = getHeaderInfo();
|
||||
<div id="hello-loop">
|
||||
Hallo
|
||||
</div>
|
||||
<?=$userinfo["fname"]?>
|
||||
<?= $userinfo["fname"] ?>
|
||||
</div>
|
||||
<img id="own-profile-picture" class="profile-picture" src="<?=$userinfo["profilepicture"]?>"/><i id="open-notifications" class="fa fa-bars"></i>
|
||||
<img alt="<?= $userinfo["lname"] ?>" id="own-profile-picture" class="profile-picture" src="<?=$userinfo["profilepicture"]?>"/><i id="open-notifications" class="fa fa-bars"></i>
|
||||
</div>
|
||||
</header>
|
||||
<?php include("notification-center.php"); ?>
|
||||
|
||||
@@ -29,6 +29,7 @@ $user = $psw = $remember ="";
|
||||
$loginErr = $resetErr = $fbRegisterErr ="";
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
$url = $_POST["url"];
|
||||
// Checks for which button is pressed
|
||||
switch ($_POST["submit"]) {
|
||||
case "login":
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="description" content="MyHyvesbook+ is het sociaal medium voor alle coole mensen. Stap nu over van facebook op het gloednieuwe en betere sociaal medium.">
|
||||
<meta name="keywords" content="MyHyvesbookPlus,Myhyvesbook+,sociaal,media">
|
||||
<meta name="author" content="MyHyvesbookplus corporation">
|
||||
<title>MyHyvesbook+</title>
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
|
||||
@@ -12,9 +12,11 @@
|
||||
</h4>
|
||||
<ul id="menu-groups-list" class="nav-list">
|
||||
</ul>
|
||||
</section>
|
||||
<section>
|
||||
<ul class="nav-list">
|
||||
<li>
|
||||
<a href="#">
|
||||
<a href="createGroup.php">
|
||||
Maak een groep aan
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
echo "<style>@import url('styles/adminbutton.css'); </style>";
|
||||
}
|
||||
?>
|
||||
<a href="logout.php" data-title="Admin"><i class="fa fa-sign-out"></i></a>
|
||||
<a href="logout.php" data-title="Uitloggen"><i class="fa fa-sign-out"></i></a>
|
||||
</section>
|
||||
<section id="friend-request-section">
|
||||
<h4>
|
||||
|
||||
@@ -5,14 +5,6 @@ $fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . "
|
||||
?>
|
||||
<div class='post-header header'>
|
||||
<h4><?=$post['title']?></h4>
|
||||
<?php if (checkPermissionOnPost($postID, $_SESSION["userID"])) {?>
|
||||
<button class="deleteButton"
|
||||
onclick="deletePost('<?=$postID?>')"
|
||||
type="submit">
|
||||
<i class="fa fa-trash"></i>
|
||||
<span>Verwijder post</span>
|
||||
</button><br />
|
||||
<?php } ?>
|
||||
<span class='postinfo'>
|
||||
gepost door <?=$fullname?>,
|
||||
<span class='posttime' title='<?=$post['creationdate']?>'>
|
||||
@@ -20,7 +12,14 @@ $fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . "
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<?php if (checkPermissionOnPost($postID, $_SESSION["userID"])) {?>
|
||||
<button class="deleteButton fancy-button"
|
||||
onclick="deletePost('<?=$postID?>')"
|
||||
type="submit">
|
||||
<span>Verwijder post</span>
|
||||
<i class="fa fa-trash"></i>
|
||||
</button><br />
|
||||
<?php } ?>
|
||||
<div class='post-content'>
|
||||
<p><?=$post['content']?></p>
|
||||
</div>
|
||||
@@ -30,7 +29,7 @@ $fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . "
|
||||
<form id="newcommentform" onsubmit="return false;">
|
||||
<input type="hidden" id="newcomment-textarea" name="postID" value="<?= $postID ?>">
|
||||
<textarea id="newcomment" name="newcomment-content" placeholder="Laat een reactie achter..." maxlength="1000"></textarea><span></span> <br>
|
||||
<button onclick="postComment('reaction')" name="button" value="reaction">Reageer!</button>
|
||||
<button onclick="postComment('reaction')" name="button" value="reaction" class="green"><i class="fa fa-comment"></i> Reageer!</button>
|
||||
<button onclick="postComment('nietslecht')" name="button" value="nietslecht" class="nietslecht">
|
||||
<?php
|
||||
if (checkNietSlecht($postID, $_SESSION["userID"])) {
|
||||
|
||||
@@ -1,12 +1,22 @@
|
||||
<div class="content">
|
||||
<div class='platform alertbox' id="alertbox">
|
||||
<span class="alerttext" id="alerttext"></span>
|
||||
</div>
|
||||
|
||||
<div class="user-box">
|
||||
<img class="profile-picture main-picture <?= $user["onlinestatus"] ?>" src="<?= $user["profilepicture"] ?>"><br />
|
||||
<img alt="<?= $user["fname"] ?>" class="profile-picture main-picture <?= $user["onlinestatus"] ?>" src="<?= $user["profilepicture"] ?>"><br />
|
||||
<div class="platform">
|
||||
<div class="status-buttons-container">
|
||||
<button disabled class="gray">
|
||||
<?= $user["onlinestatus"] ?>
|
||||
</button>
|
||||
<button disabled class="gray"><?= $user["role"] ?></button>
|
||||
<div>
|
||||
<button disabled class="gray">
|
||||
<?= $user["onlinestatus"] ?>
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<button disabled class="gray">
|
||||
<?= $user["role"] ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="friend-button-container">
|
||||
<p>:)</p>
|
||||
@@ -15,25 +25,30 @@
|
||||
<div class="profile-info">
|
||||
<h2><?= $user["fname"]?> <?=$user["lname"]?></h2>
|
||||
<h5><?=$user["username"]?></h5>
|
||||
<?php if (strlen($user["bio"]) <= 50) {
|
||||
<?php
|
||||
if (strlen($user["bio"]) <= 50 and $showProfile) {
|
||||
echo "<p>" . $user["bio"] . "</p>";
|
||||
} ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php if (strlen($user["bio"]) > 50) {
|
||||
<?php if (strlen($user["bio"]) > 50 and $showProfile) {
|
||||
echo "<div class='platform'><h3>Bio:</h3><p>" . $user["bio"] . "</p></div>";
|
||||
} ?>
|
||||
|
||||
<?php if($showProfile) { ?>
|
||||
<div class="item-box platform">
|
||||
<h3>Informatie</h3>
|
||||
<p>
|
||||
<ul>
|
||||
<li>Leeftijd: <?= getAge($user["birthdate"]) ?> jaar</li>
|
||||
<li>Locatie: <?= $user["location"] ?></li>
|
||||
<li>Lid sinds: <?= nicetime($user["creationdate"]) ?></li>
|
||||
</ul>
|
||||
</p>
|
||||
<ul>
|
||||
<?php if ($user["showBday"]) { ?>
|
||||
<li>Leeftijd: <?= getAge($user["birthdate"]) ?> jaar</li>
|
||||
<?php } ?>
|
||||
<?php if ($user["showEmail"]) { ?>
|
||||
<li>Email: <?= $user["email"] ?></li>
|
||||
<?php } ?>
|
||||
<li>Locatie: <?= $user["location"] ?></li>
|
||||
<li>Lid sinds: <?= nicetime($user["creationdate"]) ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="item-box platform">
|
||||
@@ -41,7 +56,7 @@
|
||||
<p>
|
||||
<?php
|
||||
while($friend = $profile_friends->fetch()) {
|
||||
echo "<a href='profile.php?username=${friend["username"]}' data-title='${friend["username"]}'><img class='profile-picture' src='${friend["profilepicture"]}' alt='${friend["username"]}'s profielfoto></a>";
|
||||
echo "<a href='profile.php?username=${friend["username"]}' data-title='${friend["username"]}'><img class='profile-picture' height='42' width='42' src='${friend["profilepicture"]}' alt='${friend["username"]}' /></a>";
|
||||
}
|
||||
|
||||
|
||||
@@ -85,4 +100,5 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
@@ -48,7 +48,12 @@ $group_n = ($group_currentpage - 1) * $group_perpage;
|
||||
<label for="filter">
|
||||
Filter:
|
||||
</label>
|
||||
<select name="filter" id="search-filter">
|
||||
<select name="filter"
|
||||
id="search-filter"
|
||||
onchange="$('#user-pagenumber, #group-pagenumber').prop('value', 1);
|
||||
searchUsers();
|
||||
searchGroups();
|
||||
pageNumber();">
|
||||
<option value="personal"
|
||||
<?php if ($filter == "personal") echo "selected";?>>
|
||||
Persoonlijk</option>
|
||||
|
||||
@@ -17,6 +17,7 @@ $settings = getSettings();
|
||||
<input type="text"
|
||||
name="fname"
|
||||
id="fname"
|
||||
maxlength="63"
|
||||
placeholder="Voornaam"
|
||||
title="Voornaam"
|
||||
value="<?=$settings["fname"]?>"
|
||||
@@ -27,6 +28,7 @@ $settings = getSettings();
|
||||
<input type="text"
|
||||
name="lname"
|
||||
id="lname"
|
||||
maxlength="63"
|
||||
placeholder="Achternaam"
|
||||
value="<?=$settings["lname"]?>"
|
||||
>
|
||||
@@ -36,14 +38,15 @@ $settings = getSettings();
|
||||
<input type="text"
|
||||
name="location"
|
||||
id="location"
|
||||
maxlength="50"
|
||||
placeholder="Locatie"
|
||||
value="<?=$settings["location"]?>"
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<?php $currentbday = new DateTime($settings["birthdate"]); ?>
|
||||
<label for="bday">Geboortedatum</label>
|
||||
<select name='day' id="bday">
|
||||
<label>Geboortedatum</label>
|
||||
<select name='day'>
|
||||
<?php for ($day = 1; $day <= 31; $day++): ?>
|
||||
<option value='<?=$day?>'
|
||||
<?=($day == $currentbday->format("d")) ? "selected" : ""?>
|
||||
@@ -52,7 +55,7 @@ $settings = getSettings();
|
||||
</option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
<select name='month' id="bday">
|
||||
<select name='month'>
|
||||
<?php
|
||||
$months = array ("januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus",
|
||||
"september", "oktober", "november", "december");
|
||||
@@ -65,7 +68,7 @@ $settings = getSettings();
|
||||
</option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
<select name='year' id="bday">
|
||||
<select name='year'>
|
||||
<?php
|
||||
$now = (new DateTime)->format("Y");
|
||||
for ($year = $now; $year >= 1900; $year--): ?>
|
||||
@@ -194,6 +197,7 @@ $settings = getSettings();
|
||||
<label for="email-old">Huidig Email </label>
|
||||
<input type="email"
|
||||
id="email-old"
|
||||
maxlength="255"
|
||||
value="<?=$settings["email"]?>"
|
||||
disabled
|
||||
>
|
||||
@@ -202,6 +206,7 @@ $settings = getSettings();
|
||||
<label for="email">Nieuw Email</label>
|
||||
<input type="email"
|
||||
name="email"
|
||||
maxlength="255"
|
||||
id="email"
|
||||
placeholder="Nieuw Email"
|
||||
>
|
||||
@@ -211,14 +216,16 @@ $settings = getSettings();
|
||||
<input type="email"
|
||||
name="email-confirm"
|
||||
id="email-confirm"
|
||||
maxlength="255"
|
||||
placeholder="Bevestig Email"
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<button type="submit"
|
||||
name="form"
|
||||
value="email"
|
||||
>Verander Email</button>
|
||||
value="email">
|
||||
Verander Email
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user