-
Notifications
You must be signed in to change notification settings - Fork 0
/
chat_action.php
54 lines (52 loc) · 1.48 KB
/
chat_action.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
session_start();
include ('Chat.php');
$chat = new Chat();
if($_POST['action'] == 'update_user_list') {
$chatUsers = $chat->chatUsers($_SESSION['userID']);
$data = array(
"profileHTML" => $chatUsers,
);
echo json_encode($data);
}
if($_POST['action'] == 'insert_chat') {
$chat->insertChat($_POST['to_user_id'], $_SESSION['userID'], $_POST['chat_message']);
}
if($_POST['action'] == 'show_chat') {
$chat->showUserChat($_SESSION['userID'], $_POST['to_user_id']);
}
if($_POST['action'] == 'update_user_chat') {
$conversation = $chat->getUserChat($_SESSION['userID'], $_POST['to_user_id']);
$data = array(
"conversation" => $conversation
);
echo json_encode($data);
}
if($_POST['action'] == 'update_unread_message') {
$count = $chat->getUnreadMessageCount($_POST['to_user_id'], $_SESSION['userID']);
$data = array(
"count" => $count
);
echo json_encode($data);
}
if($_POST['action'] == 'update_typing_status') {
$chat->updateTypingStatus($_POST["is_type"], $_SESSION["login_details_id"]);
}
if($_POST['action'] == 'show_typing_status') {
$message = $chat->fetchIsTypeStatus($_POST['to_user_id']);
$data = array(
"message" => $message
);
echo json_encode($data);
}
if($_POST['action'] == 'update_status') {
$chat->updateStatus($_SESSION['userID'], $_POST['status']);
}
if($_POST['action'] == 'get_settings') {
$data = $chat->getSettings($_SESSION['userID']);
$data = array(
"settings" => $conversation
);
echo json_encode($data);
}
?>