Commit 401bcb5d authored by Robert Lyon's avatar Robert Lyon
Browse files

Adjusting the replyto link for pre-multirecipient messages (Bug #1414783)



Also got the subject to pre-populate the compose message form

Change-Id: Id9e7a1af1f4516c145fa91a09fa12fd4175a7e41
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 16892d04
......@@ -175,7 +175,7 @@ function activitylistin_html($type='all', $limit=10, $offset=0) {
}
if ($record->type === 'usermessage') {
$fromusr = $record->from;
$record->url = 'user/sendmessage.php?id=' . $fromusr . '&returnto=inbox';
$record->url = 'user/sendmessage.php?id=' . $fromusr . '&oldreplyto=' . $record->id . '&returnto=inbox';
$record->urltext = get_string('sendmessageto', 'artefact.multirecipientnotification');
}
else {
......
......@@ -18,6 +18,7 @@ safe_require('search', 'internal');
safe_require('artefact', 'multirecipientnotification');
$id = param_integer('id', null);
$oldreplytoid = param_integer('oldreplyto', null);
$replytoid = param_integer('replyto', null);
$messages = null;
$users = array();
......@@ -44,6 +45,22 @@ if (null !== $id) {
$users[] = $id;
}
if (!is_null($oldreplytoid)) {
$message = get_message_thread($oldreplytoid);
if (null === $message) {
throw new AccessDeniedException(get_string('cantviewmessage', 'group'));
}
if ($message[0]->usr != $USER->id) {
throw new AccessDeniedException(get_string('cantviewmessage', 'group'));
}
$subject = $message[0]->subject;
$prefix = trim(get_string('replysubjectprefix', 'artefact.multirecipientnotification'));
if (strpos($subject, $prefix) !== 0) {
$subject = $prefix . ' ' . $subject;
}
}
if (!is_null($replytoid)) {
// Let us validate what we are going to reply first. The message should exist,
// addressed to us and originated from the user we are replying to.
......
......@@ -65,6 +65,8 @@ class PluginBlocktypeInbox extends SystemBlocktype {
$notificationrecords = get_records_sql_array($sql, array($msgidrecord->id));
if (count($notificationrecords) === 1) {
$record = $notificationrecords[0];
// need to adjust the url to avoid it clashing with multiplerecipient url
$record->url = preg_replace('/replyto/', 'oldreplyto', $record->url);
$record->msgtable = $msgidrecord->msgtable;
$records[] = $record;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment