From 7892ecf0d585ada527b66319ea39f84d62a55fee Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Thu, 14 Dec 2017 09:54:37 +0100 Subject: [PATCH] Add validations if user exist. --- main/inc/lib/message.lib.php | 45 +++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/main/inc/lib/message.lib.php b/main/inc/lib/message.lib.php index 6256d8b064..9f2049cc62 100755 --- a/main/inc/lib/message.lib.php +++ b/main/inc/lib/message.lib.php @@ -1115,20 +1115,26 @@ class MessageManager $title = Security::remove_XSS($row['title'], STUDENT, true); $content = Security::remove_XSS($row['content'], STUDENT, true); - $from_user = api_get_user_info($user_sender_id); - $name = $from_user['complete_name_with_username']; - $message_content = Display::page_subheader(str_replace("\\", "", $title)); - $user_image = ''; - if (api_get_setting('allow_social_tool') == 'true') { - $user_image = Display::img( - $from_user['avatar_small'], + + $name = get_lang('UnknownUser'); + $userImage = ''; + if (!empty($user_sender_id)) { + $fromUser = api_get_user_info($user_sender_id); + $name = $fromUser['complete_name_with_username']; + $userImage = Display::img( + $fromUser['avatar_small'], $name, array('title' => $name, 'class' => 'img-responsive img-circle', 'style' => 'max-width:35px'), false ); } - $receiverUserInfo = api_get_user_info($row['user_receiver_id']); + $message_content = Display::page_subheader(str_replace("\\", "", $title)); + + $receiverUserInfo = []; + if (!empty($row['user_receiver_id'])) { + $receiverUserInfo = api_get_user_info($row['user_receiver_id']); + } $message_content .= ''; if (api_get_setting('allow_social_tool') == 'true') { @@ -1136,17 +1142,28 @@ class MessageManager if ($source == 'outbox') { $message_content .= '
'; $message_content .= ''; $message_content .= '
'; } else { $message_content .= '
'; $message_content .= ''; $message_content .= '
'; @@ -1155,7 +1172,7 @@ class MessageManager } else { if ($source == 'outbox') { $message_content .= get_lang('From').': '.$name.' '.api_strtolower(get_lang('To')).' '. - $receiverUserInfo['complete_name'].''; + $receiverUserInfo['complete_name_with_username'].''; } else { $message_content .= get_lang('From').': '.$name.' '.api_strtolower(get_lang('To')).' '. get_lang('Me').'';