MDL-54701 message: added isread to data_for_messagearea_conversations

This commit is contained in:
Ryan Wyllie
2016-10-07 16:26:40 +08:00
committed by Mark Nelson
parent c826fa230a
commit eda6bc19e6
4 changed files with 7 additions and 3 deletions
+2 -1
View File
@@ -146,7 +146,8 @@ class helper {
}
// Check if the user is online.
$data->isonline = $userfields->lastaccess >= $time;
$data->isread = isset($contact->isread) ? $contact->isread : 0;
return new \core_message\output\contact($data);
}
}
}
+1
View File
@@ -63,6 +63,7 @@ class contact implements templatable, renderable {
$contact->profileimageurlsmall = $this->contact->profileimageurlsmall;
$contact->lastmessage = shorten_text($this->contact->lastmessage, self::MAX_MSG_LENGTH);
$contact->isonline = $this->contact->isonline;
$contact->isread = $this->contact->isread;
return $contact;
}
+2 -1
View File
@@ -485,7 +485,8 @@ class core_message_external extends external_api {
'profileimageurl' => new external_value(PARAM_URL, 'User picture URL'),
'profileimageurlsmall' => new external_value(PARAM_URL, 'Small user picture URL'),
'lastmessage' => new external_value(PARAM_NOTAGS, 'The user\'s last message', VALUE_OPTIONAL),
'isonline' => new external_value(PARAM_BOOL, 'The user\'s online status', VALUE_OPTIONAL)
'isonline' => new external_value(PARAM_BOOL, 'The user\'s online status', VALUE_OPTIONAL),
'isread' => new external_value(PARAM_BOOL, 'If the user has read the message', VALUE_OPTIONAL),
)
)
)
+2 -1
View File
@@ -342,7 +342,7 @@ function message_get_recent_conversations($user, $limitfrom=0, $limitto=100) {
$uniquefield = $DB->sql_concat('message.useridfrom', "'-'", 'message.useridto');
$sql = "SELECT $uniquefield, $userfields,
message.id as mid, message.notification, message.smallmessage, message.fullmessage,
message.fullmessagehtml, message.fullmessageformat, message.timecreated,
message.fullmessagehtml, message.fullmessageformat, message.timecreated, 1 as isread,
contact.id as contactlistid, contact.blocked
FROM {message_read} message
JOIN (
@@ -389,6 +389,7 @@ function message_get_recent_conversations($user, $limitfrom=0, $limitto=100) {
// exact same query as the one above, except for the table we are querying. So, simply replace references to
// the 'message_read' table with the 'message' table.
$sql = str_replace('{message_read}', '{message}', $sql);
$sql = str_replace('1 as isread', '0 as isread', $sql);
$unread = $DB->get_records_sql($sql, $params, $limitfrom, $limitto);
// Union the 2 result sets together looking for the message with the most