MDL-53207 message: display stock pic for msg from\to unreal user
authordg711 <devang.only@gmail.com>
Mon, 14 Mar 2016 06:39:22 +0000 (12:09 +0530)
committerdg711 <devang.only@gmail.com>
Sat, 19 Mar 2016 18:06:41 +0000 (23:36 +0530)
message/lib.php

index 604aca1..282d7e9 100644 (file)
@@ -1429,6 +1429,9 @@ function message_print_search_results($frm, $showicontext=false, $currentuser=nu
                 // Load user-to record.
                 if ($message->useridto !== $USER->id) {
                     $userto = core_user::get_user($message->useridto);
+                    if ($userto === false) {
+                        $userto = core_user::get_noreply_user();
+                    }
                     $tocontact = (array_key_exists($message->useridto, $contacts) and
                                     ($contacts[$message->useridto]->blocked == 0) );
                     $toblocked = (array_key_exists($message->useridto, $contacts) and
@@ -1442,6 +1445,9 @@ function message_print_search_results($frm, $showicontext=false, $currentuser=nu
                 // Load user-from record.
                 if ($message->useridfrom !== $USER->id) {
                     $userfrom = core_user::get_user($message->useridfrom);
+                    if ($userfrom === false) {
+                        $userfrom = core_user::get_noreply_user();
+                    }
                     $fromcontact = (array_key_exists($message->useridfrom, $contacts) and
                                     ($contacts[$message->useridfrom]->blocked == 0) );
                     $fromblocked = (array_key_exists($message->useridfrom, $contacts) and
@@ -1548,10 +1554,11 @@ function message_print_user ($user=false, $iscontact=false, $isblocked=false, $i
         } else {
             message_contact_link($user->id, 'block', $return, $script, $includeicontext);
         }
-    } else { // If not real user, then don't show any links.
+    } else {
+        // If not real user, then don't show any links.
         $userpictureparams['link'] = false;
-        echo $OUTPUT->user_picture($USER, $userpictureparams);
-        echo fullname($user);
+        // Stock profile picture should be displayed.
+        echo $OUTPUT->user_picture($user, $userpictureparams);
     }
 }