aboutsummaryrefslogtreecommitdiff
path: root/mod/messages/read.php
blob: b830aa51cbdda864b2ed50a550a82c240a022393 (plain)
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
<?php
/**
* Read a message page
*
* @package ElggMessages
*/

gatekeeper();

$message = get_entity(get_input('guid'));
if (!$message) {
	forward();
}

elgg_set_page_owner_guid($message->getOwnerGUID());
$page_owner = elgg_get_page_owner_entity();

$title = $message->title;

$inbox = false;
if ($page_owner->getGUID() == $message->toId) {
	$inbox = true;
	elgg_push_breadcrumb(elgg_echo('messages:inbox'), 'pg/messages/inbox/' . $page_owner->username);
} else {
	elgg_push_breadcrumb(elgg_echo('messages:sent'), 'pg/messages/sent/' . $page_owner->username);
}
elgg_push_breadcrumb($title);

$buttons = '';
$content = elgg_view_entity($message, true);
if ($inbox) {
	$form_params = array(
		'id' => 'messages-reply-form',
		'class' => 'hidden',
		'action' => 'action/messages/send',
	);
	$body_params = array('message' => $message);
	$content .= elgg_view_form('messages/reply', $form_params, $body_params);

	if (elgg_get_logged_in_user_guid() == elgg_get_page_owner_guid()) {
		$buttons = elgg_view('output/url', array(
			'text' => elgg_echo('messages:answer'),
			'class' => 'elgg-button elgg-button-action',
			'id' => 'messages-show-reply',
		));
	}
}

$body = elgg_view_layout('content', array(
	'content' => $content,
	'title' => $title,
	'filter' => '',
	'buttons' => $buttons,
));

echo elgg_view_page($title, $body);