Commit 4e9df2fb authored by Clare Lenihan's avatar Clare Lenihan Committed by Clare Lenihan
Browse files

added function for checking if a user is allowed to send messages to another

parent 7dc47834
......@@ -834,7 +834,17 @@ function send_user_message($to, $message, $from=null) {
throw new AccessDeniedException('Cannot send messages between ' . display_name($from) . ' and ' . display_name($to));
}
}
/**
* can a user send a message to another?
*
* @param object from the user to send the message
* @param int to the user to receive the message
* @return boolean whether userfrom is allowed to send messages to userto
*/
function can_send_message($from, $to) {
$messagepref = get_account_preference($to, 'messages');
return (is_friend($from->id, $to) && $messagepref == 'friends') || $messagepref == 'allow' || $from->get('admin');
}
function load_user_institutions($userid) {
if (empty($userid)) {
......
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