mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
a8d9b17b4b
When the messagingallusers setting is disabled only contacts that are on the same course as the user should be returned as results. We can reduce the number of candidate users significantly by pre-filtering them by being enrolled on the same courses as the user performing the search. Since we must also return the user themselves sometimes, even when they are not enrolled on a course I used a UNION as the most efficient way of retriving them, this meant that the order by had to reference returned columns by number to be sufficiently cross-database compatiable.