aboutsummaryrefslogtreecommitdiff
path: root/mod/messages
diff options
context:
space:
mode:
Diffstat (limited to 'mod/messages')
-rw-r--r--mod/messages/actions/messages/send.php2
-rw-r--r--mod/messages/start.php20
-rw-r--r--mod/messages/views/default/forms/messages/reply.php7
3 files changed, 22 insertions, 7 deletions
diff --git a/mod/messages/actions/messages/send.php b/mod/messages/actions/messages/send.php
index 9d9f6c8b7..16a971ad2 100644
--- a/mod/messages/actions/messages/send.php
+++ b/mod/messages/actions/messages/send.php
@@ -11,7 +11,7 @@ $recipient_guid = get_input('recipient_guid');
elgg_make_sticky_form('messages');
-//$reply = get_input('reply',0); // this is the guid of the message replying to
+$reply = get_input('reply',0); // this is the guid of the message replying to
if (!$recipient_guid) {
register_error(elgg_echo("messages:user:blank"));
diff --git a/mod/messages/start.php b/mod/messages/start.php
index e17640098..2bf0526da 100644
--- a/mod/messages/start.php
+++ b/mod/messages/start.php
@@ -74,25 +74,35 @@ function messages_init() {
*/
function messages_page_handler($page) {
+ $current_user = elgg_get_logged_in_user_entity();
+ if (!$current_user) {
+ register_error(elgg_echo('noaccess'));
+ $_SESSION['last_forward_from'] = current_page_url();
+ forward('');
+ }
+
elgg_load_library('elgg:messages');
- elgg_push_breadcrumb(elgg_echo('messages'), 'messages/inbox/' . elgg_get_logged_in_user_entity()->username);
+ elgg_push_breadcrumb(elgg_echo('messages'), 'messages/inbox/' . $current_user->username);
if (!isset($page[0])) {
$page[0] = 'inbox';
}
- // supporting the old inbox url /messages/<username>
- $user = get_user_by_username($page[0]);
- if ($user) {
+ // Support the old inbox url /messages/<username>, but only if it matches the logged in user.
+ // Otherwise having a username like "read" on the system could confuse this function.
+ if ($current_user->username === $page[0]) {
$page[1] = $page[0];
$page[0] = 'inbox';
}
if (!isset($page[1])) {
- $page[1] = elgg_get_logged_in_user_entity()->username;
+ $page[1] = $current_user->username;
}
+ $user = get_user_by_username($page[1]);
+ //elgg_set_page_owner_guid($user->guid);
+
$base_dir = elgg_get_plugins_path() . 'messages/pages/messages';
switch ($page[0]) {
diff --git a/mod/messages/views/default/forms/messages/reply.php b/mod/messages/views/default/forms/messages/reply.php
index 9f3f4b57e..a0a01afce 100644
--- a/mod/messages/views/default/forms/messages/reply.php
+++ b/mod/messages/views/default/forms/messages/reply.php
@@ -15,6 +15,11 @@ echo elgg_view('input/hidden', array(
'name' => 'recipient_guid',
'value' => $vars['message']->fromId,
));
+echo elgg_view('input/hidden', array(
+ 'name' => 'reply',
+ 'value' => $vars['message']->guid,
+));
+
?>
<div>
@@ -35,4 +40,4 @@ echo elgg_view('input/hidden', array(
</div>
<div class="elgg-foot">
<?php echo elgg_view('input/submit', array('value' => elgg_echo('messages:send'))); ?>
-</div> \ No newline at end of file
+</div>