1 | <?php |
||
2 | /** |
||
3 | * Read a message page |
||
4 | * |
||
5 | * @package ElggMessages |
||
6 | */ |
||
7 | |||
8 | elgg_gatekeeper(); |
||
9 | |||
10 | $guid = elgg_extract('guid', $vars); |
||
11 | |||
12 | elgg_entity_gatekeeper($guid, 'object', 'messages'); |
||
13 | |||
14 | $message = get_entity($guid); |
||
15 | /* @var ElggMessage $message */ |
||
16 | |||
17 | // mark the message as read |
||
18 | $message->readYet = true; |
||
1 ignored issue
–
show
|
|||
19 | |||
20 | elgg_set_page_owner_guid($message->getOwnerGUID()); |
||
21 | $page_owner = elgg_get_page_owner_entity(); |
||
22 | |||
23 | $title = $message->title; |
||
24 | |||
25 | $inbox = false; |
||
26 | if ($page_owner->getGUID() == $message->toId) { |
||
27 | $inbox = true; |
||
28 | elgg_push_breadcrumb(elgg_echo('messages:inbox'), 'messages/inbox/' . $page_owner->username); |
||
29 | } else { |
||
30 | elgg_push_breadcrumb(elgg_echo('messages:sent'), 'messages/sent/' . $page_owner->username); |
||
31 | } |
||
32 | elgg_push_breadcrumb($title); |
||
33 | |||
34 | $content = elgg_view_entity($message, ['full_view' => true]); |
||
35 | if ($inbox) { |
||
36 | $form_params = [ |
||
37 | 'id' => 'messages-reply-form', |
||
38 | 'class' => 'hidden mtl', |
||
39 | 'action' => 'action/messages/send', |
||
40 | ]; |
||
41 | $body_params = ['message' => $message]; |
||
42 | $content .= elgg_view_form('messages/reply', $form_params, $body_params); |
||
43 | $from_user = get_user($message->fromId); |
||
44 | |||
45 | if ((elgg_get_logged_in_user_guid() == elgg_get_page_owner_guid()) && $from_user) { |
||
46 | elgg_register_menu_item('title', [ |
||
47 | 'name' => 'reply', |
||
48 | 'href' => '#messages-reply-form', |
||
49 | 'text' => elgg_echo('reply'), |
||
50 | 'link_class' => 'elgg-button elgg-button-action', |
||
51 | 'rel' => 'toggle', |
||
52 | ]); |
||
53 | } |
||
54 | } |
||
55 | |||
56 | $body = elgg_view_layout('content', [ |
||
57 | 'content' => $content, |
||
58 | 'title' => $title, |
||
59 | 'filter' => '', |
||
60 | 'show_owner_block_menu' => false, |
||
61 | ]); |
||
62 | |||
63 | echo elgg_view_page($title, $body); |
||
64 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.