23 Commits

Author SHA1 Message Date
Lars van Hijfte
1ac6a7da87 Changed admin checkbox buttons 2017-02-03 12:40:33 +01:00
Lars van Hijfte
52ce787241 Merge remote-tracking branch 'origin/hendrik-testing' into lars 2017-02-03 12:34:19 +01:00
Lars van Hijfte
fb5f76c499 ? 2017-02-03 12:32:57 +01:00
Hendrik
f3aebddfea commentses 2017-02-03 12:21:37 +01:00
Lars van Hijfte
3aae884bb5 Added comments 2017-02-03 12:12:16 +01:00
Hendrik
b07d0712aa Merge branch 'marijn-groups' into hendrik-testing 2017-02-03 12:08:42 +01:00
Lars van Hijfte
1fd984cc02 Merge branch 'marijn-groups' into lars 2017-02-03 11:31:58 +01:00
Lars van Hijfte
16f83d93ce Merge branch 'lars' into 'master'
Lars

See merge request !206
2017-02-03 11:21:12 +01:00
Lars van Hijfte
306fd3090f Merge branch 'hendrik-testing' into 'master'
removed session id lol

See merge request !205
2017-02-03 11:20:24 +01:00
Hendrik
771567660c removed session id lol 2017-02-03 11:19:06 +01:00
Lars van Hijfte
4eae09dfc7 Merge branch 'master' into lars 2017-02-03 11:19:02 +01:00
Lars van Hijfte
53e1d7fef3 Fixed admin layout 2017-02-03 11:18:32 +01:00
Lars van Hijfte
c29be662bc Session logout now works 2017-02-03 11:18:17 +01:00
Lars van Hijfte
000d1f4072 Merge branch 'joey-testing' into 'master'
fixed login

See merge request !202
2017-02-03 11:16:48 +01:00
Lars van Hijfte
d260bf04bc Merge branch 'hendrik-testing' into 'master'
Hendrik testing

See merge request !204
2017-02-03 11:16:36 +01:00
Hendrik
a0ef234b79 Merge branch 'master' into hendrik-testing 2017-02-03 11:15:01 +01:00
Hendrik
da061de226 validated adminpanel, added shown friends limit in profile. 2017-02-03 11:14:03 +01:00
Marijn Jansen
f18088d8d2 Merge branch 'marijn-groups' into 'master'
Comments

See merge request !203
2017-02-03 11:13:46 +01:00
Joey Lai
ba6f86e70e fixed login 2017-02-03 11:12:30 +01:00
Hendrik
bb352c7a7a merge 2017-02-03 10:41:29 +01:00
Hendrik
0f202088a1 Merge branch 'master' into hendrik-testing 2017-02-03 10:40:44 +01:00
Hendrik
fde736b8c5 misc 2017-02-03 10:33:44 +01:00
Hendrik
afb45d6709 add closing of modal on escape key and clicking outside 2017-02-02 15:51:27 +01:00
24 changed files with 474 additions and 36 deletions

View File

@@ -13,7 +13,7 @@
include_once("../queries/group_page.php");
if(!$group = selectGroupByName($_GET["groupname"])) {
if(isset($_SESSION["userID"]) and !$group = selectGroupByName($_GET["groupname"])) {
header("HTTP/1.0 404 Not Found");
header("Location: error/404.php");
die();

View File

@@ -24,12 +24,14 @@ $(window).on("load", function () {
});
});
// Toggles all checkboxes based on one.
function checkAll() {
$('.checkbox-list').each(function () {
$(this).prop('checked', $('#checkall').prop('checked'));
});
}
// Simple function that checks if checkall should stay checked.
function checkCheckAll() {
var checked = true;
@@ -43,6 +45,7 @@ function checkCheckAll() {
$('#checkall').prop('checked', checked);
}
// Toggle of filter options.
function changeFilter() {
if ($('#pagetype').find(":selected").val() == "group") {
document.getElementById('admin-filter').style.display = 'none';
@@ -59,11 +62,13 @@ function changeFilter() {
}
}
// Sets the search page to one, relevant when changing filter or search.
function searchFromOne() {
$('#currentpage').prop('value', 1);
adminSearch();
}
// AJAX live search.
function adminSearch() {
$.post(
"API/adminSearchUsers.php",
@@ -74,6 +79,7 @@ function adminSearch() {
})
}
// AJAX live update.
function adminUpdate(form) {
$.post(
"API/adminChangeUser.php",
@@ -83,6 +89,7 @@ function adminUpdate(form) {
})
}
// AJAX pagenumber functionality.
function updatePageN() {
$.post(
"API/adminPageNumber.php",
@@ -92,11 +99,13 @@ function updatePageN() {
})
}
// Intended for the edit button to show a form.
function toggleBancomment(button) {
$(button).siblings("div").toggle();
$(button).toggle();
}
// AJAX value editing.
function editComment(form) {
$.post(
"API/adminChangeUser.php",

View File

@@ -51,6 +51,7 @@ function sendMessage() {
});
$("#newContent").val("");
$("#newContent").focus();
}
// Add messages to the chat.

View File

@@ -91,6 +91,21 @@ $(window).on("load", function() {
loadMorePosts(userID, groupID, postAmount, postLimit);
}
};
$(document).keyup(function(e) {
if (e.keyCode == 27) {
closeModal();
}
});
$('.modal').click(function() {
closeModal();
});
$('.modal-content').click(function(event){
event.stopPropagation();
});
});
function closeModal() {

View File

@@ -25,7 +25,8 @@ if(empty($_GET["username"])) {
$userID = getUserID($_GET["username"]);
}
if(!$user = selectUser($_SESSION["userID"], $userID)) {
if (isset($_SESSION["userID"]) and !$user = selectUser($_SESSION["userID"], $userID)) {
header("HTTP/1.0 404 Not Found");
header("Location: error/404.php");
die();

View File

@@ -1,11 +1,13 @@
.admin-panel {
min-width: 800px;
}
.admin-panel input[type="radio"], input[type="checkbox"] {
vertical-align: middle;
height: 28px;
margin: 2px;
height: 14px;
width: 14px;
margin: 7px;
}
.table-checkbox {
width: 28px;
}
.admin-searchform {
@@ -34,13 +36,15 @@
width: 100%;
}
.usertable .table-username {width: 150px}
.usertable .table-status {width: 100px}
.usertable .table-action {width: 200px}
.table-checkbox {width: 20px}
.table-username {width: 150px}
.table-status {width: 100px}
.table-action {width: 200px}
.usertable th, td {
border-bottom: 1px solid #ddd;
padding: 3px;
word-wrap: break-word;
}
.usertable th, tr {
@@ -51,6 +55,10 @@
background-color: #f5f5f5;
}
.bancomment {
width: 80%;
}
.bancommentedit {
display: none;
}

View File

@@ -224,6 +224,7 @@ function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
$data = trim($data);
return $data;
}

View File

@@ -2,10 +2,21 @@
require_once ("connect.php");
/**
* Selects all friends of a user.
* @param $userID
* @return string
*/
function selectFriends($userID) {
return selectLimitedFriends($userID, 9999);
}
/**
* Returns a limited amount of friends of a user.
* @param $userID
* @param $limit
* @return string
*/
function selectLimitedFriends($userID, $limit) {
$stmt = prepareQuery("
SELECT
@@ -46,7 +57,11 @@ function selectLimitedFriends($userID, $limit) {
return json_encode($stmt->fetchAll());
}
/**
* Selects all friends of a user.
* @param $userID
* @return PDOStatement
*/
function selectAllFriends($userID) {
$stmt = prepareQuery("
SELECT
@@ -83,6 +98,10 @@ function selectAllFriends($userID) {
return $stmt;
}
/**
* Returns all friend requests of the current user.
* @return string
*/
function selectAllFriendRequests() {
$stmt = prepareQuery("
SELECT
@@ -119,6 +138,11 @@ function selectAllFriendRequests() {
return json_encode($stmt->fetchAll());
}
/**
* Gets the friendship status from current user and userID.
* @param $userID
* @return int
*/
function getFriendshipStatus($userID) {
# -2: Query failed.
# -1: user1 and 2 are the same user
@@ -162,6 +186,11 @@ function getFriendshipStatus($userID) {
return intval($stmt->fetch()["friend_state"]);
}
/**
* Request friendship from current user to target user.
* @param $userID
* @return bool
*/
function requestFriendship($userID) {
$stmt = prepareQuery("
INSERT INTO `friendship` (user1ID, user2ID)
@@ -173,6 +202,11 @@ function requestFriendship($userID) {
return $stmt->execute();
}
/**
* Removes friendship between current and target user.
* @param $userID
* @return bool
*/
function removeFriendship($userID) {
$stmt = prepareQuery("
DELETE FROM `friendship`
@@ -189,6 +223,11 @@ function removeFriendship($userID) {
return $stmt->execute();
}
/**
* Sets the friendship between current and target user to accepted.
* @param $userID
* @return bool
*/
function acceptFriendship($userID) {
$stmt = prepareQuery("
UPDATE `friendship`
@@ -204,6 +243,11 @@ function acceptFriendship($userID) {
return $stmt->execute();
}
/**
* Sets the last time the user visited the chat with specified friend.
* @param $friend
* @return PDOStatement
*/
function setLastVisited($friend) {
$stmt = prepareQuery("
UPDATE
@@ -234,6 +278,13 @@ function setLastVisited($friend) {
return $stmt;
}
/**
* Searches m friends from n filtered by search.
* @param $n
* @param $m
* @param $search
* @return string
*/
function searchSomeFriends($n, $m, $search) {
$stmt = prepareQuery("
SELECT
@@ -281,6 +332,11 @@ function searchSomeFriends($n, $m, $search) {
return json_encode($stmt->fetchAll());
}
/**
* Counts all friends of current user filtered by search.
* @param $search
* @return string
*/
function countSomeFriends($search) {
$stmt = prepareQuery("
SELECT

View File

@@ -52,7 +52,7 @@ function updateGroupSettings(int $groupID)
}
/**
* Checks if an user is an admin for a page.
* Checks if a user is an admin for a page.
* @param int $groupID
* @param int $userID
* @return bool

View File

@@ -1,9 +1,20 @@
<?php
/**
* Returns all groups a user is member of.
* @param $userID
* @return string
*/
function selectAllGroupsFromUser($userID) {
return selectLimitedGroupsFromUser($userID, 9999);
}
/**
* Selects number of groups that a user is member of.
* @param $userID
* @param $limit
* @return string
*/
function selectLimitedGroupsFromUser($userID, $limit) {
$stmt = prepareQuery("
SELECT
@@ -27,6 +38,13 @@ function selectLimitedGroupsFromUser($userID, $limit) {
return json_encode($stmt->fetchAll());
}
/**
* Returns m groups offset by n filtered by search that the current user is part of.
* @param $n
* @param $m
* @param $search
* @return string
*/
function searchSomeOwnGroups($n, $m, $search) {
$stmt = prepareQuery("
SELECT
@@ -55,6 +73,11 @@ function searchSomeOwnGroups($n, $m, $search) {
return json_encode($stmt->fetchAll());
}
/**
* Counts all groups filtered by search that the current user is member of.
* @param $search
* @return string
*/
function countSomeOwnGroups($search) {
$stmt = prepareQuery("
SELECT
@@ -78,6 +101,13 @@ function countSomeOwnGroups($search) {
return $stmt->fetchColumn();
}
/**
* Adds a user by userID to a group by groupID with a specified role.
* @param $groupID
* @param $userID
* @param $role
* @return bool
*/
function addMember($groupID, $userID, $role) {
$stmt = prepareQuery("
INSERT INTO
@@ -92,6 +122,13 @@ function addMember($groupID, $userID, $role) {
return $stmt->execute();
}
/**
* Changes te role of a user within a group to the specified one.
* @param $groupID
* @param $userID
* @param $role
* @return bool
*/
function changeMember($groupID, $userID, $role) {
$stmt = prepareQuery("
UPDATE
@@ -109,6 +146,12 @@ function changeMember($groupID, $userID, $role) {
return $stmt->execute();
}
/**
* Removes a user from a group.
* @param $groupID
* @param $userID
* @return bool
*/
function deleteMember($groupID, $userID) {
$stmt = prepareQuery("
DELETE FROM

View File

@@ -2,6 +2,10 @@
require_once("connect.php");
/**
* Selects some info from a group by name.
* @return bool|mixed
*/
function selectGroupByName($name) {
$stmt = prepareQuery("
SELECT
@@ -41,6 +45,11 @@ function selectGroupByName($name) {
return $row;
}
/**
* Selects the current user's role within a group by the group's ID.
* @param int $groupID
* @return bool|string
*/
function selectGroupRole(int $groupID) {
$stmt = prepareQuery("
SELECT
@@ -63,6 +72,11 @@ function selectGroupRole(int $groupID) {
return $stmt->fetch()["role"];
}
/**
* Returns the status of a group by it's ID.
* @param int $groupID
* @return bool
*/
function selectGroupStatus(int $groupID) {
$stmt = prepareQuery("
SELECT
@@ -80,6 +94,11 @@ function selectGroupStatus(int $groupID) {
return $stmt->fetch()["status"];
}
/**
* Returns some info of all group members.
* @param int $groupID
* @return bool|PDOStatement
*/
function selectGroupMembers(int $groupID) {
$stmt = prepareQuery("
SELECT
@@ -105,9 +124,14 @@ function selectGroupMembers(int $groupID) {
if (!$stmt->execute()) {
return False;
}
return $stmt->fetchAll();
return $stmt;
}
/**
* Returns group info by it's ID.
* @param $groupID
* @return PDOStatement
*/
function selectGroupById($groupID) {
$q = prepareQuery("
SELECT
@@ -127,6 +151,11 @@ function selectGroupById($groupID) {
return $q;
}
/**
* Returns some info of 20 groups offset by n.
* @param $n
* @return PDOStatement
*/
function select20GroupsFromN($n) {
$q = prepareQuery("
SELECT
@@ -149,6 +178,12 @@ function select20GroupsFromN($n) {
return $q;
}
/**
* Returns info of 20 groups offset by n, filtered by status.
* @param $n
* @param $status
* @return PDOStatement
*/
function select20GroupsByStatusFromN($n, $status) {
$q = prepareQuery("
SELECT
@@ -174,6 +209,13 @@ function select20GroupsByStatusFromN($n, $status) {
return $q;
}
/**
* Returns info of 20 groups offset by n, filtered by status, filtered by search.
* @param $n
* @param $keyword
* @param $status
* @return PDOStatement
*/
function search20GroupsFromNByStatus($n, $keyword, $status) {
$q = prepareQuery("
SELECT
@@ -201,6 +243,14 @@ function search20GroupsFromNByStatus($n, $keyword, $status) {
return $q;
}
/**
* Returns info of n groups offset by m, filtered by status and search.
* @param $n
* @param $m
* @param $search
* @param $status
* @return PDOStatement
*/
function searchSomeGroupsByStatus($n, $m, $search, $status) {
// parentheses not needed in where clause, for clarity as
// role search should override status filter.
@@ -233,6 +283,12 @@ function searchSomeGroupsByStatus($n, $m, $search, $status) {
return $q;
}
/**
* Count all groups filtered by status and search.
* @param $search
* @param $status
* @return PDOStatement
*/
function countSomeGroupsByStatus($search, $status) {
$q = prepareQuery("
SELECT
@@ -256,6 +312,12 @@ function countSomeGroupsByStatus($search, $status) {
return $q;
}
/**
* Changes the status of a group with the given ID.
* @param $id
* @param $status
* @return PDOStatement
*/
function changeGroupStatusByID($id, $status) {
$q = prepareQuery("
UPDATE
@@ -272,6 +334,12 @@ function changeGroupStatusByID($id, $status) {
return $q;
}
/**
* Changes the status of multiple groups to 1 status by an array of IDs.
* @param $ids
* @param $status
* @return PDOStatement
*/
function changeMultipleGroupStatusByID($ids, $status) {
$q = prepareQuery("
UPDATE
@@ -289,6 +357,13 @@ function changeMultipleGroupStatusByID($ids, $status) {
return $q;
}
/**
* Returns m groups offset by n, filtered by search.
* @param $n
* @param $m
* @param $search
* @return string
*/
function searchSomeGroups($n, $m, $search) {
$stmt = prepareQuery("
SELECT
@@ -312,6 +387,11 @@ function searchSomeGroups($n, $m, $search) {
return json_encode($stmt->fetchAll());
}
/**
* Counts all group filtered by search.
* @param $search
* @return PDOStatement
*/
function countSomeGroups($search) {
$stmt = prepareQuery("
SELECT

View File

@@ -38,7 +38,6 @@ function getUserID() {
}
function validateLogin($username, $password, $url){
echo $url;
// Empty username or password field
if (empty($username) || empty($password)) {
throw new loginException("Inloggegevens zijn niet ingevuld");

View File

@@ -1,9 +1,16 @@
<?php
/**
* Return a relative dutch and readable text when given a datetime.
* @param $date
* @return string
*/
function nicetime($date) {
if(empty($date)) {
return "No date provided";
}
// Create dutch arrays so it has dutch words.
$single_periods = array("seconde", "minuut", "uur", "dag", "week", "maand", "jaar", "decennium");
$multiple_periods = array("seconden", "minuten", "uur", "dagen", "weken", "maanden", "jaar", "decennia");
$lengths = array("60", "60", "24", "7", "4.35", "12", "10", "0");
@@ -15,7 +22,8 @@ function nicetime($date) {
return "Bad date";
}
if($now > $unix_date) {
// Check if it is in the future or not.
if($now >= $unix_date) {
$difference = $now - $unix_date;
$tense = "geleden";
} else {
@@ -23,6 +31,7 @@ function nicetime($date) {
$tense = "vanaf nu";
}
// Get the nice time.
for($i = 0; $difference >= $lengths[$i] && $i < count($lengths) - 1; $i++) {
$difference /= $lengths[$i];
}

View File

@@ -2,6 +2,12 @@
require_once("connect.php");
/**
* Select all posts on a user.
* @param $userID
* @param $groupID
* @return bool|PDOStatement
*/
function selectAllPosts($userID, $groupID) {
$stmt = prepareQuery("
SELECT
@@ -46,6 +52,14 @@ function selectAllPosts($userID, $groupID) {
}
/**
* Select $limit posts from $offset from a user or group.
* @param $userID
* @param $groupID
* @param $offset
* @param $limit
* @return bool|PDOStatement
*/
function selectSomePosts($userID, $groupID, $offset, $limit) {
$stmt = prepareQuery("
SELECT
@@ -94,9 +108,13 @@ function selectSomePosts($userID, $groupID, $offset, $limit) {
return False;
}
return $stmt;
}
/**
* Select all the post information from an postID.
* @param $postID
* @return PDOStatement
*/
function selectPostById($postID) {
$stmt = prepareQuery("
SELECT
@@ -122,6 +140,11 @@ function selectPostById($postID) {
return $stmt;
}
/**
* Get all the comments from a post.
* @param $postID
* @return PDOStatement
*/
function selectCommentsByPostId($postID) {
$stmt = prepareQuery("
SELECT
@@ -148,6 +171,13 @@ function selectCommentsByPostId($postID) {
return $stmt;
}
/**
* Insert a post to a group or user
* @param $userID
* @param $groupID
* @param $title
* @param $content
*/
function makePost($userID, $groupID, $title, $content) {
$stmt = prepareQuery("
INSERT INTO
@@ -172,6 +202,13 @@ function makePost($userID, $groupID, $title, $content) {
$stmt->execute();
}
/**
* Insert a comment by a post.
* @param $postID
* @param $userID
* @param $content
* @return int
*/
function makeComment($postID, $userID, $content) : int {
$stmt = prepareQuery("
INSERT INTO
@@ -194,6 +231,12 @@ function makeComment($postID, $userID, $content) : int {
return $stmt->rowCount();
}
/**
* If a post already is niet slechted.
* @param int $postID
* @param int $userID
* @return int
*/
function makeNietSlecht(int $postID, int $userID) : int {
if (checkNietSlecht($postID, $userID)) {
return deleteNietSlecht($postID, $userID);
@@ -202,6 +245,12 @@ function makeNietSlecht(int $postID, int $userID) : int {
}
}
/**
* Toggle a niet slecht of a post.
* @param int $postID
* @param int $userID
* @return int
*/
function checkNietSlecht(int $postID, int $userID) {
$stmt = prepareQuery("
SELECT
@@ -218,6 +267,12 @@ function checkNietSlecht(int $postID, int $userID) {
return $stmt->rowCount();
}
/**
* Add a niet slecht to a post.
* @param int $postID
* @param int $userID
* @return int
*/
function addNietSlecht(int $postID, int $userID) {
$stmt = prepareQuery("
INSERT INTO
@@ -230,6 +285,12 @@ function addNietSlecht(int $postID, int $userID) {
return $stmt->rowCount();
}
/**
* Delete a niet slecht.
* @param int $postID
* @param int $userID
* @return int
*/
function deleteNietSlecht(int $postID, int $userID) {
$stmt = prepareQuery("
DELETE FROM
@@ -244,6 +305,11 @@ function deleteNietSlecht(int $postID, int $userID) {
return $stmt->rowCount();
}
/**
* Delete a post
* @param int $postID
* @param int $userID
*/
function deletePost(int $postID, int $userID) {
if (checkPermissionOnPost($postID, $userID)) {
$stmt = prepareQuery("
@@ -257,6 +323,12 @@ function deletePost(int $postID, int $userID) {
}
}
/**
* Check if a user has premissions to delete a post.
* @param int $postID
* @param int $userID
* @return bool
*/
function checkPermissionOnPost(int $postID, int $userID) : bool {
$getGroupID = prepareQuery("
SELECT
@@ -282,10 +354,10 @@ function checkPermissionOnPost(int $postID, int $userID) : bool {
}
/**
* Returns role of an user.
* Returns role of a user.
* @param int $userID
* @param int $groupID
* @return mixed role of an user.
* @return mixed role of a user.
*/
function getRoleInGroup(int $userID, int $groupID) {
$stmt = prepareQuery("

View File

@@ -1,5 +1,10 @@
<?php
/**
* Get the the last 100 chat messages.
* @param $user2ID
* @return string
*/
function getOldChatMessages($user2ID) {
require_once ("friendship.php");
$user1ID = $_SESSION["userID"];
@@ -36,6 +41,12 @@ function getOldChatMessages($user2ID) {
}
}
/**
* Send a chat message.
* @param $destination
* @param $content
* @return bool
*/
function sendMessage($destination, $content) {
require_once("friendship.php");
if (getFriendshipStatus($destination) == 1) {
@@ -65,6 +76,12 @@ function sendMessage($destination, $content) {
}
}
/**
* Get all the chat messages after an messageID ($lastID).
* @param $lastID
* @param $destination
* @return string
*/
function getNewChatMessages($lastID, $destination) {
require_once("friendship.php");
if (getFriendshipStatus($destination) == 1) {
@@ -96,7 +113,10 @@ function getNewChatMessages($lastID, $destination) {
}
}
/**
* Get of every friend the first unread chat message.
* @return string
*/
function selectAllUnreadChat() {
$stmt = prepareQuery("
SELECT

View File

@@ -2,6 +2,10 @@
require_once ("connect.php");
/**
* This sets the last activity of the session user to now.
* @return bool, true is it ran correctly
*/
function updateLastActivity() {
$stmt = prepareQuery("
UPDATE
@@ -15,6 +19,11 @@ function updateLastActivity() {
return $stmt->execute();
}
/**
* This gets the userID from a username
* @param $username
* @return mixed
*/
function getUserID($username) {
$stmt = prepareQuery("
SELECT
@@ -30,6 +39,11 @@ function getUserID($username) {
return $stmt->fetch()["userID"];
}
/**
* This gets the username from a userID
* @param $userID
* @return mixed
*/
function getUsername($userID) {
$stmt = prepareQuery("
SELECT
@@ -45,6 +59,12 @@ function getUsername($userID) {
return $stmt->fetch()["username"];
}
/**
* This selects the information about the other user and the connection between the two.
* @param $me
* @param $other
* @return bool|mixed
*/
function selectUser($me, $other) {
$stmt = prepareQuery("
SELECT
@@ -107,6 +127,11 @@ function selectUser($me, $other) {
return $stmt->fetch();
}
/**
* Select all the users from a group.
* @param $userID
* @return PDOStatement
*/
function selectAllUserGroups($userID) {
$stmt = prepareQuery("
SELECT
@@ -130,6 +155,11 @@ function selectAllUserGroups($userID) {
return $stmt;
}
/**
* Selects 20 users from a given point in the table, ordered by role and name
* @param $n
* @return PDOStatement
*/
function select20UsersFromN($n) {
$q = prepareQuery("
SELECT
@@ -155,6 +185,12 @@ function select20UsersFromN($n) {
return $q;
}
/**
* Search 20 users from a given point in the table, ordered by role and name
* @param $n
* @param $keyword
* @return PDOStatement
*/
function search20UsersFromN($n, $keyword) {
$q = prepareQuery("
SELECT
@@ -183,6 +219,13 @@ function search20UsersFromN($n, $keyword) {
return $q;
}
/**
* Search 20 users from a given point in the database where the status @param $status
* @param $n
* @param $keyword
* @param $status
* @return PDOStatement
*/
function search20UsersFromNByStatus($n, $keyword, $status) {
$q = prepareQuery("
SELECT
@@ -215,6 +258,14 @@ function search20UsersFromNByStatus($n, $keyword, $status) {
return $q;
}
/**
* Search users from a given point in the database where the status @param $status
* @param $n
* @param $m
* @param $search
* @param $status
* @return PDOStatement
*/
function searchSomeUsersByStatus($n, $m, $search, $status) {
// parentheses not needed in where clause, for clarity as
// role search should override status filter.
@@ -252,6 +303,12 @@ function searchSomeUsersByStatus($n, $m, $search, $status) {
return $q;
}
/**
* Count the users with a name like $search and a $status
* @param $search
* @param $status
* @return PDOStatement
*/
function countSomeUsersByStatus($search, $status) {
$q = prepareQuery("
SELECT
@@ -276,7 +333,12 @@ function countSomeUsersByStatus($search, $status) {
return $q;
}
/**
* Change the user status
* @param $id
* @param $status
* @return PDOStatement
*/
function changeUserStatusByID($id, $status) {
$q = prepareQuery("
UPDATE
@@ -293,6 +355,12 @@ function changeUserStatusByID($id, $status) {
return $q;
}
/**
* Change multiple user statuses by an id array.
* @param $ids
* @param $status
* @return PDOStatement
*/
function changeMultipleUserStatusByID($ids, $status) {
$q = prepareQuery("
UPDATE
@@ -310,6 +378,13 @@ function changeMultipleUserStatusByID($ids, $status) {
return $q;
}
/**
* Change multiple user statuses by an id array.
* This excludes that admins and owners statuses can be changed.
* @param $ids
* @param $status
* @return PDOStatement
*/
function changeMultipleUserStatusByIDAdmin($ids, $status) {
$q = prepareQuery("
UPDATE
@@ -329,6 +404,11 @@ function changeMultipleUserStatusByIDAdmin($ids, $status) {
return $q;
}
/**
* Select a random user that is nog your friend.
* @param $userID
* @return mixed
*/
function selectRandomNotFriendUser($userID) {
$stmt = prepareQuery("
SELECT
@@ -357,6 +437,13 @@ function selectRandomNotFriendUser($userID) {
return $stmt->fetch();
}
/**
* Search users.
* @param $n
* @param $m
* @param $search
* @return string
*/
function searchSomeUsers($n, $m, $search) {
$stmt = prepareQuery("
SELECT
@@ -397,6 +484,11 @@ function searchSomeUsers($n, $m, $search) {
return json_encode($stmt->fetchAll());
}
/**
* Count the users that you get searching for a user with a keyword.
* @param $search
* @return PDOStatement
*/
function countSomeUsers($search) {
$q = prepareQuery("
SELECT
@@ -420,6 +512,11 @@ function countSomeUsers($search) {
return $q;
}
/**
* Get the role of a user by userID.
* @param $userID
* @return mixed
*/
function getRoleByID($userID) {
$stmt = prepareQuery("
SELECT
@@ -435,6 +532,11 @@ function getRoleByID($userID) {
return $stmt->fetch()["role"];
}
/**
* Edit the ban comment.
* @param $userID
* @param $comment
*/
function editBanCommentByID($userID, $comment) {
$stmt = prepareQuery("
UPDATE

View File

@@ -3,7 +3,7 @@
<th class="table-username">Groepsnaam</th>
<th class="table-status">Status</th>
<th class="table-comment">Beschrijving</th>
<th class="table-action">Actie</th>
<th class="table-action">Zichtbaarheid</th>
</tr>
<?php

View File

@@ -13,6 +13,7 @@ Pagina:
id="currentpage"
form="admin-searchform"
onchange="adminSearch();">
<!-- Construct the options. -->
<?php
for ($i=1; $i <= ceil($countresults / $entries); $i++) {
if ($currentpage == $i) {

View File

@@ -1,5 +1,5 @@
<tr>
<th><input class="table-checkbox" type="checkbox" id="checkall" name="checkall" onchange="checkAll()"></th>
<th class="table-checkbox"><input class="table-checkbox" type="checkbox" id="checkall" name="checkall" onchange="checkAll()"></th>
<th class="table-username">Gebruikersnaam</th>
<th class="table-status">Status</th>
<th class="table-comment">Aantekening</th>

View File

@@ -1,5 +1,4 @@
<!-- function test_input taken from http://www.w3schools.com/php/php_form_validation.asp -->
<!-- Form value holding. -->
<?php
$search = "";
$status = array("user", "frozen", "banned", "unconfirmed", "admin", "owner");
@@ -127,11 +126,11 @@ if (isset($_GET["groupstatus"])) {
if ($userinfo == 'owner') {
echo "<button type=\"submit\"
name=\"batchactions\"
id=\"admin\"
id=\"batch-admin\"
value=\"admin\">Maak Admin</button>
<button type=\"submit\"
name=\"batchactions\"
id=\"owner\"
id=\"batch-owner\"
value=\"owner\">Maak Eigenaar</button>";
}
?>
@@ -140,9 +139,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">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>
<button type="submit" name="batchactions" id="batch-hide" value="hidden">Verborgen</button>
<button type="submit" name="batchactions" id="batch-public" value="public">Publiek</button>
<button type="submit" name="batchactions" id="batch-members" value="membersonly">Alleen Leden</button>
</form>
</div>
@@ -152,5 +151,3 @@ if (isset($_GET["groupstatus"])) {
</div>
</div>
</div>
</body>
</html>

View File

@@ -16,9 +16,18 @@
<h2>Leden (<?= $group['members'] ?>)</h2>
<p>
<?php
foreach($members as $member) {
$membercount = $members->rowCount();
$memberdif = $membercount - 7;
for ($i = 0; $i < min($membercount, 7); $i += 1) {
$member = $members->fetch();
echo "<a href=\"profile.php?username=" . $member["username"] . "\" data-title=\"" . $member["username"] . "\"><img class=\"profile-picture\" src=\"" . $member["profilepicture"] . "\" alt=\"" . $member["username"] . "'s profielfoto\"></a>";
}
if ($memberdif > 0) {
echo $memberdif === 1 ? "en nog 1 andere." : "...en nog $memberdif anderen.";
}
?>
</p>
</div>

View File

@@ -1,7 +1,7 @@
<?php
session_start();
// Checks if there's an user already logged in
// Checks if there's a user already logged in
if(isset($_SESSION["userID"])){
echo "<script>
window.onload=checkLoggedIn();

View File

@@ -55,10 +55,17 @@
<h3>Vrienden</h3>
<p>
<?php
while($friend = $profile_friends->fetch()) {
$friendcount = $profile_friends->rowCount();
$frienddif = $friendcount - 7;
for ($i = 0; $i < min($friendcount, 7); $i += 1) {
$friend = $profile_friends->fetch();
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>";
}
if ($frienddif > 0) {
echo $frienddif === 1 ? "en nog 1 andere." : "...en nog $frienddif anderen.";
}
if($profile_friends->rowCount() === 0) {
echo "<p>Deze gebruiker heeft nog geen vrienden gemaakt.</p>";
@@ -71,10 +78,18 @@
<h3>Groepen</h3>
<p>
<?php
while($group = $profile_groups->fetch()) {
$groupcount = $profile_groups->rowCount();
$groupdif = $groupcount - 7;
for ($i = 0; $i < min($groupcount, 7); $i += 1) {
$group = $profile_groups->fetch();
echo "<a href='group.php?groupname=${group['name']}' data-title='${group["name"]}'><img class='group-picture' src='${group["picture"]}' alt='${group["name"]}s logo'></a>";
}
if ($groupdif > 0) {
echo $groupdif === 1 ? "en nog 1 andere." : "...en nog $groupdif anderen.";
}
if($profile_groups->rowCount() === 0) {
echo "<p>Deze gebruiker is nog geen lid van een groep.</p>";
}