-
Notifications
You must be signed in to change notification settings - Fork 0
/
messages.php
63 lines (53 loc) · 1.71 KB
/
messages.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
55
56
57
58
59
60
61
62
63
<?php
/**
* messages
*
*
*
*/
// fetch bootloader
require('bootloader.php');
// user access
user_access();
// page header
page_header(__("Messages"));
try {
// check the view
$view = (!isset($_GET['view'])) ? 'message' : 'new';
// get view content
if ($view == 'message') {
if (!isset($_GET['cid'])) {
if ($user->_data['conversations']) {
$conversation = $user->_data['conversations'][0];
$conversation['messages'] = $user->get_conversation_messages($conversation['conversation_id']);
}
} else {
/* check cid is valid */
if (is_empty($_GET['cid']) || !is_numeric($_GET['cid'])) {
_error(404);
}
$conversation = $user->get_conversation($_GET['cid']);
$conversation['messages'] = $user->get_conversation_messages($conversation['conversation_id']);
}
// assign variables
$smarty->assign('conversation', $conversation);
} elseif ($view == 'new') {
/* get recipient */
if (isset($_GET['uid'])) {
$get_recipient = $db->query(sprintf("SELECT user_id, user_name, CONCAT(users.user_firstname,' ',users.user_lastname) as user_fullname FROM users WHERE user_id = %s", secure($_GET['uid'], 'int'))) or _error('SQL_ERROR_THROWEN');
if ($get_recipient->num_rows > 0) {
$recipient = $get_recipient->fetch_assoc();
$recipient["user_fullname"] = ($system['show_usernames_enabled']) ? $recipient['user_name'] : $recipient['user_fullname'];
/* assign variables */
$smarty->assign('recipient', $recipient);
}
}
}
//check
/* assign variables */
$smarty->assign('view', $view);
} catch (Exception $e) {
_error(__("Error"), $e->getMessage());
}
// page footer
page_footer('messages');