MDL-31869: Searching for users in messaging with multiple roles generates a warning
authorTim Lock <tim.lock@netspot.com.au>
Mon, 5 Mar 2012 01:48:58 +0000 (12:18 +1030)
committerAndrew Davis <andrew@moodle.com>
Mon, 19 Mar 2012 02:31:46 +0000 (09:31 +0700)
message/lib.php

index c3801e1..f1d5d3b 100644 (file)
@@ -1497,7 +1497,7 @@ function message_search_users($courseid, $searchtext, $sort='', $exceptions='')
 
         // everyone who has a role assignment in this course or higher
         $params = array($USER->id, "%$searchtext%");
-        $users = $DB->get_records_sql("SELECT $ufields, mc.id as contactlistid, mc.blocked
+        $users = $DB->get_records_sql("SELECT DISTINCT $ufields, mc.id as contactlistid, mc.blocked
                                          FROM {user} u
                                          JOIN {role_assignments} ra ON ra.userid = u.id
                                          LEFT JOIN {message_contacts} mc