MDL-63303 message: fix get_member_info iscontact check
authorRyan Wyllie <ryan@moodle.com>
Tue, 6 Nov 2018 06:14:29 +0000 (14:14 +0800)
committerRyan Wyllie <ryan@moodle.com>
Thu, 15 Nov 2018 06:40:12 +0000 (14:40 +0800)
message/classes/helper.php

index 74b0059..38b4e55 100644 (file)
@@ -507,11 +507,11 @@ class helper {
         $userssql = "SELECT $userfields, u.deleted, mc.id AS contactid, mub.id AS blockedid
                        FROM {user} u
                   LEFT JOIN {message_contacts} mc
-                         ON (mc.userid = ? AND mc.contactid = u.id)
+                         ON ((mc.userid = ? AND mc.contactid = u.id) OR (mc.userid = u.id AND mc.contactid = ?))
                   LEFT JOIN {message_users_blocked} mub
                          ON (mub.userid = ? AND mub.blockeduserid = u.id)
                       WHERE u.id $useridsql";
-        $usersparams = array_merge([$referenceuserid, $referenceuserid], $usersparams);
+        $usersparams = array_merge([$referenceuserid, $referenceuserid, $referenceuserid], $usersparams);
         $otherusers = $DB->get_records_sql($userssql, $usersparams);
 
         $members = [];