Added direct button on the profile to chat with someone #137
@@ -4,12 +4,14 @@ function placeFriendButtons() {
|
|||||||
friendshipStatus = data;
|
friendshipStatus = data;
|
||||||
$buttonContainer = $("div.friend-button-container");
|
$buttonContainer = $("div.friend-button-container");
|
||||||
$buttonContainer.children().remove();
|
$buttonContainer.children().remove();
|
||||||
|
$("#start-profile-chat-form").hide();
|
||||||
if (friendshipStatus == -1) {
|
if (friendshipStatus == -1) {
|
||||||
return;
|
return;
|
||||||
} else if(friendshipStatus == 0) {
|
} else if(friendshipStatus == 0) {
|
||||||
$buttonContainer.append($("<button class=\"green friend-button\" value=\"request\"><i class=\"fa fa-handshake-o\"></i> Bevriend</button>"));
|
$buttonContainer.append($("<button class=\"green friend-button\" value=\"request\"><i class=\"fa fa-handshake-o\"></i> Bevriend</button>"));
|
||||||
} else if(friendshipStatus == 1) {
|
} else if(friendshipStatus == 1) {
|
||||||
$buttonContainer.append($("<button class=\"red friend-button\" value=\"delete\"><i class=\"fa fa-times\"></i> Verwijder</button>"));
|
$buttonContainer.append($("<button class=\"red friend-button\" value=\"delete\"><i class=\"fa fa-times\"></i> Verwijder</button>"));
|
||||||
|
$("#start-profile-chat-form").show();
|
||||||
} else if(friendshipStatus == 2) {
|
} else if(friendshipStatus == 2) {
|
||||||
$buttonContainer.append($("<button class=\"red friend-button\" value=\"delete\"><i class=\"fa fa-times\"></i> Trek verzoek in</button>"));
|
$buttonContainer.append($("<button class=\"red friend-button\" value=\"delete\"><i class=\"fa fa-times\"></i> Trek verzoek in</button>"));
|
||||||
} else if(friendshipStatus == 3) {
|
} else if(friendshipStatus == 3) {
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
function getOldChatMessages($user2ID) {
|
function getOldChatMessages($user2ID) {
|
||||||
|
require_once ("friendship.php");
|
||||||
$user1ID = $_SESSION["userID"];
|
$user1ID = $_SESSION["userID"];
|
||||||
|
if (getFriendshipStatus($user2ID) == 1) {
|
||||||
$stmt = $GLOBALS["db"]->prepare("
|
$stmt = $GLOBALS["db"]->prepare("
|
||||||
SELECT
|
SELECT
|
||||||
*
|
*
|
||||||
@@ -23,9 +24,13 @@ function getOldChatMessages($user2ID) {
|
|||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
return json_encode($stmt->fetchAll());
|
return json_encode($stmt->fetchAll());
|
||||||
|
} else {
|
||||||
|
return "[]";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendMessage($destination, $content) {
|
function sendMessage($destination, $content) {
|
||||||
|
if (getFriendshipStatus($destination) == 1) {
|
||||||
$stmt = $GLOBALS["db"]->prepare("
|
$stmt = $GLOBALS["db"]->prepare("
|
||||||
INSERT INTO
|
INSERT INTO
|
||||||
`private_message`
|
`private_message`
|
||||||
@@ -47,9 +52,13 @@ function sendMessage($destination, $content) {
|
|||||||
"destination" => $destination,
|
"destination" => $destination,
|
||||||
"content" => $content
|
"content" => $content
|
||||||
));
|
));
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNewChatMessages($lastID, $destination) {
|
function getNewChatMessages($lastID, $destination) {
|
||||||
|
if (getFriendshipStatus($user2ID) == 1) {
|
||||||
$stmt = $GLOBALS["db"]->prepare("
|
$stmt = $GLOBALS["db"]->prepare("
|
||||||
SELECT
|
SELECT
|
||||||
*
|
*
|
||||||
@@ -73,6 +82,9 @@ function getNewChatMessages($lastID, $destination) {
|
|||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
return json_encode($stmt->fetchAll());
|
return json_encode($stmt->fetchAll());
|
||||||
|
} else {
|
||||||
|
return "[]";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -101,7 +113,8 @@ function selectAllUnreadChat() {
|
|||||||
`friendship`.chatLastVisted2 IS NULL)) AND
|
`friendship`.chatLastVisted2 IS NULL)) AND
|
||||||
`private_message`.`origin` = `user`.`userID` AND
|
`private_message`.`origin` = `user`.`userID` AND
|
||||||
`private_message`.`destination` = :userID AND
|
`private_message`.`destination` = :userID AND
|
||||||
`user`.`role` != 'banned'
|
`user`.`role` != 'banned' AND
|
||||||
|
`friendship`.`status` = 'confirmed'
|
||||||
|
|
||||||
GROUP BY `user`.`userID`
|
GROUP BY `user`.`userID`
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ function getUsername($userID) {
|
|||||||
function selectUser($me, $other) {
|
function selectUser($me, $other) {
|
||||||
$stmt = $GLOBALS["db"]->prepare("
|
$stmt = $GLOBALS["db"]->prepare("
|
||||||
SELECT
|
SELECT
|
||||||
|
`userID`,
|
||||||
`username`,
|
`username`,
|
||||||
`birthdate`,
|
`birthdate`,
|
||||||
`location`,
|
`location`,
|
||||||
@@ -94,7 +95,7 @@ function selectAllUserGroups($userID) {
|
|||||||
`group_page`.`groupID` = `group_member`.`groupID`
|
`group_page`.`groupID` = `group_member`.`groupID`
|
||||||
WHERE
|
WHERE
|
||||||
`userID` = :userID AND
|
`userID` = :userID AND
|
||||||
`role` = 1
|
`role` = 'member'
|
||||||
");
|
");
|
||||||
|
|
||||||
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
|
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
|
||||||
@@ -331,9 +332,10 @@ function searchSomeUsers($n, $m, $search) {
|
|||||||
FROM
|
FROM
|
||||||
`user`
|
`user`
|
||||||
WHERE
|
WHERE
|
||||||
`username` LIKE :keyword OR
|
(`username` LIKE :keyword OR
|
||||||
`fname` LIKE :keyword OR
|
`fname` LIKE :keyword OR
|
||||||
`lname` LIKE :keyword
|
`lname` LIKE :keyword) AND
|
||||||
|
`role` != 'banned'
|
||||||
ORDER BY
|
ORDER BY
|
||||||
`fname`,
|
`fname`,
|
||||||
`lname`,
|
`lname`,
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="profile-box platform">
|
<div class="profile-box platform">
|
||||||
<img class="left profile-picture" src="<?php echo $user["profilepicture"] ?>">
|
<img class="left profile-picture" src="<?php echo $user["profilepicture"] ?>">
|
||||||
|
<form id="start-profile-chat-form" class="right" action="chat.php" method="get">
|
||||||
|
<button name="username"
|
||||||
|
class="friend-button green"
|
||||||
|
value="<?php echo $user["userID"] ?>">
|
||||||
|
<i class="fa fa-comment-o"></i> Chat
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
<div class="friend-button-container">
|
<div class="friend-button-container">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user