MDL-63691 core_message: added api::can_create_group_conversation
This commit is contained in:
@@ -1385,6 +1385,25 @@ class api {
|
||||
return $conversation->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a user can create a group conversation.
|
||||
*
|
||||
* @param int $userid The id of the user attempting to create the conversation
|
||||
* @param \context $context The context they are creating the conversation from, most likely course context
|
||||
* @return bool
|
||||
*/
|
||||
public static function can_create_group_conversation(int $userid, \context $context) : bool {
|
||||
global $CFG;
|
||||
|
||||
// If we can't message at all, then we can't create a conversation.
|
||||
if (empty($CFG->messaging)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We need to check they have the capability to create the conversation.
|
||||
return has_capability('moodle/course:creategroupconversations', $context, $userid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a user can create a contact request.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user