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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
<?php
/**
* Elgg messages individual view
*
* @package ElggMessages
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
* @author Curverider Ltd <info@elgg.com>
* @copyright Curverider Ltd 2008-2010
* @link http://elgg.com/
*
*
* @uses $vars['entity'] Optionally, the message to view
* @uses get_input('type') If the user accesses the message from their sentbox, this variable is passed
* and used to make sure the correct icon and name is displayed
*/
// set some variables to use below
if(get_input("type") == "sent"){
// send back to the users sentbox
$url = $vars['url'] . "mod/messages/sent.php";
// set up breadcrumbs context
$breadcrumb_root_text = elgg_echo('messages:sent');
//this is used on the delete link so we know which type of message it is
$type = "sent";
} else {
//send back to the users inbox
$url = $vars['url'] . "pg/messages/" . $vars['user']->username;
// set up breadcrumbs context
$breadcrumb_root_text = elgg_echo('messages:inbox');
//this is used on the delete link so we know which type of message it is
$type = "inbox";
}
// fix for RE: RE: RE: that builds on replies
$reply_title = $vars['entity']->title;
if (strncmp($reply_title, "RE:", 3) != 0) {
$reply_title = "RE: " . $reply_title;
}
if (isloggedin())
if (isset($vars['entity'])) {
if ($vars['entity']->toId == $vars['user']->guid
|| $vars['entity']->owner_guid == $vars['user']->guid) {
// display breadcrumbs
echo elgg_view('page_elements/breadcrumbs', array(
'breadcrumb_root_url' => $url,
'breadcrumb_root_text' => $breadcrumb_root_text,
/*
'breadcrumb_level1_url' => $url,
'breadcrumb_level1_text' => $vars['entity']->title,
'breadcrumb_level2_url' => $url,
'breadcrumb_level2_text' => $vars['entity']->title,
*/
'breadcrumb_currentpage' => $vars['entity']->title
));
?>
<!-- display the content header block -->
<div id="content_header" class="clearfloat">
<div class="content_header_title"><h2><?php echo $vars['entity']->title; ?></h2></div>
<div class="content_header_options">
<a class="action_button message_reply" href="#" onclick="elgg_slide_toggle(this,'#elgg_page_contents','#message_reply_form');"><?php echo elgg_echo('messages:answer'); ?></a>
<?php echo elgg_view("output/confirmlink", array(
'href' => $vars['url'] . "action/messages/delete?message_id=" . $vars['entity']->getGUID() . "&type={$type}&submit=" . elgg_echo('delete'),
'text' => elgg_echo('delete'),
'confirm' => elgg_echo('deleteconfirm'),
'class' => "action_button disabled"
));
?>
</div>
</div>
<div class="entity_listing messages clearfloat">
<?php
// we need a different user icon and name depending on whether the user is reading the message
// from their inbox or sentbox. If it is the inbox, then the icon and name will be the person who sent
// the message. If it is the sentbox, the icon and name will be the user the message was sent to
if($type == "sent"){
//get an instance of the user who the message has been sent to so we can access the name and icon
$user_object = get_entity($vars['entity']->toId);
$message_icon = elgg_view("profile/icon",array('entity' => $user_object, 'size' => 'tiny'));
$message_owner = elgg_echo('messages:to').": <a href='{$vars['url']}pg/profile/".$user_object->username."'>".$user_object->name."</a>";
}else{
$user_object = get_entity($vars['entity']->fromId);
$message_icon = elgg_view("profile/icon",array('entity' => $user_object, 'size' => 'tiny'));
$message_owner = elgg_echo('messages:from').": <a href='{$vars['url']}pg/profile/".$user_object->username."'>".get_entity($vars['entity']->fromId)->name."</a>";
}
?>
<div class="entity_listing_icon"><?php echo $message_icon ?></div>
<div class="entity_listing_info"><p><?php echo $message_owner ?></p>
<p class="entity_subtext"><?php echo friendly_time($vars['entity']->time_created); ?></p>
</div>
</div>
<div class="messagebody margin_top clearfloat">
<?php
// if the message is a reply, display the message the reply was for
// @todo I need to figure out how to get the description out using -> (anyone?)
if($main_message = $vars['entity']->getEntitiesFromRelationship("reply")){
echo $main_message[0][description];
}
?>
<!-- display the message -->
<?php echo elgg_view('output/longtext',array('value' => $vars['entity']->description)); ?>
</div>
<!-- reply form -->
<div id="message_reply_form" class="hidden margin_top">
<h2><?php echo elgg_echo('messages:answer'); ?></h2>
<form action="<?php echo $vars['url']; ?>action/messages/send" method="post" name="messageForm" class="margin_top" id="messages_send_form">
<?php echo elgg_view('input/securitytoken'); ?>
<p><label><?php echo elgg_echo("messages:title"); ?>: <br /><input type='text' name='title' class="input_text" value='<?php echo $reply_title; ?>' /></label></p>
<p class="longtext_editarea"><label><?php echo elgg_echo("messages:message"); ?>:</label></p>
<div id="message_reply_editor">
<?php echo elgg_view("input/longtext", array(
"internalname" => "message",
"value" => '',
));
?></div>
<?php
//pass across the guid of the message being replied to
echo "<input type='hidden' name='reply' value='" . $vars['entity']->getGUID() . "' />";
//pass along the owner of the message being replied to
echo "<input type='hidden' name='send_to' value='" . $vars['entity']->fromId . "' />";
?>
<input type="submit" class="submit_button" value="<?php echo elgg_echo("messages:fly"); ?>" />
</form>
</div>
<?php
}
}
|