Added direct button on the profile to chat with someone
This commit is contained in:
@@ -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,78 +1,90 @@
|
|||||||
<?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("
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
`private_message`
|
||||||
|
WHERE
|
||||||
|
`origin` = :user1 AND
|
||||||
|
`destination` = :user2 OR
|
||||||
|
`origin` = :user2 AND
|
||||||
|
`destination` = :user1
|
||||||
|
ORDER BY
|
||||||
|
`messageID` ASC
|
||||||
|
");
|
||||||
|
|
||||||
$stmt = $GLOBALS["db"]->prepare("
|
$stmt->bindParam(":user1", $user1ID);
|
||||||
SELECT
|
$stmt->bindParam(":user2", $user2ID);
|
||||||
*
|
|
||||||
FROM
|
|
||||||
`private_message`
|
|
||||||
WHERE
|
|
||||||
`origin` = :user1 AND
|
|
||||||
`destination` = :user2 OR
|
|
||||||
`origin` = :user2 AND
|
|
||||||
`destination` = :user1
|
|
||||||
ORDER BY
|
|
||||||
`messageID` ASC
|
|
||||||
");
|
|
||||||
|
|
||||||
$stmt->bindParam(":user1", $user1ID);
|
$stmt->execute();
|
||||||
$stmt->bindParam(":user2", $user2ID);
|
|
||||||
|
|
||||||
$stmt->execute();
|
return json_encode($stmt->fetchAll());
|
||||||
|
} else {
|
||||||
return json_encode($stmt->fetchAll());
|
return "[]";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendMessage($destination, $content) {
|
function sendMessage($destination, $content) {
|
||||||
$stmt = $GLOBALS["db"]->prepare("
|
if (getFriendshipStatus($destination) == 1) {
|
||||||
INSERT INTO
|
$stmt = $GLOBALS["db"]->prepare("
|
||||||
`private_message`
|
INSERT INTO
|
||||||
(
|
`private_message`
|
||||||
`origin`,
|
(
|
||||||
`destination`,
|
`origin`,
|
||||||
`content`
|
`destination`,
|
||||||
)
|
`content`
|
||||||
VALUES
|
)
|
||||||
(
|
VALUES
|
||||||
:origin,
|
(
|
||||||
:destination,
|
:origin,
|
||||||
:content
|
:destination,
|
||||||
)
|
:content
|
||||||
");
|
)
|
||||||
|
");
|
||||||
|
|
||||||
return $stmt->execute(array(
|
return $stmt->execute(array(
|
||||||
"origin" => $_SESSION["userID"],
|
"origin" => $_SESSION["userID"],
|
||||||
"destination" => $destination,
|
"destination" => $destination,
|
||||||
"content" => $content
|
"content" => $content
|
||||||
));
|
));
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNewChatMessages($lastID, $destination) {
|
function getNewChatMessages($lastID, $destination) {
|
||||||
$stmt = $GLOBALS["db"]->prepare("
|
if (getFriendshipStatus($user2ID) == 1) {
|
||||||
SELECT
|
$stmt = $GLOBALS["db"]->prepare("
|
||||||
*
|
SELECT
|
||||||
FROM
|
*
|
||||||
`private_message`
|
FROM
|
||||||
WHERE
|
`private_message`
|
||||||
(
|
WHERE
|
||||||
`origin` = :user1 AND
|
(
|
||||||
`destination` = :user2 OR
|
`origin` = :user1 AND
|
||||||
`origin` = :user2 AND
|
`destination` = :user2 OR
|
||||||
`destination` = :user1) AND
|
`origin` = :user2 AND
|
||||||
`messageID` > :lastID
|
`destination` = :user1) AND
|
||||||
ORDER BY
|
`messageID` > :lastID
|
||||||
`messageID` ASC
|
ORDER BY
|
||||||
");
|
`messageID` ASC
|
||||||
|
");
|
||||||
|
|
||||||
$stmt->bindParam(':user1', $_SESSION["userID"]);
|
$stmt->bindParam(':user1', $_SESSION["userID"]);
|
||||||
$stmt->bindParam(':user2', $destination);
|
$stmt->bindParam(':user2', $destination);
|
||||||
$stmt->bindParam(':lastID', $lastID);
|
$stmt->bindParam(':lastID', $lastID);
|
||||||
|
|
||||||
$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