Commit c155ad0f authored by Richard Mansfield's avatar Richard Mansfield Committed by Gerrit Code Review
Browse files

Merge "Show an error when user tries to send a message to a deleted user"

parents 802c5d4a 1481257e
......@@ -309,6 +309,7 @@ $string['denyfriendrequest'] = 'Deny Friend Request';
$string['sendfriendshiprequest'] = 'Send %s a friendship request';
$string['cantdenyrequest'] = 'That is not a valid friendship request';
$string['cantmessageuser'] = 'You cannot send this user a message';
$string['cantmessageuserdeleted'] = 'You cannot send this user a message because the account has been deleted';
$string['cantviewmessage'] = 'You cannot view this message';
$string['requestedfriendship'] = 'requested friendship';
$string['notinanygroups'] = 'Not in any groups';
......@@ -67,10 +67,16 @@ switch ($returnto) {
$goto = 'user/myfriends.php';
$user = get_record('usr', 'id', $id, 'deleted', 0);
$user = get_record('usr', 'id', $id);
if (!$user || !can_send_message($USER->to_stdclass(), $id)) {
throw new AccessDeniedException(get_string('cantmessageuser', 'group'));
if (!$user) {
throw new UserNotFoundException(get_string('cantmessageuser', 'group'));
else if ($user->deleted != 0) {
throw new AccessDeniedException(get_string('cantmessageuserdeleted', 'group'));
else if (!can_send_message($USER->to_stdclass(), $id)) {
throw new AccessDeniedException(get_string('cantmessageuser', 'group'));
define('TITLE', get_string('sendmessageto', 'group', display_name($user)));
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment