Skip to content
Permalink
Browse files

Merge branch 'MDL-64058-master' of https://github.com/snake/moodle

  • Loading branch information...
andrewnicols committed Nov 20, 2018
2 parents 2f7076e + 4283291 commit 04e83dcf10886063345b3ddbb0f8781169644013
Showing with 25 additions and 6 deletions.
  1. +25 −6 message/lib.php
@@ -866,6 +866,25 @@ function core_message_standard_after_main_region_html() {
// Enter to send.
$entertosend = get_user_preferences('message_entertosend', false, $USER);
// Get the unread counts for the current user.
$unreadcounts = \core_message\api::get_unread_conversation_counts($USER->id);
// Determine which section will be expanded.
// Default behaviour - if no unread counts exist.
$favouritesexpanded = !empty($favouriteconversationcount);
$groupmessagesexpanded = empty($favouriteconversationcount) && !empty($groupconversationcount);
$messagesexpanded = empty($favouriteconversationcount) && empty($groupconversationcount);
// There is an unread conversation somewhere, so that takes priority.
if ($unreadcounts['favourites'] > 0 || $unreadcounts['types'][\core_message\api::MESSAGE_CONVERSATION_TYPE_GROUP] > 0 ||
$unreadcounts['types'][\core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL] > 0) {
$favouritesexpanded = $unreadcounts['favourites'] > 0;
$groupmessagesexpanded = !$favouritesexpanded &&
$unreadcounts['types'][\core_message\api::MESSAGE_CONVERSATION_TYPE_GROUP] > 0;
$messagesexpanded = !$groupmessagesexpanded && !$favouritesexpanded &&
$unreadcounts['types'][\core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL] > 0;
}
return $renderer->render_from_template('core_message/message_drawer', [
'contactrequestcount' => $requestcount,
'loggedinuser' => [
@@ -874,25 +893,25 @@ function core_message_standard_after_main_region_html() {
],
'overview' => [
'messages' => [
'expanded' => empty($favouriteconversationcount) && empty($groupconversationcount),
'expanded' => $messagesexpanded,
'count' => [
'unread' => 0, // TODO: fix me.
'unread' => $unreadcounts['types'][\core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL],
'total' => $individualconversationcount
],
'placeholders' => array_fill(0, $individualconversationcount, true)
],
'groupmessages' => [
'expanded' => empty($favouriteconversationcount) && !empty($groupconversationcount),
'expanded' => $groupmessagesexpanded,
'count' => [
'unread' => 0, // TODO: fix me.
'unread' => $unreadcounts['types'][\core_message\api::MESSAGE_CONVERSATION_TYPE_GROUP],
'total' => $groupconversationcount
],
'placeholders' => array_fill(0, $groupconversationcount, true)
],
'favourites' => [
'expanded' => !empty($favouriteconversationcount),
'expanded' => $favouritesexpanded,
'count' => [
'unread' => 0, // TODO: fix me.
'unread' => $unreadcounts['favourites'],
'total' => $favouriteconversationcount
],
'placeholders' => array_fill(0, $favouriteconversationcount, true)

0 comments on commit 04e83dc

Please sign in to comment.
You can’t perform that action at this time.