Skip to content

Commit

Permalink
Merge branch 'wip-mdl-45565' of https://github.com/rajeshtaneja/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Hemelryk committed May 28, 2014
2 parents f94891c + 3c4b599 commit 69ab6b4
Show file tree
Hide file tree
Showing 4 changed files with 408 additions and 38 deletions.
3 changes: 3 additions & 0 deletions lib/phpunit/classes/util.php
Expand Up @@ -207,6 +207,9 @@ public static function reset_all_data($detectchanges = false) {
core_text::reset_caches();
get_message_processors(false, true);
filter_manager::reset_caches();
// Reset internal users.
core_user::reset_internal_users();

//TODO MDL-25290: add more resets here and probably refactor them to new core function

// Reset course and module caches.
Expand Down
22 changes: 14 additions & 8 deletions message/lib.php
Expand Up @@ -370,21 +370,27 @@ function message_get_contacts($user1=null, $user2=null) {
ORDER BY u.firstname ASC";

$rs = $DB->get_recordset_sql($strangersql, array($USER->id));
// Add user id as array index, so supportuser and noreply user don't get duplicated (if they are real users).
foreach ($rs as $rd) {
$strangers[] = $rd;
$strangers[$rd->id] = $rd;
}
$rs->close();

// Add noreply user and support user to the list.
// Add noreply user and support user to the list, if they don't exist.
$supportuser = core_user::get_support_user();
$supportuser->messagecount = message_count_unread_messages($USER, $supportuser);
if ($supportuser->messagecount > 0) {
$strangers[] = $supportuser;
if (!isset($strangers[$supportuser->id])) {
$supportuser->messagecount = message_count_unread_messages($USER, $supportuser);
if ($supportuser->messagecount > 0) {
$strangers[$supportuser->id] = $supportuser;
}
}

$noreplyuser = core_user::get_noreply_user();
$noreplyuser->messagecount = message_count_unread_messages($USER, $noreplyuser);
if ($noreplyuser->messagecount > 0) {
$strangers[] = $noreplyuser;
if (!isset($strangers[$noreplyuser->id])) {
$noreplyuser->messagecount = message_count_unread_messages($USER, $noreplyuser);
if ($noreplyuser->messagecount > 0) {
$strangers[$noreplyuser->id] = $noreplyuser;
}
}
return array($onlinecontacts, $offlinecontacts, $strangers);
}
Expand Down

0 comments on commit 69ab6b4

Please sign in to comment.