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/pages/messages/read.php4
-rw-r--r--mod/messages/start.php67
-rw-r--r--mod/messages/views/default/forms/messages/reply.php7
4 files changed, 50 insertions, 30 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/pages/messages/read.php b/mod/messages/pages/messages/read.php
index eb36eaa4b..4223c6bac 100644
--- a/mod/messages/pages/messages/read.php
+++ b/mod/messages/pages/messages/read.php
@@ -38,9 +38,9 @@ if ($inbox) {
);
$body_params = array('message' => $message);
$content .= elgg_view_form('messages/reply', $form_params, $body_params);
- $from_user = get_user($message->fromID);
+ $from_user = get_user($message->fromId);
- if (elgg_get_logged_in_user_guid() == elgg_get_page_owner_guid() && $from_user) {
+ if ((elgg_get_logged_in_user_guid() == elgg_get_page_owner_guid()) && $from_user) {
elgg_register_menu_item('title', array(
'name' => 'reply',
'href' => '#messages-reply-form',
diff --git a/mod/messages/start.php b/mod/messages/start.php
index 2e61d6e21..50952ef4b 100644
--- a/mod/messages/start.php
+++ b/mod/messages/start.php
@@ -93,6 +93,9 @@ function messages_page_handler($page) {
$page[1] = elgg_get_logged_in_user_entity()->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]) {
@@ -212,18 +215,20 @@ function messages_can_edit_container($hook_name, $entity_type, $return_value, $p
*
* @param string $subject The subject line of the message
* @param string $body The body of the mesage
- * @param int $send_to The GUID of the user to send to
- * @param int $from Optionally, the GUID of the user to send from
- * @param int $reply The GUID of the message to reply from (default: none)
- * @param true|false $notify Send a notification (default: true)
- * @param true|false $add_to_sent If true (default), will add a message to the sender's 'sent' tray
+ * @param int $recipient_guid The GUID of the user to send to
+ * @param int $sender_guid Optionally, the GUID of the user to send from
+ * @param int $original_msg_guid The GUID of the message to reply from (default: none)
+ * @param bool $notify Send a notification (default: true)
+ * @param bool $add_to_sent If true (default), will add a message to the sender's 'sent' tray
* @return bool
*/
-function messages_send($subject, $body, $send_to, $from = 0, $reply = 0, $notify = true, $add_to_sent = true) {
+function messages_send($subject, $body, $recipient_guid, $sender_guid = 0, $original_msg_guid = 0, $notify = true, $add_to_sent = true) {
+ // @todo remove globals
global $messagesendflag;
$messagesendflag = 1;
+ // @todo remove globals
global $messages_pm;
if ($notify) {
$messages_pm = 1;
@@ -231,33 +236,40 @@ function messages_send($subject, $body, $send_to, $from = 0, $reply = 0, $notify
$messages_pm = 0;
}
- // If $from == 0, set to current user
- if ($from == 0) {
- $from = (int) elgg_get_logged_in_user_guid();
+ // If $sender_guid == 0, set to current user
+ if ($sender_guid == 0) {
+ $sender_guid = (int) elgg_get_logged_in_user_guid();
}
// Initialise 2 new ElggObject
$message_to = new ElggObject();
$message_sent = new ElggObject();
+
$message_to->subtype = "messages";
$message_sent->subtype = "messages";
- $message_to->owner_guid = $send_to;
- $message_to->container_guid = $send_to;
- $message_sent->owner_guid = $from;
- $message_sent->container_guid = $from;
+
+ $message_to->owner_guid = $recipient_guid;
+ $message_to->container_guid = $recipient_guid;
+ $message_sent->owner_guid = $sender_guid;
+ $message_sent->container_guid = $sender_guid;
+
$message_to->access_id = ACCESS_PUBLIC;
$message_sent->access_id = ACCESS_PUBLIC;
+
$message_to->title = $subject;
$message_to->description = $body;
+
$message_sent->title = $subject;
$message_sent->description = $body;
- $message_to->toId = $send_to; // the user receiving the message
- $message_to->fromId = $from; // the user receiving the message
+
+ $message_to->toId = $recipient_guid; // the user receiving the message
+ $message_to->fromId = $sender_guid; // the user receiving the message
$message_to->readYet = 0; // this is a toggle between 0 / 1 (1 = read)
$message_to->hiddenFrom = 0; // this is used when a user deletes a message in their sentbox, it is a flag
$message_to->hiddenTo = 0; // this is used when a user deletes a message in their inbox
- $message_sent->toId = $send_to; // the user receiving the message
- $message_sent->fromId = $from; // the user receiving the message
+
+ $message_sent->toId = $recipient_guid; // the user receiving the message
+ $message_sent->fromId = $sender_guid; // the user receiving the message
$message_sent->readYet = 0; // this is a toggle between 0 / 1 (1 = read)
$message_sent->hiddenFrom = 0; // this is used when a user deletes a message in their sentbox, it is a flag
$message_sent->hiddenTo = 0; // this is used when a user deletes a message in their inbox
@@ -270,7 +282,7 @@ function messages_send($subject, $body, $send_to, $from = 0, $reply = 0, $notify
// Save the copy of the message that goes to the sender
if ($add_to_sent) {
- $success2 = $message_sent->save();
+ $message_sent->save();
}
$message_to->access_id = ACCESS_PRIVATE;
@@ -283,22 +295,25 @@ function messages_send($subject, $body, $send_to, $from = 0, $reply = 0, $notify
// if the new message is a reply then create a relationship link between the new message
// and the message it is in reply to
- if ($reply && $success){
- $create_relationship = add_entity_relationship($message_sent->guid, "reply", $reply);
+ if ($original_msg_guid && $success) {
+ add_entity_relationship($message_sent->guid, "reply", $original_msg_guid);
}
$message_contents = strip_tags($body);
- if ($send_to != elgg_get_logged_in_user_entity() && $notify) {
+ if (($recipient_guid != elgg_get_logged_in_user_guid()) && $notify) {
+ $recipient = get_user($recipient_guid);
+ $sender = get_user($sender_guid);
+
$subject = elgg_echo('messages:email:subject');
$body = elgg_echo('messages:email:body', array(
- elgg_get_logged_in_user_entity()->name,
+ $sender->name,
$message_contents,
- elgg_get_site_url() . "messages/inbox/" . $user->username,
- elgg_get_logged_in_user_entity()->name,
- elgg_get_site_url() . "messages/compose?send_to=" . elgg_get_logged_in_user_guid()
+ elgg_get_site_url() . "messages/inbox/" . $recipient->username,
+ $sender->name,
+ elgg_get_site_url() . "messages/compose?send_to=" . $sender_guid
));
- notify_user($send_to, elgg_get_logged_in_user_guid(), $subject, $body);
+ notify_user($recipient_guid, $sender_guid, $subject, $body);
}
$messagesendflag = 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>