public static function remove_members_from_conversation(array $userids, int $convid) {
        global $DB;

        $conversation = $DB->get_record('message_conversations', ['id' => $convid], '*', MUST_EXIST);

        if ($conversation->type != self::MESSAGE_CONVERSATION_TYPE_GROUP) {
            throw new \moodle_exception('You can not remove members from a non-group conversation.');
        }

        list($useridcondition, $params) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED);
        $params['convid'] = $convid;

        $DB->delete_records_select('message_conversation_members',
            "conversationid = :convid AND userid $useridcondition", $params);
    }
public static function remove_members_from_conversation(array $userids, int $convid) {
        global $DB;

        $conversation = $DB->get_record('message_conversations', ['id' => $convid], '*', MUST_EXIST);

        if ($conversation->type != self::MESSAGE_CONVERSATION_TYPE_GROUP) {
            throw new \moodle_exception('You can not remove members from a non-group conversation.');
        }

        list($useridcondition, $params) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED);
        $params['convid'] = $convid;

        $DB->delete_records_select('message_conversation_members',
            "conversationid = :convid AND userid $useridcondition", $params);
    }
public static function remove_members_from_conversation ( array $ userids , int $ convid ) { global $ DB ; $ conversation = $ DB -> get_record ( 'message_conversations' , [ 'id' => $ convid ] , '*' , MUST_EXIST ) ; if ( $ conversation -> type != self :: MESSAGE_CONVERSATION_TYPE_GROUP ) { throw new \ moodle_exception ( 'You can not remove members from a non-group conversation.' ) ; } list ( $ useridcondition , $ params ) = $ DB -> get_in_or_equal ( $ userids , SQL_PARAMS_NAMED ) ; $ params [ 'convid' ] = $ convid ; $ DB -> delete_records_select ( 'message_conversation_members' , "conversationid = :convid AND userid $useridcondition" , $ params ) ; }
Remove some members from an existing conversation.

@param array $userids The user ids to remove from conversation members.
@param int $convid The conversation id. Must exists.
@throws \dml_exception
@throws \moodle_exception If trying to remove a member(s) from a non-group conversation
Remove some members from an existing conversation .