public static function get_courses($search, $downloadable, $enrollable, $options) {
        static $availableoptions = ['ids', 'sitecourseids', 'coverage', 'licenceshortname', 'subject', 'audience',
            'educationallevel', 'language', 'orderby', 'givememore', 'allsitecourses'];

        if (empty($options)) {
            $options = [];
        } else if (is_object($options)) {
            $options = (array)$options;
        } else if (!is_array($options)) {
            throw new \coding_exception('Parameter $options is invalid');
        }

        if ($unknownkeys = array_diff(array_keys($options), $availableoptions)) {
            throw new \coding_exception('Unknown option(s): ' . join(', ', $unknownkeys));
        }

        $params = [
            'search' => $search,
            'downloadable' => (int)(bool)$downloadable,
            'enrollable' => (int)(bool)$enrollable,
            'options' => $options
        ];
        $result = self::call('hub_get_courses', $params, true);
        $courses = $result['courses'];
        $coursetotal = $result['coursetotal'];

        foreach ($courses as $idx => $course) {
            $courses[$idx]['screenshotbaseurl'] = null;
            if (!empty($course['screenshots'])) {
                $courses[$idx]['screenshotbaseurl'] = new moodle_url(HUB_MOODLEORGHUBURL . '/local/hub/webservice/download.php',
                    array('courseid' => $course['id'],
                        'filetype' => self::HUB_SCREENSHOT_FILE_TYPE));
            }
            $courses[$idx]['commenturl'] = new moodle_url(HUB_MOODLEORGHUBURL,
                array('courseid' => $course['id'], 'mustbelogged' => true));
        }

        return [$courses, $coursetotal];
    }