mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-57394 mod_chat: Move get session messages code to new function
This commit is contained in:
parent
26b4e8580d
commit
2971d8421c
4 changed files with 43 additions and 29 deletions
|
@ -681,16 +681,8 @@ class mod_chat_external extends external_api {
|
|||
}
|
||||
}
|
||||
|
||||
// If the user is allocated to a group, only show messages from people in the same group, or no group.
|
||||
$queryparams = array('chatid' => $chat->id);
|
||||
if ($groupid) {
|
||||
$groupselect = " AND (groupid = :groupid OR groupid = 0)";
|
||||
$queryparams['groupid'] = $groupid;
|
||||
} else {
|
||||
$groupselect = "";
|
||||
}
|
||||
|
||||
if ($messages = $DB->get_records_select('chat_messages', "chatid = :chatid $groupselect", $queryparams, "timestamp DESC")) {
|
||||
$messages = chat_get_session_messages($chat->id, $groupid, 0, 0, 'timestamp DESC');
|
||||
if ($messages) {
|
||||
$chatsessions = chat_get_sessions($messages, $params['showall']);
|
||||
// Format sessions for external.
|
||||
foreach ($chatsessions as $session) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue