private function get_course_header_and_o365object()

in block_microsoft.php [256:284]


    private function get_course_header_and_o365object(int $courseid) {
        global $DB;

        $o365record = null;

        if (utils::course_is_group_feature_enabled($courseid, 'team')) {
            if ($o365record = $DB->get_record('local_o365_objects',
                ['type' => 'group', 'subtype' => 'courseteam', 'moodleid' => $courseid])) {
                // The course is configured to be connected to a Team, and is connected.
                $html = html_writer::tag('h5', get_string('course_connected_to_team', 'block_microsoft'));
            } else {
                // The course is configured to be connected to a Team, but the Team cannot be found.
                $html = html_writer::tag('h5', get_string('course_connected_to_team_missing', 'block_microsoft'));
            }
        } else if (utils::course_is_group_enabled($courseid)) {
            if ($o365record = $DB->get_record('local_o365_objects',
                ['type' => 'group', 'subtype' => 'course', 'moodleid' => $courseid])) {
                // The course is configured to be connected to a group, and is connected.
                $html = html_writer::tag('h5', get_string('course_connected_to_group', 'block_microsoft'));
            } else {
                // The course is configured to be connected to a group, but the group cannot be found.
                $html = html_writer::tag('h5', get_string('course_connected_to_group_missing', 'block_microsoft'));
            }
        } else {
            $html = html_writer::tag('h5', get_string('course_not_connected', 'block_microsoft'));
        }

        return [$html, $o365record];
    }