public static function can_view_course_info($course, $user = null) {
        if ($course->id == SITEID) {
            return true;
        }
        if (!$course->visible) {
            $coursecontext = context_course::instance($course->id);
            if (!has_capability('moodle/course:viewhiddencourses', $coursecontext, $user)) {
                return false;
            }
        }
        $categorycontext = isset($course->category) ? context_coursecat::instance($course->category) :
            context_course::instance($course->id)->get_parent_context();
        return has_capability('moodle/category:viewcourselist', $categorycontext, $user);
    }