Commit 229d0ced authored by Nigel McNie's avatar Nigel McNie
Browse files

Correct the order of arguments passed to can_message_user on user/view.php....

Correct the order of arguments passed to can_message_user on user/view.php. Fix a case in that function that might result in a fatal error, if an id is passed to it for $from.
parent bd4bcedd
......@@ -783,7 +783,7 @@ function can_send_message($from, $to) {
return false;
}
$messagepref = get_account_preference($to, 'messages');
return (is_friend($from->id, $to) && $messagepref == 'friends') || $messagepref == 'allow' || $from->get('admin');
return (is_friend($from->id, $to) && $messagepref == 'friends') || $messagepref == 'allow' || $from->admin;
}
function load_user_institutions($userid) {
......
......@@ -36,7 +36,7 @@ $returnto = param_alpha('returnto', 'myfriends');
$user = get_record('usr', 'id', $id, 'deleted', 0);
if (!$user || !can_send_message($USER, $id)) {
if (!$user || !can_send_message($USER->to_stdclass(), $id)) {
throw new AccessDeniedException(get_string('cantmessageuser', 'group'));
}
......
......@@ -334,7 +334,7 @@ if ($loggedinid != $userid) {
if (isset($introduction)) {
$smarty->assign('introduction', $introduction);
}
$smarty->assign('canmessage', can_send_message($userid, $loggedinid));
$smarty->assign('canmessage', can_send_message($loggedinid, $userid));
$smarty->assign('NAME',$name);
$smarty->assign('USERID', $userid);
$smarty->assign('USERFIELDS',$userfields);
......
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