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
|
<?php
/**
* Elgg messages individual view
*
* @package ElggMessages
*
*
* @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 = elgg_get_site_url() . "mod/messages/sent.php";
// set up breadcrumbs context
elgg_push_breadcrumb(elgg_echo('messages:sent'), $url);
//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 = elgg_get_site_url() . "pg/messages/" . get_loggedin_user()->username;
// set up breadcrumbs context
elgg_push_breadcrumb(elgg_echo('messages:inbox'), $url);
//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 == get_loggedin_userid()
|| $vars['entity']->owner_guid == get_loggedin_userid()) {
// display breadcrumbs
elgg_push_breadcrumb($vars['entity']->title);
echo elgg_view('navigation/breadcrumbs');
?>
<!-- display the content header block -->
<div id="content-header" class="clearfix">
<div class="content-header-title"><h2><?php echo $vars['entity']->title; ?></h2></div>
<div class="content-header-options">
<a class="elgg-action-button message_reply" 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' => "action/messages/delete?message_id=" . $vars['entity']->getGUID() . "&type={$type}&submit=" . elgg_echo('delete'),
'text' => elgg_echo('delete'),
'confirm' => elgg_echo('deleteconfirm'),
'class' => "elgg-action-button disabled"
));
?>
</div>
</div>
<div class="entity-listing messages clearfix">
<?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='".elgg_get_site_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='".elgg_get_site_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 elgg_view_friendly_time($vars['entity']->time_created); ?></p>
</div>
</div>
<div class="messagebody margin-top clearfix">
<?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 elgg_get_site_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_inputarea"><label><?php echo elgg_echo("messages:message"); ?>:</label>
<?php echo elgg_view("input/longtext", array(
"internalname" => "message",
"value" => '',
));
?></p>
<?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 . "' />";
echo elgg_view('input/submit', array('value' => elgg_echo("messages:fly")));
?>
</form>
</div>
<?php
}
}
|