Marijn button #99

Merged
11166932 merged 152 commits from marijn-button into master 2017-01-23 13:25:08 +01:00
5 changed files with 77 additions and 20 deletions
Showing only changes of commit 14d96e89ad - Show all commits

View File

@@ -42,12 +42,11 @@ function nicetime($date) {
}
if(empty($_GET["username"])) {
echo "User does not exist!";
return;
$userID = $_SESSION["userID"];
} else {
$userID = getUserID($_GET["username"]);
}
$userID = getUserID($_GET["username"]);
$user = selectUser($userID);
$profile_friends = selectAllFriends($userID);
$profile_groups = selectAllUserGroups($userID);

View File

@@ -30,7 +30,7 @@
cursor: pointer;
}
.friend-item:hover {
.friend-item:hover, .group-item:hover {
background: #845663;
color: white;
}

View File

@@ -1,4 +1,5 @@
<?php
require("connect.php");
function getUserID($username) {
@@ -244,4 +245,30 @@ function changeMultipleUserStatusByID($ids, $status) {
return $q;
}
?>
function selectRandomNotFriendUser($userID) {
$stmt = $GLOBALS["db"]->prepare("
SELECT
`user`.`username`
FROM
`user`
WHERE
`userID` NOT IN (SELECT
`user1ID`
FROM
`friendship`
WHERE `user1ID` = :userID) OR
`userID` NOT IN (SELECT
`user2ID`
FROM
`friendship`
WHERE `user2ID` = :userID)
ORDER BY
RAND()
LIMIT
1
");
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
$stmt->execute();
return $stmt->fetch();
}

View File

@@ -15,7 +15,8 @@
</style>
<?php
include_once("../queries/connect.php");
require_once ("../queries/checkInput.php");
require_once ("../queries/connect.php");
session_start();

View File

@@ -7,7 +7,8 @@
<?php
// Load file.
include_once("../queries/friendship.php");
require_once("../queries/friendship.php");
require_once("../queries/user.php");
// Get all the friends of a user.
$friends = selectAllFriends($_SESSION["userID"]);
@@ -45,13 +46,31 @@
</li>
";
}
$randomUser = selectRandomNotFriendUser($_SESSION["userID"])["username"];
echo "
<li class='friend-item'>
<form action='profile.php' method='get'>
<button type='submit'
name='username'
value='$randomUser'>
<div class='friend'>
Klik hier voor een nieuw vriendje :)
</div>
</button>
</form>
</li>
";
if ($i > 1) {
$i -= 1;
echo "
<li class='more-item' id='more-friends-click'>
En nog $i anderen...
</li>";
<li class='more-item' id='more-friends-click'>
En nog $i anderen...
</li>
";
}
?>
</ul>
</section>
@@ -87,17 +106,28 @@
// Echo the friend.
echo "
<a href='#' class='$extraItem'>
<li class='group-item'>
<div class='group'>
<img alt='PF' class='group-picture' src='$picture'/>
$name
</div>
</li>
</a>
<li class='group-item'>
<form action='group.php' method='get'>
<button type='submit'
name='groupname'
value='$name'>
<div class='group'>
<img alt='PF' class='group-picture' src='$picture'/>
$name
</div>
</button>
</form>
</li>
";
}
if ($i > 3) {
if ($i == 0) {
echo "<li class='group-item'>
<div class='group'>
Je hoort nergens bij.
</div>
</li>";
} else if ($i > 3) {
$i -= 3;
echo "
<li class='more-item' id='more-groups-click'>